XenevaOS
Loading...
Searching...
No Matches
xhci_cmd.h
Go to the documentation of this file.
1
30#ifndef __XHCI_CMD_H__
31#define __XHCI_CMD_H__
32
33#include <stdint.h>
34#include "usb3.h"
35
36/* Standard XHCI defined Transfer/Command/Event
37* TRB type values
38*/
39#define TRB_TRANSFER_NORMAL 1
40#define TRB_TRANSFER_SETUP_STAGE 2
41#define TRB_TRANSFER_DATA_STAGE 3
42#define TRB_TRANSFER_STATUS_STAGE 4
43#define TRB_TRANSFER_ISOCH 5
44#define TRB_TRANSFER_LINK 6
45#define TRB_TRANSFER_EVENT_DATA 7
46#define TRB_TRANSFER_NO_OP 8
47#define TRB_CMD_ENABLE_SLOT 9
48#define TRB_CMD_DISABLE_SLOT 10
49#define TRB_CMD_ADDRESS_DEV 11
50#define TRB_CMD_CONFIG_ENDPOINT 12
51#define TRB_CMD_EVALUATE_CTX 13
52#define TRB_CMD_RESET_ENDPOINT 14
53#define TRB_CMD_STOP_ENDPOINT 15
54#define TRB_CMD_SET_TR_DEQ_POINTER 16
55#define TRB_CMD_RESET_DEV 17
56#define TRB_CMD_FORCE_EVENT 18
57#define TRB_CMD_NEGOTIATE_BANDWIDTH 19
58#define TRB_CMD_SET_LATENCY_TOLERANCE_VALUE 20
59#define TRB_CMD_GET_PORT_BANDWIDTH 21
60#define TRB_CMD_FORCE_HEADER 22
61#define TRB_CMD_NO_OP 23
62#define TRB_CMD_GET_EXT_PROPERTY 24
63#define TRB_CMD_SET_EXT_PROPERTY 25
64#define TRB_EVENT_TRANSFER 32
65#define TRB_EVENT_CMD_COMPLETION 33
66#define TRB_EVENT_PORT_STATUS_CHANGE 34
67#define TRB_EVENT_BANDWIDTH_REQUEST 35
68#define TRB_EVENT_DOORBELL 36
69#define TRB_EVENT_HOST_CONTROLLER 37
70#define TRB_EVENT_DEVICE_NOTIFICATION 38
71#define TRB_EVENT_MFINDEX 39
72
73/*
74* XHCIEnableSlot -- sends enable slot command to xHC
75* @param dev -- Pointer to usb device structure
76* @param slot_type -- type of slot mainly in between 0-31
77*/
78extern void XHCIEnableSlot(USBDevice *dev, uint8_t slot_type);
79
80/*
81* XHCIDisableSlot -- sends disable slot command to xHC
82* @param dev -- Pointer to usb device structure
83* @param slot_num -- slot id to disable
84*/
85extern void XHCIDisableSlot(USBDevice *dev, uint8_t slot_num);
86
87/* XHCISendNoopCmd -- Send No operation command
88* @param dev -- Pointer to USB structure
89*/
90extern void XHCISendNoopCmd(USBDevice* dev);
91
92/*
93* XHCICreateSetupTRB -- creates a setup stage trb
94*/
95void XHCICreateSetupTRB(XHCISlot *slot, uint8_t rType, uint8_t bRequest, uint16_t value, uint16_t wIndex, uint16_t wLength, uint8_t trt);
96
97/*
98* XHCICreateDataTRB -- creates data stage trb
99* @param dev -- pointer to usb structure
100* @param buffer -- pointer to memory area
101* @param size -- size of the buffer
102* @param in_direction -- direction
103*/
104void XHCICreateDataTRB(XHCISlot *slot, uint64_t buffer, uint16_t size, bool in_direction);
105
106/*
107* XHCICreateStatusTRB -- creates status stage trb
108* @param dev -- pointer to usb strucutue
109* @param in_direction -- direction
110*/
111void XHCICreateStatusTRB(XHCISlot* slot, bool in_direction);
112
113/*
114* XHCISendAddressDevice -- issues address device command
115* @param dev -- pointer to usb device structure
116* @param bsr -- block set address request (BSR)
117* @param input_ctx_ptr -- address of input context
118* @param slot_id -- slot id number
119*/
120void XHCISendAddressDevice(USBDevice* dev, XHCISlot *slot, uint8_t bsr, uint64_t input_ctx_ptr, uint8_t slot_id);
121
122#define CTL_TRANSFER_TRT_NO_DATA 0
123#define CTL_TRANSFER_TRT_RESV 1
124#define CTL_TRANSFER_TRT_OUT_DATA 2
125#define CTL_TRANSFER_TRT_IN_DATA 3
126/*
127* XHCISendControlCmd -- Sends control commands to xhci
128* @param dev -- pointer to usb device structure
129* @param slot_id -- slot number
130* @param request -- USB request packet structure
131* @param buffer_addr -- input buffer address
132* @param len -- length of the buffer
133*/
134void XHCISendControlCmd(USBDevice* dev, XHCISlot* slot, uint8_t slot_id, const USB_REQUEST_PACKET *request, uint64_t buffer_addr, const size_t len,
136/*
137* XHCISendControlCmdEndp -- Sends control commands to xhci
138* @param dev -- pointer to usb device structure
139* @param slot_id -- slot number
140* @param request -- USB request packet structure
141* @param buffer_addr -- input buffer address
142* @param len -- length of the buffer
143* @param endpnum -- Endpoint number
144*/
145void XHCISendControlCmdEndp(USBDevice* dev, XHCISlot* slot, uint8_t slot_id, const USB_REQUEST_PACKET *request, uint64_t buffer_addr, const size_t len,
146 uint32_t endpnum);
147
148/*
149* XHCISendNormalTRB -- sends a normal trb
150*/
151void XHCISendNormalTRB(USBDevice* dev, XHCISlot *slot, uint64_t data_buffer, uint16_t data_len, XHCIEndpoint* ep);
152/*
153* XHCIEvaluateContextCmd -- evaluate context command
154* @param dev -- Pointer to usb device
155* @param input_ctx_ptr -- input context physical address
156* @param slot_id -- slot number
157*/
158void XHCIEvaluateContextCmd(USBDevice* dev, uint64_t input_ctx_ptr, uint8_t slot_id);
159
160/*
161* XHIConfigureEndpoint -- configure the endpoint
162*/
163void XHCIConfigureEndpoint(USBDevice* dev, uint64_t input_ctx_ptr, uint8_t slot_id);
164
165
166#endif
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
Definition xhci.h:183
Definition usb3.h:40
Definition xhci.h:202
void XHCICreateStatusTRB(XHCISlot *slot, bool in_direction)
Definition xhci_cmd.cpp:98
void XHCISendNormalTRB(USBDevice *dev, XHCISlot *slot, uint64_t data_buffer, uint16_t data_len, XHCIEndpoint *ep)
Definition xhci_cmd.cpp:203
void XHCIEnableSlot(USBDevice *dev, uint8_t slot_type)
Definition xhci_cmd.cpp:44
void XHCICreateDataTRB(XHCISlot *slot, uint64_t buffer, uint16_t size, bool in_direction)
Definition xhci_cmd.cpp:84
void XHCISendControlCmdEndp(USBDevice *dev, XHCISlot *slot, uint8_t slot_id, const USB_REQUEST_PACKET *request, uint64_t buffer_addr, const size_t len, uint32_t endpnum)
Definition xhci_cmd.cpp:170
void XHCIDisableSlot(USBDevice *dev, uint8_t slot_num)
Definition xhci_cmd.cpp:55
void XHCIConfigureEndpoint(USBDevice *dev, uint64_t input_ctx_ptr, uint8_t slot_id)
Definition xhci_cmd.cpp:195
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
void XHCISendAddressDevice(USBDevice *dev, XHCISlot *slot, uint8_t bsr, uint64_t input_ctx_ptr, uint8_t slot_id)
Definition xhci_cmd.cpp:114
void XHCISendNoopCmd(USBDevice *dev)
Definition xhci_cmd.cpp:65
void XHCIEvaluateContextCmd(USBDevice *dev, uint64_t input_ctx_ptr, uint8_t slot_id)
Definition xhci_cmd.cpp:186
void XHCISendControlCmd(USBDevice *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 xhci_cmd.cpp:129
#define CTL_TRANSFER_TRT_IN_DATA
Definition xhci_cmd.h:125