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
;
75 uint8_t bSynchAddress
;
77 uint8_t is_audio
; /* has bRefresh + bSynchAddress */
86 typedef const char *USBDescStrings
[256];
90 const USBDescDevice
*full
;
91 const USBDescDevice
*high
;
92 const char* const *str
;
95 /* generate usb packages from structs */
96 int usb_desc_device(const USBDescID
*id
, const USBDescDevice
*dev
,
97 uint8_t *dest
, size_t len
);
98 int usb_desc_device_qualifier(const USBDescDevice
*dev
,
99 uint8_t *dest
, size_t len
);
100 int usb_desc_config(const USBDescConfig
*conf
, uint8_t *dest
, size_t len
);
101 int usb_desc_iface_group(const USBDescIfaceAssoc
*iad
, uint8_t *dest
,
103 int usb_desc_iface(const USBDescIface
*iface
, uint8_t *dest
, size_t len
);
104 int usb_desc_endpoint(const USBDescEndpoint
*ep
, uint8_t *dest
, size_t len
);
105 int usb_desc_other(const USBDescOther
*desc
, uint8_t *dest
, size_t len
);
107 /* control message emulation helpers */
108 void usb_desc_init(USBDevice
*dev
);
109 void usb_desc_attach(USBDevice
*dev
);
110 void usb_desc_set_string(USBDevice
*dev
, uint8_t index
, const char *str
);
111 const char *usb_desc_get_string(USBDevice
*dev
, uint8_t index
);
112 int usb_desc_string(USBDevice
*dev
, int index
, uint8_t *dest
, size_t len
);
113 int usb_desc_get_descriptor(USBDevice
*dev
, int value
, uint8_t *dest
, size_t len
);
114 int usb_desc_handle_control(USBDevice
*dev
, USBPacket
*p
,
115 int request
, int value
, int index
, int length
, uint8_t *data
);
117 #endif /* QEMU_HW_USB_DESC_H */