Revision 806b6024 hw/usb.h
b/hw/usb.h | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
|
25 | 25 |
#include "block.h" |
26 |
#include "qdev.h" |
|
26 | 27 |
|
27 | 28 |
#define USB_TOKEN_SETUP 0x2d |
28 | 29 |
#define USB_TOKEN_IN 0x69 /* device -> host */ |
... | ... | |
116 | 117 |
#define USB_ENDPOINT_XFER_BULK 2 |
117 | 118 |
#define USB_ENDPOINT_XFER_INT 3 |
118 | 119 |
|
120 |
typedef struct USBBus USBBus; |
|
119 | 121 |
typedef struct USBPort USBPort; |
120 | 122 |
typedef struct USBDevice USBDevice; |
123 |
typedef struct USBDeviceInfo USBDeviceInfo; |
|
121 | 124 |
typedef struct USBPacket USBPacket; |
122 | 125 |
|
123 | 126 |
/* definition of a USB device */ |
124 | 127 |
struct USBDevice { |
128 |
DeviceState qdev; |
|
129 |
USBDeviceInfo *info; |
|
125 | 130 |
void *opaque; |
126 | 131 |
|
127 |
/* |
|
128 |
* Process USB packet. |
|
132 |
int speed; |
|
133 |
uint8_t addr; |
|
134 |
char devname[32]; |
|
135 |
|
|
136 |
int state; |
|
137 |
uint8_t setup_buf[8]; |
|
138 |
uint8_t data_buf[1024]; |
|
139 |
int remote_wakeup; |
|
140 |
int setup_state; |
|
141 |
int setup_len; |
|
142 |
int setup_index; |
|
143 |
}; |
|
144 |
|
|
145 |
struct USBDeviceInfo { |
|
146 |
DeviceInfo qdev; |
|
147 |
int (*init)(USBDevice *dev); |
|
148 |
|
|
149 |
/* |
|
150 |
* Process USB packet. |
|
129 | 151 |
* Called by the HC (Host Controller). |
130 | 152 |
* |
131 |
* Returns length of the transaction
|
|
153 |
* Returns length of the transaction |
|
132 | 154 |
* or one of the USB_RET_XXX codes. |
133 |
*/
|
|
155 |
*/ |
|
134 | 156 |
int (*handle_packet)(USBDevice *dev, USBPacket *p); |
135 | 157 |
|
136 |
/*
|
|
158 |
/* |
|
137 | 159 |
* Called when device is destroyed. |
138 | 160 |
*/ |
139 | 161 |
void (*handle_destroy)(USBDevice *dev); |
140 | 162 |
|
141 |
int speed; |
|
142 |
|
|
143 |
/* The following fields are used by the generic USB device |
|
144 |
layer. They are here just to avoid creating a new structure |
|
145 |
for them. */ |
|
146 |
|
|
147 | 163 |
/* |
148 | 164 |
* Reset the device |
149 |
*/
|
|
165 |
*/ |
|
150 | 166 |
void (*handle_reset)(USBDevice *dev); |
151 | 167 |
|
152 | 168 |
/* |
... | ... | |
165 | 181 |
* Returns length or one of the USB_RET_ codes. |
166 | 182 |
*/ |
167 | 183 |
int (*handle_data)(USBDevice *dev, USBPacket *p); |
168 |
|
|
169 |
uint8_t addr; |
|
170 |
char devname[32]; |
|
171 |
|
|
172 |
int state; |
|
173 |
uint8_t setup_buf[8]; |
|
174 |
uint8_t data_buf[1024]; |
|
175 |
int remote_wakeup; |
|
176 |
int setup_state; |
|
177 |
int setup_len; |
|
178 |
int setup_index; |
|
179 | 184 |
}; |
180 | 185 |
|
181 | 186 |
typedef void (*usb_attachfn)(USBPort *port, USBDevice *dev); |
... | ... | |
297 | 302 |
uint32_t musb_core_intr_get(MUSBState *s); |
298 | 303 |
void musb_core_intr_clear(MUSBState *s, uint32_t mask); |
299 | 304 |
void musb_set_size(MUSBState *s, int epnum, int size, int is_tx); |
305 |
|
|
306 |
/* usb-bus.c */ |
|
307 |
|
|
308 |
struct USBBus { |
|
309 |
BusState qbus; |
|
310 |
int busnr; |
|
311 |
int nfree; |
|
312 |
int nused; |
|
313 |
TAILQ_HEAD(, USBPort) free; |
|
314 |
TAILQ_HEAD(, USBPort) used; |
|
315 |
TAILQ_ENTRY(USBBus) next; |
|
316 |
}; |
|
317 |
|
|
318 |
USBBus *usb_bus_new(DeviceState *host); |
|
319 |
USBBus *usb_bus_find(int busnr); |
|
320 |
void usb_qdev_register(USBDeviceInfo *info); |
|
321 |
void usb_qdev_register_many(USBDeviceInfo *info); |
|
322 |
USBDevice *usb_create_simple(USBBus *bus, const char *name); |
Also available in: Unified diff