arm-semi.c: Use correct check for failure of do_brk()
[qemu.git] / hw / usb-desc.h
blob9d7ed599ce8b2973cb5fe45ab499aaf37f9c97b1
1 #ifndef QEMU_HW_USB_DESC_H
2 #define QEMU_HW_USB_DESC_H
4 #include <inttypes.h>
6 struct USBDescID {
7 uint16_t idVendor;
8 uint16_t idProduct;
9 uint16_t bcdDevice;
10 uint8_t iManufacturer;
11 uint8_t iProduct;
12 uint8_t iSerialNumber;
15 struct USBDescDevice {
16 uint16_t bcdUSB;
17 uint8_t bDeviceClass;
18 uint8_t bDeviceSubClass;
19 uint8_t bDeviceProtocol;
20 uint8_t bMaxPacketSize0;
21 uint8_t bNumConfigurations;
23 const USBDescConfig *confs;
26 struct USBDescConfig {
27 uint8_t bNumInterfaces;
28 uint8_t bConfigurationValue;
29 uint8_t iConfiguration;
30 uint8_t bmAttributes;
31 uint8_t bMaxPower;
33 /* grouped interfaces */
34 uint8_t nif_groups;
35 const USBDescIfaceAssoc *if_groups;
37 /* "normal" interfaces */
38 uint8_t nif;
39 const USBDescIface *ifs;
42 /* conceptually an Interface Association Descriptor, and releated interfaces */
43 struct USBDescIfaceAssoc {
44 uint8_t bFirstInterface;
45 uint8_t bInterfaceCount;
46 uint8_t bFunctionClass;
47 uint8_t bFunctionSubClass;
48 uint8_t bFunctionProtocol;
49 uint8_t iFunction;
51 uint8_t nif;
52 const USBDescIface *ifs;
55 struct USBDescIface {
56 uint8_t bInterfaceNumber;
57 uint8_t bAlternateSetting;
58 uint8_t bNumEndpoints;
59 uint8_t bInterfaceClass;
60 uint8_t bInterfaceSubClass;
61 uint8_t bInterfaceProtocol;
62 uint8_t iInterface;
64 uint8_t ndesc;
65 USBDescOther *descs;
66 USBDescEndpoint *eps;
69 struct USBDescEndpoint {
70 uint8_t bEndpointAddress;
71 uint8_t bmAttributes;
72 uint16_t wMaxPacketSize;
73 uint8_t bInterval;
76 struct USBDescOther {
77 uint8_t length;
78 uint8_t *data;
81 typedef const char *USBDescStrings[256];
83 struct USBDesc {
84 USBDescID id;
85 const USBDescDevice *full;
86 const USBDescDevice *high;
87 const char* const *str;
90 /* generate usb packages from structs */
91 int usb_desc_device(const USBDescID *id, const USBDescDevice *dev,
92 uint8_t *dest, size_t len);
93 int usb_desc_device_qualifier(const USBDescDevice *dev,
94 uint8_t *dest, size_t len);
95 int usb_desc_config(const USBDescConfig *conf, uint8_t *dest, size_t len);
96 int usb_desc_iface_group(const USBDescIfaceAssoc *iad, uint8_t *dest,
97 size_t len);
98 int usb_desc_iface(const USBDescIface *iface, uint8_t *dest, size_t len);
99 int usb_desc_endpoint(const USBDescEndpoint *ep, uint8_t *dest, size_t len);
100 int usb_desc_other(const USBDescOther *desc, uint8_t *dest, size_t len);
102 /* control message emulation helpers */
103 void usb_desc_init(USBDevice *dev);
104 void usb_desc_attach(USBDevice *dev);
105 void usb_desc_set_string(USBDevice *dev, uint8_t index, const char *str);
106 const char *usb_desc_get_string(USBDevice *dev, uint8_t index);
107 int usb_desc_string(USBDevice *dev, int index, uint8_t *dest, size_t len);
108 int usb_desc_get_descriptor(USBDevice *dev, int value, uint8_t *dest, size_t len);
109 int usb_desc_handle_control(USBDevice *dev, USBPacket *p,
110 int request, int value, int index, int length, uint8_t *data);
112 #endif /* QEMU_HW_USB_DESC_H */