From 0fd80d40a2c82a02959cd974153c387abc5ddbbc Mon Sep 17 00:00:00 2001 From: DizzyOfCRN Date: Thu, 14 Aug 2014 11:27:53 +0000 Subject: [PATCH] For every VXHCI controller create only one roothub (and only one unit per controller) that contains all the ports regardless of port type. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@49331 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- rom/usb/vusbhc/vxhci/vxhci_commands.c | 39 ++++++------ rom/usb/vusbhc/vxhci/vxhci_device.c | 110 ++++++++++++---------------------- rom/usb/vusbhc/vxhci/vxhci_device.h | 12 ++-- 3 files changed, 66 insertions(+), 95 deletions(-) diff --git a/rom/usb/vusbhc/vxhci/vxhci_commands.c b/rom/usb/vusbhc/vxhci/vxhci_commands.c index 35b7c977fe..43ea125627 100644 --- a/rom/usb/vusbhc/vxhci/vxhci_commands.c +++ b/rom/usb/vusbhc/vxhci/vxhci_commands.c @@ -2,8 +2,8 @@ Copyright © 2014, The AROS Development Team. All rights reserved. $Id$ - Desc: - Lang: english + Desc: Virtual XHCI USB host controller + Lang: English */ #ifdef DEBUG @@ -11,7 +11,10 @@ #endif #define DEBUG 1 +#include #include +#include +#include #include #include @@ -156,7 +159,7 @@ WORD cmdControlXFerRootHub(struct IOUsbHWReq *ioreq) { UWORD bmRequestRecipient = (ioreq->iouh_SetupData.bmRequestType) & (URTF_DEVICE | URTF_INTERFACE | URTF_ENDPOINT | URTF_OTHER); UWORD bRequest = (ioreq->iouh_SetupData.bRequest); - D(UWORD wIndex = AROS_WORD2LE(ioreq->iouh_SetupData.wIndex)); + UWORD wIndex = AROS_WORD2LE(ioreq->iouh_SetupData.wIndex); UWORD wValue = AROS_WORD2LE(ioreq->iouh_SetupData.wValue); UWORD wLength = AROS_WORD2LE(ioreq->iouh_SetupData.wLength); @@ -305,6 +308,15 @@ WORD cmdControlXFerRootHub(struct IOUsbHWReq *ioreq) { case UDT_BOS: bug("[VXHCI] cmdControlXFerRootHub: UDT_BOS\n"); + /* TODO: Arbitrary, set real values according to the host controller */ + unit->roothub.bosdesc.wTotalLength = 16; + unit->roothub.bosdesc.bNumDeviceCaps = 2; + + ioreq->iouh_Actual = (wLength > sizeof(struct UsbStdBOSDesc)) ? sizeof(struct UsbStdBOSDesc) : wLength; + CopyMem((APTR) &unit->roothub.bosdesc, ioreq->iouh_Data, ioreq->iouh_Actual); + + mybug_unit(0, ("Done\n\n")); + return UHIOERR_NO_ERROR; break; case UDT_DEVICE_CAPABILITY: @@ -330,6 +342,8 @@ WORD cmdControlXFerRootHub(struct IOUsbHWReq *ioreq) { return UHIOERR_NO_ERROR; break; + //case USR_GET_INTERFACE: //Undefined. Hubs are allowed to support only one interface. + } /* switch(bRequest) */ break; /* case URTF_DEVICE: */ @@ -383,24 +397,12 @@ WORD cmdControlXFerRootHub(struct IOUsbHWReq *ioreq) { mybug_unit(0, ("[VXHCI] cmdControlXFerRootHub: USR_GET_DESCRIPTOR\n")); switch( (wValue>>8) ) { - case UDT_HUB: - mybug_unit(0, ("UDT_HUB\n")); - mybug_unit(0, ("GetRootHubDescriptor USB2.0 (%ld)\n", wLength)); - - ioreq->iouh_Actual = (wLength > sizeof(struct UsbHubDesc)) ? sizeof(struct UsbHubDesc) : wLength; - CopyMem((APTR) &unit->roothub.hubdesc.usb20, ioreq->iouh_Data, ioreq->iouh_Actual); - - mybug_unit(0, ("Done\n\n")); - return UHIOERR_NO_ERROR; - break; - - /* switch( (wValue>>8) ) */ case UDT_SSHUB: mybug_unit(0, ("UDT_SSHUB\n")); mybug_unit(0, ("GetRootHubDescriptor USB3.0 (%ld)\n", wLength)); ioreq->iouh_Actual = (wLength > sizeof(struct UsbSSHubDesc)) ? sizeof(struct UsbSSHubDesc) : wLength; - CopyMem((APTR) &unit->roothub.hubdesc.usb30, ioreq->iouh_Data, ioreq->iouh_Actual); + CopyMem((APTR) &unit->roothub.hubdesc, ioreq->iouh_Data, ioreq->iouh_Actual); mybug_unit(0, ("Done\n\n")); return UHIOERR_NO_ERROR; @@ -467,6 +469,7 @@ WORD cmdControlXFerRootHub(struct IOUsbHWReq *ioreq) { switch(bmRequestRecipient) { case URTF_DEVICE: mybug_unit(0, ("[VXHCI] cmdControlXFerRootHub: URTF_DEVICE\n")); + switch(bRequest) { case USR_SET_ADDRESS: mybug_unit(0, ("USR_SET_ADDRESS\n")); @@ -484,6 +487,8 @@ WORD cmdControlXFerRootHub(struct IOUsbHWReq *ioreq) { return UHIOERR_NO_ERROR; break; + //case USR_SET_INTERFACE: //Undefined. Hubs are allowed to support only one interface. + } /* switch(bRequest) */ break; @@ -635,8 +640,6 @@ WORD cmdControlXFerRootHub(struct IOUsbHWReq *ioreq) { mybug_unit(-1, ("wLength %d\n", wLength)); mybug_unit(-1, ("Nothing done!\n\n")) ); - - return UHIOERR_BADPARAMS; } diff --git a/rom/usb/vusbhc/vxhci/vxhci_device.c b/rom/usb/vusbhc/vxhci/vxhci_device.c index 600c73cb1f..4762ea3919 100644 --- a/rom/usb/vusbhc/vxhci/vxhci_device.c +++ b/rom/usb/vusbhc/vxhci/vxhci_device.c @@ -11,7 +11,10 @@ #endif #define DEBUG 1 +#include #include +#include +#include #include #include @@ -26,7 +29,7 @@ #include LC_LIBDEFS_FILE -struct VXHCIUnit *VXHCI_AddNewUnit(ULONG unitnum, UWORD bcdusb); +struct VXHCIUnit *VXHCI_AddNewUnit(ULONG unitnum); struct VXHCIPort *VXHCI_AddNewPort(struct VXHCIUnit *unit, ULONG portnum); static int GM_UNIQUENAME(Init)(LIBBASETYPEPTR VXHCIBase) { @@ -39,29 +42,7 @@ static int GM_UNIQUENAME(Init)(LIBBASETYPEPTR VXHCIBase) { VXHCIBase->unit_count = 0; for (i=0; iunit_count, 0x210); - if(unit == NULL) { - mybug(-1, ("[VXHCI] Init: Failed to create new unit!\n")); - - /* - Free previous units if any exists - */ - - ForeachNode(&VXHCIBase->unit_list, unit) { - mybug(-1,("[VXHCI] Init: Removing unit structure %s at %p\n", unit->node.ln_Name, unit)); - REMOVE(unit); - FreeVec(unit); - } - return FALSE; - } else { - AddTail(&VXHCIBase->unit_list,(struct Node *)unit); - VXHCIBase->unit_count++; - } - #endif - - unit = VXHCI_AddNewUnit(VXHCIBase->unit_count, 0x311); + unit = VXHCI_AddNewUnit(VXHCIBase->unit_count); if(unit == NULL) { mybug(-1, ("[VXHCI] Init: Failed to create new unit!\n")); @@ -274,7 +255,7 @@ AROS_LH1(LONG, AbortIO, AROS_LHA(struct IOUsbHWReq *, ioreq, A1), struct VXHCIBa AROS_LIBFUNC_EXIT } -struct VXHCIUnit *VXHCI_AddNewUnit(ULONG unitnum, UWORD bcdusb) { +struct VXHCIUnit *VXHCI_AddNewUnit(ULONG unitnum) { struct VXHCIUnit *unit; struct VXHCIPort *port; @@ -293,37 +274,23 @@ struct VXHCIUnit *VXHCI_AddNewUnit(ULONG unitnum, UWORD bcdusb) { NEWLIST(&unit->roothub.port_list); - /* Set the correct bcdUSB and bcdDevice for the hub device descriptor */ - if(bcdusb>=0x0300) { - unit->roothub.devdesc.bcdUSB = AROS_WORD2LE(0x0300); - } else { - unit->roothub.devdesc.bcdUSB = AROS_WORD2LE(0x0200); - } + unit->roothub.devdesc.bcdUSB = AROS_WORD2LE(0x0300); + unit->roothub.devdesc.bcdDevice = AROS_WORD2LE(0x0300); - unit->roothub.devdesc.bcdDevice = AROS_WORD2LE(bcdusb); + sprintf(unit->name, "VXHCI_USB30[%d]", unit->number); - sprintf(unit->name, "VXHCI_USB%x%x[%d]", (AROS_LE2WORD(unit->roothub.devdesc.bcdUSB)>>8)&0xf, (AROS_LE2WORD(unit->roothub.devdesc.bcdUSB)>>4)&0xf, unit->number); - - #ifdef VXHCI_NUMPORTS20 - if( (bcdusb >= 0x0200) && (bcdusb < 0x0300) ) { - unit->roothub.devdesc.bMaxPacketSize0 = 8; - unit->roothub.devdesc.bDeviceProtocol = 1; - unit->roothub.config.epdesc.wMaxPacketSize = AROS_WORD2LE(8); - imax = VXHCI_NUMPORTS20; - } else { - unit->roothub.devdesc.bMaxPacketSize0 = 9; - unit->roothub.devdesc.bDeviceProtocol = 3; - unit->roothub.config.epdesc.wMaxPacketSize = AROS_WORD2LE(1024); - imax = VXHCI_NUMPORTS30; - } - #else + /* CHECKME: */ unit->roothub.devdesc.bMaxPacketSize0 = 9; unit->roothub.devdesc.bDeviceProtocol = 3; unit->roothub.config.epdesc.wMaxPacketSize = AROS_WORD2LE(1024); + + #ifdef VXHCI_NUMPORTS20 + imax = VXHCI_NUMPORTS30 + VXHCI_NUMPORTS20; + #else imax = VXHCI_NUMPORTS30; #endif - for (i=0; iroothub.config.epdesc.bInterval = 12; /* This is our root hub hub descriptor */ - if( (bcdusb >= 0x0200) && (bcdusb < 0x0300) ) { - unit->roothub.hubdesc.usb20.bLength = sizeof(struct UsbHubDesc); - unit->roothub.hubdesc.usb20.bDescriptorType = UDT_HUB; - unit->roothub.hubdesc.usb20.bNbrPorts = (UBYTE) unit->roothub.port_count; - unit->roothub.hubdesc.usb20.wHubCharacteristics = AROS_WORD2LE(UHCF_INDIVID_POWER|UHCF_INDIVID_OVP); - //unit->roothub.hubdesc.usb20.bPwrOn2PwrGood = 0; - unit->roothub.hubdesc.usb20.bHubContrCurrent = 1; - unit->roothub.hubdesc.usb20.DeviceRemovable = 1; - //unit->roothub.hubdesc.usb20.PortPwrCtrlMask = 0; - } else { - unit->roothub.hubdesc.usb30.bLength = sizeof(struct UsbSSHubDesc); - unit->roothub.hubdesc.usb30.bDescriptorType = UDT_SSHUB; - unit->roothub.hubdesc.usb30.bNbrPorts = (UBYTE) unit->roothub.port_count;; - unit->roothub.hubdesc.usb30.wHubCharacteristics = AROS_WORD2LE(UHCF_INDIVID_POWER|UHCF_INDIVID_OVP); - //unit->roothub.hubdesc.usb30.bPwrOn2PwrGood = 0; - unit->roothub.hubdesc.usb30.bHubContrCurrent = 10; - //unit->roothub.hubdesc.usb30.bHubHdrDecLat = 0; - //unit->roothub.hubdesc.usb30.wHubDelay = 0; - //unit->roothub.hubdesc.usb30.DeviceRemovable = 0; - } + unit->roothub.hubdesc.bLength = sizeof(struct UsbSSHubDesc); + unit->roothub.hubdesc.bDescriptorType = UDT_SSHUB; + unit->roothub.hubdesc.bNbrPorts = (UBYTE) unit->roothub.port_count;; + unit->roothub.hubdesc.wHubCharacteristics = AROS_WORD2LE(UHCF_INDIVID_POWER|UHCF_INDIVID_OVP); + //unit->roothub.hubdesc.bPwrOn2PwrGood = 0; + unit->roothub.hubdesc.bHubContrCurrent = 10; + //unit->roothub.hubdesc.bHubHdrDecLat = 0; + //unit->roothub.hubdesc.wHubDelay = 0; + //unit->roothub.hubdesc.DeviceRemovable = 0; + + unit->roothub.bosdesc.bLength = sizeof(struct UsbStdBOSDesc); + unit->roothub.bosdesc.bDescriptorType = UDT_BOS; + /* Command interface sets these */ + //unit->roothub.bosdesc.wTotalLength = 0; + //unit->roothub.bosdesc.bNumDeviceCaps = 0; D( mybug(0, ("[VXHCI] VXHCI_AddNewUnit:\n")); mybug(0, (" Created new unit numbered %d at %p\n",unit->number, unit)); @@ -442,15 +404,21 @@ struct VXHCIPort *VXHCI_AddNewPort(struct VXHCIUnit *unit, ULONG portnum) { } else { port->node.ln_Type = NT_USER; /* Poseidon treats port number 0 as roothub */ - port->number = portnum+1; - - sprintf(port->name, "VXHCI_USB%x%x[%d:%d]", (AROS_LE2WORD(unit->roothub.devdesc.bcdUSB)>>8)&0xf, (AROS_LE2WORD(unit->roothub.devdesc.bcdUSB)>>4)&0xf, unit->number, port->number); + port->number = portnum; + if(portnum<=VXHCI_NUMPORTS30) { + port->usbbcd = 0x0300; + sprintf(port->name, "VXHCI_USB30[%d:%d]", unit->number, port->number); + } else { + port->usbbcd = 0x0210; + sprintf(port->name, "VXHCI_USB20[%d:%d]", unit->number, port->number); + } port->node.ln_Name = (STRPTR)&port->name; } mybug(0, ("[VXHCI] VXHCI_AddNewPort:\n")); mybug(0, (" Created new port numbered %d at %p\n",port->number, port)); mybug(0, (" Port node name %s\n", port->node.ln_Name)); + mybug(0, (" Port usbbcd %04x\n", port->usbbcd)); return port; } diff --git a/rom/usb/vusbhc/vxhci/vxhci_device.h b/rom/usb/vusbhc/vxhci/vxhci_device.h index 3d25de5abd..64b763361c 100644 --- a/rom/usb/vusbhc/vxhci/vxhci_device.h +++ b/rom/usb/vusbhc/vxhci/vxhci_device.h @@ -24,8 +24,8 @@ #define VXHCI_NUMCONTROLLERS 1 /* Number of ports per host controller (USB2.0/USB3.0) */ -//#define VXHCI_NUMPORTS20 2 -#define VXHCI_NUMPORTS30 4 +#define VXHCI_NUMPORTS20 2 +#define VXHCI_NUMPORTS30 2 #define RC_OK 0 #define RC_DONTREPLY -1 @@ -49,6 +49,7 @@ struct VXHCIPort { char name[256]; ULONG number; ULONG state; + UWORD usbbcd; }; struct VXHCIUnit { @@ -65,16 +66,15 @@ struct VXHCIUnit { struct UsbStdDevDesc devdesc; + struct UsbStdBOSDesc bosdesc; + struct RHConfig { struct UsbStdCfgDesc cfgdesc; struct UsbStdIfDesc ifdesc; struct UsbStdEPDesc epdesc; } config; - union { - struct UsbHubDesc usb20; - struct UsbSSHubDesc usb30; - } hubdesc; + struct UsbSSHubDesc hubdesc; } roothub; -- 2.11.4.GIT