Changeset cb89430 in mainline for uspace/drv/bus/usb/xhci/hw_struct
- Timestamp:
- 2017-06-22T13:59:15Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e4d7363
- Parents:
- 62ba2cbe
- Location:
- uspace/drv/bus/usb/xhci/hw_struct
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/hw_struct/context.h
r62ba2cbe rcb89430 43 43 44 44 #include <stdint.h> 45 #include <common.h>45 #include "common.h" 46 46 47 47 /** … … 67 67 #define XHCI_EP_TR_DPTR(ctx) XHCI_DWORD_EXTRACT((ctx).data[2], 63, 4) 68 68 69 } ep_ctx_t __attribute__((packed));69 } __attribute__((packed)) xhci_ep_ctx_t; 70 70 71 71 /** … … 93 93 #define XHCI_SLOT_SLOT_STATE(ctx) XHCI_DWORD_EXTRACT((ctx).data[3], 31, 27) 94 94 95 } xhci_slot_ctx_t __attribute__((packed));95 } __attribute__((packed)) xhci_slot_ctx_t; 96 96 97 97 /** … … 101 101 xhci_slot_ctx_t slot_ctx; 102 102 xhci_ep_ctx_t endpoint_ctx [31]; 103 } xhci_device_ctx_t;103 } __attribute__((packed)) xhci_device_ctx_t; 104 104 105 105 /** … … 108 108 typedef struct xhci_stream_ctx { 109 109 uint64_t data [2]; 110 } xhci_stream_ctx_t __attribute__((packed));110 } __attribute__((packed)) xhci_stream_ctx_t; 111 111 112 112 #endif -
uspace/drv/bus/usb/xhci/hw_struct/regs.h
r62ba2cbe rcb89430 43 43 #include "common.h" 44 44 45 /*46 */47 48 45 #define XHCI_PIO_CHANGE_UDELAY 5 49 50 #define host2xhci(size, val) host2uint##size##_t_le((val))51 #define xhci2host(size, val) uint##size##_t_le2host((val))52 46 53 47 /* … … 63 57 #define XHCI_REG_SET(reg_set, reg_spec, value) XHCI_REG_SET_INNER(reg_set, value, reg_spec) 64 58 #define XHCI_REG_CLR(reg_set, reg_spec, value) XHCI_REG_CLR_INNER(reg_set, value, reg_spec) 59 #define XHCI_REG_MASK(reg_spec) XHCI_REG_MASK_INNER(reg_spec) 60 #define XHCI_REG_SHIFT(reg_spec) XHCI_REG_SHIFT_INNER(reg_spec) 65 61 66 62 /* … … 78 74 #define XHCI_REG_CLR_INNER(reg_set, value, field, size, type, ...) \ 79 75 XHCI_REG_CLR_##type(&(reg_set)->field, value, size, ##__VA_ARGS__) 76 77 #define XHCI_REG_MASK_INNER(field, size, type, ...) \ 78 XHCI_REG_MASK_##type(size, ##__VA_ARGS__) 79 80 #define XHCI_REG_SHIFT_INNER(field, size, type, ...) \ 81 XHCI_REG_SHIFT_##type(size, ##__VA_ARGS__) 80 82 81 83 /* … … 86 88 #define XHCI_REG_SET_FIELD(ptr, value, size) pio_set_##size((ptr), host2xhci(size, value), XHCI_PIO_CHANGE_UDELAY); 87 89 #define XHCI_REG_CLR_FIELD(ptr, value, size) pio_clear_##size((ptr), host2xhci(size, value), XHCI_PIO_CHANGE_UDELAY); 90 #define XHCI_REG_MASK_FIELD(size) (~((uint##size##_t) 0)) 91 #define XHCI_REG_SHIFT_FIELD(size) (0) 88 92 89 93 /* … … 94 98 #define XHCI_REG_SET_FLAG(ptr, value, size, offset) XHCI_REG_SET_RANGE((ptr), (value), size, (offset), (offset)) 95 99 #define XHCI_REG_CLR_FLAG(ptr, value, size, offset) XHCI_REG_CLR_RANGE((ptr), (value), size, (offset), (offset)) 100 #define XHCI_REG_MASK_FLAG(size, offset) BIT_V(uint##size##_t, offset) 101 #define XHCI_REG_SHIFT_FLAG(size, offset) (offset) 96 102 97 103 /* … … 113 119 pio_clear_##size((ptr), host2xhci(size, BIT_RANGE_INSERT(uint##size##_t, (hi), (lo), (value))), \ 114 120 XHCI_PIO_CHANGE_UDELAY); 121 122 #define XHCI_REG_MASK_RANGE(size, hi, lo) BIT_RANGE(uint##size##_t, hi, lo) 123 #define XHCI_REG_SHIFT_RANGE(size, hi, lo) (lo) 115 124 116 125 /** HC capability registers: section 5.3 */ … … 215 224 #define XHCI_CAP_CIC hccparams2, 32, FLAG, 5 216 225 226 static inline unsigned xhci_get_max_spbuf(xhci_cap_regs_t *cap_regs) { 227 return XHCI_REG_RD(cap_regs, XHCI_CAP_MAX_SPBUF_HI) << 5 228 | XHCI_REG_RD(cap_regs, XHCI_CAP_MAX_SPBUF_LO); 229 } 230 217 231 /** 218 232 * XHCI Port Register Set: section 5.4, table 32 … … 395 409 #define XHCI_OP_CRCR_LO crcr_lo, 32, RANGE, 31, 6 396 410 #define XHCI_OP_CRCR_HI crcr_lo, 32, FIELD 411 #define XHCI_OP_DCBAAP_LO dcbaap_lo, 32, FIELD 412 #define XHCI_OP_DCBAAP_HI dcbaap_lo, 32, FIELD 413 #define XHCI_OP_MAX_SLOTS_EN config, 32, RANGE, 7, 0 414 #define XHCI_OP_U3E config, 32, FLAG, 8 415 #define XHCI_OP_CIE config, 32, FLAG, 9 416 417 /* Aggregating field to read & write whole status at once */ 418 #define XHCI_OP_STATUS usbsts, 32, RANGE, 12, 0 419 420 /* RW1C fields in usbsts */ 421 #define XHCI_STATUS_ACK_MASK 0x41C 397 422 398 423 /** … … 444 469 ioport32_t mfindex; 445 470 446 PADD32 [ 5];447 448 xhci_interrupter_regs_t ir [1024];471 PADD32 [7]; 472 473 xhci_interrupter_regs_t ir []; 449 474 } xhci_rt_regs_t; 450 475 … … 452 477 453 478 /** 454 * XHCI Doorbel Registers: section 5.6455 * 456 * These registers are write-only, thus convenience macros are useless.479 * XHCI Doorbell Registers: section 5.6 480 * 481 * These registers are to be written as a whole field. 457 482 */ 458 483 typedef ioport32_t xhci_doorbell_t; -
uspace/drv/bus/usb/xhci/hw_struct/trb.h
r62ba2cbe rcb89430 84 84 XHCI_TRB_TYPE_DEVICE_NOTIFICATION_EVENT, 85 85 XHCI_TRB_TYPE_MFINDEX_WRAP_EVENT, 86 87 XHCI_TRB_TYPE_MAX 86 88 }; 87 89 … … 93 95 xhci_dword_t status; 94 96 xhci_dword_t control; 95 } xhci_trb_t;97 } __attribute__((packed)) xhci_trb_t; 96 98 97 99 #define TRB_TYPE(trb) XHCI_DWORD_EXTRACT((trb).control, 15, 10) 100 #define TRB_CYCLE(trb) XHCI_DWORD_EXTRACT((trb).control, 0, 0) 98 101 #define TRB_LINK_TC(trb) XHCI_DWORD_EXTRACT((trb).control, 1, 1) 99 102 … … 114 117 static inline void xhci_trb_set_cycle(xhci_trb_t *trb, bool cycle) 115 118 { 116 xhci_dword_set_bits(&trb->control, cycle, 1, 1);119 xhci_dword_set_bits(&trb->control, cycle, 0, 0); 117 120 } 118 121 … … 137 140 } 138 141 139 140 142 /** 141 143 * Event Ring Segment Table: section 6.5 142 144 */ 143 145 typedef struct xhci_erst_entry { 144 xhci_qword_t rs_base_ptr; // sans bits 0-6 145 xhci_dword_t size; // only low 16 bits, the rest is reserved 146 xhci_qword_t rs_base_ptr; /* 64B aligned */ 147 xhci_dword_t size; /* only low 16 bits, the rest is RsvdZ */ 148 xhci_dword_t _reserved; 146 149 } xhci_erst_entry_t; 147 150 151 static inline void xhci_fill_erst_entry(xhci_erst_entry_t *entry, uintptr_t phys, int segments) 152 { 153 xhci_qword_set(&entry->rs_base_ptr, phys); 154 xhci_dword_set_bits(&entry->size, segments, 16, 0); 155 } 156 148 157 #endif
Note:
See TracChangeset
for help on using the changeset viewer.