summaryrefslogtreecommitdiffstats
path: root/qemu/roms/SLOF/lib/libusb/usb.code
blob: fd92d9e78f6a73dcbacd7fa0b7a0dfca0850a4f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/******************************************************************************
 * Copyright (c) 2013 IBM Corporation
 * All rights reserved.
 * This program and the accompanying materials
 * are made available under the terms of the BSD License
 * which accompanies this distribution, and is available at
 * http://www.opensource.org/licenses/bsd-license.php
 *
 * Contributors:
 *     IBM Corporation - initial implementation
 *****************************************************************************/
/*
 * libusb bindings for SLOF - implementation
 */

#include <usb.h>


/************************************************/
/* Register with the usb-core                   */
/* SLOF:   USB-OHCI-REGISTER  ( -- )            */
/* LIBNEWUSB: usb_ohci_register(void)           */
/************************************************/
PRIM(USB_X2d_OHCI_X2d_REGISTER)
	usb_ohci_register();
MIRP

/************************************************/
/* Register with the usb-core                   */
/* SLOF:   USB-EHCI-REGISTER  ( -- )            */
/* LIBNEWUSB: usb_ehci_register(void)           */
/************************************************/
PRIM(USB_X2d_EHCI_X2d_REGISTER)
	usb_ehci_register();
MIRP

/************************************************/
/* Register with the usb-core                   */
/* SLOF:   USB-XHCI-REGISTER  ( -- )            */
/* LIBNEWUSB: usb_xhci_register(void)           */
/************************************************/
PRIM(USB_X2d_XHCI_X2d_REGISTER)
	usb_xhci_register();
MIRP

/************************************************/
/* Initialize hcidev with the usb-core          */
/* SLOF:   USB-HCD-INIT  ( hcidev -- )          */
/* LIBNEWUSB: usb_hcd_init(hcidev)              */
/************************************************/
PRIM(USB_X2d_HCD_X2d_INIT)
	void *hcidev = TOS.a; POP;
	usb_hcd_init(hcidev);
MIRP

/************************************************/
/* Remove hcidev with the usb-core              */
/* SLOF:   USB-HCD-EXIT  ( hcidev -- )          */
/* LIBNEWUSB: usb_hcd_exit(hcidev)              */
/************************************************/
PRIM(USB_X2d_HCD_X2d_EXIT)
	void *hcidev = TOS.a; POP;
	usb_hcd_exit(hcidev);
MIRP

/************************************************/
/* Initialize hid                               */
/* SLOF:   USB-HID-INIT  ( dev -- true | false )*/
/* LIBNEWUSB: usb_hid_init(hcidev)              */
/************************************************/
PRIM(USB_X2d_HID_X2d_INIT)
	void *dev = TOS.a;
	TOS.n = usb_hid_init(dev);
MIRP

/************************************************/
/* Exit hid                                     */
/* SLOF:   USB-HID-EXIT  ( dev -- true | false )*/
/* LIBNEWUSB: usb_hid_exit(hcidev)              */
/************************************************/
PRIM(USB_X2d_HID_X2d_EXIT)
	void *dev = TOS.a;
	TOS.n = usb_hid_exit(dev);
MIRP

/************************************************/
/* Read usb keyboard for key                    */
/* SLOF:   USB-READ-KEYB  ( dev --              */
/*                        ( key | false  ))     */
/* LIBNEWUSB: usb_read_keyb                     */
/************************************************/
PRIM(USB_X2d_READ_X2d_KEYB)
	void *dev = TOS.a;
	TOS.n = usb_read_keyb(dev);
MIRP

/************************************************/
/* Is USB KEY available                         */
/* SLOF:   USB-KEY-AVAILABLE ( dev -- ( true |  */
/*                                      false ))*/
/* LIBNEWUSB: usb_key_available                 */
/************************************************/
PRIM(USB_X2d_KEY_X2d_AVAILABLE)
	void *dev = TOS.a;
	TOS.n = usb_key_available(dev);
MIRP

/************************************************/
/* Initialize and enumerate generic hub         */
/* SLOF: USB-HUB-INIT ( dev -- true | false )   */
/* LIBNEWUSB: usb_hub_init                      */
/************************************************/
PRIM(USB_X2d_HUB_X2d_INIT)
	void *dev = TOS.a;
	TOS.n = usb_hub_init(dev);
MIRP

/************************************************/
/* Initialize msc                               */
/* SLOF:   USB-MSC-INIT  ( dev -- true | false )*/
/* LIBNEWUSB: usb_msc_init(hcidev)              */
/************************************************/
PRIM(USB_X2d_MSC_X2d_INIT)
	void *dev = TOS.a;
	TOS.n = usb_msc_init(dev);
MIRP

/************************************************/
/* Exit msc                                     */
/* SLOF:   USB-MSC-EXIT  ( dev -- true | false )*/
/* LIBNEWUSB: usb_msc_exit(hcidev)              */
/************************************************/
PRIM(USB_X2d_MSC_X2d_EXIT)
	void *dev = TOS.a;
	TOS.n = usb_msc_exit(dev);
MIRP

/*****************************************************************************/
/* Transfer data through control endpoint                                    */
/* SLOF:   USB-TRANSFER_CTRL ( dev req data -- true | false )                */
/* LIBNEWUSB: int usb_transfer_ctrl(void *dev, void *req, void *data)        */
/*****************************************************************************/
PRIM(USB_X2d_TRANSFER_X2d_CTRL)
	void *data = TOS.a; POP;
	void *req = TOS.a; POP;
	TOS.n = usb_transfer_ctrl(TOS.a, req, data);
MIRP

/*****************************************************************************/
/* Transfer data through bulk endpoint                                       */
/* SLOF:  USB-TRANSFER_BULK ( dev dir td td-phys data size -- true | false ) */
/* LIBNEWUSB: int usb_transfer_bulk(void *dev, int dir, void *td,            */
/*                                  void *td_phys, void *data, int size)     */
/*****************************************************************************/
PRIM(USB_X2d_TRANSFER_X2d_BULK)
	int size = TOS.u; POP;
	void *data = TOS.a; POP;
	void *td_phys = TOS.a; POP;
	void *td = TOS.a; POP;
	int dir = TOS.u; POP;
	TOS.n = usb_transfer_bulk(TOS.a, dir, td, td_phys, data, size);
MIRP