X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FUSB%2FCore%2Fusb_poll.c;h=8fd1b0ce9ded1d4bf8a0ed2830415e10d2f74a8b;hb=0e361ff8d9472885f770a370c0d477c229041572;hp=92e0292292d9f148953139b49ad3216165db0c84;hpb=89e41793b9d495d98633f90e6595722b8e5979d3;p=tpg%2Facess2.git diff --git a/Modules/USB/Core/usb_poll.c b/Modules/USB/Core/usb_poll.c index 92e02922..8fd1b0ce 100644 --- a/Modules/USB/Core/usb_poll.c +++ b/Modules/USB/Core/usb_poll.c @@ -26,7 +26,7 @@ void USB_StartPollingEndpoint(tUSBInterface *Iface, int Endpoint) tUSBEndpoint *endpt; // Some sanity checks - if(Endpoint <= 0 || Endpoint >= Iface->nEndpoints) return ; + if(Endpoint <= 0 || Endpoint > Iface->nEndpoints) return ; endpt = &Iface->Endpoints[Endpoint-1]; if(endpt->PollingPeriod > POLL_MAX || endpt->PollingPeriod <= 0) return ; @@ -39,8 +39,14 @@ void USB_StartPollingEndpoint(tUSBInterface *Iface, int Endpoint) endpt->PollingAtoms = (endpt->PollingPeriod + POLL_ATOM-1) / POLL_ATOM; if(endpt->PollingAtoms > POLL_SLOTS) endpt->PollingAtoms = POLL_SLOTS; // Add to poll queue - endpt->Next = gUSB_PollQueues[endpt->PollingAtoms]; - gUSB_PollQueues[endpt->PollingAtoms] = endpt; + // TODO: Locking + { + 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; + } } /** @@ -48,6 +54,7 @@ void USB_StartPollingEndpoint(tUSBInterface *Iface, int Endpoint) */ int USB_PollThread(void *unused) { + Threads_SetName("USB Polling Thread"); for(;;) { tUSBEndpoint *ep, *prev; @@ -56,9 +63,11 @@ int USB_PollThread(void *unused) prev = (void*)( (tVAddr)&gUSB_PollQueues[giUSB_PollPosition] - offsetof(tUSBEndpoint, Next) ); // Process queue +// LOG("giUSB_PollPosition = %i", giUSB_PollPosition); 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); // Check for invalid entries if(period_in_atoms < 0 || period_in_atoms > POLL_ATOM) @@ -81,7 +90,7 @@ int USB_PollThread(void *unused) // TODO: Async checking? // - Send the read request on all of them then wait for the first to complete USB_RecvDataA( - ep->Interface, ep->EndpointIdx, + ep->Interface, ep->EndpointIdx+1, ep->MaxPacketSize, ep->InputData, ep->Interface->Driver->Endpoints[ep->EndpointIdx].DataAvail );