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#include <Sync/spinlock.h>
36#include <Hal/x86_64_sched.h>
37
38#define XHCI_VENDOR_INTEL 0x8086
39#define XHCI_VENDOR_AMD 0x1022
40#define XHCI_VENDOR_ASMEDIA 0x1B21
41#define XHCI_VENDOR_LINUX_FOUNDATION 0x1D6A
42#define XHCI_VENDOR_NEC 0x1033
43#define XHCI_VENDOR_NVIDIA 0x10DE
44#define XHCI_VENDOR_FRESCO 0x1E31
45#define XHCI_VENDOR_VIA 0x1106
46
47#define XHCI_USB_CMD_INTE (1<<2) //Interrupter enable
48#define XHCI_USB_CMD_HSEE (1<<3) // Host System Error enable
49
50#define XHCI_USB_STS_HCH (1<<0) //HC Halted
51#define XHCI_USB_STS_HSE (1<<2) //Host System Error -- 1 on error
52#define XHCI_USB_STS_EINT (1<<3) //Event Interrupt
53#define XHCI_USB_STS_PCD (1<<4) //Port Change Detect
54#define XHCI_USB_STS_SSS (1<<8) //Save state status -- 1 when cmd_css is 1
55#define XHCI_USB_STS_RSS (1<<9) //Restore state status
56#define XHCI_USB_STS_SRE (1<<10) //Save Restore error
57#define XHCI_USB_STS_CNR (1<<11) //Controller Not Ready
58#define XHCI_USB_STS_HCE (1<<12) //Host Controller Error
59
60#define XHCI_USB_CFG_MXSLOT_ENABLE 0xFF
61#define XHCI_USB_CFG_U3_EN (1<<8) //U3 Entry Enable
62#define XHCI_USB_CFG_CINFO_EN (1 << 9) //Config Information Enable
63
64#define XHCI_USB_CCR_RCS (1<<0) //Ring Cycle State
65#define XHCI_USB_CCR_CS (1<<1) //Command Stop
66#define XHCI_USB_CCR_CA (1<<2) //Command Abort
67#define XHCI_USB_CCR_CRR (1<<3) //Command Ring Running
68
69#define XHCI_USB_CCR_PTR_LO 0xFFFFFFC0
70#define XCHI_USB_CCR_PTR 0xFFFFFFFFFFFFFFC0
71
72#define XHCI_PORTSC_CCS (1<<0) //Current Connect Status
73#define XHCI_PORTSC_PED (1<<1) //Port Enabled/Disabled
74#define XHCI_PORTSC_OCA (1<<3) //Overcurrent Active
75#define XHCI_PORTSC_PR (1<<4) //Port Reset
76#define XHCI_PORTSC_PP (1<<9) //Port Power
77#define XHCI_PORTSC_CSC (1<<17) //Connect Status Change
78#define XHCI_PORTSC_PEC (1<<18) //Port Enabled/Disabled Change
79#define XHCI_PORTSC_PRC (1<<21) //Port Reset Change
80#define XHCI_PORTSC_WPR (1<<31) //On USB3 port warm reset
81
82#define XHCI_INT_ERDP_BUSY (1<<3)
83
84
85#define XHCI_TRB_SIZE 16
86#define XHCI_EVENT_RING_SEG_TBL_ENTRY_SIZE 16
87
88#define XHCI_TRB_ENT 0x200000000
89#define XHCI_TRB_ISP 0x400000000
90#define XHCI_TRB_IOC 0x2000000000
91#define XHCI_TRB_IDT 0x4000000000
92#define XHCI_TRB_TRT(x) ((uint64_t)x << 48)
93#define XHCI_TRB_DIR_IN ((uint64_t)1 << 48)
94
95#define XHCI_DOORBELL_ENDPOINT_0 1
96#define XHCI_DOORBELL_ENDPOINT_1 2
97
98/* USB speed numbers */
99#define USB_SPEED_RESERVED 0
100#define USB_FULL_SPEED 1
101#define USB_LOW_SPEED 2
102#define USB_HIGH_SPEED 3
103#define USB_SUPER_SPEED 4
104#define USB_SUPER_SPEED_PLUS 5
105
106/* Standard XHCI defined Transfer/Command/Event
107* TRB type values
108*/
109#define TRB_TRANSFER_NORMAL 1
110#define TRB_TRANSFER_SETUP_STAGE 2
111#define TRB_TRANSFER_DATA_STAGE 3
112#define TRB_TRANSFER_STATUS_STAGE 4
113#define TRB_TRANSFER_ISOCH 5
114#define TRB_TRANSFER_LINK 6
115#define TRB_TRANSFER_EVENT_DATA 7
116#define TRB_TRANSFER_NO_OP 8
117#define TRB_CMD_ENABLE_SLOT 9
118#define TRB_CMD_DISABLE_SLOT 10
119#define TRB_CMD_ADDRESS_DEV 11
120#define TRB_CMD_CONFIG_ENDPOINT 12
121#define TRB_CMD_EVALUATE_CTX 13
122#define TRB_CMD_RESET_ENDPOINT 14
123#define TRB_CMD_STOP_ENDPOINT 15
124#define TRB_CMD_SET_TR_DEQ_POINTER 16
125#define TRB_CMD_RESET_DEV 17
126#define TRB_CMD_FORCE_EVENT 18
127#define TRB_CMD_NEGOTIATE_BANDWIDTH 19
128#define TRB_CMD_SET_LATENCY_TOLERANCE_VALUE 20
129#define TRB_CMD_GET_PORT_BANDWIDTH 21
130#define TRB_CMD_FORCE_HEADER 22
131#define TRB_CMD_NO_OP 23
132#define TRB_CMD_GET_EXT_PROPERTY 24
133#define TRB_CMD_SET_EXT_PROPERTY 25
134#define TRB_EVENT_TRANSFER 32
135#define TRB_EVENT_CMD_COMPLETION 33
136#define TRB_EVENT_PORT_STATUS_CHANGE 34
137#define TRB_EVENT_BANDWIDTH_REQUEST 35
138#define TRB_EVENT_DOORBELL 36
139#define TRB_EVENT_HOST_CONTROLLER 37
140#define TRB_EVENT_DEVICE_NOTIFICATION 38
141#define TRB_EVENT_MFINDEX 39
142
143typedef void(*endpoint_callback)(void* dev, void* slot, void* Endp);
144
145#pragma pack(push,1)
146typedef struct _xhci_cap_regs_ {
157#pragma pack(pop)
158
159#pragma pack(push,1)
160typedef struct _xhci_op_regs_ {
164 uint32_t op_pad1[2];
167 uint32_t op_pad2[4];
172#pragma pack(pop)
173
174#pragma pack(push,1)
175typedef struct _xhci_intr_reg_ {
176 unsigned intr_man;
177 unsigned intr_mod;
178 unsigned evtRngSegTabSz;
179 unsigned res;
180 unsigned evtRngSegBaseLo;
181 unsigned evtRngSegBaseHi;
182 unsigned evtRngDeqPtrLo;
183 unsigned evtRngDeqPtrHi;
185#pragma pack(pop)
186
187#pragma pack(push,1)
188typedef struct _xhci_runtime_regs_ {
189 unsigned micro_frame_index;
190 char res[28];
193#pragma pack(pop)
194
195#pragma pack(push,1)
196typedef struct _xhci_doorbell_ {
197 unsigned doorbell[256];
199#pragma pack(pop)
200
201#pragma pack(push,1)
202typedef struct _xhci_trb_ {
208#pragma pack(pop)
209
210#pragma pack(push,1)
211typedef struct _xhci_ex_cap_ {
212 uint32_t id : 8;
213 uint32_t next : 8;
215 uint32_t rsvd : 7;
217 uint32_t rsvd2 : 7;
219#pragma pack(pop)
220
221#pragma pack(push,1)
222typedef struct _xhci_port_reg_ {
228#pragma pack(pop)
229
230#pragma pack(push,1)
231typedef struct _endp_ {
239 unsigned cmd_ring_index;
240 unsigned cmd_ring_max;
241 unsigned cmd_ring_cycle;
242 uint8_t dci;
246 uint8_t dir;
249#pragma pack(pop)
250
251#pragma pack(push,1)
252typedef struct _xhci_slot_ {
263 unsigned cmd_ring_index;
264 unsigned cmd_ring_max;
265 unsigned cmd_ring_cycle;
270#pragma pack(pop)
271
272#pragma pack(push,1)
273typedef struct _xhci_event_trb_ {
275 uint32_t rsvd : 24;
277 uint32_t cycleBit : 1;
278 uint32_t rsvd2 : 9;
279 uint32_t trbType : 6;
280 uint32_t rsvd3 : 16;
282#pragma pack(pop)
283
284#pragma pack(push,1)
285typedef struct _xhci_link_trb_ {
287 uint32_t rsvd : 24;
291 uint32_t rsvd2 : 2;
293 uint32_t ioc : 1;
294 uint32_t rsvd3 : 4;
295 uint32_t trb_type : 6;
296 uint32_t rsvd4 : 16;
298#pragma pack (pop)
299
300#pragma pack(push,1)
301typedef struct _xhci_setup_trb_t_ {
303 uint32_t bRequest : 8;
304 uint32_t wValue : 16;
305 uint32_t wIndex : 16;
306 uint32_t wLength : 16;
308 uint32_t rsvdZ : 5;
310 uint32_t cycleBit : 1;
311 uint32_t rsvdZ2 : 4;
312 uint32_t ioc : 1;
314 uint32_t rsvdZ3 : 3;
315 uint32_t trbType : 6;
317 uint32_t rsvdZ4 : 14;
319#pragma pack(pop)
320
321
322#pragma pack(push,1)
323typedef struct _xhci_data_trb_ {
326 uint32_t size : 5;
328 uint32_t cycleBit : 1;
331 uint32_t no_snoop : 1;
333 uint32_t ioc : 1;
335 uint32_t rsvdZ : 3;
336 uint32_t trb_type : 6;
338 uint32_t rsvdZ2 : 15;
340#pragma pack(pop)
341
342typedef struct _xhci_status_trb_ {
343 uint32_t rsvdZ0[2];
344 uint32_t rsvdZ : 22;
348 uint32_t rsvdZ2 : 2;
349 uint32_t chainBit : 1;
350 uint32_t ioc : 1;
351 uint32_t rsvdZ3 : 4;
352 uint32_t trb_type : 6;
354 uint32_t rsvdZ4 : 15;
356#pragma pack(pop)
357
358#pragma pack(push,1)
359typedef struct _xhci_ex_cap_protocol_ {
361 unsigned char name[4];
365#pragma pack(pop)
366
367#pragma pack(push,1)
372#pragma pack(pop)
373
374#pragma pack(push,1)
375typedef struct _xhci_noop_trb_ {
376 uint32_t rsvdZ[3];
377 uint32_t cycleBit : 1;
378 uint32_t rsvdZ2 : 9;
379 uint32_t trb_type : 6;
380 uint32_t rsvdZ3 : 16;
382#pragma pack(pop)
383
384#pragma pack(push,1)
385typedef struct _xhci_erst_ {
391#pragma pack(pop)
392
393#pragma pack(push,1)
394typedef struct _xhci_input_ctx_ {
404#pragma pack(pop)
405
406#pragma pack(push,1)
440#pragma pack(pop)
441
442typedef struct _usb_hotplug_ {
443 unsigned int portNum;
446
447
448#define CTL_TRANSFER_TRT_NO_DATA 0
449#define CTL_TRANSFER_TRT_RESV 1
450#define CTL_TRANSFER_TRT_OUT_DATA 2
451#define CTL_TRANSFER_TRT_IN_DATA 3
452
453#define USB_SLOT_CTX_DWORD0(entries, hub, multi_tt, speed, route_string) \
454 (((entries & 0x1F) << 27) | ((hub & 1) << 26) | ((multi_tt & 1) << 25) | ((speed & 0xF) << 20) | (route_string & ((1 << 20) - 1)))
455
456#define USB_SLOT_CTX_DWORD1(num_ports, root_hub_port, max_exit_latency) \
457 (((num_ports & 0xFF) << 24) | ((root_hub_port & 0xFF) << 16) | (max_exit_latency & 0xFFFF))
458
459#define USB_ENDPOINT_CTX_DWORD0(max_esit_high, interval, lsa, max_p_streams, mult, ep_state) \
460 (((max_esit_high & 0xFF) << 24) | ((interval & 0xFF) << 16) | ((lsa & 1) << 15) | ((max_p_streams & 0x1F) << 10) | ((mult & 0x3) << 8) | (ep_state & 0x7))
461
462#define USB_ENDPOINT_CTX_DWORD1(max_packet_size, max_burst_size, hid, ep_type, cerr) \
463 (((max_packet_size & 0xFFFF) << 16) | ((max_burst_size & 0xFF) << 8) | ((hid & 1) << 7) | ((ep_type & 0x7) << 3) | ((cerr & 0x3) << 1))
464
465#define USB_ENDPOINT_CTX_DWORD2(trdp, dcs) \
466 ((trdp & 0xFFFFFFFF) | (dcs & 1))
467
468#define USB_ENDPOINT_CTX_DWORD3(trdp) \
469 ((trdp >> 32) & 0xFFFFFFFF)
470
471#define USB_ENDPOINT_CTX_DWORD4(max_esit_lo, average_trb_len) \
472 (((max_esit_lo & 0xFFFF) << 16) | (average_trb_len & 0xFFFF))
473
474
475
476/*
477* XHCISlotGetEP_DCI -- returns an endpoint by its endpoint number
478*/
479extern XHCIEndpoint* XHCISlotGetEP_DCI(XHCISlot* slot, uint8_t endp_num);
480
481/*
482* XHCIGetSlotByID -- returns a slot from slot list
483* @param dev -- Pointer to USB device
484* @param slot_id -- slot id
485*/
486extern XHCISlot* XHCIGetSlotByID(XHCIDevice* dev, uint8_t slot_id);
487
488/*
489 * XHCIGetHost -- returns the host device
490 * data structure
491 */
492extern XHCIDevice* XHCIGetHost();
493
494/*
495 * XHCIAddSlot -- adds a slot structure to slot list
496 * @param dev -- Pointer to usb device
497 * @param slot -- pointer to slot
498 */
499extern void XHCIAddSlot(XHCIDevice* dev, XHCISlot* slot);
500
501/*
502* XHCISlotRemove -- remove a slot structure from slot list
503* @param dev -- Pointer to usb device structure
504* @param slot_id -- slot id
505*/
506extern void XHCISlotRemove(XHCIDevice* dev, uint8_t slot_id);
507
508/*
509* XHCIRingDoorbellHost -- rings the host doorbell
510* @param dev -- Pointer to usb structure
511*/
512extern void XHCIRingDoorbellHost(XHCIDevice* dev);
513
514/*
515* XHCIPollEvent -- waits for an event to occur on interrupts
516* @param usb_device -- pointer to usb device structure
517* @param trb_type -- type of trb to look
518* @return trb_event_index -- index of the trb on event_ring_segment
519*/
520extern int XHCIPollEvent(XHCIDevice* usb_device, int trb_type);
521
522/*
523* XHCIRingDoorbellSlot -- rings the doorbell by slot
524* @param dev -- Pointer to usb structure
525* @param slot -- slot id
526* @param endpoint -- endpoint number, it should be 0 if
527* the slot is 0, else values 1-255 should be placed
528*
529*/
531
532/*
533* XHCISendCmdToHost -- Sends command to XHCI
534* host
535* @param dev -- Pointer to usb device structure
536* @param param1 -- parameter 1 of TRB
537* @param param2 -- parameter 2 of TRB
538* @param status -- status of TRB
539* @param ctrl -- control for TRB
540*/
541extern void XHCISendCmdToHost(XHCIDevice* dev, uint32_t param1, uint32_t param2, uint32_t status, uint32_t ctrl);
542
543/*
544* XHCISendCmdOtherEP -- sends command to endpoint trb
545* @param slot -- pointer to slot data structure
546* @param endp_num -- endpoint number
547* @param param1 -- first parameter of trb structure
548* @param param2 -- 2nd parameter of trb structure
549* @param status -- status field of trb structure
550* @param ctrl -- control field of trb structure
551*/
552extern void XHCISendCmdOtherEP(XHCISlot* slot, uint8_t endp_num, uint32_t param1, uint32_t param2, uint32_t status, uint32_t ctrl);
553
554
555/*
556* XHCISendCmdDefaultEP -- sends command to slot trb, i.e
557* default control endpoint
558* @param slot -- pointer to slot data structure
559* @param param1 -- first parameter of trb structure
560* @param param2 -- 2nd parameter of trb structure
561* @param status -- status field of trb structure
562* @param ctrl -- control field of trb structure
563*/
564extern void XHCISendCmdDefaultEP(XHCISlot* slot, uint32_t param1, uint32_t param2, uint32_t status, uint32_t ctrl);
565
566
567/*
568 * XHCIEvaluateContextCmd -- evaluate context command
569 * @param dev -- Pointer to usb device
570 * @param input_ctx_ptr -- input context physical address
571 * @param slot_id -- slot number
572 */
573extern void XHCIEvaluateContextCmd(XHCIDevice* dev, uint64_t input_ctx_ptr, uint8_t slot_id);
574
575/*
576 * XHIConfigureEndpoint -- configure the endpoint
577 */
578extern void XHCIConfigureEndpoint(XHCIDevice* dev, uint64_t input_ctx_ptr, uint8_t slot_id);
579
580/*
581* XHCISendAddressDevice -- issues address device command
582* @param dev -- pointer to usb device structure
583* @param bsr -- block set address request (BSR)
584* @param input_ctx_ptr -- address of input context
585* @param slot_id -- slot id number
586*/
587extern void XHCISendAddressDevice(XHCIDevice* dev, XHCISlot* slot, uint8_t bsr, uint64_t input_ctx_ptr, uint8_t slot_id);
588
589/*
590* XHCICreateSetupTRB -- creates a setup stage trb
591*/
592extern void XHCICreateSetupTRB(XHCISlot* slot, uint8_t rType, uint8_t bRequest, uint16_t value, uint16_t wIndex, uint16_t wLength, uint8_t trt);
593
594/*
595* XHCICreateDataTRB -- creates data stage trb
596* @param dev -- pointer to usb structure
597* @param buffer -- pointer to memory area
598* @param size -- size of the buffer
599* @param in_direction -- direction
600*/
601extern void XHCICreateDataTRB(XHCISlot* slot, uint64_t buffer, uint16_t size, bool in_direction);
602
603/*
604* XHCICreateStatusTRB -- creates status stage trb
605* @param dev -- pointer to usb strucutue
606* @param in_direction -- direction
607*/
608extern void XHCICreateStatusTRB(XHCISlot* slot, bool in_direction);
609
610/*
611* XHCIEnableSlot -- sends enable slot command to xHC
612* @param dev -- Pointer to usb device structure
613* @param slot_type -- type of slot mainly in between 0-31
614*/
615extern void XHCIEnableSlot(XHCIDevice* dev, uint8_t slot_type);
616
617/*
618* XHCIDisableSlot -- sends disable slot command to xHC
619* @param dev -- Pointer to usb device structure
620* @param slot_num -- slot id to disable
621*/
622extern void XHCIDisableSlot(XHCIDevice* dev, uint8_t slot_num);
623
624/* XHCISendNoopCmd -- Send No operation command
625* @param dev -- Pointer to USB structure
626*/
627extern void XHCISendNoopCmd(XHCIDevice* dev);
628
629
630#pragma pack(push,1)
631struct USB_REQUEST_PACKET {
637};
638#pragma pack(pop)
639
640
641/*
642* XHCISendControlCmd -- Sends control commands to USB Device's
643* default control pipe
644* @param dev -- pointer to usb device structure
645* @param slot_id -- slot number
646* @param request -- USB request packet structure
647* @param buffer_addr -- input buffer address
648* @param len -- length of the buffer
649*/
650extern void XHCISendControlCmd(XHCIDevice* dev, XHCISlot* slot, uint8_t slot_id, const USB_REQUEST_PACKET* request, uint64_t buffer_addr, const size_t len,
652
653
654/*
655 * XHCISendNormalTRB -- sends a normal trb
656 */
657extern void XHCISendNormalTRB(XHCIDevice* dev, XHCISlot* slot, uint64_t data_buffer, uint16_t data_len, XHCIEndpoint* ep);
658
659/*
660 * XHCIBulkTransfer -- Bulk transfer callback
661 * @param dev -- Pointer to host device structure
662 * @param slot -- Pointer to device slot
663 * @param buffer -- Pointer to memory buffer
664 * @param data_len -- total data length
665 * @param ep_ -- Pointer to endpoint structure
666 */
667extern void XHCIBulkTransfer(XHCIDevice* dev, XHCISlot* slot, uint64_t buffer, uint16_t data_len, XHCIEndpoint* ep_);
668
669
670/*
671 * XHCIGetMaxPacketSize -- get the packe size by
672 * looking USB speed
673 * @param speed -- speed of USB port
674 */
675extern size_t XHCIGetMaxPacketSize(uint8_t speed);
676
677
678#endif
void * endpoint
Definition main.cpp:149
USBDevice * usb_device
Definition main.cpp:47
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 XHCISendCmdDefaultEP(XHCISlot *slot, uint32_t param1, uint32_t param2, uint32_t status, uint32_t ctrl)
Definition xhci.cpp:135
void(* endpoint_callback)(void *dev, void *slot, void *Endp)
Definition xhci.h:143
int XHCIPollEvent(XHCIDevice *usb_device, int trb_type)
Definition xhci.cpp:247
void XHCIRingDoorbellSlot(XHCIDevice *dev, uint8_t slot, uint32_t endpoint)
Definition xhci.cpp:235
void XHCIRingDoorbellHost(XHCIDevice *dev)
Definition xhci.cpp:223
void XHCICreateStatusTRB(XHCISlot *slot, bool in_direction)
Definition xhci_cmd.cpp:98
void XHCISlotRemove(XHCIDevice *dev, uint8_t slot_id)
Definition xhci.cpp:91
void XHCICreateDataTRB(XHCISlot *slot, uint64_t buffer, uint16_t size, bool in_direction)
Definition xhci_cmd.cpp:84
void XHCIEvaluateContextCmd(XHCIDevice *dev, uint64_t input_ctx_ptr, uint8_t slot_id)
Definition cmd.cpp:42
struct _usb_hotplug_ USBHotPlug
void XHCISendCmdToHost(XHCIDevice *dev, uint32_t param1, uint32_t param2, uint32_t status, uint32_t ctrl)
Definition xhci.cpp:199
XHCIDevice * XHCIGetHost()
Definition main.cpp:565
void XHCISendControlCmd(XHCIDevice *dev, XHCISlot *slot, uint8_t slot_id, const USB_REQUEST_PACKET *request, uint64_t buffer_addr, const size_t len, uint8_t trt=CTL_TRANSFER_TRT_IN_DATA)
Definition cmd.cpp:146
size_t XHCIGetMaxPacketSize(uint8_t speed)
Definition usb3.cpp:135
struct _xhci_dev_ XHCIDevice
XHCIEndpoint * XHCISlotGetEP_DCI(XHCISlot *slot, uint8_t endp_num)
Definition usb3.cpp:221
void XHCIAddSlot(XHCIDevice *dev, XHCISlot *slot)
Definition xhci.cpp:82
void XHCIBulkTransfer(XHCIDevice *dev, XHCISlot *slot, uint64_t buffer, uint16_t data_len, XHCIEndpoint *ep_)
Definition cmd.cpp:223
void XHCICreateSetupTRB(XHCISlot *slot, uint8_t rType, uint8_t bRequest, uint16_t value, uint16_t wIndex, uint16_t wLength, uint8_t trt)
Definition xhci_cmd.cpp:73
XHCISlot * XHCIGetSlotByID(XHCIDevice *dev, uint8_t slot_id)
Definition xhci.cpp:54
void XHCIDisableSlot(XHCIDevice *dev, uint8_t slot_num)
Definition cmd.cpp:122
void XHCIConfigureEndpoint(XHCIDevice *dev, uint64_t input_ctx_ptr, uint8_t slot_id)
Definition cmd.cpp:51
void XHCIEnableSlot(XHCIDevice *dev, uint8_t slot_type)
Definition cmd.cpp:111
void XHCISendNormalTRB(XHCIDevice *dev, XHCISlot *slot, uint64_t data_buffer, uint16_t data_len, XHCIEndpoint *ep)
Definition cmd.cpp:180
void XHCISendNoopCmd(XHCIDevice *dev)
Definition cmd.cpp:132
void XHCISendCmdOtherEP(XHCISlot *slot, uint8_t endp_num, uint32_t param1, uint32_t param2, uint32_t status, uint32_t ctrl)
Definition xhci.cpp:165
void XHCISendAddressDevice(XHCIDevice *dev, XHCISlot *slot, uint8_t bsr, uint64_t input_ctx_ptr, uint8_t slot_id)
Definition cmd.cpp:64
#define CTL_TRANSFER_TRT_IN_DATA
Definition xhci.h:451
struct __xhci_legacy_cap__ xhci_legacy_cap_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 usb3.h:150
uint8_t request
Definition usb3.h:152
uint16_t index
Definition usb3.h:154
uint16_t length
Definition usb3.h:155
uint8_t request_type
Definition usb3.h:151
uint16_t value
Definition usb3.h:153
Definition xhci.h:368
volatile uint32_t cap_id_and_next
Definition xhci.h:369
volatile uint32_t legctlsts
Definition xhci.h:370
Definition x86_64_sched.h:118
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 endpointAttr
Definition xhci.h:234
uint8_t interval
Definition xhci.h:187
unsigned cmd_ring_index
Definition xhci.h:189
xhci_trb_t * cmd_ring
Definition xhci.h:184
uint8_t endpoint_num
Definition xhci.h:185
uint32_t offset
Definition xhci.h:193
uint16_t max_packet_sz
Definition xhci.h:238
unsigned cmd_ring_cycle
Definition xhci.h:191
uint8_t endpointAddress
Definition xhci.h:233
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 spinlock.h:37
Definition xhci.h:442
unsigned int portNum
Definition xhci.h:443
bool initialized
Definition xhci.h:444
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:407
bool is_csz_64
Definition xhci.h:409
unsigned evnt_ring_index
Definition xhci.h:429
bool event_available
Definition xhci.h:433
unsigned cmd_ring_cycle
Definition xhci.h:426
xhci_doorbell_regs_t * db_regs
Definition xhci.h:413
uint64_t cmd_ring_phys
Definition xhci.h:423
xhci_trb_t * cmd_ring
Definition xhci.h:422
unsigned cmd_ring_index
Definition xhci.h:424
int poll_return_trb_type
Definition xhci.h:434
xhci_op_regs_t * op_regs
Definition xhci.h:412
int trb_event_index
Definition xhci.h:435
uint16_t max_intrs
Definition xhci.h:419
unsigned evnt_ring_max
Definition xhci.h:431
uint64_t * event_ring_segment
Definition xhci.h:427
int poll_event_for_trb
Definition xhci.h:432
xhci_runtime_regs_t * rt_regs
Definition xhci.h:414
list_t * slot_list
Definition xhci.h:410
xhci_cap_regs_t * cap_regs
Definition xhci.h:411
AuThread * usbThread
Definition xhci.h:438
uint16_t vendor
Definition xhci.h:436
uint32_t num_ports
Definition xhci.h:418
uint32_t num_slots
Definition xhci.h:417
uint64_t * event_ring_seg_phys
Definition xhci.h:428
xhci_ext_cap_t * ext_cap
Definition xhci.h:415
unsigned cmd_ring_max
Definition xhci.h:425
xhci_port_regs_t * ports
Definition xhci.h:416
bool initialised
Definition xhci.h:408
uint64_t * dev_ctx_base_array
Definition xhci.h:421
Spinlock * usb_lock
Definition xhci.h:437
uint8_t irq
Definition xhci.h:420
unsigned evnt_ring_cycle
Definition xhci.h:430
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