3 * - By John Hodge (thePowersGang)
15 extern tUSBHost *gUSB_Hosts;
16 extern tUSBDriver gUSBHub_Driver;
21 tUSBHub *USB_RegisterHost(tUSBHostDef *HostDef, void *ControllerPtr, int nPorts);
24 tUSBDriver *gpUSB_InterfaceDrivers = &gUSBHub_Driver;
27 tUSBHub *USB_RegisterHost(tUSBHostDef *HostDef, void *ControllerPtr, int nPorts)
31 host = malloc(sizeof(tUSBHost) + nPorts*sizeof(void*));
36 host->HostDef = HostDef;
37 host->Ptr = ControllerPtr;
38 memset(host->AddressBitmap, 0, sizeof(host->AddressBitmap));
40 host->RootHubDev.ParentHub = NULL;
41 host->RootHubDev.Host = host;
42 host->RootHubDev.Address = 0;
44 // host->RootHubIf.Next = NULL;
45 host->RootHubIf.Dev = &host->RootHubDev;
46 host->RootHubIf.Driver = NULL;
47 host->RootHubIf.Data = NULL;
48 host->RootHubIf.nEndpoints = 0;
50 host->RootHub.Interface = &host->RootHubIf;
51 host->RootHub.nPorts = nPorts;
52 memset(host->RootHub.Devices, 0, sizeof(void*)*nPorts);
55 host->Next = gUSB_Hosts;
58 return &host->RootHub;
62 void USB_RegisterDriver(tUSBDriver *Driver)
64 Log_Warning("USB", "TODO: Implement USB_RegisterDriver");
67 tUSBDriver *USB_int_FindDriverByClass(Uint32 ClassCode)
69 ENTER("xClassCode", ClassCode);
70 for( tUSBDriver *ret = gpUSB_InterfaceDrivers; ret; ret = ret->Next )
72 LOG(" 0x%x & 0x%x == 0x%x?", ClassCode, ret->Match.Class.ClassMask, ret->Match.Class.ClassCode);
73 if( (ClassCode & ret->Match.Class.ClassMask) == ret->Match.Class.ClassCode )
75 LOG("Found '%s'", ret->Name);
84 // --- Hub Registration ---
85 // NOTE: Doesn't do much nowdays
86 tUSBHub *USB_RegisterHub(tUSBInterface *Device, int PortCount)
90 ret = malloc(sizeof(tUSBHub) + sizeof(ret->Devices[0])*PortCount);
91 ret->Interface = Device;
92 ret->nPorts = PortCount;
93 memset(ret->Devices, 0, sizeof(ret->Devices[0])*PortCount);
97 void USB_RemoveHub(tUSBHub *Hub)
99 for( int i = 0; i < Hub->nPorts; i ++ )
101 if( Hub->Devices[i] )
103 USB_DeviceDisconnected( Hub, i );