X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FUSB%2FCore%2Fusb_devinit.c;h=7eb55f9d2fee79441dd45b14d49b86a0f3b1c1b1;hb=25b02822ad95feb8f82f7b8fef44a58e29afb79b;hp=7b1b724f8485837c3e29fed40d0c356daae00673;hpb=3fe8c9a20ecc6cd5d03f5903e6b4a65e38a42480;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/USB/Core/usb_devinit.c b/KernelLand/Modules/USB/Core/usb_devinit.c index 7b1b724f..7eb55f9d 100644 --- a/KernelLand/Modules/USB/Core/usb_devinit.c +++ b/KernelLand/Modules/USB/Core/usb_devinit.c @@ -13,7 +13,7 @@ #include "usb_proto.h" #include "usb_lowlevel.h" -#define DUMP_DESCRIPTORS 0 +#define DUMP_DESCRIPTORS 1 // === PROTOTYPES === void USB_DeviceConnected(tUSBHub *Hub, int Port); @@ -102,6 +102,8 @@ void USB_DeviceConnected(tUSBHub *Hub, int Port) } #endif #endif + + memcpy(&dev->DevDesc, &desc, sizeof(desc)); } // TODO: Support alternate configurations @@ -115,6 +117,7 @@ void USB_DeviceConnected(tUSBHub *Hub, int Port) size_t total_length; USB_int_ReadDescriptor(dev, 0, 2, i, sizeof(desc), &desc); + // TODO: Check return length? (Do we get a length?) #if DUMP_DESCRIPTORS LOG("Configuration Descriptor %i = {", i); LOG(" .Length = %i", desc.Length); @@ -133,6 +136,11 @@ void USB_DeviceConnected(tUSBHub *Hub, int Port) } #endif + if( desc.NumInterfaces == 0 ) { + Log_Notice("USB", "Device does not have any interfaces"); + continue ; + } + // TODO: Split here and allow some method of selection // Allocate device now that we have the configuration @@ -144,10 +152,10 @@ void USB_DeviceConnected(tUSBHub *Hub, int Port) total_length = LittleEndian16(desc.TotalLength); full_buf = malloc( total_length ); USB_int_ReadDescriptor(dev, 0, 2, i, total_length, full_buf); - ptr_ofs += desc.Length; - // TODO: Interfaces + + // Interfaces! for( int j = 0; ptr_ofs < total_length && j < desc.NumInterfaces; j ++ ) { struct sDescriptor_Interface *iface; @@ -179,21 +187,23 @@ void USB_DeviceConnected(tUSBHub *Hub, int Port) LOG(" .InterfaceClass = 0x%x", iface->InterfaceClass); LOG(" .InterfaceSubClass = 0x%x", iface->InterfaceSubClass); LOG(" .InterfaceProcol = 0x%x", iface->InterfaceProtocol); - # if DEBUG if( iface->InterfaceStr ) { char *tmp = USB_int_GetDeviceString(dev, 0, iface->InterfaceStr); LOG(" .InterfaceStr = %i '%s'", iface->InterfaceStr, tmp); free(tmp); } - # endif LOG("}"); #endif - dev_if = malloc(sizeof(tUSBInterface) + iface->NumEndpoints*sizeof(dev_if->Endpoints[0])); + dev_if = malloc( + sizeof(tUSBInterface) + + iface->NumEndpoints*sizeof(dev_if->Endpoints[0]) + ); dev_if->Dev = dev; dev_if->Driver = NULL; dev_if->Data = NULL; dev_if->nEndpoints = iface->NumEndpoints; + memcpy(&dev_if->IfaceDesc, iface, sizeof(*iface)); dev->Interfaces[j] = dev_if; // Copy interface data @@ -246,11 +256,11 @@ void USB_DeviceConnected(tUSBHub *Hub, int Port) ); } else { + LOG("Driver '%s' in use", dev_if->Driver->Name); dev_if->Driver->Connected( dev_if, full_buf + iface_base_ofs, ptr_ofs - iface_base_ofs ); - // dev_if->Driver->Connected( dev_if ); } }