1 #define OHCI_NUMBER_OF_INTERRUPTS 32
2 #define OHCI_MAX_PORT_COUNT 15
4 #define OHCI_MAXIMUM_OVERHEAD 210 // 5.4 FrameInterval Counter, in bit-times
5 #define OHCI_DEFAULT_FRAME_INTERVAL 11999 // 6.3.1 Frame Timing
6 #define OHCI_MINIMAL_POTPGT 25 // == 50 ms., PowerOnToPowerGoodTime (HcRhDescriptorA Register)
8 /* Controller states */
9 #define OHCI_HC_STATE_RESET 0
10 #define OHCI_HC_STATE_RESUME 1
11 #define OHCI_HC_STATE_OPERATIONAL 2
12 #define OHCI_HC_STATE_SUSPEND 3
14 /* Endpoint Descriptor Control */
15 #define OHCI_ED_DATA_FLOW_DIRECTION_FROM_TD 0
16 #define OHCI_ED_DATA_FLOW_DIRECTION_OUT 1
17 #define OHCI_ED_DATA_FLOW_DIRECTION_IN 2
19 #define OHCI_ENDPOINT_FULL_SPEED 0
20 #define OHCI_ENDPOINT_LOW_SPEED 1
22 #define OHCI_ENDPOINT_GENERAL_FORMAT 0
23 #define OHCI_ENDPOINT_ISOCHRONOUS_FORMAT 1
25 /* Transfer Descriptor Control */
26 #define OHCI_TD_INTERRUPT_IMMEDIATE 0
27 #define OHCI_TD_INTERRUPT_NONE 7
29 #define OHCI_TD_DIRECTION_PID_SETUP 0
30 #define OHCI_TD_DIRECTION_PID_OUT 1
31 #define OHCI_TD_DIRECTION_PID_IN 2
32 #define OHCI_TD_DIRECTION_PID_RESERVED 3
34 #define OHCI_TD_DATA_TOGGLE_FROM_ED 0
35 #define OHCI_TD_DATA_TOGGLE_DATA0 2
36 #define OHCI_TD_DATA_TOGGLE_DATA1 3
38 #define OHCI_TD_CONDITION_NO_ERROR 0x00
39 #define OHCI_TD_CONDITION_CRC_ERROR 0x01
40 #define OHCI_TD_CONDITION_BIT_STUFFING 0x02
41 #define OHCI_TD_CONDITION_TOGGLE_MISMATCH 0x03
42 #define OHCI_TD_CONDITION_STALL 0x04
43 #define OHCI_TD_CONDITION_NO_RESPONSE 0x05
44 #define OHCI_TD_CONDITION_PID_CHECK_FAILURE 0x06
45 #define OHCI_TD_CONDITION_UNEXPECTED_PID 0x07
46 #define OHCI_TD_CONDITION_DATA_OVERRUN 0x08
47 #define OHCI_TD_CONDITION_DATA_UNDERRUN 0x09
48 #define OHCI_TD_CONDITION_BUFFER_OVERRUN 0x0C
49 #define OHCI_TD_CONDITION_BUFFER_UNDERRUN 0x0D
50 #define OHCI_TD_CONDITION_NOT_ACCESSED 0x0E
52 typedef union _OHCI_TRANSFER_CONTROL
{
55 ULONG BufferRounding
: 1;
56 ULONG DirectionPID
: 2;
57 ULONG DelayInterrupt
: 3;
60 ULONG ConditionCode
: 4;
63 } OHCI_TRANSFER_CONTROL
, *POHCI_TRANSFER_CONTROL
;
65 C_ASSERT(sizeof(OHCI_TRANSFER_CONTROL
) == sizeof(ULONG
));
67 typedef struct _OHCI_TRANSFER_DESCRIPTOR
{ // must be aligned to a 16-byte boundary
68 OHCI_TRANSFER_CONTROL Control
;
69 ULONG CurrentBuffer
; // physical address of the next memory location
70 ULONG NextTD
; // pointer to the next TD on the list of TDs
71 ULONG BufferEnd
; // physical address of the last byte
72 } OHCI_TRANSFER_DESCRIPTOR
, *POHCI_TRANSFER_DESCRIPTOR
;
74 C_ASSERT(sizeof(OHCI_TRANSFER_DESCRIPTOR
) == 16);
76 typedef union _OHCI_ISO_TRANSFER_CONTROL
{
78 ULONG StartingFrame
: 16;
80 ULONG DelayInterrupt
: 3;
83 ULONG ConditionCode
: 4;
86 } OHCI_ISO_TRANSFER_CONTROL
, *POHCI_ISO_TRANSFER_CONTROL
;
88 C_ASSERT(sizeof(OHCI_ISO_TRANSFER_CONTROL
) == sizeof(ULONG
));
90 typedef struct _OHCI_ISO_TRANSFER_DESCRIPTOR
{ // must be aligned to a 32-byte boundary
91 OHCI_ISO_TRANSFER_CONTROL Control
;
92 ULONG BufferPage0
; // physical page number of the 1 byte of the data buffer
93 ULONG NextTD
; // pointer to the next Isochronous TD on the queue of Isochronous TDs
94 ULONG BufferEnd
; // physical address of the last byte in the buffer
95 USHORT Offset
[8]; // for determine size and start addr. iso packet | PacketStatusWord - completion code
96 } OHCI_ISO_TRANSFER_DESCRIPTOR
, *POHCI_ISO_TRANSFER_DESCRIPTOR
;
98 C_ASSERT(sizeof(OHCI_ISO_TRANSFER_DESCRIPTOR
) == 32);
100 typedef union _OHCI_ENDPOINT_CONTROL
{
102 ULONG FunctionAddress
: 7;
103 ULONG EndpointNumber
: 4;
108 ULONG MaximumPacketSize
: 11;
112 } OHCI_ENDPOINT_CONTROL
, *POHCI_ENDPOINT_CONTROL
;
114 C_ASSERT(sizeof(OHCI_ENDPOINT_CONTROL
) == sizeof(ULONG
));
116 /* Bit flags for HeadPointer member of the EP descriptor */
117 #define OHCI_ED_HEAD_POINTER_HALT 0x00000001 // hardware stopped bit
118 #define OHCI_ED_HEAD_POINTER_CARRY 0x00000002 // hardware toggle carry bit
119 #define OHCI_ED_HEAD_POINTER_MASK 0XFFFFFFF0 // mask physical pointer
120 #define OHCI_ED_HEAD_POINTER_FLAGS_MASK 0X0000000F // mask bit flags
122 typedef struct _OHCI_ENDPOINT_DESCRIPTOR
{ // must be aligned to a 16-byte boundary
123 OHCI_ENDPOINT_CONTROL EndpointControl
;
124 ULONG TailPointer
; // if TailP and HeadP are different, then the list contains a TD to be processed
125 ULONG HeadPointer
; // physical pointer to the next TD to be processed for this endpoint
126 ULONG NextED
; // entry points to the next ED on the list
127 } OHCI_ENDPOINT_DESCRIPTOR
, *POHCI_ENDPOINT_DESCRIPTOR
;
129 C_ASSERT(sizeof(OHCI_ENDPOINT_DESCRIPTOR
) == 16);
131 typedef struct _OHCI_HCCA
{ // must be located on a 256-byte boundary
132 ULONG InterrruptTable
[OHCI_NUMBER_OF_INTERRUPTS
];
136 UCHAR reserved_hc
[116];
138 } OHCI_HCCA
, *POHCI_HCCA
;
140 C_ASSERT(sizeof(OHCI_HCCA
) == 256);
142 typedef union _OHCI_REG_CONTROL
{
144 ULONG ControlBulkServiceRatio
: 2;
145 ULONG PeriodicListEnable
: 1;
146 ULONG IsochronousEnable
: 1;
147 ULONG ControlListEnable
: 1;
148 ULONG BulkListEnable
: 1;
149 ULONG HostControllerFunctionalState
: 2;
150 ULONG InterruptRouting
: 1;
151 ULONG RemoteWakeupConnected
: 1;
152 ULONG RemoteWakeupEnable
: 1;
156 } OHCI_REG_CONTROL
, *POHCI_REG_CONTROL
;
158 C_ASSERT(sizeof(OHCI_REG_CONTROL
) == sizeof(ULONG
));
160 typedef union _OHCI_REG_COMMAND_STATUS
{
162 ULONG HostControllerReset
: 1;
163 ULONG ControlListFilled
: 1;
164 ULONG BulkListFilled
: 1;
165 ULONG OwnershipChangeRequest
: 1;
166 ULONG Reserved1
: 12;
167 ULONG SchedulingOverrunCount
: 1;
168 ULONG Reserved2
: 15;
171 } OHCI_REG_COMMAND_STATUS
, *POHCI_REG_COMMAND_STATUS
;
173 C_ASSERT(sizeof(OHCI_REG_COMMAND_STATUS
) == sizeof(ULONG
));
175 typedef union _OHCI_REG_INTERRUPT_STATUS
{
177 ULONG SchedulingOverrun
: 1;
178 ULONG WritebackDoneHead
: 1;
179 ULONG StartofFrame
: 1;
180 ULONG ResumeDetected
: 1;
181 ULONG UnrecoverableError
: 1;
182 ULONG FrameNumberOverflow
: 1;
183 ULONG RootHubStatusChange
: 1;
184 ULONG Reserved1
: 23;
185 ULONG OwnershipChange
: 1;
189 } OHCI_REG_INTERRUPT_STATUS
, *POHCI_REG_INTERRUPT_STATUS
;
191 C_ASSERT(sizeof(OHCI_REG_INTERRUPT_STATUS
) == sizeof(ULONG
));
193 typedef union _OHCI_REG_INTERRUPT_ENABLE_DISABLE
{
195 ULONG SchedulingOverrun
: 1;
196 ULONG WritebackDoneHead
: 1;
197 ULONG StartofFrame
: 1;
198 ULONG ResumeDetected
: 1;
199 ULONG UnrecoverableError
: 1;
200 ULONG FrameNumberOverflow
: 1;
201 ULONG RootHubStatusChange
: 1;
202 ULONG Reserved1
: 23;
203 ULONG OwnershipChange
: 1;
204 ULONG MasterInterruptEnable
: 1;
207 } OHCI_REG_INTERRUPT_ENABLE_DISABLE
, *POHCI_REG_INTERRUPT_ENABLE_DISABLE
;
209 C_ASSERT(sizeof(OHCI_REG_INTERRUPT_ENABLE_DISABLE
) == sizeof(ULONG
));
211 typedef union _OHCI_REG_FRAME_INTERVAL
{
213 ULONG FrameInterval
: 14;
215 ULONG FSLargestDataPacket
: 15;
216 ULONG FrameIntervalToggle
: 1;
219 } OHCI_REG_FRAME_INTERVAL
, *POHCI_REG_FRAME_INTERVAL
;
221 C_ASSERT(sizeof(OHCI_REG_FRAME_INTERVAL
) == sizeof(ULONG
));
223 typedef union _OHCI_REG_RH_DESCRIPTORA
{
225 ULONG NumberDownstreamPorts
: 8;
226 ULONG PowerSwitchingMode
: 1;
227 ULONG NoPowerSwitching
: 1;
228 ULONG DeviceType
: 1;
229 ULONG OverCurrentProtectionMode
: 1;
230 ULONG NoOverCurrentProtection
: 1;
232 ULONG PowerOnToPowerGoodTime
: 8;
235 } OHCI_REG_RH_DESCRIPTORA
, *POHCI_REG_RH_DESCRIPTORA
;
237 C_ASSERT(sizeof(OHCI_REG_RH_DESCRIPTORA
) == sizeof(ULONG
));
239 typedef union _OHCI_REG_RH_STATUS
{
242 ULONG LocalPowerStatus
: 1;
243 ULONG OverCurrentIndicator
: 1;
244 ULONG Reserved10
: 13;
245 ULONG DeviceRemoteWakeupEnable
: 1;
246 ULONG LocalPowerStatusChange
: 1;
247 ULONG OverCurrentIndicatorChangeR
: 1;
248 ULONG Reserved20
: 14;
251 ULONG ClearGlobalPower
: 1;
252 ULONG Reserved11
: 14;
253 ULONG SetRemoteWakeupEnable
: 1;
254 ULONG SetGlobalPower
: 1;
255 ULONG OverCurrentIndicatorChangeW
: 1;
256 ULONG Reserved22
: 13;
257 ULONG ClearRemoteWakeupEnable
: 1;
261 } OHCI_REG_RH_STATUS
, *POHCI_REG_RH_STATUS
;
263 C_ASSERT(sizeof(OHCI_REG_RH_STATUS
) == sizeof(ULONG
));
265 typedef union _OHCI_REG_RH_PORT_STATUS
{
269 USHORT CurrentConnectStatus
: 1;
270 USHORT PortEnableStatus
: 1;
271 USHORT PortSuspendStatus
: 1;
272 USHORT PortOverCurrentIndicator
: 1;
273 USHORT PortResetStatus
: 1;
274 USHORT Reserved1r
: 3;
275 USHORT PortPowerStatus
: 1;
276 USHORT LowSpeedDeviceAttached
: 1;
277 USHORT Reserved2r
: 6;
280 USHORT ClearPortEnable
: 1;
281 USHORT SetPortEnable
: 1;
282 USHORT SetPortSuspend
: 1;
283 USHORT ClearSuspendStatus
: 1;
284 USHORT SetPortReset
: 1;
285 USHORT Reserved1w
: 3;
286 USHORT SetPortPower
: 1;
287 USHORT ClearPortPower
: 1;
288 USHORT Reserved2w
: 6;
291 USHORT ConnectStatusChange
: 1;
292 USHORT PortEnableStatusChange
: 1;
293 USHORT PortSuspendStatusChange
: 1;
294 USHORT PortOverCurrentIndicatorChange
: 1;
295 USHORT PortResetStatusChange
: 1;
296 USHORT Reserved3
: 11;
299 } OHCI_REG_RH_PORT_STATUS
, *POHCI_REG_RH_PORT_STATUS
;
301 C_ASSERT(sizeof(OHCI_REG_RH_PORT_STATUS
) == sizeof(ULONG
));
303 typedef struct _OHCI_OPERATIONAL_REGISTERS
{
305 OHCI_REG_CONTROL HcControl
;
306 OHCI_REG_COMMAND_STATUS HcCommandStatus
;
307 OHCI_REG_INTERRUPT_STATUS HcInterruptStatus
;
308 OHCI_REG_INTERRUPT_ENABLE_DISABLE HcInterruptEnable
;
309 OHCI_REG_INTERRUPT_ENABLE_DISABLE HcInterruptDisable
;
311 ULONG HcPeriodCurrentED
;
312 ULONG HcControlHeadED
;
313 ULONG HcControlCurrentED
;
315 ULONG HcBulkCurrentED
;
317 OHCI_REG_FRAME_INTERVAL HcFmInterval
;
320 ULONG HcPeriodicStart
;
322 OHCI_REG_RH_DESCRIPTORA HcRhDescriptorA
;
323 ULONG HcRhDescriptorB
;
324 OHCI_REG_RH_STATUS HcRhStatus
;
325 OHCI_REG_RH_PORT_STATUS HcRhPortStatus
[OHCI_MAX_PORT_COUNT
];
326 } OHCI_OPERATIONAL_REGISTERS
, *POHCI_OPERATIONAL_REGISTERS
;