From: John Hodge Date: Sat, 26 Nov 2011 14:10:41 +0000 (+0800) Subject: Modules/USB - Parsing interface descriptors now X-Git-Tag: rel0.14~66 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=61e738e9f111f0beac621db5efbccff0d64760a2;p=tpg%2Facess2.git Modules/USB - Parsing interface descriptors now --- diff --git a/Modules/USB/Core/usb.c b/Modules/USB/Core/usb.c index b43aae4d..52968e30 100644 --- a/Modules/USB/Core/usb.c +++ b/Modules/USB/Core/usb.c @@ -138,9 +138,10 @@ void USB_DeviceConnected(tUSBHub *Hub, int Port) for( int i = 0; i < 1; i ++ ) { struct sDescriptor_Configuration desc; -// void *full_buf; + void *full_buf; + char *cur_ptr; - USB_int_ReadDescriptor(dev, 0, 2, 0, sizeof(desc), &desc); + USB_int_ReadDescriptor(dev, 0, 2, i, sizeof(desc), &desc); LOG("Configuration Descriptor %i = {", i); LOG(" .Length = %i", desc.Length); LOG(" .Type = %i", desc.Type); @@ -156,8 +157,46 @@ void USB_DeviceConnected(tUSBHub *Hub, int Port) LOG("ConfigurationStr = '%s'", tmp); free(tmp); } - + + cur_ptr = full_buf = malloc( LittleEndian16(desc.TotalLength) ); + USB_int_ReadDescriptor(dev, 0, 2, i, desc.TotalLength, full_buf); + + cur_ptr += desc.Length; + // TODO: Interfaces + for( int j = 0; j < desc.NumInterfaces; j ++ ) + { + struct sDescriptor_Interface *iface; + iface = (void*)cur_ptr; + // TODO: Sanity check with remaining space + cur_ptr += sizeof(*iface); + + LOG("Interface %i/%i = {"); + LOG(" .InterfaceNum = %i", iface->InterfaceNum); + LOG(" .NumEndpoints = %i", iface->NumEndpoints); + LOG(" .InterfaceClass = 0x%x", iface->InterfaceClass); + LOG(" .InterfaceSubClass = 0x%x", iface->InterfaceSubClass); + LOG(" .InterfaceProcol = 0x%x", iface->InterfaceProtocol); + + if( iface->InterfaceStr ) { + char *tmp = USB_int_GetDeviceString(dev, 0, iface->InterfaceStr); + LOG(" .InterfaceStr = %i '%s'", iface->InterfaceStr, tmp); + free(tmp); + } + LOG("}"); + + for( int k = 0; k < iface->NumEndpoints; k ++ ) + { + struct sDescriptor_Endpoint *endpt; + endpt = (void*)cur_ptr; + // TODO: Sanity check with remaining space + cur_ptr += sizeof(*endpt); + + + } + } + + free(full_buf); } // Done. diff --git a/Modules/USB/Core/usb_proto.h b/Modules/USB/Core/usb_proto.h index 776237da..b5399e8e 100644 --- a/Modules/USB/Core/usb_proto.h +++ b/Modules/USB/Core/usb_proto.h @@ -33,7 +33,7 @@ struct sDescriptor_Device Uint8 SerialNumberStr; Uint8 NumConfigurations; -}; +} PACKED; struct sDescriptor_Configuration { @@ -46,7 +46,7 @@ struct sDescriptor_Configuration Uint8 ConfigurationStr; Uint8 AttributesBmp; Uint8 MaxPower; // in units of 2 mA -}; +} PACKED; struct sDescriptor_String { @@ -54,7 +54,7 @@ struct sDescriptor_String Uint8 Type; // = 3 Uint16 Data[62]; // 62 is arbitary -}; +} PACKED; struct sDescriptor_Interface { @@ -70,7 +70,7 @@ struct sDescriptor_Interface Uint8 InterfaceProtocol; Uint8 InterfaceStr; -}; +} PACKED; struct sDescriptor_Endpoint { @@ -100,7 +100,7 @@ struct sDescriptor_Endpoint * */ Uint8 PollingInterval; -}; +} PACKED; #endif