usb: Move default pipe max packet size code from xhci to main code.

Also, the max packet size for super speed devices is 512 bytes (not
256 bytes).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c
index 65d1be0..93f39c0 100644
--- a/src/hw/usb-xhci.c
+++ b/src/hw/usb-xhci.c
@@ -282,13 +282,6 @@
     [ USB_SUPERSPEED ] = 4,
 };
 
-static const int speed_to_ctlsize[] = {
-    [ USB_FULLSPEED  ] = 8,
-    [ USB_LOWSPEED   ] = 8,
-    [ USB_HIGHSPEED  ] = 64,
-    [ USB_SUPERSPEED ] = 256,
-};
-
 static const int eptype_to_xhci_in[] = {
     [ USB_ENDPOINT_XFER_CONTROL] = 4,
     [ USB_ENDPOINT_XFER_ISOC   ] = 5,
@@ -955,12 +948,12 @@
         struct xhci_epctx *ep = (void*)&in[2 << xhci->context64];
         ep->ctx[0]   |= (3 << 16); // interval: 1ms
         ep->ctx[1]   |= (4 << 3);  // control pipe
-        ep->ctx[1]   |= (speed_to_ctlsize[usbdev->speed] << 16);
+        ep->ctx[1]   |= (pipe->pipe.maxpacket << 16);
 
         ep->deq_low  = (u32)&pipe->reqs.ring[0];
         ep->deq_low  |= 1;         // dcs
         ep->deq_high = 0;
-        ep->length   = 8;
+        ep->length   = pipe->pipe.maxpacket;
 
         int cc = xhci_cmd_address_device(xhci, slotid, in);
         free(in);
diff --git a/src/hw/usb.c b/src/hw/usb.c
index ff20b6c..7b8a9f5 100644
--- a/src/hw/usb.c
+++ b/src/hw/usb.c
@@ -261,6 +261,13 @@
  * Initialization and enumeration
  ****************************************************************/
 
+static const int speed_to_ctlsize[] = {
+    [ USB_FULLSPEED  ] = 8,
+    [ USB_LOWSPEED   ] = 8,
+    [ USB_HIGHSPEED  ] = 64,
+    [ USB_SUPERSPEED ] = 512,
+};
+
 // Assign an address to a device in the default state on the given
 // controller.
 static int
@@ -276,7 +283,7 @@
 
     // Create a pipe for the default address.
     struct usb_endpoint_descriptor epdesc = {
-        .wMaxPacketSize = 8,
+        .wMaxPacketSize = speed_to_ctlsize[usbdev->speed],
         .bmAttributes = USB_ENDPOINT_XFER_CONTROL,
     };
     usbdev->defpipe = usb_alloc_pipe(usbdev, &epdesc);