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.

363 lines
10 KiB

  1. /*++
  2. Copyright (c) 1999, 2000 Microsoft Corporation
  3. Module Name:
  4. uhci.h
  5. Abstract:
  6. Definitions from USB 1.0 Universal host controller specification
  7. Environment:
  8. Kernel & user mode
  9. Revision History:
  10. 7-20-00 : created jsenior
  11. --*/
  12. #ifndef __UHCI_H__
  13. #define __UHCI_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. //
  21. // PCI host controller hardware registers
  22. //
  23. #define VIA_FIFO_MANAGEMENT 0x42 // offset of VIA's fifo management bit
  24. #define VIA_FIFO_DISABLE 0x07 // bit two disables the fifo, and
  25. #define VIA_DISABLE_BABBLE_DETECT 0x40 // Bit to set to disable babble detect
  26. #define VIA_INTERNAL_REGISTER 0x40 // offset of reg that enables detects babble
  27. typedef UCHAR VIAFIFO;
  28. typedef ULONG VIABABBLE;
  29. #define LEGACY_BIOS_REGISTER 0xc0 // offset of legacy bios reg
  30. #define LEGSUP_HCD_MODE 0x2000 // value to put in LEGSUP reg for normal HCD use JMD
  31. #define LEGSUP_BIOS_MODE 0x00BF // value to put in LEGSUP reg for BIOS/SMI use JMD
  32. #define LEGSUP_USBPIRQD_EN 0x2000 // bit 13
  33. #define LEGSUP_SMI_ENABLE 0x0010
  34. typedef USHORT USBSETUP;
  35. //
  36. // Host Controler Hardware Registers as accessed in memory
  37. //
  38. //
  39. // USBCMD - USB Command Register
  40. //
  41. typedef union _USBCMD {
  42. USHORT us;
  43. struct {
  44. USHORT RunStop:1; // 0
  45. USHORT HostControllerReset:1; // 1
  46. USHORT GlobalReset:1; // 2
  47. USHORT EnterGlobalSuspendMode:1; // 3
  48. USHORT ForceGlobalResume:1; // 4
  49. USHORT SoftwareDebug:1; // 5
  50. USHORT ConfigureFlag:1; // 6
  51. USHORT MaxPacket:1; // 7
  52. USHORT Reserved:8; // 8-15
  53. };
  54. } USBCMD, *PUSBCMD;
  55. C_ASSERT((sizeof(USBCMD) == sizeof(USHORT)));
  56. //
  57. // USBSTS - USB Status Register
  58. //
  59. #define HcInterruptStatusMask 0x0000003F
  60. typedef union _USBSTS {
  61. USHORT us;
  62. struct {
  63. // controller interrupt status bits
  64. USHORT UsbInterrupt:1; // 0
  65. USHORT UsbError:1; // 1
  66. USHORT ResumeDetect:1; // 2
  67. USHORT HostSystemError:1; // 3
  68. USHORT HostControllerProcessError:1; // 4
  69. USHORT HCHalted:1; // 5
  70. USHORT Reserved:10; // 6-15
  71. };
  72. } USBSTS, *PUSBSTS;
  73. C_ASSERT((sizeof(USBSTS) == sizeof(USHORT)));
  74. //
  75. // USBINTR - USB Interrupt Enable Register
  76. //
  77. typedef union _USBINTR {
  78. USHORT us;
  79. struct {
  80. USHORT TimeoutCRC:1; // 0
  81. USHORT Resume:1; // 1
  82. USHORT InterruptOnComplete:1; // 2
  83. USHORT ShortPacket:1; // 3
  84. USHORT Reserved:12; // 4-15
  85. };
  86. } USBINTR, *PUSBINTR;
  87. C_ASSERT((sizeof(USBINTR) == sizeof(USHORT)));
  88. //
  89. // FRNUM - Frame Number Register
  90. //
  91. typedef union _FRNUM {
  92. USHORT us;
  93. struct {
  94. USHORT FrameListCurrentIndex:11; // 0-10
  95. USHORT Reserved:5; // 11-15
  96. };
  97. } FRNUM, *PFRNUM;
  98. C_ASSERT((sizeof(FRNUM) == sizeof(USHORT)));
  99. //
  100. // FLBASEADD - Frame list base address register
  101. //
  102. typedef union _FRBASEADD {
  103. HW_32BIT_PHYSICAL_ADDRESS ul;
  104. struct {
  105. ULONG Reserved:12; // 0-11
  106. ULONG BaseAddress:20; // 12-31
  107. };
  108. } FRBASEADD, *PFRBASEADD;
  109. C_ASSERT((sizeof(FRBASEADD) == sizeof(ULONG)));
  110. //
  111. // FRNUM - Frame Number Register
  112. //
  113. typedef union _SOFMOD {
  114. UCHAR uc;
  115. struct {
  116. UCHAR SOFTimingValue:7; // 0-6
  117. UCHAR Reserved:1; // 7
  118. };
  119. } SOFMOD, *PSOFMOD;
  120. C_ASSERT((sizeof(SOFMOD) == sizeof(UCHAR)));
  121. //
  122. // PORTSC - Port Status and Control Register
  123. //
  124. typedef union _PORTSC {
  125. USHORT us;
  126. struct {
  127. USHORT PortConnect:1; // 0
  128. USHORT PortConnectChange:1; // 1
  129. USHORT PortEnable:1; // 2
  130. USHORT PortEnableChange:1; // 3
  131. USHORT LineStatus:2; // 4-5
  132. USHORT ResumeDetect:1; // 6
  133. USHORT Reserved1:1; // 7
  134. USHORT LowSpeedDevice:1; // 8
  135. USHORT PortReset:1; // 9
  136. USHORT Overcurrent:1; // 10
  137. USHORT OvercurrentChange:1; // 11
  138. USHORT Suspend:1; // 12
  139. USHORT Reserved3:3; // 13-15
  140. };
  141. } PORTSC, *PPORTSC;
  142. C_ASSERT((sizeof(PORTSC) == sizeof(USHORT)));
  143. // OPERATIONAL REGISTER
  144. typedef struct _HC_REGISTER {
  145. USBCMD UsbCommand; // 00-01h
  146. USBSTS UsbStatus; // 02-03h
  147. USBINTR UsbInterruptEnable; // 04-05h
  148. FRNUM FrameNumber; // 06-07h
  149. FRBASEADD FrameListBasePhys; // 08-0Bh
  150. SOFMOD StartOfFrameModify; // 0Ch
  151. UCHAR Reserved[3]; // 0D-0Fh
  152. PORTSC PortRegister[2];
  153. } HC_REGISTER, *PHC_REGISTER;
  154. #define HcDTYPE_iTD 0 // iterative TD
  155. #define HcDTYPE_QH 1 // queue head
  156. #define HcDTYPE_siTD 2 // isochronousTD
  157. #define HW_LINK_FLAGS_MASK 0x00000007
  158. //
  159. // Queue head
  160. //
  161. typedef union _TD_LINK_POINTER {
  162. HW_32BIT_PHYSICAL_ADDRESS HwAddress;
  163. struct {
  164. ULONG Terminate:1; // 0
  165. ULONG QHTDSelect:1; // 1
  166. ULONG DepthBreadthSelect:1; // 2
  167. ULONG Reserved:1; // 3
  168. ULONG LinkPointer:28; // 4-31
  169. };
  170. } TD_LINK_POINTER, *PTD_LINK_POINTER;
  171. C_ASSERT((sizeof(TD_LINK_POINTER) == sizeof(ULONG)));
  172. typedef union _QH_LINK_POINTER {
  173. HW_32BIT_PHYSICAL_ADDRESS HwAddress;
  174. struct {
  175. ULONG Terminate:1; // 0
  176. ULONG QHTDSelect:1; // 1
  177. ULONG Reserved:2; // 3
  178. ULONG LinkPointer:28; // 4-31
  179. };
  180. } QH_LINK_POINTER, *PQh_LINK_POINTER;
  181. C_ASSERT((sizeof(QH_LINK_POINTER) == sizeof(ULONG)));
  182. //
  183. // Queue Head Descriptor
  184. //
  185. typedef struct _HW_QUEUE_HEAD {
  186. QH_LINK_POINTER HLink; // HC horizontal link ptr
  187. // Host Controller Read Only
  188. TD_LINK_POINTER volatile VLink; // HC Element (vertical) link ptr
  189. // Host Controller Read/Write
  190. } HW_QUEUE_HEAD, *PHW_QUEUE_HEAD;
  191. C_ASSERT((sizeof(HW_QUEUE_HEAD) == 8));
  192. //
  193. // Queue Element Transfer Descriptor
  194. //
  195. //
  196. // some USB constants
  197. //
  198. #define InPID 0x69
  199. #define OutPID 0xe1
  200. #define GetPID(ad) ((ad & 0x80) == 0x80) ? InPID : OutPID
  201. #define SetupPID 0x2d
  202. #define DataToggle0 0
  203. #define DataToggle1 1
  204. typedef ULONG HC_BUFFER_POINTER, *PHC_BUFFER_POINTER;
  205. C_ASSERT((sizeof(HC_BUFFER_POINTER) == sizeof(ULONG)));
  206. #define NULL_PACKET_LENGTH 0x7ff
  207. #define MAXIMUM_LENGTH(l) ((l) == 0 ? NULL_PACKET_LENGTH : (l)-1)
  208. #define ACTUAL_LENGTH(l) ((l) == NULL_PACKET_LENGTH ? 0 : (l)+1)
  209. typedef union _HC_QTD_TOKEN {
  210. ULONG ul;
  211. struct {
  212. ULONG Pid:8; // 0-7
  213. ULONG DeviceAddress:7; // 8-14
  214. ULONG Endpoint:4; // 15-18
  215. ULONG DataToggle:1; // 19
  216. ULONG Reserved:1; // 20
  217. ULONG MaximumLength:11; // 21-31
  218. };
  219. } HC_QTD_TOKEN, *PHC_QTD_TOKEN;
  220. C_ASSERT((sizeof(HC_QTD_TOKEN) == sizeof(ULONG)));
  221. #define CONTROL_STATUS_MASK 0x007E0000
  222. typedef union _HC_QTD_CONTROL {
  223. ULONG ul;
  224. struct {
  225. ULONG ActualLength:11; // 0-10
  226. ULONG Reserved1:5; // 11-15
  227. // status bits
  228. ULONG Reserved2:1; // 16
  229. ULONG BitstuffError:1; // 17
  230. ULONG TimeoutCRC:1; // 18
  231. ULONG NAKReceived:1; // 19
  232. ULONG BabbleDetected:1; // 20
  233. ULONG DataBufferError:1; // 21
  234. ULONG Stalled:1; // 22
  235. ULONG Active:1; // 23
  236. ULONG InterruptOnComplete:1; // 24
  237. ULONG IsochronousSelect:1; // 25
  238. ULONG LowSpeedDevice:1; // 26
  239. ULONG ErrorCount:2; // 27-28
  240. ULONG ShortPacketDetect:1; // 29
  241. ULONG Reserved3:2; // 30-31
  242. };
  243. } HC_QTD_CONTROL, *PHC_QTD_CONTROL;
  244. C_ASSERT((sizeof(HC_QTD_CONTROL) == sizeof(ULONG)));
  245. typedef struct _HW_QUEUE_ELEMENT_TD {
  246. TD_LINK_POINTER LinkPointer; // Host Controller Read Only
  247. HC_QTD_CONTROL volatile Control; // Host Controller Read/Write
  248. HC_QTD_TOKEN Token; // Host Controller Read Only
  249. HC_BUFFER_POINTER Buffer; // Host Controller Read Only
  250. } HW_QUEUE_ELEMENT_TD, *PHW_QUEUE_ELEMENT_TD;
  251. C_ASSERT((sizeof(HW_QUEUE_ELEMENT_TD) == 16));
  252. //
  253. // General Transfer Descriptor
  254. //
  255. typedef union _HW_TRANSFER_DESCRIPTOR {
  256. HW_QUEUE_ELEMENT_TD qTD;
  257. } HW_TRANSFER_DESCRIPTOR, *PHW_TRANSFER_DESCRIPTOR;
  258. C_ASSERT((sizeof(HW_TRANSFER_DESCRIPTOR) == 16));
  259. #include <POPPACK.H>
  260. #endif /* __UHCI_H__ */