revert between 56095 -> 55830 in arch
[AROS.git] / workbench / devs / USB / stack / stubs / usb_stubs.c
blob8c9215c883b0242dfadb238b16624ce1824c8fcb
1 /*
2 Copyright © 2004, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Stub functions for USB subsystem
6 Lang: English
7 */
9 #ifndef AROS_USE_OOP
10 # define AROS_USE_OOP
11 #endif
13 #include <stdint.h>
14 #include <exec/libraries.h>
15 #include <exec/interrupts.h>
17 #include <utility/tagitem.h>
18 #include <utility/hooks.h>
20 #include <oop/oop.h>
21 #include <oop/static_mid.h>
23 #include <hidd/hidd.h>
25 #include <usb/usb.h>
27 #include <proto/oop.h>
29 #undef OOPBase
30 #define OOPBase (OOP_OOPBASE(obj))
32 BOOL HIDD_USB_AttachDriver(OOP_Object *obj, OOP_Object *driver)
34 STATIC_MID;
35 struct pHidd_USB_AttachDriver p;
37 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USB, moHidd_USB_AttachDriver);
39 p.mID = static_mid;
40 p.driverObject = driver;
42 return OOP_DoMethod(obj, &p.mID);
45 BOOL HIDD_USB_DetachDriver(OOP_Object *obj, OOP_Object *driver)
47 STATIC_MID;
48 struct pHidd_USB_DetachDriver p;
50 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USB, moHidd_USB_DetachDriver);
52 p.mID = static_mid;
53 p.driverObject = driver;
55 return OOP_DoMethod(obj, &p.mID);
58 void HIDD_USB_AddClass(OOP_Object *obj, const char *className)
60 STATIC_MID;
61 struct pHidd_USB_AddClass p;
63 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USB, moHidd_USB_AddClass);
65 p.mID = static_mid;
66 p.className = className;
68 OOP_DoMethod(obj, &p.mID);
71 uint8_t HIDD_USB_AllocAddress(OOP_Object *obj, OOP_Object *driver)
73 STATIC_MID;
74 struct pHidd_USB_AllocAddress p;
76 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USB, moHidd_USB_AllocAddress);
78 p.mID = static_mid;
79 p.driverObject = driver;
81 return OOP_DoMethod(obj, &p.mID);
84 void HIDD_USB_FreeAddress(OOP_Object *obj, OOP_Object *driver, uint8_t address)
86 STATIC_MID;
87 struct pHidd_USB_FreeAddress p;
89 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USB, moHidd_USB_FreeAddress);
91 p.mID = static_mid;
92 p.driverObject = driver;
93 p.address = address;
95 OOP_DoMethod(obj, &p.mID);
98 OOP_Object *HIDD_USB_NewDevice(OOP_Object *obj, OOP_Object *hub, BOOL fast)
100 STATIC_MID;
101 struct pHidd_USB_NewDevice p;
103 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USB, moHidd_USB_NewDevice);
105 p.mID = static_mid;
106 p.hub = hub;
107 p.fast = fast;
109 return (OOP_Object *)OOP_DoMethod(obj, &p.mID);
114 BOOL HIDD_USBDevice_GetDescriptor(OOP_Object *obj, uint8_t type, uint8_t index, uint16_t length, APTR descriptor)
116 STATIC_MID;
117 struct pHidd_USBDevice_GetDescriptor p;
119 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDevice, moHidd_USBDevice_GetDescriptor);
121 p.mID = static_mid;
122 p.type = type;
123 p.index = index;
124 p.length = length;
125 p.descriptor = descriptor;
127 return OOP_DoMethod(obj, &p.mID);
130 BOOL HIDD_USBDevice_GetConfigDescriptor(OOP_Object *obj, uint8_t index, usb_config_descriptor_t *descriptor)
132 STATIC_MID;
133 struct pHidd_USBDevice_GetConfigDescriptor p;
135 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDevice, moHidd_USBDevice_GetConfigDescriptor);
137 p.mID = static_mid;
138 p.index = index;
139 p.descriptor = descriptor;
141 return OOP_DoMethod(obj, &p.mID);
144 BOOL HIDD_USBDevice_GetDeviceDescriptor(OOP_Object *obj, usb_device_descriptor_t *descriptor)
146 STATIC_MID;
147 struct pHidd_USBDevice_GetDeviceDescriptor p;
149 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDevice, moHidd_USBDevice_GetDeviceDescriptor);
151 p.mID = static_mid;
152 p.descriptor = descriptor;
154 return OOP_DoMethod(obj, &p.mID);
157 BOOL HIDD_USBDevice_GetStatus(OOP_Object *obj, usb_status_t *status)
159 STATIC_MID;
160 struct pHidd_USBDevice_GetStatus p;
162 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDevice, moHidd_USBDevice_GetStatus);
164 p.mID = static_mid;
165 p.status = status;
167 return OOP_DoMethod(obj, &p.mID);
171 BOOL HIDD_USBDevice_GetString(OOP_Object *obj, int8_t id, uint16_t language, usb_string_descriptor_t *string)
173 STATIC_MID;
174 struct pHidd_USBDevice_GetString p;
176 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDevice, moHidd_USBDevice_GetString);
178 p.mID = static_mid;
179 p.id = id;
180 p.language = language;
181 p.string = string;
183 return OOP_DoMethod(obj, &p.mID);
186 void * HIDD_USBDevice_CreatePipe(OOP_Object *obj, enum USB_PipeType type, uint8_t endpoint, uint8_t period, uint16_t maxpacket, uint32_t timeout)
188 STATIC_MID;
189 struct pHidd_USBDevice_CreatePipe p;
191 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDevice, moHidd_USBDevice_CreatePipe);
193 p.mID = static_mid;
194 p.type = type;
195 p.endpoint = endpoint;
196 p.period = period;
197 p.maxpacket = maxpacket;
198 p.timeout = timeout;
200 return (void *) OOP_DoMethod(obj, &p.mID);
203 void HIDD_USBDevice_DeletePipe(OOP_Object *obj, APTR pipe)
205 STATIC_MID;
206 struct pHidd_USBDevice_DeletePipe p;
208 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDevice, moHidd_USBDevice_DeletePipe);
210 p.mID = static_mid;
211 p.pipe = pipe;
213 OOP_DoMethod(obj, &p.mID);
216 void HIDD_USBDevice_SetTimeout(OOP_Object *obj, APTR pipe, uint32_t timeout)
218 STATIC_MID;
219 struct pHidd_USBDevice_SetTimeout p;
221 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDevice, moHidd_USBDevice_SetTimeout);
223 p.mID = static_mid;
224 p.pipe = pipe;
225 p.timeout = timeout;
227 OOP_DoMethod(obj, &p.mID);
230 BOOL HIDD_USBDevice_ControlMessage(OOP_Object *obj, APTR pipe, USBDevice_Request *request, APTR buffer, uint32_t length)
232 STATIC_MID;
233 struct pHidd_USBDevice_ControlMessage p;
235 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDevice, moHidd_USBDevice_ControlMessage);
237 p.mID = static_mid;
238 p.pipe = pipe;
239 p.request = request;
240 p.buffer = buffer;
241 p.length = length;
243 return OOP_DoMethod(obj, &p.mID);
246 BOOL HIDD_USBDevice_BulkTransfer(OOP_Object *obj, APTR pipe, APTR buffer, uint32_t length)
248 STATIC_MID;
249 struct pHidd_USBDevice_BulkTransfer p;
251 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDevice, moHidd_USBDevice_BulkTransfer);
253 p.mID = static_mid;
254 p.pipe = pipe;
255 p.buffer = buffer;
256 p.length = length;
258 return OOP_DoMethod(obj, &p.mID);
261 BOOL HIDD_USBDevice_Configure(OOP_Object *obj, uint8_t configNr)
263 STATIC_MID;
264 struct pHidd_USBDevice_Configure p;
266 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDevice, moHidd_USBDevice_Configure);
268 p.mID = static_mid;
269 p.configNr = configNr;
271 return OOP_DoMethod(obj, &p.mID);
274 usb_interface_descriptor_t *HIDD_USBDevice_GetInterface(OOP_Object *obj, uint8_t interface)
276 STATIC_MID;
277 struct pHidd_USBDevice_GetInterface p;
279 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDevice, moHidd_USBDevice_GetInterface);
281 p.mID = static_mid;
282 p.interface = interface;
284 return (usb_interface_descriptor_t *)OOP_DoMethod(obj, &p.mID);
287 usb_endpoint_descriptor_t *HIDD_USBDevice_GetEndpoint(OOP_Object *obj, uint8_t interface, uint8_t endpoint)
289 STATIC_MID;
290 struct pHidd_USBDevice_GetEndpoint p;
292 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDevice, moHidd_USBDevice_GetEndpoint);
294 p.mID = static_mid;
295 p.interface = interface;
296 p.endpoint = endpoint;
298 return (usb_endpoint_descriptor_t *)OOP_DoMethod(obj, &p.mID);
301 BOOL HIDD_USBHub_OnOff(OOP_Object *obj, BOOL on)
303 STATIC_MID;
304 struct pHidd_USBHub_OnOff p;
306 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBHub, moHidd_USBHub_OnOff);
308 p.mID = static_mid;
309 p.on = on;
311 return OOP_DoMethod(obj, &p.mID);
314 BOOL HIDD_USBHub_PortEnable(OOP_Object *obj, uint8_t port, BOOL enable)
316 STATIC_MID;
317 struct pHidd_USBHub_PortEnable p;
319 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBHub, moHidd_USBHub_PortEnable);
321 p.mID = static_mid;
322 p.portNummer = port;
323 p.enable = enable;
325 return OOP_DoMethod(obj, &p.mID);
328 BOOL HIDD_USBHub_PortReset(OOP_Object *obj, uint8_t port)
330 STATIC_MID;
331 struct pHidd_USBHub_PortReset p;
333 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBHub, moHidd_USBHub_PortReset);
335 p.mID = static_mid;
336 p.portNummer = port;
338 return OOP_DoMethod(obj, &p.mID);
341 BOOL HIDD_USBHub_GetPortStatus(OOP_Object *obj, uint8_t port, usb_port_status_t *status)
343 STATIC_MID;
344 struct pHidd_USBHub_GetPortStatus p;
346 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBHub, moHidd_USBHub_GetPortStatus);
348 p.mID = static_mid;
349 p.port = port;
350 p.status = status;
352 return OOP_DoMethod(obj, &p.mID);
355 BOOL HIDD_USBHub_GetHubStatus(OOP_Object *obj, usb_hub_status_t *status)
357 STATIC_MID;
358 struct pHidd_USBHub_GetHubStatus p;
360 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBHub, moHidd_USBHub_GetHubStatus);
362 p.mID = static_mid;
363 p.status = status;
365 return OOP_DoMethod(obj, &p.mID);
368 BOOL HIDD_USBHub_ClearHubFeature(OOP_Object *obj, int feature)
370 STATIC_MID;
371 struct pHidd_USBHub_ClearHubFeature p;
373 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBHub, moHidd_USBHub_ClearHubFeature);
375 p.mID = static_mid;
376 p.feature = feature;
378 return OOP_DoMethod(obj, &p.mID);
381 BOOL HIDD_USBHub_SetHubFeature(OOP_Object *obj, int feature)
383 STATIC_MID;
384 struct pHidd_USBHub_SetHubFeature p;
386 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBHub, moHidd_USBHub_SetHubFeature);
388 p.mID = static_mid;
389 p.feature = feature;
391 return OOP_DoMethod(obj, &p.mID);
394 BOOL HIDD_USBHub_ClearPortFeature(OOP_Object *obj, uint8_t port, int feature)
396 STATIC_MID;
397 struct pHidd_USBHub_ClearPortFeature p;
399 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBHub, moHidd_USBHub_ClearPortFeature);
401 p.mID = static_mid;
402 p.port = port;
403 p.feature = feature;
405 return OOP_DoMethod(obj, &p.mID);
408 BOOL HIDD_USBHub_SetPortFeature(OOP_Object *obj, uint8_t port, int feature)
410 STATIC_MID;
411 struct pHidd_USBHub_SetPortFeature p;
413 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBHub, moHidd_USBHub_SetPortFeature);
415 p.mID = static_mid;
416 p.port = port;
417 p.feature = feature;
419 return OOP_DoMethod(obj, &p.mID);
422 BOOL HIDD_USBHub_GetHubDescriptor(OOP_Object *obj, usb_hub_descriptor_t *descriptor)
424 STATIC_MID;
425 struct pHidd_USBHub_GetHubDescriptor p;
427 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBHub, moHidd_USBHub_GetHubDescriptor);
429 p.mID = static_mid;
430 p.descriptor = descriptor;
432 return OOP_DoMethod(obj, &p.mID);
435 OOP_Object *HIDD_USBHub_GetChild(OOP_Object *obj, uint8_t port)
437 STATIC_MID;
438 struct pHidd_USBHub_GetChild p;
440 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBHub, moHidd_USBHub_GetChild);
442 p.mID = static_mid;
443 p.port = port;
445 return (OOP_Object *)OOP_DoMethod(obj, &p.mID);
449 APTR HIDD_USBDrv_CreatePipe(OOP_Object *obj, enum USB_PipeType type,
450 BOOL fullspeed, uint8_t address, uint8_t endpoint, uint8_t period, uint32_t maxpacket, uint32_t timeout)
452 STATIC_MID;
453 struct pHidd_USBDrv_CreatePipe p;
455 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDrv, moHidd_USBDrv_CreatePipe);
457 p.mID = static_mid;
458 p.type = type;
459 p.fullspeed = fullspeed;
460 p.address = address;
461 p.endpoint = endpoint;
462 p.period = period;
463 p.maxpacket = maxpacket;
464 p.timeout = timeout;
466 return (APTR)OOP_DoMethod(obj, &p.mID);
469 void HIDD_USBDrv_DeletePipe(OOP_Object *obj, APTR pipe)
471 STATIC_MID;
472 struct pHidd_USBDrv_DeletePipe p;
474 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDrv, moHidd_USBDrv_DeletePipe);
476 p.mID = static_mid;
477 p.pipe = pipe;
479 OOP_DoMethod(obj, &p.mID);
482 void HIDD_USBDrv_SetTimeout(OOP_Object *obj, APTR pipe, uint32_t timeout)
484 STATIC_MID;
485 struct pHidd_USBDrv_SetTimeout p;
487 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDrv, moHidd_USBDrv_SetTimeout);
489 p.mID = static_mid;
490 p.pipe = pipe;
491 p.timeout = timeout;
493 OOP_DoMethod(obj, &p.mID);
496 BOOL HIDD_USBDrv_ControlTransfer(OOP_Object *obj, APTR pipe, USBDevice_Request *request,
497 APTR buffer, uint32_t length)
499 STATIC_MID;
500 struct pHidd_USBDrv_ControlTransfer p;
502 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDrv, moHidd_USBDrv_ControlTransfer);
504 p.mID = static_mid;
505 p.pipe = pipe;
506 p.request = request;
507 p.buffer = buffer;
508 p.length = length;
510 return OOP_DoMethod(obj, &p.mID);
513 BOOL HIDD_USBDrv_BulkTransfer(OOP_Object *obj, APTR pipe, APTR buffer, uint32_t length)
515 STATIC_MID;
516 struct pHidd_USBDrv_BulkTransfer p;
518 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDrv, moHidd_USBDrv_BulkTransfer);
520 p.mID = static_mid;
521 p.pipe = pipe;
522 p.buffer = buffer;
523 p.length = length;
525 return OOP_DoMethod(obj, &p.mID);
528 BOOL HIDD_USBDrv_AddInterrupt(OOP_Object *obj, void *pipe, void *buffer, uint8_t length, struct Interrupt *interrupt)
530 STATIC_MID;
531 struct pHidd_USBDrv_AddInterrupt p;
533 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDrv, moHidd_USBDrv_AddInterrupt);
535 p.mID = static_mid;
536 p.pipe = pipe;
537 p.buffer = buffer;
538 p.length = length;
539 p.interrupt = interrupt;
541 return OOP_DoMethod(obj, &p.mID);
544 BOOL HIDD_USBDrv_RemInterrupt(OOP_Object *obj, void *pipe, struct Interrupt *interrupt)
546 STATIC_MID;
547 struct pHidd_USBDrv_RemInterrupt p;
549 if (!static_mid) static_mid = OOP_GetMethodID((STRPTR)IID_Hidd_USBDrv, moHidd_USBDrv_RemInterrupt);
551 p.mID = static_mid;
552 p.pipe = pipe;
553 p.interrupt = interrupt;
555 return OOP_DoMethod(obj, &p.mID);