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 void USB_RegisterDriver(tUSBDriver *Driver)
29 Driver->Next = gpUSB_InterfaceDrivers;
30 gpUSB_InterfaceDrivers = Driver;
33 tUSBHub *USB_RegisterHost(tUSBHostDef *HostDef, void *ControllerPtr, int nPorts)
37 host = malloc(sizeof(tUSBHost) + nPorts*sizeof(void*));
42 host->HostDef = HostDef;
43 host->Ptr = ControllerPtr;
44 memset(host->AddressBitmap, 0, sizeof(host->AddressBitmap));
46 host->RootHubDev.ParentHub = NULL;
47 host->RootHubDev.Host = host;
48 host->RootHubDev.Address = 0;
50 // host->RootHubIf.Next = NULL;
51 host->RootHubIf.Dev = &host->RootHubDev;
52 host->RootHubIf.Driver = NULL;
53 host->RootHubIf.Data = NULL;
54 host->RootHubIf.nEndpoints = 0;
56 host->RootHub.Interface = &host->RootHubIf;
57 host->RootHub.nPorts = nPorts;
58 memset(host->RootHub.Devices, 0, sizeof(void*)*nPorts);
61 host->Next = gUSB_Hosts;
64 return &host->RootHub;
68 void USB_RegisterDriver(tUSBDriver *Driver)
70 Log_Warning("USB", "TODO: Implement USB_RegisterDriver");
73 tUSBDriver *USB_int_FindDriverByClass(Uint32 ClassCode)
75 ENTER("xClassCode", ClassCode);
76 for( tUSBDriver *ret = gpUSB_InterfaceDrivers; ret; ret = ret->Next )
78 LOG(" 0x%x & 0x%x == 0x%x?", ClassCode, ret->Match.Class.ClassMask, ret->Match.Class.ClassCode);
79 if( (ClassCode & ret->Match.Class.ClassMask) == ret->Match.Class.ClassCode )
81 LOG("Found '%s'", ret->Name);
90 // --- Hub Registration ---
91 // NOTE: Doesn't do much nowdays
92 tUSBHub *USB_RegisterHub(tUSBInterface *Device, int PortCount)
96 ret = malloc(sizeof(tUSBHub) + sizeof(ret->Devices[0])*PortCount);
97 ret->Interface = Device;
98 ret->nPorts = PortCount;
99 memset(ret->Devices, 0, sizeof(ret->Devices[0])*PortCount);
103 void USB_RemoveHub(tUSBHub *Hub)
105 for( int i = 0; i < Hub->nPorts; i ++ )
107 if( Hub->Devices[i] )
109 USB_DeviceDisconnected( Hub, i );