grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / devs / USB / stack / usb.h
bloba70d464aa1f4ce674ef023b3c660f64168c19e59
1 #ifndef USB_H_
2 #define USB_H_
4 /*
5 Copyright (C) 2006 by Michal Schulz
6 $Id$
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Library General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU Library General Public
19 License along with this program; if not, write to the
20 Free Software Foundation, Inc.,
21 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include <stdint.h>
26 #include <exec/libraries.h>
27 #include <exec/execbase.h>
28 #include <exec/nodes.h>
29 #include <exec/lists.h>
30 #include <exec/semaphores.h>
31 #include <exec/ports.h>
32 #include <exec/interrupts.h>
33 #include <dos/bptr.h>
34 #include <dos/dosextens.h>
36 #include <aros/libcall.h>
37 #include <aros/asmcall.h>
39 #include <oop/oop.h>
41 #include <aros/arossupportbase.h>
42 #include <exec/execbase.h>
44 #include LC_LIBDEFS_FILE
46 extern OOP_AttrBase HiddAttrBase;
48 #define BITMAP_SIZE 128
49 #define MAX_HUB_PORTS 256
51 typedef struct usb_driver {
52 struct Node d_Node;
53 struct SignalSemaphore d_Lock;
54 OOP_Object *d_Driver;
55 uint32_t bitmap[BITMAP_SIZE/32];
56 } usb_driver_t;
58 struct usb_ExtClass {
59 struct Node ec_Node;
60 const char * ec_ShortName;
61 struct Library *ec_LibBase;
64 struct usb_staticdata
66 struct SignalSemaphore global_lock;
67 void *MemPool;
69 struct List driverList;
70 struct SignalSemaphore driverListLock;
72 struct List extClassList;
74 struct Process *usbProcess;
76 OOP_Object *usb;
77 OOP_Class *usbClass;
78 OOP_Class *deviceClass;
79 OOP_Class *driverClass;
80 OOP_Class *hubClass;
83 typedef struct {
84 usb_endpoint_descriptor_t *endpoint;
85 } EndpointData;
87 typedef struct {
88 usb_interface_descriptor_t *interface;
89 EndpointData *endpoints;
90 int index;
91 int altindex;
92 } InterfaceData;
94 typedef struct {
95 uint8_t address;
96 uint8_t iface;
97 uint8_t fast;
98 uint8_t maxpacket;
99 uint16_t langid;
100 usb_device_descriptor_t descriptor;
101 usb_config_descriptor_t *config_desc;
102 InterfaceData *interfaces;
104 int config;
106 char *product_name;
107 char *manufacturer_name;
108 char *serialnumber_name;
110 void *default_pipe;
111 struct usb_staticdata *sd;
112 OOP_Object *hub;
113 OOP_Object *bus;
114 struct timerequest *tr;
116 OOP_Object *next;
117 } DeviceData;
119 typedef struct {
120 struct Task *hub_task;
121 struct MsgPort *hub_port;
122 struct timerequest *tr;
123 uint8_t sigInterrupt;
125 STRPTR hub_name;
126 STRPTR proc_name;
127 struct usb_staticdata *sd;
128 OOP_Object **children;
129 usb_hub_descriptor_t descriptor;
130 uint8_t got_descriptor;
132 void *intr_pipe;
134 uint8_t root;
135 uint8_t enabled;
136 uint8_t status[20];
137 struct Interrupt interrupt;
138 } HubData;
140 struct usbbase
142 struct Library LibNode;
143 struct usb_staticdata sd;
146 enum EventType {
147 evt_Startup, // Startup message
148 evt_Cleanup, // Cleanup message
149 evt_Method, // Call method attached as ev_Event, put return value into ev_Retval, and reply
150 evt_AsyncMethod, // Call method attached as ev_Event, destroy original message
151 evt_HubAttached, // New hub (OOP_Object * in ev_RetVal) attached
152 evt_OnOff,
155 struct usbEvent {
156 struct Message ev_Message;
157 enum EventType ev_Type;
158 intptr_t ev_RetVal;
159 OOP_Object *ev_Target;
160 uint8_t ev_Event[];
163 #define METHOD(base, id, name) \
164 base ## __ ## id ## __ ## name (OOP_Class *cl, OOP_Object *o, struct p ## id ## _ ## name *msg)
166 #define BASE(lib)((struct usbbase*)(lib))
167 #define SD(cl) (&BASE(cl->UserData)->sd)
169 void setBitmap(uint32_t *bmp, uint8_t addr);
170 void freeBitmap(uint32_t *bmp, uint8_t addr);
171 uint8_t allocBitmap(uint32_t *bmp);
173 #endif /*USB_H_*/