ReactOS  0.4.14-dev-57-g333b8f1
hardware.h
Go to the documentation of this file.
1 #pragma once
2 
3 //
4 // Host Controller Capability Registers
5 //
6 #define EHCI_CAPLENGTH 0x00
7 #define EHCI_HCIVERSION 0x02
8 #define EHCI_HCSPARAMS 0x04
9 #define EHCI_HCCPARAMS 0x08
10 #define EHCI_HCSP_PORTROUTE 0x0c
11 
12 
13 //
14 // Extended Capabilities
15 //
16 #define EHCI_ECP_SHIFT 8
17 #define EHCI_ECP_MASK 0xff
18 #define EHCI_LEGSUP_CAPID_MASK 0xff
19 #define EHCI_LEGSUP_CAPID 0x01
20 #define EHCI_LEGSUP_OSOWNED (1 << 24)
21 #define EHCI_LEGSUP_BIOSOWNED (1 << 16)
22 
23 
24 //
25 // EHCI Operational Registers
26 //
27 #define EHCI_USBCMD 0x00
28 #define EHCI_USBSTS 0x04
29 #define EHCI_USBINTR 0x08
30 #define EHCI_FRINDEX 0x0C
31 #define EHCI_CTRLDSSEGMENT 0x10
32 #define EHCI_PERIODICLISTBASE 0x14
33 #define EHCI_ASYNCLISTBASE 0x18
34 #define EHCI_CONFIGFLAG 0x40
35 #define EHCI_PORTSC 0x44
36 
37 //
38 // Interrupt Register Flags
39 //
40 #define EHCI_USBINTR_INTE 0x01
41 #define EHCI_USBINTR_ERR 0x02
42 #define EHCI_USBINTR_PC 0x04
43 #define EHCI_USBINTR_FLROVR 0x08
44 #define EHCI_USBINTR_HSERR 0x10
45 #define EHCI_USBINTR_ASYNC 0x20
46 // Bits 6:31 Reserved
47 
48 //
49 // Status Register Flags
50 //
51 #define EHCI_STS_INT 0x01
52 #define EHCI_STS_ERR 0x02
53 #define EHCI_STS_PCD 0x04
54 #define EHCI_STS_FLR 0x08
55 #define EHCI_STS_FATAL 0x10
56 #define EHCI_STS_IAA 0x20
57 // Bits 11:6 Reserved
58 #define EHCI_STS_HALT 0x1000
59 #define EHCI_STS_RECL 0x2000
60 #define EHCI_STS_PSS 0x4000
61 #define EHCI_STS_ASS 0x8000
62 #define EHCI_ERROR_INT (EHCI_STS_FATAL | EHCI_STS_ERR)
63 
64 //
65 // Port Register Flags
66 //
67 #define EHCI_PRT_CONNECTED 0x01
68 #define EHCI_PRT_CONNECTSTATUSCHANGE 0x02
69 #define EHCI_PRT_ENABLED 0x04
70 #define EHCI_PRT_ENABLEDSTATUSCHANGE 0x08
71 #define EHCI_PRT_OVERCURRENTACTIVE 0x10
72 #define EHCI_PRT_OVERCURRENTCHANGE 0x20
73 #define EHCI_PRT_FORCERESUME 0x40
74 #define EHCI_PRT_SUSPEND 0x80
75 #define EHCI_PRT_RESET 0x100
76 #define EHCI_PRT_LINESTATUSA 0x400
77 #define EHCI_PRT_LINESTATUSB 0x800
78 #define EHCI_PRT_POWER 0x1000
79 #define EHCI_PRT_RELEASEOWNERSHIP 0x2000
80 
81 #define EHCI_PORTSC_DATAMASK 0xffffffd1
82 
83 #define EHCI_IS_LOW_SPEED(x) (((x) & EHCI_PRT_LINESTATUSA) && !((x) & EHCI_PRT_LINESTATUSB))
84 //
85 // Terminate Pointer used for QueueHeads and Element Transfer Descriptors to mark Pointers as the end
86 //
87 #define TERMINATE_POINTER 0x01
88 
89 //
90 // QUEUE ELEMENT TRANSFER DESCRIPTOR, defines and structs
91 //
92 
93 //
94 // Token Flags
95 //
96 #define PID_CODE_OUT_TOKEN 0x00
97 #define PID_CODE_IN_TOKEN 0x01
98 #define PID_CODE_SETUP_TOKEN 0x02
99 
100 #define DO_START_SPLIT 0x00
101 #define DO_COMPLETE_SPLIT 0x01
102 
103 #define PING_STATE_DO_OUT 0x00
104 #define PING_STATE_DO_PING 0x01
105 
106 typedef struct _PERIODICFRAMELIST
107 {
112 
113 //
114 // QUEUE ELEMENT TRANSFER DESCRIPTOR TOKEN
115 //
116 typedef struct _QETD_TOKEN_BITS
117 {
133 
134 //
135 // QUEUE ELEMENT TRANSFER DESCRIPTOR
136 //
138 {
139  //Hardware
142  union
143  {
146  } Token;
149 
150  //Software
155 
156 C_ASSERT(FIELD_OFFSET(QUEUE_TRANSFER_DESCRIPTOR, PhysicalAddr) == 0x34);
157 
158 //
159 // EndPointSpeeds Flags and END_POINT_CHARACTERISTICS
160 //
161 #define QH_ENDPOINT_FULLSPEED 0x00
162 #define QH_ENDPOINT_LOWSPEED 0x01
163 #define QH_ENDPOINT_HIGHSPEED 0x02
165 {
176 
177 //
178 // Capabilities
179 //
181 {
188 
189 //
190 // QUEUE HEAD Flags and Struct
191 //
192 #define QH_TYPE_IDT 0x00
193 #define QH_TYPE_QH 0x02
194 #define QH_TYPE_SITD 0x04
195 #define QH_TYPE_FSTN 0x06
196 
197 typedef struct _QUEUE_HEAD
198 {
199  //Hardware
203  // TERMINATE_POINTER not valid for this member
205  // TERMINATE_POINTER valid
207  // TERMINATE_POINTER valid, bits 1:4 is NAK_COUNTERd
209  // Only DataToggle, InterruptOnComplete, ErrorCounter, PingState valid
210  union
211  {
214  } Token;
217 
218  //Software
225 
226 C_ASSERT(sizeof(END_POINT_CHARACTERISTICS) == 4);
227 C_ASSERT(sizeof(END_POINT_CAPABILITIES) == 4);
228 
229 C_ASSERT(FIELD_OFFSET(QUEUE_HEAD, HorizontalLinkPointer) == 0x00);
230 C_ASSERT(FIELD_OFFSET(QUEUE_HEAD, EndPointCharacteristics) == 0x04);
231 C_ASSERT(FIELD_OFFSET(QUEUE_HEAD, EndPointCapabilities) == 0x08);
232 C_ASSERT(FIELD_OFFSET(QUEUE_HEAD, CurrentLinkPointer) == 0xC);
233 C_ASSERT(FIELD_OFFSET(QUEUE_HEAD, NextPointer) == 0x10);
234 C_ASSERT(FIELD_OFFSET(QUEUE_HEAD, AlternateNextPointer) == 0x14);
236 C_ASSERT(FIELD_OFFSET(QUEUE_HEAD, BufferPointer) == 0x1C);
237 C_ASSERT(FIELD_OFFSET(QUEUE_HEAD, PhysicalAddr) == 0x44);
238 
239 
240 //
241 // Command register content
242 //
243 typedef struct _EHCI_USBCMD_CONTENT
244 {
245  ULONG Run : 1;
259 
260 typedef struct _EHCI_HCS_CONTENT
261 {
272 
274 
275 typedef struct _EHCI_HCC_CONTENT
276 {
284 
286 
287 typedef struct _EHCI_CAPS {
291  union
292  {
295  };
296  union
297  {
300  };
303 
304 typedef struct
305 {
309 
310 #define EHCI_INTERRUPT_ENTRIES_COUNT (10 + 1)
311 #define EHCI_VFRAMELIST_ENTRIES_COUNT 128
312 #define EHCI_FRAMELIST_ENTRIES_COUNT 1024
313 
314 #define MAX_AVAILABLE_BANDWIDTH 125 // Microseconds
315 
316 #define EHCI_QH_CAPS_MULT_SHIFT 30 // Transactions per Micro-Frame
317 #define EHCI_QH_CAPS_MULT_MASK 0x03
318 #define EHCI_QH_CAPS_PORT_SHIFT 23 // Hub Port (Split-Transaction)
319 #define EHCI_QH_CAPS_PORT_MASK 0x7f
320 #define EHCI_QH_CAPS_HUB_SHIFT 16 // Hub Address (Split-Transaction)
321 #define EHCI_QH_CAPS_HUB_MASK 0x7f
322 #define EHCI_QH_CAPS_SCM_SHIFT 8 // Split Completion Mask
323 #define EHCI_QH_CAPS_SCM_MASK 0xff
324 #define EHCI_QH_CAPS_ISM_SHIFT 0 // Interrupt Schedule Mask
325 #define EHCI_QH_CAPS_ISM_MASK 0xff
ULONG PortStatus
Definition: hardware.h:306
ULONG AlternateNextPointer
Definition: hardware.h:208
ULONG NumberOfTransactionPerFrame
Definition: hardware.h:186
ULONG DWord
Definition: hardware.h:213
ULONG PortChange
Definition: hardware.h:307
struct _EHCI_USBCMD_CONTENT * PEHCI_USBCMD_CONTENT
ULONG NextPointer
Definition: hardware.h:206
UCHAR Length
Definition: hardware.h:288
END_POINT_CHARACTERISTICS EndPointCharacteristics
Definition: hardware.h:201
ULONG PortPowerControl
Definition: hardware.h:263
PVOID Request
Definition: hardware.h:223
struct _PERIODICFRAMELIST PERIODICFRAMELIST
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID _Out_ PULONG _Inout_ PLUID _Out_ PHANDLE Token
ULONG BufferPointer[5]
Definition: hardware.h:215
ULONG HorizontalLinkPointer
Definition: hardware.h:200
ULONG PortRouteRules
Definition: hardware.h:265
QETD_TOKEN_BITS Bits
Definition: hardware.h:212
struct _END_POINT_CAPABILITIES * PEND_POINT_CAPABILITIES
struct _QUEUE_TRANSFER_DESCRIPTOR * PQUEUE_TRANSFER_DESCRIPTOR
struct _EHCI_HCS_CONTENT EHCI_HCS_CONTENT
struct _EHCI_USBCMD_CONTENT EHCI_USBCMD_CONTENT
ULONG HCCParamsLong
Definition: hardware.h:299
struct _QUEUE_HEAD QUEUE_HEAD
LIST_ENTRY DescriptorEntry
Definition: hardware.h:152
USHORT HCIVersion
Definition: hardware.h:290
struct _QETD_TOKEN_BITS QETD_TOKEN_BITS
PVOID NextQueueHead
Definition: hardware.h:222
struct _PERIODICFRAMELIST * PPERIODICFRAMELIST
ULONG TransactionError
Definition: hardware.h:121
ULONG DataBufferError
Definition: hardware.h:123
struct _QUEUE_TRANSFER_DESCRIPTOR QUEUE_TRANSFER_DESCRIPTOR
EHCI_HCS_CONTENT HCSParams
Definition: hardware.h:293
struct _QETD_TOKEN_BITS * PQETD_TOKEN_BITS
PHYSICAL_ADDRESS PhysicalAddr
Definition: hardware.h:109
struct _EHCI_CAPS EHCI_CAPS
ULONG InterruptOnComplete
Definition: hardware.h:129
struct _END_POINT_CAPABILITIES END_POINT_CAPABILITIES
struct _QUEUE_HEAD * PQUEUE_HEAD
union _QUEUE_TRANSFER_DESCRIPTOR::@1285 Token
struct _EHCI_CAPS * PEHCI_CAPS
LIST_ENTRY TransferDescriptorListHead
Definition: hardware.h:221
ULONG ExtendedBufferPointer[5]
Definition: hardware.h:148
ULONG IsoSchedThreshold
Definition: hardware.h:281
UCHAR PortRoute[15]
Definition: hardware.h:301
ULONG TotalBytesToTransfer
Definition: hardware.h:130
ULONG HCSParamsLong
Definition: hardware.h:294
ULONG ExtendedBufferPointer[5]
Definition: hardware.h:216
struct _EHCI_HCC_CONTENT * PEHCI_HCC_CONTENT
struct _END_POINT_CHARACTERISTICS * PEND_POINT_CHARACTERISTICS
C_ASSERT(sizeof(PAGE_TABLE_ARM)==PAGE_SIZE)
unsigned char UCHAR
Definition: xmlstorage.h:181
ULONG MissedMicroFrame
Definition: hardware.h:120
ULONG PhysicalAddr
Definition: hardware.h:219
ULONG DataToggle
Definition: hardware.h:131
Definition: typedefs.h:117
ULONG CurrentPage
Definition: hardware.h:128
UCHAR Reserved
Definition: hardware.h:289
struct _EHCI_HCC_CONTENT EHCI_HCC_CONTENT
ULONG SplitTransactionState
Definition: hardware.h:119
ULONG PortIndicator
Definition: hardware.h:268
EHCI_HCC_CONTENT HCCParams
Definition: hardware.h:298
unsigned short USHORT
Definition: pedump.c:61
struct _EHCI_HCS_CONTENT * PEHCI_HCS_CONTENT
struct _END_POINT_CHARACTERISTICS END_POINT_CHARACTERISTICS
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
unsigned int * PULONG
Definition: retypes.h:1
END_POINT_CAPABILITIES EndPointCapabilities
Definition: hardware.h:202
PULONG VirtualAddr
Definition: hardware.h:108
union _QUEUE_HEAD::@1286 Token
LIST_ENTRY LinkedQueueHeads
Definition: hardware.h:220
ULONG VarFrameList
Definition: hardware.h:278
unsigned int ULONG
Definition: retypes.h:1
ULONG ErrorCounter
Definition: hardware.h:127
ULONG CurrentLinkPointer
Definition: hardware.h:204
ULONG BabbleDetected
Definition: hardware.h:122
QETD_TOKEN_BITS Bits
Definition: hardware.h:144