Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

570 lines
25 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. openhci.h
  5. Abstract:
  6. Definitions from OPENHCI 1.0 USB specification
  7. Environment:
  8. Kernel & user mode
  9. Revision History:
  10. 12-28-95 : created jfuller & kenray
  11. --*/
  12. #ifndef OPENHCI_H
  13. #define OPENHCI_H
  14. #include <PSHPACK4.H>
  15. //
  16. // Don't use <PSHPACK1.H> on shared memory data structures that should only
  17. // be accessed using 4-byte load/store instructions (e.g use ld4 instructions
  18. // instead of ld1 instructions on ia64 machines).
  19. //
  20. #define MAXIMUM_OVERHEAD 210
  21. #define OHCI_PAGE_SIZE 0x1000
  22. // #define OHCI_PAGE_SIZE 0x20
  23. #define OHCI_PAGE_SIZE_MASK (OHCI_PAGE_SIZE - 1)
  24. //
  25. // 7.1.1 HcRevision Register
  26. // Definition of Host Controller Revision register
  27. //
  28. typedef union _HC_REVISION {
  29. ULONG ul;
  30. struct {
  31. ULONG Rev:8;
  32. ULONG :24;
  33. };
  34. } HC_REVISION, *PHC_REVISION;
  35. C_ASSERT(sizeof(HC_REVISION) == 4);
  36. //
  37. // 7.1.2 HcControl Register
  38. // Definition of Host Controller Control register
  39. //
  40. typedef union _HC_CONTROL {
  41. ULONG ul;
  42. struct {
  43. ULONG ControlBulkServiceRatio:2;
  44. ULONG PeriodicListEnable:1;
  45. ULONG IsochronousEnable:1;
  46. ULONG ControlListEnable:1;
  47. ULONG BulkListEnable:1;
  48. ULONG HostControllerFunctionalState:2;
  49. ULONG InterruptRouting:1;
  50. ULONG RemoteWakeupConnected:1;
  51. ULONG RemoteWakeupEnable:1;
  52. ULONG :21;
  53. };
  54. } HC_CONTROL, *PHC_CONTROL;
  55. C_ASSERT(sizeof(HC_CONTROL) == 4);
  56. #define HcCtrl_CBSR_MASK 0x00000003L
  57. #define HcCtrl_CBSR_1_to_1 0x00000000L
  58. #define HcCtrl_CBSR_2_to_1 0x00000001L
  59. #define HcCtrl_CBSR_3_to_1 0x00000002L
  60. #define HcCtrl_CBSR_4_to_1 0x00000003L
  61. #define HcCtrl_PeriodicListEnable 0x00000004L
  62. #define HcCtrl_IsochronousEnable 0x00000008L
  63. #define HcCtrl_ControlListEnable 0x00000010L
  64. #define HcCtrl_BulkListEnable 0x00000020L
  65. #define HcCtrl_ListEnableMask 0x00000038L
  66. #define HcCtrl_HCFS_MASK 0x000000C0L
  67. #define HcCtrl_HCFS_USBReset 0x00000000L
  68. #define HcCtrl_HCFS_USBResume 0x00000040L
  69. #define HcCtrl_HCFS_USBOperational 0x00000080L
  70. #define HcCtrl_HCFS_USBSuspend 0x000000C0L
  71. #define HcCtrl_InterruptRouting 0x00000100L
  72. #define HcCtrl_RemoteWakeupConnected 0x00000200L
  73. #define HcCtrl_RemoteWakeupEnable 0x00000400L
  74. #define HcHCFS_USBReset 0x00000000
  75. #define HcHCFS_USBResume 0x00000001
  76. #define HcHCFS_USBOperational 0x00000002
  77. #define HcHCFS_USBSuspend 0x00000003
  78. //
  79. // 7.1.3 HcCommandStatus Register
  80. // Definition of Host Controller Command/Status register
  81. //
  82. typedef union _HC_COMMAND_STATUS {
  83. ULONG ul; // use HcCmd flags below
  84. struct {
  85. ULONG HostControllerReset:1;
  86. ULONG ControlListFilled:1;
  87. ULONG BulkListFilled:1;
  88. ULONG OwnershipChangeRequest:1;
  89. ULONG :12;
  90. ULONG SchedulingOverrunCount:2;
  91. ULONG :14;
  92. };
  93. } HC_COMMAND_STATUS, *PHC_COMMAND_STATUS;
  94. C_ASSERT(sizeof(HC_COMMAND_STATUS) == 4);
  95. #define HcCmd_HostControllerReset 0x00000001
  96. #define HcCmd_ControlListFilled 0x00000002
  97. #define HcCmd_BulkListFilled 0x00000004
  98. #define HcCmd_OwnershipChangeRequest 0x00000008
  99. #define HcCmd_SOC_Mask 0x00030000
  100. #define HcCmd_SOC_Offset 16
  101. #define HcCmd_SOC_Mask_LowBits 0x00000003
  102. //
  103. // 7.3.1 HcFmInterval Register
  104. // Definition of Host Controller Frame Interval register
  105. //
  106. typedef union _HC_FM_INTERVAL {
  107. ULONG ul; // use HcFmI flags below
  108. struct {
  109. ULONG FrameInterval:14;
  110. ULONG :2;
  111. ULONG FSLargestDataPacket:15;
  112. ULONG FrameIntervalToggle:1;
  113. };
  114. } HC_FM_INTERVAL, *PHC_FM_INTERVAL;
  115. C_ASSERT(sizeof(HC_FM_INTERVAL) == 4);
  116. #define HcFmI_FRAME_INTERVAL_MASK 0x00003FFF
  117. #define HcFmI_FS_LARGEST_DATA_PACKET_MASK 0x7FFF0000
  118. #define HcFmI_FS_LARGEST_DATA_PACKET_SHIFT 16
  119. #define HcFmI_FRAME_INTERVAL_TOGGLE 0x80000000
  120. //
  121. // 7.3.2 HcFmRemaining Register
  122. // Definition of Host Controller Frame Remaining register
  123. //
  124. typedef union _HC_FM_REMAINING {
  125. ULONG ul;
  126. struct {
  127. ULONG FrameRemaining:14;
  128. ULONG :17;
  129. ULONG FrameRemainingToggle:1;
  130. };
  131. } HC_FM_REMAINING, *PHC_FM_REMAINING;
  132. C_ASSERT(sizeof(HC_FM_REMAINING) == 4);
  133. //
  134. // 7.3.3 HcFmNumber Register
  135. // Definition of Host Controller Frame Number register
  136. //
  137. typedef union _HC_FM_NUMBER {
  138. ULONG ul;
  139. struct {
  140. ULONG FrameNumber:16;
  141. ULONG :16;
  142. };
  143. } HC_FM_NUMBER, *PHC_FM_NUMBER;
  144. C_ASSERT(sizeof(HC_FM_NUMBER) == 4);
  145. #define HcFmNumber_MASK 0x0000FFFF
  146. #define HcFmNumber_RESERVED 0xFFFF0000
  147. //
  148. // 7.4.1 HcRhDescriptorA Register
  149. // Definition of Host Controller Root Hub DescriptorA register
  150. //
  151. typedef union _HC_RH_DESCRIPTOR_A {
  152. ULONG ul;
  153. struct {
  154. ULONG NumberDownstreamPorts:8;
  155. ULONG HubChars:16;
  156. ULONG PowerOnToPowerGoodTime:8;
  157. } s;
  158. } HC_RH_DESCRIPTOR_A, *PHC_RH_DESCRIPTOR_A;
  159. C_ASSERT(sizeof(HC_RH_DESCRIPTOR_A) == 4);
  160. #define HcDescA_PowerSwitchingModePort 0x00000100L
  161. #define HcDescA_NoPowerSwitching 0x00000200L
  162. #define HcDescA_DeviceType 0x00000400L
  163. #define HcDescA_OvercurrentProtectionMode 0x00000800L
  164. #define HcDescA_NoOvercurrentProtection 0x00001000L
  165. // HcRhDescriptorA reserved bits which should not be set. Note that although
  166. // the NumberDownstreamPorts field is 8 bits wide, the maximum number of ports
  167. // supported by the OpenHCI specification is 15.
  168. //
  169. #define HcDescA_RESERVED 0x00FFE0F0L
  170. //
  171. // 7.4.2 HcRhDescriptorB Register
  172. // Definition of Host Controller Root Hub DescritorB register
  173. //
  174. typedef union _HC_RH_DESCRIPTOR_B {
  175. ULONG ul;
  176. struct {
  177. USHORT DeviceRemovableMask;
  178. USHORT PortPowerControlMask;
  179. };
  180. } HC_RH_DESCRIPTOR_B, *PHC_RH_DESCRIPTOR_B;
  181. C_ASSERT(sizeof(HC_RH_DESCRIPTOR_B) == 4);
  182. //
  183. // Host Controler Hardware Registers as accessed in memory
  184. //
  185. typedef struct _HC_OPERATIONAL_REGISTER {
  186. // 0 0x00 - 0,4,8,c
  187. HC_REVISION HcRevision;
  188. HC_CONTROL HcControl;
  189. HC_COMMAND_STATUS HcCommandStatus;
  190. ULONG HcInterruptStatus; // use HcInt flags below
  191. // 1 0x10
  192. ULONG HcInterruptEnable; // use HcInt flags below
  193. ULONG HcInterruptDisable; // use HcInt flags below
  194. ULONG HcHCCA; // physical pointer to Host Controller Communications Area
  195. ULONG HcPeriodCurrentED; // physical ptr to current periodic ED
  196. // 2 0x20
  197. ULONG HcControlHeadED; // physical ptr to head of control list
  198. ULONG HcControlCurrentED; // physical ptr to current control ED
  199. ULONG HcBulkHeadED; // physical ptr to head of bulk list
  200. ULONG HcBulkCurrentED; // physical ptr to current bulk ED
  201. // 3 0x30
  202. ULONG HcDoneHead; // physical ptr to internal done queue
  203. HC_FM_INTERVAL HcFmInterval;
  204. HC_FM_REMAINING HcFmRemaining;
  205. ULONG HcFmNumber;
  206. // 4 0x40
  207. ULONG HcPeriodicStart;
  208. ULONG HcLSThreshold;
  209. HC_RH_DESCRIPTOR_A HcRhDescriptorA;
  210. HC_RH_DESCRIPTOR_B HcRhDescriptorB;
  211. // 5 0x50
  212. ULONG HcRhStatus; // use HcRhS flags below
  213. ULONG HcRhPortStatus[15]; // use HcRhPS flags below
  214. } HC_OPERATIONAL_REGISTER, *PHC_OPERATIONAL_REGISTER;
  215. C_ASSERT(sizeof(HC_OPERATIONAL_REGISTER) == (0x54 + 4 * 15));
  216. //
  217. // 7.1.4 HcInterrruptStatus Register
  218. // 7.1.5 HcInterruptEnable Register
  219. // 7.1.6 HcInterruptDisable Register
  220. //
  221. #define HcInt_SchedulingOverrun 0x00000001L
  222. #define HcInt_WritebackDoneHead 0x00000002L
  223. #define HcInt_StartOfFrame 0x00000004L
  224. #define HcInt_ResumeDetected 0x00000008L
  225. #define HcInt_UnrecoverableError 0x00000010L
  226. #define HcInt_FrameNumberOverflow 0x00000020L
  227. #define HcInt_RootHubStatusChange 0x00000040L
  228. #define HcInt_OwnershipChange 0x40000000L
  229. #define HcInt_MasterInterruptEnable 0x80000000L
  230. //
  231. // 7.4.3 HcRhStatus Register
  232. //
  233. #define HcRhS_LocalPowerStatus 0x00000001 // read only
  234. #define HcRhS_OverCurrentIndicator 0x00000002 // read only
  235. #define HcRhS_DeviceRemoteWakeupEnable 0x00008000 // read only
  236. #define HcRhS_LocalPowerStatusChange 0x00010000 // read only
  237. #define HcRhS_OverCurrentIndicatorChange 0x00020000 // read only
  238. #define HcRhS_ClearGlobalPower 0x00000001 // write only
  239. #define HcRhS_SetRemoteWakeupEnable 0x00008000 // write only
  240. #define HcRhS_SetGlobalPower 0x00010000 // write only
  241. #define HcRhS_ClearOverCurrentIndicatorChange 0x00020000 // write only
  242. #define HcRhS_ClearRemoteWakeupEnable 0x80000000 // write only
  243. //
  244. // 7.4.4 HcRhPortStatus Register
  245. //
  246. //
  247. // The bits in this register have a double meaning depending
  248. // on if you read or write them
  249. //
  250. #define HcRhPS_CurrentConnectStatus 0x00000001 // read only
  251. #define HcRhPS_PortEnableStatus 0x00000002 // read only
  252. #define HcRhPS_PortSuspendStatus 0x00000004 // read only
  253. #define HcRhPS_PortOverCurrentIndicator 0x00000008 // read only
  254. #define HcRhPS_PortResetStatus 0x00000010 // read only
  255. #define HcRhPS_PortPowerStatus 0x00000100 // read only
  256. #define HcRhPS_LowSpeedDeviceAttached 0x00000200 // read only
  257. #define HcRhPS_ConnectStatusChange 0x00010000 // read only
  258. #define HcRhPS_PortEnableStatusChange 0x00020000 // read only
  259. #define HcRhPS_PortSuspendStatusChange 0x00040000 // read only
  260. #define HcRhPS_OverCurrentIndicatorChange 0x00080000 // read only
  261. #define HcRhPS_PortResetStatusChange 0x00100000 // read only
  262. #define HcRhPS_ClearPortEnable 0x00000001 // write only
  263. #define HcRhPS_SetPortEnable 0x00000002 // write only
  264. #define HcRhPS_SetPortSuspend 0x00000004 // write only
  265. #define HcRhPS_ClearPortSuspend 0x00000008 // write only
  266. #define HcRhPS_SetPortReset 0x00000010 // write only
  267. #define HcRhPS_SetPortPower 0x00000100 // write only
  268. #define HcRhPS_ClearPortPower 0x00000200 // write only
  269. #define HcRhPS_ClearConnectStatusChange 0x00010000 // write only
  270. #define HcRhPS_ClearPortEnableStatusChange 0x00020000 // write only
  271. #define HcRhPS_ClearPortSuspendStatusChange 0x00040000 // write only
  272. #define HcRhPS_ClearPortOverCurrentChange 0x00080000 // write only
  273. #define HcRhPS_ClearPortResetStatusChange 0x00100000 // write only
  274. #define HcRhPS_RESERVED (~(HcRhPS_CurrentConnectStatus | \
  275. HcRhPS_PortEnableStatus | \
  276. HcRhPS_PortSuspendStatus | \
  277. HcRhPS_PortOverCurrentIndicator | \
  278. HcRhPS_PortResetStatus | \
  279. HcRhPS_PortPowerStatus | \
  280. HcRhPS_LowSpeedDeviceAttached | \
  281. HcRhPS_ConnectStatusChange | \
  282. HcRhPS_PortEnableStatusChange | \
  283. HcRhPS_PortSuspendStatusChange | \
  284. HcRhPS_OverCurrentIndicatorChange | \
  285. HcRhPS_PortResetStatusChange \
  286. ))
  287. typedef struct _HCCA_BLOCK {
  288. ULONG HccaInterruptTable[32]; // physical pointer to interrupt lists
  289. USHORT HccaFrameNumber; // 16-bit current frame number
  290. USHORT HccaPad1; // When the HC updates
  291. // HccaFrameNumber, it sets
  292. // this word to zero.
  293. ULONG HccaDoneHead; // pointer to done queue
  294. ULONG Reserved[30]; // pad to 256 bytes
  295. } HCCA_BLOCK, *PHCCA_BLOCK;
  296. // this size is defined in the
  297. // OpenHCI Specification it should always be 256 bytes
  298. C_ASSERT (sizeof(HCCA_BLOCK) == 256);
  299. //
  300. // Host Controller Endpoint Descriptor Control DWORD
  301. //
  302. typedef union _HC_ENDPOINT_CONTROL {
  303. ULONG Control; // use HcEDControl flags below
  304. struct {
  305. ULONG FunctionAddress:7;
  306. ULONG EndpointNumber:4;
  307. ULONG Direction:2; // use HcEDDirection flags below
  308. ULONG LowSpeed:1;
  309. ULONG sKip:1;
  310. ULONG Isochronous:1;
  311. ULONG MaxPacket:11;
  312. ULONG Unused:5; //available for software use
  313. };
  314. } HC_ENDPOINT_CONTROL, *PHC_ENDPOINT_CONTROL;
  315. //
  316. // Definitions for HC_ENDPOINT_CONTROL.Control
  317. //
  318. #define HcEDControl_MPS_MASK 0x07FF0000 // Maximum Packet Size field
  319. #define HcEDControl_MPS_SHIFT 16 // Shift Count for MPS
  320. #define HcEDControl_ISOCH 0x00008000 // Bit set for isochronous endpoints
  321. #define HcEDControl_SKIP 0x00004000 // Bit tells hw to skip this endpoint
  322. #define HcEDControl_LOWSPEED 0x00002000 // Bit set if device is a low speed device
  323. #define HcEDControl_DIR_MASK 0x00001800 // Transfer direction field
  324. #define HcEDControl_DIR_DEFER 0x00000000 // Defer direction select to TD (Control Endpoints)
  325. #define HcEDControl_DIR_OUT 0x00000800 // Direction is from host to device
  326. #define HcEDControl_DIR_IN 0x00001000 // Direction is from device to host
  327. #define HcEDControl_EN_MASK 0x00000780 // Endpoint Number field
  328. #define HcEDControl_EN_SHIFT 7 // Shift Count for EN
  329. #define HcEDControl_FA_MASK 0x0000007F // Function Address field
  330. #define HcEDControl_FA_SHIFT 0 // Shift Count for FA
  331. //
  332. // Definitions for HC_ENDPOINT_CONTROL.Direction
  333. //
  334. #define HcEDDirection_Defer 0 // Defer direction to TD (Control Endpoints)
  335. #define HcEDDirection_Out 1 // Direction from host to device
  336. #define HcEDDirection_In 2 // Direction from device to host
  337. //
  338. // Host Controller Endpoint Descriptor, refer to Section 4.2, Endpoint Descriptor
  339. //
  340. typedef struct _HW_ENDPOINT_DESCRIPTOR {
  341. HC_ENDPOINT_CONTROL; // dword 0
  342. HW_32BIT_PHYSICAL_ADDRESS TailP; //physical pointer to HC_TRANSFER_DESCRIPTOR
  343. HW_32BIT_PHYSICAL_ADDRESS HeadP; //flags + phys ptr to HC_TRANSFER_DESCRIPTOR
  344. HW_32BIT_PHYSICAL_ADDRESS NextED; //phys ptr to HC_ENDPOINT_DESCRIPTOR
  345. } HW_ENDPOINT_DESCRIPTOR, *PHW_ENDPOINT_DESCRIPTOR;
  346. // NOTE: this structure MUST have 16 byte alignment for the hardware
  347. C_ASSERT(sizeof(HW_ENDPOINT_DESCRIPTOR) == 16);
  348. //
  349. // Definitions for HC_ENDPOINT_DESCRIPTOR.HeadP
  350. //
  351. #define HcEDHeadP_FLAGS 0x0000000F //mask for flags in HeadP
  352. #define HcEDHeadP_HALT 0x00000001 //hardware stopped bit
  353. #define HcEDHeadP_CARRY 0x00000002 //hardware toggle carry bit
  354. //
  355. // HCD Isochronous offset/status words
  356. //
  357. typedef union _HC_OFFSET_PSW {
  358. struct {
  359. USHORT Offset:13; // Offset within two pages of packet buffer
  360. USHORT Ones:3; // should be 111b when in Offset format
  361. };
  362. struct {
  363. USHORT Size:11; // Size of packet received
  364. USHORT :1; // reserved
  365. USHORT ConditionCode:4; // use HcCC flags below
  366. };
  367. USHORT PSW; // use HcPSW flags below
  368. } HC_OFFSET_PSW, *PHC_OFFSET_PSW;
  369. //
  370. // Definitions for HC_OFFSET_PSW.PSW
  371. //
  372. #define HcPSW_OFFSET_MASK 0x0FFF // Packet buffer offset field
  373. #define HcPSW_SECOND_PAGE 0x1000 // Is this packet on 2nd page
  374. #define HcPSW_ONES 0xE000 // The ones for Offset form
  375. #define HcPSW_CONDITION_CODE_MASK 0xF000 // Packet ConditionCode field
  376. #define HcPSW_CONDITION_CODE_SHIFT 12 // shift count for Code
  377. #define HcPSW_RETURN_SIZE 0x07FF // The size field.
  378. //
  379. // HCD Transfer Descriptor Control DWord
  380. //
  381. typedef union _HC_TRANSFER_CONTROL {
  382. ULONG Control; // use HcTDControl flags below
  383. struct _HC_GENERAL_TD_CONTROL{
  384. ULONG :16; // available for s/w use in GTD
  385. ULONG Isochronous:1; // should be 0 for GTD, s/w flag
  386. ULONG :1; // available for s/w use
  387. ULONG ShortXferOk:1; // if set don't report error on short transfer
  388. ULONG Direction:2; // use HcTDDirection flags below
  389. ULONG IntDelay:3; // use HcTDIntDelay flags below
  390. ULONG Toggle:2; // use HcTDToggle flags below
  391. ULONG ErrorCount:2;
  392. ULONG ConditionCode:4; // use HcCC flags below
  393. } Asy;
  394. struct _HC_ISOCHRONOUS_TD_CONTROL{
  395. ULONG StartingFrame:16;
  396. ULONG Isochronous:1;// should be 1 for ITD, s/w flag
  397. ULONG :1; // available for s/w use
  398. ULONG :3; // available for s/w use in ITD
  399. ULONG IntDelay:3; // IntDelay
  400. ULONG FrameCount:3; // one less than number of frames described in ITD
  401. ULONG :1; // available for s/w use in ITD
  402. ULONG :4; // ConditionCode
  403. } Iso;
  404. } HC_TRANSFER_CONTROL, *PHC_TRANSFER_CONTROL;
  405. //
  406. // Definitions for HC_TRANSFER_CONTROL.Control
  407. //
  408. #define HcTDControl_STARTING_FRAME 0x0000FFFF // mask for starting frame (Isochronous)
  409. #define HcTDControl_ISOCHRONOUS 0x00010000 // 1 for Isoch TD, 0 for General TD
  410. #define HcTDControl_SHORT_XFER_OK 0x00040000 // 0 if short transfers are errors
  411. #define HcTDControl_DIR_MASK 0x00180000 // Transfer direction field
  412. #define HcTDControl_DIR_SETUP 0x00000000 // direction is setup packet from host to device
  413. #define HcTDControl_DIR_OUT 0x00080000 // direction is from host to device
  414. #define HcTDControl_DIR_IN 0x00100000 // direction is from device to host
  415. #define HcTDControl_INT_DELAY_MASK 0x00E00000 // Interrupt Delay field
  416. #define HcTDControl_INT_DELAY_0_MS 0x00000000 // Interrupt at end of frame TD is completed
  417. #define HcTDControl_INT_DELAY_1_MS 0x00200000 // Interrupt no later than end of 1st frame after TD is completed
  418. #define HcTDControl_INT_DELAY_2_MS 0x00400000 // Interrupt no later than end of 2nd frame after TD is completed
  419. #define HcTDControl_INT_DELAY_3_MS 0x00600000 // Interrupt no later than end of 3rd frame after TD is completed
  420. #define HcTDControl_INT_DELAY_4_MS 0x00800000 // Interrupt no later than end of 4th frame after TD is completed
  421. #define HcTDControl_INT_DELAY_5_MS 0x00A00000 // Interrupt no later than end of 5th frame after TD is completed
  422. #define HcTDControl_INT_DELAY_6_MS 0x00C00000 // Interrupt no later than end of 6th frame after TD is completed
  423. #ifdef NSC
  424. #define HcTDControl_INT_DELAY_NO_INT 0x00C00000 // Almost infinity but not yet quite.
  425. #elif DISABLE_INT_DELAY_NO_INT
  426. #define HcTDControl_INT_DELAY_NO_INT 0x00000000 // Interrupt at the completion of all packets.
  427. #else
  428. #define HcTDControl_INT_DELAY_NO_INT 0x00E00000 // Do not cause an interrupt for normal completion of this TD
  429. #endif
  430. #define HcTDControl_FRAME_COUNT_MASK 0x07000000 // mask for FrameCount field (Isochronous)
  431. #define HcTDControl_FRAME_COUNT_SHIFT 24 // shift count for FrameCount (Isochronous)
  432. #define HcTDControl_FRAME_COUNT_MAX 8 // Max number of for frame count per TD
  433. #define HcTDControl_TOGGLE_MASK 0x03000000 // mask for Toggle control field
  434. #define HcTDControl_TOGGLE_FROM_ED 0x00000000 // get data toggle from CARRY field of ED
  435. #define HcTDControl_TOGGLE_DATA0 0x02000000 // use DATA0 for data PID
  436. #define HcTDControl_TOGGLE_DATA1 0x03000000 // use DATA1 for data PID
  437. #define HcTDControl_ERROR_COUNT 0x0C000000 // mask for Error Count field
  438. #define HcTDControl_CONDITION_CODE_MASK 0xF0000000 // mask for ConditionCode field
  439. #define HcTDControl_CONDITION_CODE_SHIFT 28 // shift count for ConditionCode
  440. //
  441. // Definitions for HC_TRANSFER_CONTROL.Direction
  442. //
  443. #define HcTDDirection_Setup 0 // setup packet from host to device
  444. #define HcTDDirection_Out 1 // direction from host to device
  445. #define HcTDDirection_In 2 // direction from device to host
  446. //
  447. // Definitions for Hc_TRANSFER_CONTROL.IntDelay
  448. //
  449. #define HcTDIntDelay_0ms 0 // interrupt at end of frame TD is completed
  450. #define HcTDIntDelay_1ms 1 // Interrupt no later than end of 1st frame after TD is completed
  451. #define HcTDIntDelay_2ms 2 // Interrupt no later than end of 2nd frame after TD is completed
  452. #define HcTDIntDelay_3ms 3 // Interrupt no later than end of 3rd frame after TD is completed
  453. #define HcTDIntDelay_4ms 4 // Interrupt no later than end of 4th frame after TD is completed
  454. #define HcTDIntDelay_5ms 5 // Interrupt no later than end of 5th frame after TD is completed
  455. #define HcTDIntDelay_6ms 6 // Interrupt no later than end of 6th frame after TD is completed
  456. #define HcTDIntDelay_NoInterrupt 7 // do not generate interrupt for normal completion of this TD
  457. //
  458. // Definitions for HC_TRANSFER_CONTROL.Toggle
  459. //
  460. #define HcTDToggle_FromEd 0 // get toggle for Endpoint Descriptor toggle CARRY bit
  461. #define HcTDToggle_Data0 2 // use Data0 PID
  462. #define HcTDToggle_Data1 3 // use Data1 PID
  463. //
  464. // Definitions for HC_TRANSFER_CONTROL.ConditionCode and HC_OFFSET_PSW.ConditionCode
  465. //
  466. #define HcCC_NoError 0x0UL
  467. #define HcCC_CRC 0x1UL
  468. #define HcCC_BitStuffing 0x2UL
  469. #define HcCC_DataToggleMismatch 0x3UL
  470. #define HcCC_Stall 0x4UL
  471. #define HcCC_DeviceNotResponding 0x5UL
  472. #define HcCC_PIDCheckFailure 0x6UL
  473. #define HcCC_UnexpectedPID 0x7UL
  474. #define HcCC_DataOverrun 0x8UL
  475. #define HcCC_DataUnderrun 0x9UL
  476. // 0xA // reserved
  477. // 0xB // reserved
  478. #define HcCC_BufferOverrun 0xCUL
  479. #define HcCC_BufferUnderrun 0xDUL
  480. #define HcCC_NotAccessed 0xEUL
  481. // 0xF // this also means NotAccessed
  482. //
  483. // Host Controller Transfer Descriptor, refer to Section 4.3, Transfer Descriptors
  484. //
  485. typedef struct _HW_TRANSFER_DESCRIPTOR {
  486. HC_TRANSFER_CONTROL; // dword 0
  487. ULONG CBP; // phys ptr to start of buffer
  488. ULONG NextTD; // phys ptr to HC_TRANSFER_DESCRIPTOR
  489. ULONG BE; // phys ptr to end of buffer (last byte)
  490. HC_OFFSET_PSW Packet[8]; // isoch & Control packets
  491. } HW_TRANSFER_DESCRIPTOR, *PHW_TRANSFER_DESCRIPTOR;
  492. C_ASSERT((sizeof(HW_TRANSFER_DESCRIPTOR) == 32));
  493. #include <POPPACK.H>
  494. #endif /* OPENHCI_H */