#ifndef _KERNEL_DEVICE_USB_H #define _KERNEL_DEVICE_USB_H #include #include #define USB_DRIVER_MAX_MATCHES 1 /* descriptor types */ #define USB_DESC_DEVICE 1 #define USB_DESC_CONFIG 2 #define USB_DESC_STRING 3 #define USB_DESC_IF 4 #define USB_DESC_ENDPOINT 5 #define USB_DESC_IF_POWER 8 #define USB_DESC_OTG 9 #define USB_DESC_DEBUG 10 #define USB_DESC_IF_ASSOC 11 #define USB_DESC_BOS 15 #define USB_DESC_DEV_CAPABILITY 16 #define USB_DESC_SS_USB_EP_COMP 48 struct usb_desc_hdr { uint8_t length; uint8_t desc_type; } PACKED; struct usb_device_desc { struct usb_desc_hdr hdr; uint16_t bcd_usb; uint8_t dev_class; uint8_t dev_subclass; uint8_t dev_proto; uint8_t max_packet_size; /* If USB 3.0, this must be read as (1 << max_packet_size) */ uint16_t vendor_id; uint16_t product_id; uint16_t bcd_device; uint8_t manufacturer; uint8_t product; uint8_t serial_num; uint8_t num_configs; } PACKED; struct usb_string_lang_desc { struct usb_desc_hdr hdr; uint16_t langs[126]; } PACKED; struct usb_config_desc { struct usb_desc_hdr hdr; uint16_t total_length; uint8_t num_ifs; uint8_t config_value; uint8_t config; uint8_t attrs; uint8_t max_power; uint8_t data[245]; } PACKED; struct usb_if_desc { struct usb_desc_hdr hdr; uint8_t if_num; uint8_t alt_setting; uint8_t num_endpoints; uint8_t if_class; uint8_t if_subclass; uint8_t if_proto; uint8_t if1; } PACKED; struct usb_endpoint_desc { struct usb_desc_hdr hdr; uint8_t endpoint_addr; uint8_t attrs; uint16_t max_packet_size; uint8_t interval; } PACKED; #define USB_CBW_SIGNATURE 0x43425355 /* command block wrapper */ struct usb_cbw { uint32_t signature; uint32_t tag; uint32_t length; uint8_t dir; uint8_t lun; uint8_t cmd_len; uint8_t data[16]; } PACKED; #define USB_CSW_SIGNATURE 0x53425355 /* command status wrapper */ struct usb_csw { uint32_t signature; uint32_t tag; uint32_t residue; uint8_t status; }; struct usb_driver_info { uint8_t if_class; uint8_t if_subclass; uint8_t if_proto; bool (*init) (void); }; extern struct usb_driver_info usb_driver_infos[USB_DRIVER_MAX_MATCHES]; #endif // _KERNEL_DEVICE_USB_H