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
;
34 const USBDescIface
*ifs
;
38 uint8_t bInterfaceNumber
;
39 uint8_t bAlternateSetting
;
40 uint8_t bNumEndpoints
;
41 uint8_t bInterfaceClass
;
42 uint8_t bInterfaceSubClass
;
43 uint8_t bInterfaceProtocol
;
51 struct USBDescEndpoint
{
52 uint8_t bEndpointAddress
;
54 uint16_t wMaxPacketSize
;
63 typedef const char *USBDescStrings
[256];
67 const USBDescDevice
*full
;
68 const USBDescDevice
*high
;
69 const char* const *str
;
72 /* generate usb packages from structs */
73 int usb_desc_device(const USBDescID
*id
, const USBDescDevice
*dev
,
74 uint8_t *dest
, size_t len
);
75 int usb_desc_device_qualifier(const USBDescDevice
*dev
,
76 uint8_t *dest
, size_t len
);
77 int usb_desc_config(const USBDescConfig
*conf
, uint8_t *dest
, size_t len
);
78 int usb_desc_iface(const USBDescIface
*iface
, uint8_t *dest
, size_t len
);
79 int usb_desc_endpoint(const USBDescEndpoint
*ep
, uint8_t *dest
, size_t len
);
80 int usb_desc_other(const USBDescOther
*desc
, uint8_t *dest
, size_t len
);
82 /* control message emulation helpers */
83 void usb_desc_init(USBDevice
*dev
);
84 void usb_desc_attach(USBDevice
*dev
);
85 void usb_desc_set_string(USBDevice
*dev
, uint8_t index
, const char *str
);
86 const char *usb_desc_get_string(USBDevice
*dev
, uint8_t index
);
87 int usb_desc_string(USBDevice
*dev
, int index
, uint8_t *dest
, size_t len
);
88 int usb_desc_get_descriptor(USBDevice
*dev
, int value
, uint8_t *dest
, size_t len
);
89 int usb_desc_handle_control(USBDevice
*dev
, int request
, int value
,
90 int index
, int length
, uint8_t *data
);
92 #endif /* QEMU_HW_USB_DESC_H */