Modules/USB - Cleaning up protocol code, working on device API
[tpg/acess2.git] / Modules / USB / Core / usb.h
1 /*
2  * AcessOS Version 1
3  * USB Stack
4  */
5 #ifndef _USB_H_
6 #define _USB_H_
7
8 #include <usb_core.h>
9 #include <usb_hub.h>
10 #include <usb_host.h>
11
12 typedef struct sUSBHost tUSBHost;
13 typedef struct sUSBDevice       tUSBDevice;
14 typedef struct sUSBEndpoint     tUSBEndpoint;
15
16 // === STRUCTURES ===
17 /**
18  * \brief USB Hub data
19  */
20 struct sUSBHub
21 {
22         tUSBInterface   *Interface;
23         
24          int    nPorts;
25         tUSBDevice      *Devices[];
26 };
27
28 struct sUSBEndpoint
29 {
30         tUSBEndpoint    *Next;  // In the poll list
31         tUSBInterface   *Interface;
32          int    EndpointNum;
33         
34          int    PollingPeriod;  // In 1ms intervals
35          int    MaxPacketSize;  // In bytes
36
37         Uint8   Type;   // Same as sUSBDriver.Endpoints.Type
38 };
39
40 /**
41  * \brief Structure for a device's interface
42  */
43 struct sUSBInterface
44 {
45         tUSBInterface   *Next;
46         tUSBDevice      *Dev;
47
48         tUSBDriver      *Driver;
49         void    *Data;
50         
51          int    nEndpoints;
52         tUSBEndpoint    Endpoints[];
53 };
54
55 /**
56  * \brief Defines a single device on the USB Bus
57  */
58 struct sUSBDevice
59 {
60         tUSBHub *ParentHub;
61
62         /**
63          * \brief Host controller used
64          */
65         tUSBHost        *Host;
66          int    Address;
67
68          int    nInterfaces;
69         tUSBInterface   *Interfaces[];
70 };
71
72 struct sUSBHost
73 {
74         struct sUSBHost *Next;
75         
76         tUSBHostDef     *HostDef;
77         void    *Ptr;
78         
79         Uint8   AddressBitmap[128/8];
80         
81         tUSBDevice      RootHubDev;
82         tUSBInterface   RootHubIf;
83         tUSBHub RootHub;
84 };
85
86 extern void     USB_NewDevice(tUSBHub *Hub);
87
88 #endif

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