.Type = &gUSB_RootNodeType
}
};
-tUSBHost *gUSB_Hosts = NULL;
// === CODE ===
/**
tUSBHub *USB_RegisterHost(tUSBHostDef *HostDef, void *ControllerPtr, int nPorts);
// === GLOBALS ===
+tMutex glUSB_Hosts;
+tUSBHost *gUSB_Hosts = NULL;
+tMutex glUSB_InterfaceDrivers;
tUSBDriver *gpUSB_InterfaceDrivers = &gUSBHub_Driver;
// === CODE ===
host->RootHub.nPorts = nPorts;
memset(host->RootHub.Devices, 0, sizeof(void*)*nPorts);
- // TODO: Lock
+ // Append to list
+ Mutex_Acquire( &glUSB_Hosts );
host->Next = gUSB_Hosts;
gUSB_Hosts = host;
+ Mutex_Release( &glUSB_Hosts );
return &host->RootHub;
}
// --- Drivers ---
void USB_RegisterDriver(tUSBDriver *Driver)
{
+ Mutex_Acquire( &glUSB_InterfaceDrivers );
Driver->Next = gpUSB_InterfaceDrivers;
gpUSB_InterfaceDrivers = Driver;
+ Mutex_Release( &glUSB_InterfaceDrivers );
+
+ // TODO: Recheck devices that didn't have a driver
}
tUSBDriver *USB_int_FindDriverByClass(Uint32 ClassCode)
* usb_poll.c
* - Endpoint polling
*/
-#define DEBUG 0
+#define DEBUG 1
#include <usb_core.h>
#include "usb.h"
#include <timers.h>
op->Length = Length;
op->Data = ep->InputData;
+ LOG("op %p, endpoint %p (0x%x)", op, ep,
+ ep->Interface->Dev->Address * 16 + ep->EndpointNum);
+
Workqueue_AddWork(&gUSB_AsyncQueue, op);
}
endpt = &Iface->Endpoints[Endpoint-1];
LOG("endpt(%p)->PollingPeriod = %i", endpt, endpt->PollingPeriod);
if(endpt->PollingPeriod > 256 || endpt->PollingPeriod <= 0) {
+ LOG("Invalid polling period");
LEAVE('-');
return ;
}
// TODO: Check that this endpoint isn't already on the queue
endpt->InputData = malloc(endpt->MaxPacketSize);
-
+ LOG("Polling 0x%x at %i ms", Iface->Dev->Address * 16 + endpt->EndpointNum, endpt->PollingPeriod);
Iface->Dev->Host->HostDef->InterruptIN(
Iface->Dev->Host->Ptr,
Iface->Dev->Address * 16 + endpt->EndpointNum,