Annotation of qemu/roms/seabios/src/usb.h, revision 1.1.1.5

1.1       root        1: // USB functions and data.
                      2: #ifndef __USB_H
                      3: #define __USB_H
                      4: 
1.1.1.3   root        5: #include "util.h" // struct mutex_s
                      6: 
                      7: // Information on a USB end point.
                      8: struct usb_pipe {
                      9:     struct usb_s *cntl;
1.1.1.4   root       10:     u64 path;
1.1.1.3   root       11:     u8 type;
                     12:     u8 ep;
                     13:     u8 devaddr;
                     14:     u8 speed;
                     15:     u16 maxpacket;
                     16:     u8 tt_devaddr;
                     17:     u8 tt_port;
                     18: };
                     19: 
                     20: // Common information for usb controllers.
1.1       root       21: struct usb_s {
1.1.1.3   root       22:     struct usb_pipe *defaultpipe;
                     23:     struct mutex_s resetlock;
1.1.1.5 ! root       24:     struct pci_device *pci;
1.1.1.3   root       25:     int busid;
1.1       root       26:     u8 type;
                     27:     u8 maxaddr;
1.1.1.3   root       28: };
                     29: 
                     30: // Information for enumerating USB hubs
                     31: struct usbhub_s {
                     32:     struct usbhub_op_s *op;
                     33:     struct usb_pipe *pipe;
                     34:     struct usb_s *cntl;
                     35:     struct mutex_s lock;
                     36:     u32 powerwait;
                     37:     u32 port;
                     38:     u32 threads;
                     39:     u32 portcount;
                     40:     u32 devcount;
                     41: };
1.1       root       42: 
1.1.1.3   root       43: // Hub callback (32bit) info
                     44: struct usbhub_op_s {
                     45:     int (*detect)(struct usbhub_s *hub, u32 port);
                     46:     int (*reset)(struct usbhub_s *hub, u32 port);
                     47:     void (*disconnect)(struct usbhub_s *hub, u32 port);
1.1       root       48: };
                     49: 
                     50: #define USB_TYPE_UHCI 1
                     51: #define USB_TYPE_OHCI 2
1.1.1.3   root       52: #define USB_TYPE_EHCI 3
1.1       root       53: 
1.1.1.3   root       54: #define USB_FULLSPEED 0
                     55: #define USB_LOWSPEED  1
                     56: #define USB_HIGHSPEED 2
1.1       root       57: 
                     58: #define USB_MAXADDR 127
                     59: 
                     60: 
                     61: /****************************************************************
1.1.1.3   root       62:  * usb structs and flags
1.1       root       63:  ****************************************************************/
                     64: 
1.1.1.3   root       65: // USB mandated timings (in ms)
                     66: #define USB_TIME_SIGATT 100
                     67: #define USB_TIME_ATTDB  100
                     68: #define USB_TIME_DRST   10
                     69: #define USB_TIME_DRSTR  50
                     70: #define USB_TIME_RSTRCY 10
1.1       root       71: 
1.1.1.3   root       72: #define USB_TIME_SETADDR_RECOVERY 2
1.1       root       73: 
                     74: #define USB_PID_OUT                     0xe1
                     75: #define USB_PID_IN                      0x69
                     76: #define USB_PID_SETUP                   0x2d
                     77: 
                     78: #define USB_DIR_OUT                     0               /* to device */
                     79: #define USB_DIR_IN                      0x80            /* to host */
                     80: 
                     81: #define USB_TYPE_MASK                   (0x03 << 5)
                     82: #define USB_TYPE_STANDARD               (0x00 << 5)
                     83: #define USB_TYPE_CLASS                  (0x01 << 5)
                     84: #define USB_TYPE_VENDOR                 (0x02 << 5)
                     85: #define USB_TYPE_RESERVED               (0x03 << 5)
                     86: 
                     87: #define USB_RECIP_MASK                  0x1f
                     88: #define USB_RECIP_DEVICE                0x00
                     89: #define USB_RECIP_INTERFACE             0x01
                     90: #define USB_RECIP_ENDPOINT              0x02
                     91: #define USB_RECIP_OTHER                 0x03
                     92: 
                     93: #define USB_REQ_GET_STATUS              0x00
                     94: #define USB_REQ_CLEAR_FEATURE           0x01
                     95: #define USB_REQ_SET_FEATURE             0x03
                     96: #define USB_REQ_SET_ADDRESS             0x05
                     97: #define USB_REQ_GET_DESCRIPTOR          0x06
                     98: #define USB_REQ_SET_DESCRIPTOR          0x07
                     99: #define USB_REQ_GET_CONFIGURATION       0x08
                    100: #define USB_REQ_SET_CONFIGURATION       0x09
                    101: #define USB_REQ_GET_INTERFACE           0x0A
                    102: #define USB_REQ_SET_INTERFACE           0x0B
                    103: #define USB_REQ_SYNCH_FRAME             0x0C
                    104: 
                    105: struct usb_ctrlrequest {
                    106:     u8 bRequestType;
                    107:     u8 bRequest;
                    108:     u16 wValue;
                    109:     u16 wIndex;
                    110:     u16 wLength;
                    111: } PACKED;
                    112: 
                    113: #define USB_DT_DEVICE                   0x01
                    114: #define USB_DT_CONFIG                   0x02
                    115: #define USB_DT_STRING                   0x03
                    116: #define USB_DT_INTERFACE                0x04
                    117: #define USB_DT_ENDPOINT                 0x05
                    118: #define USB_DT_DEVICE_QUALIFIER         0x06
                    119: #define USB_DT_OTHER_SPEED_CONFIG       0x07
                    120: 
                    121: struct usb_device_descriptor {
                    122:     u8  bLength;
                    123:     u8  bDescriptorType;
                    124: 
                    125:     u16 bcdUSB;
                    126:     u8  bDeviceClass;
                    127:     u8  bDeviceSubClass;
                    128:     u8  bDeviceProtocol;
                    129:     u8  bMaxPacketSize0;
                    130:     u16 idVendor;
                    131:     u16 idProduct;
                    132:     u16 bcdDevice;
                    133:     u8  iManufacturer;
                    134:     u8  iProduct;
                    135:     u8  iSerialNumber;
                    136:     u8  bNumConfigurations;
                    137: } PACKED;
                    138: 
                    139: #define USB_CLASS_PER_INTERFACE         0       /* for DeviceClass */
                    140: #define USB_CLASS_AUDIO                 1
                    141: #define USB_CLASS_COMM                  2
                    142: #define USB_CLASS_HID                   3
                    143: #define USB_CLASS_PHYSICAL              5
                    144: #define USB_CLASS_STILL_IMAGE           6
                    145: #define USB_CLASS_PRINTER               7
                    146: #define USB_CLASS_MASS_STORAGE          8
                    147: #define USB_CLASS_HUB                   9
                    148: 
                    149: struct usb_config_descriptor {
                    150:     u8  bLength;
                    151:     u8  bDescriptorType;
                    152: 
                    153:     u16 wTotalLength;
                    154:     u8  bNumInterfaces;
                    155:     u8  bConfigurationValue;
                    156:     u8  iConfiguration;
                    157:     u8  bmAttributes;
                    158:     u8  bMaxPower;
                    159: } PACKED;
                    160: 
                    161: struct usb_interface_descriptor {
                    162:     u8  bLength;
                    163:     u8  bDescriptorType;
                    164: 
                    165:     u8  bInterfaceNumber;
                    166:     u8  bAlternateSetting;
                    167:     u8  bNumEndpoints;
                    168:     u8  bInterfaceClass;
                    169:     u8  bInterfaceSubClass;
                    170:     u8  bInterfaceProtocol;
                    171:     u8  iInterface;
                    172: } PACKED;
                    173: 
                    174: struct usb_endpoint_descriptor {
                    175:     u8  bLength;
                    176:     u8  bDescriptorType;
                    177: 
                    178:     u8  bEndpointAddress;
                    179:     u8  bmAttributes;
                    180:     u16 wMaxPacketSize;
                    181:     u8  bInterval;
                    182: } PACKED;
                    183: 
                    184: #define USB_ENDPOINT_NUMBER_MASK        0x0f    /* in bEndpointAddress */
                    185: #define USB_ENDPOINT_DIR_MASK           0x80
                    186: 
                    187: #define USB_ENDPOINT_XFERTYPE_MASK      0x03    /* in bmAttributes */
                    188: #define USB_ENDPOINT_XFER_CONTROL       0
                    189: #define USB_ENDPOINT_XFER_ISOC          1
                    190: #define USB_ENDPOINT_XFER_BULK          2
                    191: #define USB_ENDPOINT_XFER_INT           3
                    192: #define USB_ENDPOINT_MAX_ADJUSTABLE     0x80
                    193: 
1.1.1.3   root      194: 
                    195: /****************************************************************
                    196:  * function defs
                    197:  ****************************************************************/
                    198: 
                    199: // usb.c
                    200: void usb_setup(void);
                    201: void usb_enumerate(struct usbhub_s *hub);
                    202: int send_default_control(struct usb_pipe *pipe, const struct usb_ctrlrequest *req
                    203:                          , void *data);
                    204: int usb_send_bulk(struct usb_pipe *pipe, int dir, void *data, int datasize);
                    205: void free_pipe(struct usb_pipe *pipe);
                    206: struct usb_pipe *alloc_bulk_pipe(struct usb_pipe *pipe
                    207:                                  , struct usb_endpoint_descriptor *epdesc);
                    208: struct usb_pipe *alloc_intr_pipe(struct usb_pipe *pipe
                    209:                                  , struct usb_endpoint_descriptor *epdesc);
                    210: int usb_poll_intr(struct usb_pipe *pipe, void *data);
                    211: struct usb_endpoint_descriptor *findEndPointDesc(
                    212:     struct usb_interface_descriptor *iface, int imax, int type, int dir);
                    213: u32 mkendpFromDesc(struct usb_pipe *pipe
                    214:                    , struct usb_endpoint_descriptor *epdesc);
                    215: 
1.1       root      216: #endif // usb.h

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.