Modules/USB - Working on a structure for the USB subsystem
[tpg/acess2.git] / Modules / USB / Core / usb.c
1 /*
2  * Acess 2 USB Stack
3  * USB Packet Control
4  */
5 #define DEBUG   1
6 #include <acess.h>
7 #include <vfs.h>
8 #include <drv_pci.h>
9 #include "usb.h"
10 #include "usb_proto.h"
11
12 // === STRUCTURES ===
13
14 // === CODE ===
15 tUSBHub *USB_RegisterHost(tUSBHostDef *HostDef, void *ControllerPtr, int nPorts)
16 {
17         // TODO:
18         return NULL;
19 }
20
21 void USB_DeviceConnected(tUSBHub *Hub, int Port)
22 {
23         if( Port >= Hub->nPorts )       return ;
24         if( Hub->Devices[Port] )        return ;
25
26         // 0. Perform port init? (done in hub?) 
27         // 1. Assign an address
28         
29         // 2. Get device information
30 }
31
32 void USB_DeviceDisconnected(tUSBHub *Hub, int Port)
33 {
34         
35 }
36
37 void *USB_GetDeviceDataPtr(tUSBDevice *Dev) { return Dev->Data; }
38 void USB_SetDeviceDataPtr(tUSBDevice *Dev, void *Ptr) { Dev->Data = Ptr; }
39
40 int USB_int_AllocateAddress(tUSBHost *Host)
41 {
42          int    i;
43         for( i = 1; i < 128; i ++ )
44         {
45                 if(Host->AddressBitmap[i/8] & (1 << i))
46                         continue ;
47                 return i;
48         }
49         return 0;
50 }
51
52 int USB_int_SendSetupSetAddress(tUSBHost *Host, void *Ptr, int Address)
53 {
54         struct sDeviceRequest   req;
55         req.ReqType = 0;        // bmRequestType
56         req.Request = 5;        // SET_ADDRESS
57         req.Value = Address & 0x7F;     // wValue
58         req.Index = 0;  // wIndex
59         req.Length = 0; // wLength
60         
61         // Addr 0:0, Data Toggle = 0, no interrupt
62         return Host->HostDef->SendSETUP(Ptr, 0, 0, 0, FALSE, &req, sizeof(req)) == NULL;
63 }

UCC git Repository :: git.ucc.asn.au