| 1 | /* TODO: spec citations per structure */ |
| 2 | |
| 3 | #include <drivers/usb/xhci.h> |
| 4 | #include <drivers/verifier.h> |
| 5 | |
| 6 | #define DV_STRUCT xhci_cap_regs |
| 7 | dv_size(0x20); |
| 8 | dv_align(1); |
| 9 | dv_field(uint8_t, cap_length, 0x00); |
| 10 | dv_field(uint8_t, reserved, 0x01); |
| 11 | dv_field(uint16_t, hci_version, 0x02); |
| 12 | dv_field(uint32_t, hcs_params1, 0x04); |
| 13 | dv_field(uint32_t, hcs_params2, 0x08); |
| 14 | dv_field(uint32_t, hcs_params3, 0x0C); |
| 15 | dv_field(uint32_t, hcc_params1, 0x10); |
| 16 | dv_field(uint32_t, dboff, 0x14); |
| 17 | dv_field(uint32_t, rtsoff, 0x18); |
| 18 | dv_field(uint32_t, hcc_params2, 0x1C); |
| 19 | #undef DV_STRUCT |
| 20 | |
| 21 | #define DV_STRUCT xhci_op_regs |
| 22 | dv_size(0x400); |
| 23 | dv_field(struct xhci_usbcmd, usbcmd, 0x00); |
| 24 | dv_field(uint32_t, usbsts, 0x04); |
| 25 | dv_field(uint32_t, pagesize, 0x08); |
| 26 | dv_field(uint32_t[2], reserved, 0x0C); |
| 27 | dv_field(uint32_t, dnctrl, 0x14); |
| 28 | dv_field(uint64_t, crcr, 0x18); |
| 29 | dv_field(uint32_t[4], reserved2, 0x20); |
| 30 | dv_field(uint64_t, dcbaap, 0x30); |
| 31 | dv_field(uint32_t, config, 0x38); |
| 32 | dv_field(uint32_t[241], reserved3, 0x3C); |
| 33 | dv_field_at(regs, 0x400); |
| 34 | #undef DV_STRUCT |
| 35 | |
| 36 | #define DV_STRUCT xhci_port_regs |
| 37 | dv_size(0x10); |
| 38 | dv_field(uint32_t, portsc, 0x00); |
| 39 | dv_field(uint32_t, portpmsc, 0x04); |
| 40 | dv_field(uint32_t, portli, 0x08); |
| 41 | dv_field(uint32_t, portct, 0x0C); |
| 42 | #undef DV_STRUCT |
| 43 | |
| 44 | #define DV_STRUCT xhci_usbcmd |
| 45 | dv_size(0x04); |
| 46 | dv_align(1); |
| 47 | #undef DV_STRUCT |
| 48 | |
| 49 | #define DV_STRUCT xhci_slot_ctx |
| 50 | dv_size(0x20); |
| 51 | dv_align(1); |
| 52 | dv_field(uint32_t[4], reserved3, 0x10); |
| 53 | /* bitfields: route_string, speed, reserved0, mtt, hub, context_entries, |
| 54 | * max_exit_latency, root_hub_port, num_ports, parent_hub_slot_id, |
| 55 | * parent_port_number, parent_think_time, reserved1, interrupter_target, |
| 56 | * usb_device_address, reserved2, slot_state */ |
| 57 | #undef DV_STRUCT |
| 58 | |
| 59 | /* xHCI specification, page 450 */ |
| 60 | #define DV_STRUCT xhci_ep_ctx |
| 61 | dv_size(0x20); |
| 62 | dv_align(1); |
| 63 | dv_field(uint32_t[3], reserved5, 0x14); |
| 64 | /* bitfields: ep_state, reserved1, mult, max_pstreams, lsa, interval, |
| 65 | * max_esit_payload_hi, reserved2, error_count, ep_type, reserved3, |
| 66 | * host_initiate_disable, max_burst_size, max_packet_size, average_trb_length, |
| 67 | * max_esit_payload_lo */ |
| 68 | #undef DV_STRUCT |
| 69 | |
| 70 | /* xHCI specification, page 461 */ |
| 71 | #define DV_STRUCT xhci_input_ctrl_ctx |
| 72 | dv_size(0x20); |
| 73 | dv_align(1); |
| 74 | dv_field(uint32_t, drop_flags, 0x00); |
| 75 | dv_field(uint32_t, add_flags, 0x04); |
| 76 | dv_field(uint32_t[5], reserved, 0x08); |
| 77 | /* bitfields: config, interface_num, alternate_setting, reserved1 */ |
| 78 | #undef DV_STRUCT |
| 79 | |
| 80 | /* xHCI specification, page 460 */ |
| 81 | #define DV_STRUCT xhci_input_ctx |
| 82 | dv_size(0x420); |
| 83 | dv_align(1); |
| 84 | dv_field(struct xhci_input_ctrl_ctx, ctrl_ctx, 0x00); |
| 85 | dv_field(struct xhci_slot_ctx, slot_ctx, 0x20); |
| 86 | dv_field(struct xhci_ep_ctx[31], ep_ctx, 0x40); |
| 87 | #undef DV_STRUCT |
| 88 | |
| 89 | #define DV_STRUCT xhci_device_ctx |
| 90 | dv_size(0x420); |
| 91 | dv_align(1); |
| 92 | dv_field(struct xhci_slot_ctx, slot_ctx, 0x00); |
| 93 | dv_field(struct xhci_ep_ctx[32], ep_ctx, 0x20); |
| 94 | #undef DV_STRUCT |
| 95 | |
| 96 | #define DV_STRUCT xhci_trb |
| 97 | dv_size(0x10); |
| 98 | dv_align(1); |
| 99 | dv_field(uint64_t, parameter, 0x00); |
| 100 | dv_field(uint32_t, status, 0x08); |
| 101 | dv_field(uint32_t, control, 0x0C); |
| 102 | #undef DV_STRUCT |
| 103 | |
| 104 | #define DV_STRUCT xhci_erst_entry |
| 105 | dv_size(0x10); |
| 106 | dv_align(1); |
| 107 | dv_field(uint64_t, ring_segment_base, 0x00); |
| 108 | dv_field(uint32_t, ring_segment_size, 0x08); |
| 109 | dv_field(uint32_t, reserved, 0x0C); |
| 110 | #undef DV_STRUCT |
| 111 | |
| 112 | #define DV_STRUCT xhci_interrupter_regs |
| 113 | dv_size(0x20); |
| 114 | dv_align(1); |
| 115 | dv_field(uint32_t, iman, 0x00); |
| 116 | dv_field(uint32_t, imod, 0x04); |
| 117 | dv_field(uint32_t, erstsz, 0x08); |
| 118 | dv_field(uint32_t, reserved, 0x0C); |
| 119 | dv_field(uint64_t, erstba, 0x10); |
| 120 | dv_field(uint64_t, erdp, 0x18); |
| 121 | #undef DV_STRUCT |
| 122 | |
| 123 | /* xHCI specification, page 441 */ |
| 124 | #define DV_STRUCT xhci_dcbaa |
| 125 | dv_size(0x800); |
| 126 | dv_align(64); |
| 127 | dv_field(uint64_t[256], ptrs, 0x00); |
| 128 | #undef DV_STRUCT |
| 129 | |