XenevaOS
Loading...
Searching...
No Matches
xhci.h
Go to the documentation of this file.
1
30#ifndef __XHCI_H__
31#define __XHCI_H__
32
33#include <stdint.h>
34#include <list.h>
35
36#define XHCI_USB_CMD_INTE (1<<2) //Interrupter enable
37#define XHCI_USB_CMD_HSEE (1<<3) // Host System Error enable
38
39#define XHCI_USB_STS_HCH (1<<0) //HC Halted
40#define XHCI_USB_STS_HSE (1<<2) //Host System Error -- 1 on error
41#define XHCI_USB_STS_EINT (1<<3) //Event Interrupt
42#define XHCI_USB_STS_PCD (1<<4) //Port Change Detect
43#define XHCI_USB_STS_SSS (1<<8) //Save state status -- 1 when cmd_css is 1
44#define XHCI_USB_STS_RSS (1<<9) //Restore state status
45#define XHCI_USB_STS_SRE (1<<10) //Save Restore error
46#define XHCI_USB_STS_CNR (1<<11) //Controller Not Ready
47#define XHCI_USB_STS_HCE (1<<12) //Host Controller Error
48
49#define XHCI_USB_CFG_MXSLOT_ENABLE 0xFF
50#define XHCI_USB_CFG_U3_EN (1<<8) //U3 Entry Enable
51#define XHCI_USB_CFG_CINFO_EN (1 << 9) //Config Information Enable
52
53#define XHCI_USB_CCR_RCS (1<<0) //Ring Cycle State
54#define XHCI_USB_CCR_CS (1<<1) //Command Stop
55#define XHCI_USB_CCR_CA (1<<2) //Command Abort
56#define XHCI_USB_CCR_CRR (1<<3) //Command Ring Running
57
58#define XHCI_USB_CCR_PTR_LO 0xFFFFFFC0
59#define XCHI_USB_CCR_PTR 0xFFFFFFFFFFFFFFC0
60
61#define XHCI_PORTSC_CCS (1<<0) //Current Connect Status
62#define XHCI_PORTSC_PED (1<<1) //Port Enabled/Disabled
63#define XHCI_PORTSC_OCA (1<<3) //Overcurrent Active
64#define XHCI_PORTSC_PR (1<<4) //Port Reset
65#define XHCI_PORTSC_PP (1<<9) //Port Power
66#define XHCI_PORTSC_CSC (1<<17) //Connect Status Change
67#define XHCI_PORTSC_PEC (1<<18) //Port Enabled/Disabled Change
68#define XHCI_PORTSC_PRC (1<<21) //Port Reset Change
69#define XHCI_PORTSC_WPR (1<<31) //On USB3 port warm reset
70
71#define XHCI_INT_ERDP_BUSY (1<<3)
72
73
74#define XHCI_TRB_SIZE 16
75#define XHCI_EVENT_RING_SEG_TBL_ENTRY_SIZE 16
76
77#define XHCI_TRB_ENT 0x200000000
78#define XHCI_TRB_ISP 0x400000000
79#define XHCI_TRB_IOC 0x2000000000
80#define XHCI_TRB_IDT 0x4000000000
81#define XHCI_TRB_TRT(x) ((uint64_t)x << 48)
82#define XHCI_TRB_DIR_IN ((uint64_t)1 << 48)
83
84#define XHCI_DOORBELL_ENDPOINT_0 1
85#define XHCI_DOORBELL_ENDPOINT_1 2
86
87/* USB speed numbers */
88#define USB_SPEED_RESERVED 0
89#define USB_FULL_SPEED 1
90#define USB_LOW_SPEED 2
91#define USB_HIGH_SPEED 3
92#define USB_SUPER_SPEED 4
93#define USB_SUPER_SPEED_PLUS 5
94
95typedef void(*endpoint_callback)(void* dev, void* slot,void* Endp);
96
97#pragma pack(push,1)
109#pragma pack(pop)
110
111#pragma pack(push,1)
124#pragma pack(pop)
125
126#pragma pack(push,1)
137#pragma pack(pop)
138
139#pragma pack(push,1)
145#pragma pack(pop)
146
147#pragma pack(push,1)
151#pragma pack(pop)
152
153#pragma pack(push,1)
160#pragma pack(pop)
161
162#pragma pack(push,1)
171#pragma pack(pop)
172
173#pragma pack(push,1)
180#pragma pack(pop)
181
182#pragma pack(push,1)
199#pragma pack(pop)
200
201#pragma pack(push,1)
220#pragma pack(pop)
221
222#pragma pack(push,1)
232#pragma pack(pop)
233
234#pragma pack(push,1)
248#pragma pack (pop)
249
250#pragma pack(push,1)
269#pragma pack(pop)
270
271
272#pragma pack(push,1)
290#pragma pack(pop)
291
306#pragma pack(pop)
307
308#pragma pack(push,1)
315#pragma pack(pop)
316
317#pragma pack(push,1)
325#pragma pack(pop)
326
327#pragma pack(push,1)
334#pragma pack(pop)
335
336#pragma pack(push,1)
347#pragma pack(pop)
348#endif
struct _xhci_slot_ XHCISlot
struct _endp_ XHCIEndpoint
void(* endpoint_callback)(void *dev, void *slot, void *Endp)
Definition xhci.h:95
struct _xhci_noop_trb_ xhci_noop_cmd_trb_t
struct _xhci_event_trb_ xhci_event_trb_t
struct _xhci_link_trb_ xhci_link_trb_t
struct _xhci_op_regs_ xhci_op_regs_t
struct _xhci_data_trb_ xhci_data_trb_t
struct _xhci_ex_cap_protocol_ xhci_ex_cap_protocol_t
struct _xhci_setup_trb_t_ xhci_setup_trb_t
struct _xhci_status_trb_ xhci_status_trb_t
struct _xhci_runtime_regs_ xhci_runtime_regs_t
struct _xhci_erst_ xhci_erst_t
struct _xhci_ex_cap_ xhci_ext_cap_t
struct _xhci_trb_ xhci_trb_t
struct _xhci_intr_reg_ xhci_interrupter_reg_t
struct _xhci_input_ctx_ XHCIInputContext
struct _xhci_doorbell_ xhci_doorbell_regs_t
struct _xhci_cap_regs_ xhci_cap_regs_t
struct _xhci_port_reg_ xhci_port_regs_t
void(* endpoint_callback)(void *dev, void *slot, void *Endp)
Definition xhci.h:143
struct _xhci_intr_reg_ xhci_interrupter_reg_t
unsigned int uint32_t
Definition acefiex.h:163
unsigned char uint8_t
Definition acefiex.h:161
COMPILER_DEPENDENT_UINT64 uint64_t
Definition acefiex.h:165
unsigned short int uint16_t
Definition acefiex.h:162
Definition xhci.h:183
endpoint_callback callback
Definition xhci.h:197
uint8_t ep_type
Definition xhci.h:195
unsigned cmd_ring_max
Definition xhci.h:190
uint8_t interval
Definition xhci.h:187
unsigned cmd_ring_index
Definition xhci.h:189
uint8_t max_packet_sz
Definition xhci.h:188
xhci_trb_t * cmd_ring
Definition xhci.h:184
uint8_t endpoint_num
Definition xhci.h:185
uint32_t offset
Definition xhci.h:193
unsigned cmd_ring_cycle
Definition xhci.h:191
uint32_t dc_offset
Definition xhci.h:194
uint8_t endpoint_type
Definition xhci.h:186
uint8_t dci
Definition xhci.h:192
uint8_t dir
Definition xhci.h:196
Definition list.h:46
Definition xhci.h:98
uint32_t cap_hccparams2
Definition xhci.h:107
uint32_t cap_hcsparams3
Definition xhci.h:104
uint16_t hci_version
Definition xhci.h:101
uint32_t cap_hcsparams1
Definition xhci.h:102
uint32_t cap_dboff
Definition xhci.h:106
uint32_t cap_hcsparams2
Definition xhci.h:103
uint8_t reserved
Definition xhci.h:100
uint8_t cap_caplen_version
Definition xhci.h:99
uint32_t cap_hccparams1
Definition xhci.h:105
Definition xhci.h:273
uint32_t evaluateNextTRB
Definition xhci.h:279
uint32_t immediate_data
Definition xhci.h:284
uint64_t dataBuffer
Definition xhci.h:274
uint32_t direction
Definition xhci.h:287
uint32_t trb_type
Definition xhci.h:286
uint32_t transferLength
Definition xhci.h:275
uint32_t no_snoop
Definition xhci.h:281
uint32_t interrupterTarget
Definition xhci.h:277
uint32_t rsvdZ2
Definition xhci.h:288
uint32_t interrupt_on_short_packet
Definition xhci.h:280
uint32_t cycleBit
Definition xhci.h:278
uint32_t rsvdZ
Definition xhci.h:285
uint32_t size
Definition xhci.h:276
uint32_t chain_bit
Definition xhci.h:282
uint32_t ioc
Definition xhci.h:283
Definition xhci.h:148
unsigned doorbell[256]
Definition xhci.h:149
Definition xhci.h:328
uint32_t rerserved
Definition xhci.h:332
uint32_t ring_seg_size
Definition xhci.h:331
uint32_t event_ring_seg_hi
Definition xhci.h:330
uint32_t event_ring_segment_lo
Definition xhci.h:329
Definition xhci.h:223
uint32_t rsvd3
Definition xhci.h:230
uint32_t trbType
Definition xhci.h:229
uint32_t completionCode
Definition xhci.h:226
uint32_t rsvd2
Definition xhci.h:228
uint32_t rsvd
Definition xhci.h:225
uint64_t ptr
Definition xhci.h:224
uint32_t cycleBit
Definition xhci.h:227
Definition xhci.h:163
uint32_t rsvd
Definition xhci.h:167
uint32_t rsvd2
Definition xhci.h:169
uint32_t controller_os_sem
Definition xhci.h:168
uint32_t next
Definition xhci.h:165
uint32_t controller_bios_semaphore
Definition xhci.h:166
uint32_t id
Definition xhci.h:164
Definition xhci.h:309
uint32_t port_cap_field2
Definition xhci.h:313
uint32_t port_cap_field
Definition xhci.h:312
xhci_ext_cap_t base
Definition xhci.h:310
unsigned char name[4]
Definition xhci.h:311
Definition xhci.h:337
uint32_t rsvd3
Definition xhci.h:342
uint32_t rsvd2
Definition xhci.h:341
uint32_t drop_ctx_flags
Definition xhci.h:338
uint32_t rsvd1
Definition xhci.h:340
uint32_t paramlast
Definition xhci.h:345
uint32_t rsvd5
Definition xhci.h:344
uint32_t add_ctx_flags
Definition xhci.h:339
uint32_t rsvd4
Definition xhci.h:343
Definition xhci.h:127
unsigned evtRngSegTabSz
Definition xhci.h:130
unsigned res
Definition xhci.h:131
unsigned intr_mod
Definition xhci.h:129
unsigned evtRngDeqPtrHi
Definition xhci.h:135
unsigned evtRngSegBaseHi
Definition xhci.h:133
unsigned intr_man
Definition xhci.h:128
unsigned evtRngDeqPtrLo
Definition xhci.h:134
unsigned evtRngSegBaseLo
Definition xhci.h:132
Definition xhci.h:318
uint32_t rsvdZ[3]
Definition xhci.h:319
uint32_t rsvdZ3
Definition xhci.h:323
uint32_t rsvdZ2
Definition xhci.h:321
uint32_t trb_type
Definition xhci.h:322
uint32_t cycleBit
Definition xhci.h:320
Definition xhci.h:112
uint32_t op_pad1[2]
Definition xhci.h:116
uint32_t op_dnctrl
Definition xhci.h:117
uint32_t op_dcbaap_hi
Definition xhci.h:121
uint64_t op_crcr
Definition xhci.h:118
uint32_t op_usbcmd
Definition xhci.h:113
uint32_t op_usbsts
Definition xhci.h:114
uint32_t op_config
Definition xhci.h:122
uint32_t op_pagesize
Definition xhci.h:115
uint32_t op_pad2[4]
Definition xhci.h:119
uint32_t op_dcbaap_lo
Definition xhci.h:120
Definition xhci.h:174
uint32_t port_hardware_LMP_ctl
Definition xhci.h:178
uint32_t port_sc
Definition xhci.h:175
uint32_t port_link_info
Definition xhci.h:177
uint32_t port_pmsc
Definition xhci.h:176
Definition xhci.h:140
char res[28]
Definition xhci.h:142
unsigned micro_frame_index
Definition xhci.h:141
xhci_interrupter_reg_t intr_reg[]
Definition xhci.h:143
Definition xhci.h:251
uint32_t immediateData
Definition xhci.h:263
uint32_t rsvdZ4
Definition xhci.h:267
uint32_t interrupterTarget
Definition xhci.h:259
uint32_t ioc
Definition xhci.h:262
uint32_t rsvdZ
Definition xhci.h:258
uint32_t bmRequestType
Definition xhci.h:252
uint32_t rsvdZ3
Definition xhci.h:264
uint32_t bRequest
Definition xhci.h:253
uint32_t wIndex
Definition xhci.h:255
uint32_t trbType
Definition xhci.h:265
uint32_t transferType
Definition xhci.h:266
uint32_t wValue
Definition xhci.h:254
uint32_t trbTransferLength
Definition xhci.h:257
uint32_t cycleBit
Definition xhci.h:260
uint32_t wLength
Definition xhci.h:256
uint32_t rsvdZ2
Definition xhci.h:261
Definition xhci.h:202
uint8_t classC
Definition xhci.h:209
unsigned cmd_ring_max
Definition xhci.h:214
uint64_t descriptor_buff
Definition xhci.h:216
list_t * endpoints
Definition xhci.h:218
xhci_trb_t * cmd_ring
Definition xhci.h:212
uint8_t port_speed
Definition xhci.h:205
uint8_t subClassC
Definition xhci.h:210
uint8_t root_hub_port_num
Definition xhci.h:204
uint64_t output_context_phys
Definition xhci.h:208
uint64_t cmd_ring_base
Definition xhci.h:206
uint64_t input_context_phys
Definition xhci.h:207
uint8_t prot
Definition xhci.h:211
unsigned cmd_ring_cycle
Definition xhci.h:215
unsigned cmd_ring_index
Definition xhci.h:213
uint16_t interface_val
Definition xhci.h:217
uint8_t slot_id
Definition xhci.h:203
Definition xhci.h:292
uint32_t rsvdZ
Definition xhci.h:294
uint32_t rsvdZ4
Definition xhci.h:304
uint32_t interrupter_target
Definition xhci.h:295
uint32_t trb_type
Definition xhci.h:302
uint32_t cycle_bit
Definition xhci.h:296
uint32_t ioc
Definition xhci.h:300
uint32_t evaluateNextTRB
Definition xhci.h:297
uint32_t chainBit
Definition xhci.h:299
uint32_t direction
Definition xhci.h:303
uint32_t rsvdZ2
Definition xhci.h:298
uint32_t rsvdZ0[2]
Definition xhci.h:293
uint32_t rsvdZ3
Definition xhci.h:301
Definition xhci.h:154
uint32_t trb_param_1
Definition xhci.h:155
uint32_t trb_control
Definition xhci.h:158
uint32_t trb_param_2
Definition xhci.h:156
uint32_t trb_status
Definition xhci.h:157