From a79a695585e69376330fd6b83b32a573d7df9dc7 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 30 Nov 2011 23:54:00 +0800 Subject: [PATCH] Modules/USB - Cleanup mostly --- Modules/USB/Core/hub.c | 13 +++++++++++++ Modules/USB/Core/usb_lowlevel.c | 2 ++ Modules/USB/Core/usb_poll.c | 15 +++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Modules/USB/Core/hub.c b/Modules/USB/Core/hub.c index 04a9cc52..849e8a3f 100644 --- a/Modules/USB/Core/hub.c +++ b/Modules/USB/Core/hub.c @@ -163,4 +163,17 @@ void Hub_int_HandleChange(tUSBInterface *Dev, int Port) USB_Request(Dev, 0, 0x23, CLEAR_FEATURE, C_PORT_CONNECTION, Port, 0, NULL); } + + // Reset change + if( status[1] & 0x0010 ) + { + if( status[0] & 0x0010 ) { + // Reset complete + } + else { + // Useful? + } + // ACK + USB_Request(Dev, 0, 0x23, CLEAR_FEATURE, C_PORT_RESET, Port, 0, NULL); + } } diff --git a/Modules/USB/Core/usb_lowlevel.c b/Modules/USB/Core/usb_lowlevel.c index 99423a73..65365d3b 100644 --- a/Modules/USB/Core/usb_lowlevel.c +++ b/Modules/USB/Core/usb_lowlevel.c @@ -132,6 +132,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); diff --git a/Modules/USB/Core/usb_poll.c b/Modules/USB/Core/usb_poll.c index 11afc130..ec03036f 100644 --- a/Modules/USB/Core/usb_poll.c +++ b/Modules/USB/Core/usb_poll.c @@ -13,6 +13,9 @@ #define POLL_MAX 256 // Max period that can be nominated #define POLL_SLOTS ((int)(POLL_MAX/POLL_ATOM)) +// === IMPORTS === +extern tUSBHost *gUSB_Hosts; + // === PROTOTYPES === void USB_StartPollingEndpoint(tUSBInterface *Iface, int Endpoint); @@ -43,7 +46,6 @@ void USB_StartPollingEndpoint(tUSBInterface *Iface, int Endpoint) { int idx = giUSB_PollPosition + 1; if(idx >= POLL_SLOTS) idx -= POLL_SLOTS; - LOG("idx = %i", idx); endpt->Next = gUSB_PollQueues[idx]; gUSB_PollQueues[idx] = endpt; } @@ -59,6 +61,15 @@ int USB_PollThread(void *unused) { tUSBEndpoint *ep, *prev; + if(giUSB_PollPosition == 0) + { + // Check hosts + for( tUSBHost *host = gUSB_Hosts; host; host = host->Next ) + { + host->HostDef->CheckPorts(host->Ptr); + } + } + // A little evil for neater code prev = (void*)( (tVAddr)&gUSB_PollQueues[giUSB_PollPosition] - offsetof(tUSBEndpoint, Next) ); @@ -67,7 +78,7 @@ int USB_PollThread(void *unused) for( ep = gUSB_PollQueues[giUSB_PollPosition]; ep; prev = ep, ep = ep->Next ) { int period_in_atoms = ep->PollingAtoms; - LOG("%i: ep = %p", giUSB_PollPosition, ep); +// LOG("%i: ep = %p", giUSB_PollPosition, ep); // Check for invalid entries if(period_in_atoms < 0 || period_in_atoms > POLL_ATOM) -- 2.20.1