1 #ifndef __USB_XHCI_H 2 #define __USB_XHCI_H 3 4 struct usbdevice_s; 5 struct usb_endpoint_descriptor; 6 struct usb_pipe; 7 8 // -------------------------------------------------------------- 9 10 // usb-xhci.c 11 void xhci_setup(void); 12 struct usb_pipe *xhci_realloc_pipe(struct usbdevice_s *usbdev 13 , struct usb_pipe *upipe 14 , struct usb_endpoint_descriptor *epdesc); 15 int xhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd 16 , void *data, int datasize); 17 int xhci_poll_intr(struct usb_pipe *p, void *data); 18 19 // -------------------------------------------------------------- 20 // register interface 21 22 // capabilities 23 struct xhci_caps { 24 u8 caplength; 25 u8 reserved_01; 26 u16 hciversion; 27 u32 hcsparams1; 28 u32 hcsparams2; 29 u32 hcsparams3; 30 u32 hccparams; 31 u32 dboff; 32 u32 rtsoff; 33 } PACKED; 34 35 // extended capabilities 36 struct xhci_xcap { 37 u32 cap; 38 u32 data[]; 39 } PACKED; 40 41 // operational registers 42 struct xhci_op { 43 u32 usbcmd; 44 u32 usbsts; 45 u32 pagesize; 46 u32 reserved_01[2]; 47 u32 dnctl; 48 u32 crcr_low; 49 u32 crcr_high; 50 u32 reserved_02[4]; 51 u32 dcbaap_low; 52 u32 dcbaap_high; 53 u32 config; 54 } PACKED; 55 56 // port registers 57 struct xhci_pr { 58 u32 portsc; 59 u32 portpmsc; 60 u32 portli; 61 u32 reserved_01; 62 } PACKED; 63 64 // doorbell registers 65 struct xhci_db { 66 u32 doorbell; 67 } PACKED; 68 69 // runtime registers 70 struct xhci_rts { 71 u32 mfindex; 72 } PACKED; 73 74 // interrupter registers 75 struct xhci_ir { 76 u32 iman; 77 u32 imod; 78 u32 erstsz; 79 u32 reserved_01; 80 u32 erstba_low; 81 u32 erstba_high; 82 u32 erdp_low; 83 u32 erdp_high; 84 } PACKED; 85 86 // -------------------------------------------------------------- 87 // memory data structs 88 89 // slot context 90 struct xhci_slotctx { 91 u32 ctx[4]; 92 u32 reserved_01[4]; 93 } PACKED; 94 95 // endpoint context 96 struct xhci_epctx { 97 u32 ctx[2]; 98 u32 deq_low; 99 u32 deq_high; 100 u32 length; 101 u32 reserved_01[3]; 102 } PACKED; 103 104 // device context array element 105 struct xhci_devlist { 106 u32 ptr_low; 107 u32 ptr_high; 108 } PACKED; 109 110 // input context 111 struct xhci_inctx { 112 u32 del; 113 u32 add; 114 u32 reserved_01[6]; 115 } PACKED; 116 117 // transfer block (ring element) 118 struct xhci_trb { 119 u32 ptr_low; 120 u32 ptr_high; 121 u32 status; 122 u32 control; 123 } PACKED; 124 125 // event ring segment 126 struct xhci_er_seg { 127 u32 ptr_low; 128 u32 ptr_high; 129 u32 size; 130 u32 reserved_01; 131 } PACKED; 132 133 #endif // usb-xhci.h 134