* usb_devinit.c
* - USB Device Initialisation
*/
-#define DEBUG 1
+#define DEBUG 0
#include <acess.h>
#include <vfs.h>
#include <drv_pci.h>
tUSBDevice tmpdev;
tUSBDevice *dev = &tmpdev;
if( Port >= Hub->nPorts ) return ;
- if( Hub->Devices[Port] ) return ;
+ if( Hub->Ports[Port].Dev ) return ;
ENTER("pHub iPort", Hub, Port);
free(full_buf);
}
- Hub->Devices[Port] = dev;
+ Hub->Ports[Port].Dev = dev;
// Done.
LEAVE('-');
void USB_DeviceDisconnected(tUSBHub *Hub, int Port)
{
tUSBDevice *dev;
- if( !Hub->Devices[Port] ) {
+ if( !Hub->Ports[Port].Dev ) {
Log_Error("USB", "Non-registered device disconnected");
return;
}
- dev = Hub->Devices[Port];
+ dev = Hub->Ports[Port].Dev;
// TODO: Free related resources
// - Endpoint registrations
// - Bus Address
USB_int_DeallocateAddress(dev->Host, dev->Address);
// - Inform handler
- // - Allocate memory
+ // - Release memory
free(dev);
+ Hub->Ports[Port].Dev = NULL;
}
void *USB_GetDeviceDataPtr(tUSBInterface *Dev) { return Dev->Data; }
int USB_int_AllocateAddress(tUSBHost *Host)
{
int i;
+ ASSERT(Host);
for( i = 1; i < 128; i ++ )
{
if(Host->AddressBitmap[i/8] & (1 << (i%8)))