HACK
[asbestos.git] / stage1 / lv2.h
blob1b63bd401d40670b1a7865845fade780474d6e38
1 /* lv2.h - Lv-2 defines, thunks, and functions
3 Copyright (C) 2010-2011 Hector Martin "marcan" <hector@marcansoft.com>
5 This code is licensed to you under the terms of the GNU GPL, version 2;
6 see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
7 */
9 #ifndef LV2_H
10 #define LV2_H
12 #define NULL 0
14 typedef unsigned char u8;
15 typedef unsigned short u16;
16 typedef unsigned int u32;
17 typedef unsigned long u64;
19 typedef signed char s8;
20 typedef signed short s16;
21 typedef signed int s32;
22 typedef signed long s64;
24 #define CBTHUNK(ret, name, args) asm("" \
25 " .section \".text\"\n" \
26 " .align 2\n" \
27 " .p2align 3,,7\n" \
28 " .globl "#name"\n" \
29 " .section \".opd\",\"aw\"\n" \
30 " .align 3\n" \
31 #name": \n" \
32 " .quad .L."#name",.TOC.@tocbase\n" \
33 " .previous\n" \
34 " .type "#name", @function\n" \
35 ".L."#name":\n" \
36 " mflr 0\n" \
37 " std 0, 32(1)\n" \
38 " std 2, 40(1)\n" \
39 " clrrdi 2, 2, 32\n" \
40 " oris 2, 2, __toc@h\n" \
41 " ori 2, 2, __toc@l\n" \
42 " bl .L._"#name"\n" \
43 " ld 2, 40(1)\n" \
44 " ld 0, 32(1)\n" \
45 " mtlr 0\n" \
46 " blr\n" \
47 " .size "#name",.-.L."#name"\n"); \
48 ret name args; \
49 ret _##name args
51 typedef struct {
52 const char *name;
53 int (*probe_func)(int device_id);
54 int (*attach_func)(int device_id);
55 int (*detach_func)(int device_id);
57 } usb_driver_t;
59 typedef struct {
60 u8 bmRequestType;
61 u8 bRequest;
62 u16 wValue;
63 u16 wIndex;
64 u16 wLength;
65 } control_transfer_t;
67 // lv1 but meh
68 void panic(void);
69 void reboot(void);
71 // lv2 functions
72 void *usbGetDescriptor(int device_id, void *start, u8 type);
73 int usbOpenEndpoint(int device_id, void *epdesc);
74 int usbControlTransfer(int pipe_id, control_transfer_t *request, void *data, void *cb, void *cbarg);
75 int printf(const char *fmt, ...);
77 #endif