X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FUSB%2FCore%2Fusb.c;h=44f0c6fe8f402577c0c003a5634854de625a443b;hb=f7ec06bee2b80613d80c314bf864c69209d09829;hp=e20f53cd0b8f112d3cdc901f1db9a1922b241fbb;hpb=70a143a9de252ddc4f148866b0a93e28904073e5;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/USB/Core/usb.c b/KernelLand/Modules/USB/Core/usb.c index e20f53cd..44f0c6fe 100644 --- a/KernelLand/Modules/USB/Core/usb.c +++ b/KernelLand/Modules/USB/Core/usb.c @@ -5,7 +5,7 @@ * usb.c * - USB Structure */ -#define DEBUG 1 +#define DEBUG 0 #include #include #include @@ -31,7 +31,7 @@ tUSBHub *USB_RegisterHost(tUSBHostDef *HostDef, void *ControllerPtr, int nPorts) { tUSBHost *host; - host = malloc(sizeof(tUSBHost) + nPorts*sizeof(void*)); + host = malloc(sizeof(tUSBHost) + nPorts*sizeof(tUSBHubPort) + sizeof(tUSBDevice) + sizeof(tUSBInterface)); if(!host) { // Oh, bugger. return NULL; @@ -40,19 +40,23 @@ tUSBHub *USB_RegisterHost(tUSBHostDef *HostDef, void *ControllerPtr, int nPorts) host->Ptr = ControllerPtr; memset(host->AddressBitmap, 0, sizeof(host->AddressBitmap)); - host->RootHubDev.ParentHub = NULL; - host->RootHubDev.Host = host; - host->RootHubDev.Address = 0; + host->RootHubDev = (void*)(host->RootHub.Ports + nPorts); + host->RootHubDev->ParentHub = NULL; + host->RootHubDev->Host = host; + host->RootHubDev->Address = 0; + ASSERT(HostDef->InitControl); + host->RootHubDev->EndpointHandles[0] = HostDef->InitControl(ControllerPtr, 0, 64); + host->RootHubDev->nInterfaces = 0; -// host->RootHubIf.Next = NULL; - host->RootHubIf.Dev = &host->RootHubDev; - host->RootHubIf.Driver = NULL; - host->RootHubIf.Data = NULL; - host->RootHubIf.nEndpoints = 0; + host->RootHubIf = (void*)(host->RootHubDev + 1); + host->RootHubIf->Dev = host->RootHubDev; + host->RootHubIf->Driver = NULL; + host->RootHubIf->Data = NULL; + host->RootHubIf->nEndpoints = 0; - host->RootHub.Interface = &host->RootHubIf; + host->RootHub.Interface = host->RootHubIf; host->RootHub.nPorts = nPorts; - memset(host->RootHub.Devices, 0, sizeof(void*)*nPorts); + memset(host->RootHub.Ports, 0, sizeof(tUSBHubPort)*nPorts); // Append to list Mutex_Acquire( &glUSB_Hosts ); @@ -97,10 +101,10 @@ tUSBHub *USB_RegisterHub(tUSBInterface *Device, int PortCount) { tUSBHub *ret; - ret = malloc(sizeof(tUSBHub) + sizeof(ret->Devices[0])*PortCount); + ret = malloc(sizeof(tUSBHub) + sizeof(ret->Ports[0])*PortCount); ret->Interface = Device; ret->nPorts = PortCount; - memset(ret->Devices, 0, sizeof(ret->Devices[0])*PortCount); + memset(ret->Ports, 0, sizeof(ret->Ports[0])*PortCount); return ret; } @@ -108,7 +112,7 @@ void USB_RemoveHub(tUSBHub *Hub) { for( int i = 0; i < Hub->nPorts; i ++ ) { - if( Hub->Devices[i] ) + if( Hub->Ports[i].Dev ) { USB_DeviceDisconnected( Hub, i ); }