1 #ifndef QEMU_HW_USB_DESC_H
2 #define QEMU_HW_USB_DESC_H
10 uint8_t iManufacturer
;
12 uint8_t iSerialNumber
;
15 struct USBDescDevice
{
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
;
33 /* grouped interfaces */
35 const USBDescIfaceAssoc
*if_groups
;
37 /* "normal" interfaces */
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
;
52 const USBDescIface
*ifs
;
56 uint8_t bInterfaceNumber
;
57 uint8_t bAlternateSetting
;
58 uint8_t bNumEndpoints
;
59 uint8_t bInterfaceClass
;
60 uint8_t bInterfaceSubClass
;
61 uint8_t bInterfaceProtocol
;
69 struct USBDescEndpoint
{
70 uint8_t bEndpointAddress
;
72 uint16_t wMaxPacketSize
;
81 typedef const char *USBDescStrings
[256];
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
,
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 */