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.

489 lines
12 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. shpc.h
  5. Abstract:
  6. Type definitions describing a Standard Hotplug Controller
  7. Author:
  8. Davis Walker (dwalker) 10 October 2000
  9. Revision History:
  10. --*/
  11. #ifndef _SHPC_
  12. #define _SHPC_
  13. #include "pshpack1.h"
  14. //
  15. // Register set structures
  16. //
  17. //
  18. // Slots Available Registers
  19. //
  20. // This is a two DWORD structure.
  21. //
  22. typedef struct _SHPC_SLOTS_AVAILABLE_REGISTER {
  23. ULONG NumSlots33Conv:5; // HWINIT
  24. ULONG:3; // RsvdP
  25. ULONG NumSlots66PciX:5; // HWINIT
  26. ULONG:3; // RsvdP
  27. ULONG NumSlots100PciX:5; // HWINIT
  28. ULONG:3; // RsvdP
  29. ULONG NumSlots133PciX:5; // HWINIT
  30. ULONG:3; // RsvdP
  31. ULONG NumSlots66Conv:5; // HWINIT
  32. ULONG:27; // RsvdP
  33. } SHPC_SLOTS_AVAILABLE_REGISTER, *PSHPC_SLOTS_AVAILABLE_REGISTER;
  34. //
  35. // Slot Configuration Register
  36. //
  37. typedef struct _SHPC_SLOT_CONFIGURATION_REGISTER {
  38. ULONG NumSlots:5; // HWINIT
  39. ULONG:3; // RsvdP
  40. ULONG FirstDeviceID:5; // HWINIT
  41. ULONG:3; // RsvdP
  42. ULONG PhysicalSlotNumber:11; // HWINIT
  43. ULONG:2; // RsvdP
  44. ULONG UpDown:1; // HWINIT
  45. ULONG MRLSensorsImplemented:1; // HWINIT
  46. ULONG AttentionButtonImplemented:1; // HWINIT
  47. } SHPC_SLOT_CONFIGURATION_REGISTER, *PSHPC_SLOT_CONFIGURATION_REGISTER;
  48. //
  49. // Secondary Bus Configuration Register
  50. //
  51. typedef enum _SHPC_BUS_SPEED_MODE {
  52. SHPC_SPEED_33_CONV = 0,
  53. SHPC_SPEED_66_CONV,
  54. SHPC_SPEED_66_PCIX,
  55. SHPC_SPEED_100_PCIX,
  56. SHPC_SPEED_133_PCIX
  57. } SHPC_BUS_SPEED_MODE, *PSHPC_BUS_SPEED_MODE;
  58. typedef struct _SHPC_BUS_CONFIG_REGISTER {
  59. ULONG CurrentBusMode:3; // RO SHPC_SPEED_XXX
  60. ULONG Rsvd:21; // RsvdP
  61. ULONG ProgIF:8; // RO
  62. } SHPC_BUS_CONFIG_REGISTER, *PSHPC_BUS_CONFIG_REGISTER;
  63. //
  64. // Command Register
  65. //
  66. #define SHPC_SLOT_OPERATION_CODE 0x0
  67. #define SHPC_BUS_SEGMENT_OPERATION_CODE 0x8
  68. #define SHPC_POWER_ALL_SLOTS_CODE 0x48
  69. #define SHPC_ENABLE_ALL_SLOTS_CODE 0x49
  70. //
  71. // Command defines
  72. //
  73. #define IS_COMMAND_SLOT_OPERATION(x) \
  74. (x.SlotOperation.CommandCode == SHPC_SLOT_OPERATION_CODE)
  75. #define IS_COMMAND_SET_BUS_SEGMENT(x) \
  76. (x.BusSegmentOperation.CommandCode == SHPC_BUS_SEGMENT_OPERATION_CODE)
  77. #define IS_COMMAND_POWER_ALL_SLOTS(x) \
  78. (x.AsUchar = SHPC_POWER_ALL_SLOTS_CODE)
  79. #define IS_COMMAND_ENABLE_ALL_SLOTS(x) \
  80. (x.AsUchar = SHPC_ENABLE_ALL_SLOTS_CODE)
  81. typedef union _SHPC_CONTROLLER_COMMAND {
  82. struct {
  83. UCHAR SlotState:2;
  84. UCHAR PowerIndicator:2;
  85. UCHAR AttentionIndicator:2;
  86. UCHAR CommandCode:2;
  87. } SlotOperation;
  88. struct {
  89. UCHAR BusSpeed:3; // SHPC_SPEED_XXX
  90. UCHAR CommandCode:5;
  91. } BusSegmentOperation;
  92. struct {
  93. UCHAR Command:6;
  94. UCHAR CommandCode:2;
  95. } General;
  96. UCHAR AsUchar;
  97. } SHPC_CONTROLLER_COMMAND, *PSHPC_CONTROLLER_COMMAND;
  98. typedef struct _SHPC_COMMAND_STATUS {
  99. USHORT ControllerBusy:1; // RO
  100. USHORT MRLOpen:1; // RO
  101. USHORT InvalidCommand:1; // RO
  102. USHORT InvalidSpeedMode:1; // RO
  103. USHORT Rsvd:12; // RsvdP
  104. } SHPC_COMMAND_STATUS, *PSHPC_COMMAND_STATUS;
  105. typedef struct _SHPC_COMMAND_REGISTER {
  106. SHPC_CONTROLLER_COMMAND Command;
  107. struct {
  108. UCHAR TargetForCommand:4;
  109. UCHAR Rsvd:4; // RsvdP
  110. } Target;
  111. SHPC_COMMAND_STATUS Status;
  112. } SHPC_COMMAND_REGISTER, *PSHPC_COMMAND_REGISTER;
  113. //
  114. // Interrupt Locator Register
  115. //
  116. typedef struct _SHPC_INT_LOCATOR_REGISTER {
  117. ULONG CommandCompleteIntPending:1; // RO
  118. ULONG InterruptLocator:31; // RO
  119. } SHPC_INT_LOCATOR_REGISTER, *PSHPC_INT_LOCATOR_REGISTER;
  120. //
  121. // SERR Locator Register
  122. //
  123. typedef struct _SHPC_SERR_LOCATOR_REGISTER {
  124. ULONG ArbiterSERRPending:1; // RO
  125. ULONG SERRLocator:31; // RO
  126. } SHPC_SERR_LOCATOR_REGISTER, *PSHPC_SERR_LOCATOR_REGISTER;
  127. //
  128. // Controller SERR-INT Register
  129. //
  130. // The low word is the interrupt mask. When mask bits are set, the
  131. // corresponding operation is masked out.
  132. //
  133. #define SHPC_MASK_INT_COMMAND_COMPLETE 0x0001
  134. #define SHPC_MASK_INT_GLOBAL 0x0002
  135. #define SHPC_MASK_SERR_GLOBAL 0x0004
  136. #define SHPC_MASK_SERR_ARBITER_TIMEOUT 0x0008
  137. // all other bits in the low word are RsvdP
  138. //
  139. // The high word is the detected word.
  140. //
  141. #define SHPC_DETECTED_COMMAND_COMPLETE 0x0001
  142. #define SHPC_DETECTED_ARBITER_TIMEOUT 0x0002
  143. // all other bits in the high word are RsvdZ
  144. typedef struct _SHPC_SERR_INT_REGISTER {
  145. USHORT SERRIntMask;
  146. USHORT SERRIntDetected;
  147. } SHPC_SERR_INT_REGISTER, *PSHPC_SERR_INT_REGISTER;
  148. //
  149. // Slot Specific Registers
  150. //
  151. //
  152. // Status Field
  153. //
  154. #define SHPC_SLOT_NOP 0
  155. #define SHPC_SLOT_POWERED 1
  156. #define SHPC_SLOT_ENABLED 2
  157. #define SHPC_SLOT_OFF 3
  158. #define SHPC_INDICATOR_NOP 0
  159. #define SHPC_INDICATOR_ON 1
  160. #define SHPC_INDICATOR_BLINK 2
  161. #define SHPC_INDICATOR_OFF 3
  162. #define SHPC_PCIX_NO_CAP 0x0
  163. #define SHPC_PCIX_66_CAP 0x1
  164. #define SHPC_PCIX_133_CAP 0x3
  165. #define SHPC_MRL_CLOSED 0
  166. #define SHPC_MRL_OPEN 1
  167. #define SHPC_PRSNT_7_5_WATTS 0
  168. #define SHPC_PRSNT_25_WATTS 1
  169. #define SHPC_PRSNT_15_WATTS 2
  170. #define SHPC_PRSNT_EMPTY 3
  171. typedef struct _SHPC_SLOT_STATUS_REGISTER {
  172. USHORT SlotState:2; // SHPC_SLOT_XXX
  173. USHORT PowerIndicatorState:2; // SHPC_INDICATOR_XXX
  174. USHORT AttentionIndicatorState:2; // SHPC_INDICATOR_XXX
  175. USHORT PowerFaultDetected:1;
  176. USHORT AttentionButtonState:1;
  177. USHORT MRLSensorState:1; // SHPC_MRL_XXX
  178. USHORT SpeedCapability:1;
  179. USHORT PrsntState:2;
  180. USHORT PCIXCapability:2; //SHPC_PCIX_XXX
  181. USHORT Rsvd:2;
  182. } SHPC_SLOT_STATUS_REGISTER, *PSHPC_SLOT_STATUS_REGISTER;
  183. //
  184. // Slot Event Latch Field
  185. //
  186. // This register is a UCHAR with bit meanings defined
  187. // below.
  188. // All undefined bits are RsvdZ
  189. //
  190. #define SHPC_SLOT_EVENT_CARD_PRESENCE 0x01
  191. #define SHPC_SLOT_EVENT_ISO_FAULT 0x02
  192. #define SHPC_SLOT_EVENT_ATTEN_BUTTON 0x04
  193. #define SHPC_SLOT_EVENT_MRL_SENSOR 0x08
  194. #define SHPC_SLOT_EVENT_CONNECT_FAULT 0x10
  195. #define SHPC_SLOT_EVENT_ALL (SHPC_SLOT_EVENT_CARD_PRESENCE | \
  196. SHPC_SLOT_EVENT_ISO_FAULT | \
  197. SHPC_SLOT_EVENT_ATTEN_BUTTON | \
  198. SHPC_SLOT_EVENT_MRL_SENSOR | \
  199. SHPC_SLOT_EVENT_CONNECT_FAULT)
  200. //
  201. // Slot INT-SERR Mask Field
  202. //
  203. // This register is a UCHAR with bit meanings defined below
  204. // All undefined bits are RsvdP
  205. //
  206. #define SHPC_SLOT_INT_CARD_PRESENCE 0x01
  207. #define SHPC_SLOT_INT_ISO_FAULT 0x02
  208. #define SHPC_SLOT_INT_ATTEN_BUTTON 0x04
  209. #define SHPC_SLOT_INT_MRL_SENSOR 0x08
  210. #define SHPC_SLOT_INT_CONNECT_FAULT 0x10
  211. #define SHPC_SLOT_SERR_MRL_SENSOR 0x20
  212. #define SHPC_SLOT_SERR_CONNECT_FAULT 0x40
  213. #define SHPC_SLOT_INT_ALL (SHPC_SLOT_INT_CARD_PRESENCE | \
  214. SHPC_SLOT_INT_ISO_FAULT | \
  215. SHPC_SLOT_INT_ATTEN_BUTTON | \
  216. SHPC_SLOT_INT_MRL_SENSOR | \
  217. SHPC_SLOT_INT_CONNECT_FAULT)
  218. #define SHPC_SLOT_SERR_ALL (SHPC_SLOT_SERR_CONNECT_FAULT | \
  219. SHPC_SLOT_SERR_MRL_SENSOR)
  220. //
  221. // Overall Slot Register structure
  222. //
  223. typedef struct _SHPC_SLOT_REGISTER {
  224. SHPC_SLOT_STATUS_REGISTER SlotStatus; //RO
  225. UCHAR SlotEventLatch;
  226. UCHAR IntSERRMask;
  227. } SHPC_SLOT_REGISTER, *PSHPC_SLOT_REGISTER;
  228. //
  229. // Overall Register Set Structures
  230. //
  231. #define SHPC_MAX_SLOT_REGISTERS 31
  232. typedef struct _SHPC_WORKING_REGISTERS {
  233. ULONG BaseOffset;
  234. SHPC_SLOTS_AVAILABLE_REGISTER SlotsAvailable;
  235. SHPC_SLOT_CONFIGURATION_REGISTER SlotConfig;
  236. SHPC_BUS_CONFIG_REGISTER BusConfig;
  237. SHPC_COMMAND_REGISTER Command;
  238. SHPC_INT_LOCATOR_REGISTER IntLocator;
  239. SHPC_SERR_LOCATOR_REGISTER SERRLocator;
  240. SHPC_SERR_INT_REGISTER SERRInt;
  241. SHPC_SLOT_REGISTER SlotRegisters[SHPC_MAX_SLOT_REGISTERS];
  242. } SHPC_WORKING_REGISTERS, *PSHPC_WORKING_REGISTERS;
  243. //
  244. // Register access structures and defines
  245. //
  246. #define SHPC_NUM_REGISTERS sizeof(SHPC_WORKING_REGISTERS)/sizeof(ULONG)
  247. #define SHPC_FIRST_SLOT_REG (SHPC_NUM_REGISTERS - SHPC_MAX_SLOT_REGISTERS)
  248. typedef union _SHPC_REGISTER_SET {
  249. SHPC_WORKING_REGISTERS WorkingRegisters;
  250. ULONG AsULONGs[SHPC_NUM_REGISTERS];
  251. } SHPC_REGISTER_SET, *PSHPC_REGISTER_SET;
  252. //
  253. // HBRB defines
  254. //
  255. #define HBRB_PACKAGE_COUNT 2
  256. typedef struct _HBRB_HEADER {
  257. USHORT VendorID;
  258. USHORT DeviceID;
  259. UCHAR RevisionID;
  260. UCHAR ProgIF;
  261. UCHAR BusNumber;
  262. UCHAR HBRBVersion;
  263. USHORT SubVendorID;
  264. USHORT SubSystemID;
  265. ULONG Size;
  266. ULONG CapabilitiesPtr;
  267. } HBRB_HEADER, *PHBRB_HEADER;
  268. typedef struct _HBRB_CAPABILITIES_HEADER {
  269. ULONG CapabilityID;
  270. ULONG Next;
  271. } HBRB_CAPABILITIES_HEADER, *PHBRB_CAPABILITIES_HEADER;
  272. typedef struct _HBRB_CAPABILITY {
  273. HBRB_CAPABILITIES_HEADER Header;
  274. SHPC_WORKING_REGISTERS RegisterSet;
  275. } SHPC_HBRB_CAPABILITY, *PSHPC_HBRB_CAPABILITY;
  276. //
  277. // SHPC config space defines
  278. //
  279. typedef union _SHPC_CONFIG_PENDING {
  280. struct {
  281. UCHAR ControllerSERRPending:1; // RO
  282. UCHAR ControllerIntPending:1; // RO
  283. UCHAR:6; // RsvdP
  284. } Field;
  285. UCHAR AsUCHAR;
  286. } SHPC_CONFIG_PENDING, *PSHPC_CONFIG_PENDING;
  287. typedef struct _SHPC_CONFIG_SPACE {
  288. PCI_CAPABILITIES_HEADER Header; //RO
  289. UCHAR DwordSelect;
  290. SHPC_CONFIG_PENDING Pending;
  291. ULONG Data;
  292. } SHPC_CONFIG_SPACE, *PSHPC_CONFIG_SPACE;
  293. #include "poppack.h"
  294. #define SHPC_CAPABILITY_ID 0xC
  295. //
  296. // Bit type masks
  297. //
  298. //
  299. // XxxRO indicates the mask of bits in the register that are Read Only
  300. // XxxRW indicates the mask of bits in the register that are Read Write
  301. // XxxRWC indicates the mask of bits in the register that are Read/Write Clear
  302. // XxxRsvdP indicates the mask of bits in the register that are Reserved
  303. // and whose values should be preserved on writes.
  304. // XxxRsvdZ indicates the mask of bits in the register that are Reserved
  305. // and whose values should be always written as zeros.
  306. //
  307. // All of the listed masks for a register should always add to 0xFFFFFFFF
  308. //
  309. //
  310. // Base Offset Register
  311. //
  312. #define BaseOffsetRO 0xFFFFFFFF
  313. //
  314. // Slots Available Registers
  315. // DWord1 is the lower dword
  316. // DWord2 is the upper dword
  317. //
  318. #define SlotsAvailDWord1RO 0x1F1F1F1F
  319. #define SlotsAvailDWord1RsvdP 0xE0E0E0E0
  320. #define SlotsAvailDWord2RO 0x0000001F
  321. #define SlotsAvailDWord2RsvdP 0xFFFFFFE0
  322. //
  323. // Slot Configuration Register
  324. //
  325. #define SlotConfigRO 0xE7FF1F1F
  326. #define SlotConfigRsvdP 0x1800E0E0
  327. //
  328. // Secondary Bus Configuration Register
  329. // This mask includes the SHPC Programming Interface register
  330. //
  331. #define BusConfigRO 0xFF000007
  332. #define BusConfigRsvdP 0x00FFFFF8
  333. //
  334. // Controller Command/Status Register
  335. // This mask includes both the Command and Command Status registers
  336. //
  337. #define CommandStatusRO 0x000F0000
  338. #define CommandStatusRW 0x00001FFF
  339. #define CommandStatusRsvdP 0xFFF0E000
  340. //
  341. // Interrupt Locator Register
  342. //
  343. #define IntLocatorRO 0xFFFFFFFF
  344. //
  345. // SERR Locator Register
  346. //
  347. #define SERRLocatorRO 0xFFFFFFFF
  348. //
  349. // Controller SERR-INT Register
  350. //
  351. #define ControllerMaskRW 0x0000000F
  352. #define ControllerMaskRWC 0x00030000
  353. #define ControllerMaskRsvdP 0x0000FFF0
  354. #define ControllerMaskRsvdZ 0xFFFC0000
  355. //
  356. // Slot Specific Registers
  357. //
  358. #define SlotRO 0x00003FFF
  359. #define SlotRW 0x7F000000
  360. #define SlotRWC 0x001F0000
  361. #define SlotRsvdP 0x80000000
  362. #define SlotRsvdZ 0x00E0C000
  363. #endif