X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FUSB%2FCore%2Fusb_lowlevel.c;h=0e53bad940bee2f6bc512b338c316f80b514f6f2;hb=4c717bb526a0a7b1aa44ed7fc4f07a6b7da5d2f9;hp=4c0fb73040ab249391249ff1fc3bc815648e5b4e;hpb=9c8d1751ca2eb1470a1707e42896262d19efe31d;p=tpg%2Facess2.git diff --git a/Modules/USB/Core/usb_lowlevel.c b/Modules/USB/Core/usb_lowlevel.c index 4c0fb730..0e53bad9 100644 --- a/Modules/USB/Core/usb_lowlevel.c +++ b/Modules/USB/Core/usb_lowlevel.c @@ -30,7 +30,7 @@ void *USB_int_Request(tUSBHost *Host, int Addr, int EndPt, int Type, int Req, in req.Index = LittleEndian16( Indx ); req.Length = LittleEndian16( Len ); - hdl = Host->HostDef->SendSETUP(Host->Ptr, Addr, EndPt, 0, NULL, &req, sizeof(req)); + hdl = Host->HostDef->SendSETUP(Host->Ptr, Addr, EndPt, 0, NULL, NULL, &req, sizeof(req)); // TODO: Data toggle? // TODO: Multi-packet transfers @@ -38,9 +38,9 @@ void *USB_int_Request(tUSBHost *Host, int Addr, int EndPt, int Type, int Req, in { void *hdl2; - hdl = Host->HostDef->SendIN(Host->Ptr, Addr, EndPt, 0, NULL, Data, Len); + hdl = Host->HostDef->SendIN(Host->Ptr, Addr, EndPt, 0, NULL, NULL, Data, Len); - hdl2 = Host->HostDef->SendOUT(Host->Ptr, Addr, EndPt, 0, NULL, NULL, 0); + hdl2 = Host->HostDef->SendOUT(Host->Ptr, Addr, EndPt, 0, NULL, NULL, NULL, 0); while( Host->HostDef->IsOpComplete(Host->Ptr, hdl2) == 0 ) Time_Delay(1); } @@ -49,12 +49,12 @@ void *USB_int_Request(tUSBHost *Host, int Addr, int EndPt, int Type, int Req, in void *hdl2; if( Len > 0 ) - hdl = Host->HostDef->SendOUT(Host->Ptr, Addr, EndPt, 0, NULL, Data, Len); + hdl = Host->HostDef->SendOUT(Host->Ptr, Addr, EndPt, 0, NULL, NULL, Data, Len); else hdl = NULL; // Status phase (DataToggle=1) - hdl2 = Host->HostDef->SendIN(Host->Ptr, Addr, EndPt, 1, NULL, NULL, 0); + hdl2 = Host->HostDef->SendIN(Host->Ptr, Addr, EndPt, 1, NULL, NULL, NULL, 0); while( Host->HostDef->IsOpComplete(Host->Ptr, hdl2) == 0 ) Time_Delay(1); } @@ -75,6 +75,13 @@ int USB_int_ReadDescriptor(tUSBDevice *Dev, int Endpoint, int Type, int Index, i void *final; req.ReqType = 0x80; + switch( Type & 0xF00 ) + { + case 0x000: req.ReqType |= (0 << 5); break; // Standard + case 0x100: req.ReqType |= (1 << 5); break; // Class + case 0x200: req.ReqType |= (2 << 5); break; // Vendor + } + req.Request = 6; // GET_DESCRIPTOR req.Value = LittleEndian16( ((Type & 0xFF) << 8) | (Index & 0xFF) ); req.Index = LittleEndian16( 0 ); // TODO: Language ID @@ -82,7 +89,7 @@ int USB_int_ReadDescriptor(tUSBDevice *Dev, int Endpoint, int Type, int Index, i Dev->Host->HostDef->SendSETUP( Dev->Host->Ptr, Dev->Address, Endpoint, - 0, NULL, + 0, NULL, NULL, &req, sizeof(req) ); @@ -91,7 +98,7 @@ int USB_int_ReadDescriptor(tUSBDevice *Dev, int Endpoint, int Type, int Index, i { Dev->Host->HostDef->SendIN( Dev->Host->Ptr, Dev->Address, Endpoint, - bToggle, NULL, + bToggle, NULL, NULL, Dest, ciMaxPacketSize ); bToggle = !bToggle; @@ -100,7 +107,7 @@ int USB_int_ReadDescriptor(tUSBDevice *Dev, int Endpoint, int Type, int Index, i final = Dev->Host->HostDef->SendIN( Dev->Host->Ptr, Dev->Address, Endpoint, - bToggle, INVLPTR, + bToggle, INVLPTR, NULL, Dest, Length ); @@ -115,8 +122,15 @@ char *USB_int_GetDeviceString(tUSBDevice *Dev, int Endpoint, int Index) struct sDescriptor_String str; int src_len, new_len; char *ret; + + if(Index == 0) return strdup(""); USB_int_ReadDescriptor(Dev, Endpoint, 3, Index, sizeof(str), &str); + if(str.Length < 2) { + Log_Error("USB", "String %p:%i:%i:%i descriptor is undersized (%i)", + Dev->Host, Dev->Address, Endpoint, Index, str.Length); + return NULL; + } // if(str.Length > sizeof(str)) { // // IMPOSSIBLE! // Log_Error("USB", "String is %i bytes, which is over prealloc size (%i)", @@ -125,6 +139,8 @@ char *USB_int_GetDeviceString(tUSBDevice *Dev, int Endpoint, int Index) // } src_len = (str.Length - 2) / sizeof(str.Data[0]); + LOG("&str = %p, src_len = %i", &str, src_len); + new_len = _UTF16to8(str.Data, src_len, NULL); ret = malloc( new_len + 1 ); _UTF16to8(str.Data, src_len, ret);