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.

436 lines
16 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. res_bios
  5. Abstract:
  6. PnP BIOS/ISA configuration data definitions
  7. Author:
  8. Shie-Lin Tzong (shielint) April 12, 1995
  9. Stephane Plante (splante) Feb 13, 1997
  10. Revision History:
  11. Feb 13 1997
  12. Changed and fully adapted to ACPI driver
  13. --*/
  14. #ifndef _RES_BIOS_H_
  15. #define _RES_BIOS_H_
  16. //
  17. // Constants
  18. //
  19. #define SMALL_RESOURCE_TAG (UCHAR)(0x00)
  20. #define LARGE_RESOURCE_TAG (UCHAR)(0x80)
  21. #define SMALL_TAG_MASK 0xf8
  22. #define SMALL_TAG_SIZE_MASK 7
  23. //
  24. // Small Resource Tags with length bits stripped off
  25. //
  26. #define TAG_IRQ 0x20
  27. #define TAG_DMA 0x28
  28. #define TAG_START_DEPEND 0x30
  29. #define TAG_END_DEPEND 0x38
  30. #define TAG_IO 0x40
  31. #define TAG_IO_FIXED 0x48
  32. #define TAG_VENDOR 0x70
  33. #define TAG_END 0x78
  34. //
  35. // Large Resource Tags
  36. //
  37. #define TAG_MEMORY 0x81
  38. #define TAG_VENDOR_LONG 0x84
  39. #define TAG_MEMORY32 0x85
  40. #define TAG_MEMORY32_FIXED 0x86
  41. #define TAG_DOUBLE_ADDRESS 0x87
  42. #define TAG_WORD_ADDRESS 0x88
  43. #define TAG_EXTENDED_IRQ 0x89
  44. #define TAG_QUAD_ADDRESS 0x8a
  45. #include "pshpack1.h"
  46. //
  47. // PNP ISA Port descriptor definition
  48. //
  49. typedef struct _PNP_PORT_DESCRIPTOR_ {
  50. UCHAR Tag; // 01000111B, small item name = 08, length = 7
  51. UCHAR Information; // bit [0] = 1 device decodes full 16 bit addr
  52. // = 0 device decodes ISA addr bits[9-0]
  53. USHORT MinimumAddress;
  54. USHORT MaximumAddress;
  55. UCHAR Alignment; // Increment in 1 byte blocks
  56. UCHAR Length; // # contiguous Port requested
  57. } PNP_PORT_DESCRIPTOR, *PPNP_PORT_DESCRIPTOR;
  58. #define PNP_PORT_DECODE_MASK 0x1
  59. #define PNP_PORT_10_BIT_DECODE 0x0
  60. #define PNP_PORT_16_BIT_DECODE 0x1
  61. //
  62. // PNP ISA fixed Port descriptor definition
  63. //
  64. typedef struct _PNP_FIXED_PORT_DESCRIPTOR_ {
  65. UCHAR Tag; // 01001011B, small item name = 09, length = 3
  66. USHORT MinimumAddress;
  67. UCHAR Length; // # contiguous Port requested
  68. } PNP_FIXED_PORT_DESCRIPTOR, *PPNP_FIXED_PORT_DESCRIPTOR;
  69. //
  70. // PNP ISA IRQ descriptor definition
  71. //
  72. typedef struct _PNP_IRQ_DESCRIPTOR_ {
  73. UCHAR Tag; // 0010001XB small item name = 4 length = 2/3
  74. USHORT IrqMask; // bit 0 is irq 0
  75. UCHAR Information; // Optional
  76. } PNP_IRQ_DESCRIPTOR, *PPNP_IRQ_DESCRIPTOR;
  77. #define PNP_IRQ_LEVEL 0x08
  78. #define PNP_IRQ_LATCHED 0x01
  79. #define PNP_IRQ_SHARED 0x10
  80. //
  81. // PNP ISA DMA descriptor definition
  82. //
  83. typedef struct _PNP_DMA_DESCRIPTOR_ {
  84. UCHAR Tag; // 00101010B, small item name = 05, length = 2
  85. UCHAR ChannelMask; // bit 0 is channel 0
  86. UCHAR Flags; // see spec
  87. } PNP_DMA_DESCRIPTOR, *PPNP_DMA_DESCRIPTOR;
  88. //
  89. // Defination and mask for the various flags
  90. //
  91. #define PNP_DMA_SIZE_MASK 0x03
  92. #define PNP_DMA_SIZE_8 0x00
  93. #define PNP_DMA_SIZE_8_AND_16 0x01
  94. #define PNP_DMA_SIZE_16 0x02
  95. #define PNP_DMA_SIZE_RESERVED 0x03
  96. #define PNP_DMA_BUS_MASTER 0x04
  97. #define PNP_DMA_TYPE_MASK 0x60
  98. #define PNP_DMA_TYPE_COMPATIBLE 0x00
  99. #define PNP_DMA_TYPE_A 0x20
  100. #define PNP_DMA_TYPE_B 0x40
  101. #define PNP_DMA_TYPE_F 0x60
  102. //
  103. // PNP ISA MEMORY descriptor
  104. //
  105. typedef struct _PNP_MEMORY_DESCRIPTOR_ {
  106. UCHAR Tag; // 10000001B, Large item name = 1
  107. USHORT Length; // Length of the descriptor = 9
  108. UCHAR Information; // See def below
  109. USHORT MinimumAddress; // address bit [8-23]
  110. USHORT MaximumAddress; // address bit [8-23]
  111. USHORT Alignment; // 0x0000 = 64KB
  112. USHORT MemorySize; // In 256 byte blocks
  113. } PNP_MEMORY_DESCRIPTOR, *PPNP_MEMORY_DESCRIPTOR;
  114. //
  115. // PNP ISA MEMORY32 descriptor
  116. //
  117. typedef struct _PNP_MEMORY32_DESCRIPTOR_ {
  118. UCHAR Tag; // 10000101B, Large item name = 5
  119. USHORT Length; // Length of the descriptor = 17
  120. UCHAR Information; // See def below
  121. ULONG MinimumAddress; // 32 bit addr
  122. ULONG MaximumAddress; // 32 bit addr
  123. ULONG Alignment; // 32 bit alignment
  124. ULONG MemorySize; // 32 bit length
  125. } PNP_MEMORY32_DESCRIPTOR, *PPNP_MEMORY32_DESCRIPTOR;
  126. //
  127. // PNP ISA FIXED MEMORY32 descriptor
  128. //
  129. typedef struct _PNP_FIXED_MEMORY32_DESCRIPTOR_ {
  130. UCHAR Tag; // 10000110B, Large item name = 6
  131. USHORT Length; // Length of the descriptor = 9
  132. UCHAR Information; // See def below
  133. ULONG BaseAddress; // 32 bit addr
  134. ULONG MemorySize; // 32 bit length
  135. } PNP_FIXED_MEMORY32_DESCRIPTOR, *PPNP_FIXED_MEMORY32_DESCRIPTOR;
  136. #define PNP_MEMORY_READ_ONLY 0x00
  137. #define PNP_MEMORY_READ_WRITE 0x01
  138. //
  139. // PNP ISA Resource Source descriptor definition
  140. //
  141. typedef struct _PNP_RESOURCE_SOURCE_DESCRIPTOR_ {
  142. UCHAR Index; // Varies with type of Source
  143. UCHAR String[1]; // Start of a variable string
  144. } PNP_RESOURCE_SOURCE_DESCRIPTOR, *PPNP_RESOURCE_SOURCE_DESCRIPTOR;
  145. //
  146. // PNP DWORD Address descriptor definition
  147. //
  148. typedef struct _PNP_DWORD_ADDRESS_DESCRIPTOR_ {
  149. UCHAR Tag; // 10000111B, Large item name= 7
  150. USHORT Length; // Length of the descriptor = 23 (min)
  151. UCHAR RFlag; // Resource Flags
  152. UCHAR GFlag; // General Flags
  153. UCHAR TFlag; // Type specific flags
  154. ULONG Granularity; // Memory Decode Bits
  155. ULONG MinimumAddress; // Minium Address in range
  156. ULONG MaximumAddress; // Maximum Address in range
  157. ULONG TranslationAddress; // How to translate the address
  158. ULONG AddressLength; // Number of bytes requested
  159. } PNP_DWORD_ADDRESS_DESCRIPTOR, *PPNP_DWORD_ADDRESS_DESCRIPTOR;
  160. typedef struct _PNP_QWORD_ADDRESS_DESCRIPTOR_ {
  161. UCHAR Tag; // 10001010B, Large item name= 10
  162. USHORT Length; // Length of the descriptor = 23 (min)
  163. UCHAR RFlag; // Resource Flags
  164. UCHAR GFlag; // General Flags
  165. UCHAR TFlag; // Type specific flags
  166. ULONGLONG Granularity; // Memory Decode Bits
  167. ULONGLONG MinimumAddress; // Minium Address in range
  168. ULONGLONG MaximumAddress; // Maximum Address in range
  169. ULONGLONG TranslationAddress; // How to translate the address
  170. ULONGLONG AddressLength; // Number of bytes requested
  171. } PNP_QWORD_ADDRESS_DESCRIPTOR, *PPNP_QWORD_ADDRESS_DESCRIPTOR;
  172. typedef struct _PNP_WORD_ADDRESS_DESCRIPTOR_ {
  173. UCHAR Tag; // 10001000B, Large item name= 8
  174. USHORT Length; // Length of the descriptor = 13 (min)
  175. UCHAR RFlag; // Resource Flags
  176. UCHAR GFlag; // General Flags
  177. UCHAR TFlag; // Type specific flags
  178. USHORT Granularity; // Memory Decode Bits
  179. USHORT MinimumAddress; // Minium Address in range
  180. USHORT MaximumAddress; // Maximum Address in range
  181. USHORT TranslationAddress; // How to translate the address
  182. USHORT AddressLength; // Number of Bytes requested
  183. } PNP_WORD_ADDRESS_DESCRIPTOR, *PPNP_WORD_ADDRESS_DESCRIPTOR;
  184. //
  185. // These are the valid minimum lengths. We bugcheck if the descriptors
  186. // are less then these
  187. //
  188. #define PNP_ADDRESS_WORD_MINIMUM_LENGTH 0x0D
  189. #define PNP_ADDRESS_DWORD_MINIMUM_LENGTH 0x17
  190. #define PNP_ADDRESS_QWORD_MINIMUM_LENGTH 0x2B
  191. //
  192. // These are the possible values for RFlag Means
  193. //
  194. #define PNP_ADDRESS_MEMORY_TYPE 0x0
  195. #define PNP_ADDRESS_IO_TYPE 0x1
  196. #define PNP_ADDRESS_BUS_NUMBER_TYPE 0x2
  197. //
  198. // The Global flags
  199. //
  200. #define PNP_ADDRESS_FLAG_CONSUMED_ONLY 0x1
  201. #define PNP_ADDRESS_FLAG_SUBTRACTIVE_DECODE 0x2
  202. #define PNP_ADDRESS_FLAG_MINIMUM_FIXED 0x4
  203. #define PNP_ADDRESS_FLAG_MAXIMUM_FIXED 0x8
  204. //
  205. // This mask is used when the RFLags indicates that this is
  206. // memory address descriptor. The mask is used with the TFlags
  207. // and the result is compared to the next 4 defines to determine
  208. // the memory type
  209. //
  210. #define PNP_ADDRESS_TYPE_MEMORY_MASK 0x1E
  211. #define PNP_ADDRESS_TYPE_MEMORY_NONCACHEABLE 0x00
  212. #define PNP_ADDRESS_TYPE_MEMORY_CACHEABLE 0x02
  213. #define PNP_ADDRESS_TYPE_MEMORY_WRITE_COMBINE 0x04
  214. #define PNP_ADDRESS_TYPE_MEMORY_PREFETCHABLE 0x06
  215. //
  216. // If this bit is set, then this memory is read-write
  217. //
  218. #define PNP_ADDRESS_TYPE_MEMORY_READ_WRITE 0x01
  219. #define PNP_ADDRESS_TYPE_MEMORY_READ_ONLY 0x00
  220. //
  221. // These are used when the RFlags indicates that this is an IO descriptor
  222. //
  223. #define PNP_ADDRESS_TYPE_IO_NON_ISA_RANGE 0x01
  224. #define PNP_ADDRESS_TYPE_IO_ISA_RANGE 0x02
  225. #define PNP_ADDRESS_TYPE_IO_SPARSE_TRANSLATION 0x20
  226. #define PNP_ADDRESS_TYPE_IO_TRANSLATE_IO_TO_MEM 0x10
  227. //
  228. // PNP ISA Extended IRQ descriptor definition [fixed block]
  229. //
  230. typedef struct _PNP_EXTENDED_IRQ_DESCRIPTOR_ {
  231. UCHAR Tag; // 10001001B, Large item name = 9
  232. USHORT Length; // Length of the descriptor = 12 (min)
  233. UCHAR Flags; // Vector Flags
  234. UCHAR TableSize; // How many items in the table
  235. ULONG Table[1]; // Table of interrupts
  236. } PNP_EXTENDED_IRQ_DESCRIPTOR, *PPNP_EXTENDED_IRQ_DESCRIPTOR;
  237. #define PNP_EXTENDED_IRQ_RESOURCE_CONSUMER_ONLY 0x01
  238. #define PNP_EXTENDED_IRQ_MODE 0x02
  239. #define PNP_EXTENDED_IRQ_POLARITY 0x04
  240. #define PNP_EXTENDED_IRQ_SHARED 0x08
  241. #define PNP_VENDOR_SPECIFIC_MASK 0x07
  242. //
  243. // These are the flags that can be passed into the Bios to Io engine
  244. //
  245. #define PNP_BIOS_TO_IO_NO_CONSUMED_RESOURCES 0x01
  246. #include "poppack.h"
  247. VOID
  248. PnpiBiosAddressHandleBusFlags(
  249. IN PVOID Buffer,
  250. IN PIO_RESOURCE_DESCRIPTOR Descriptor
  251. );
  252. VOID
  253. PnpiBiosAddressHandleGlobalFlags(
  254. IN PVOID Buffer,
  255. IN PIO_RESOURCE_DESCRIPTOR Descriptor
  256. );
  257. VOID
  258. PnpiBiosAddressHandleMemoryFlags(
  259. IN PVOID Buffer,
  260. IN PIO_RESOURCE_DESCRIPTOR Descriptor
  261. );
  262. VOID
  263. PnpiBiosAddressHandlePortFlags(
  264. IN PVOID Buffer,
  265. IN PIO_RESOURCE_DESCRIPTOR Descriptor
  266. );
  267. NTSTATUS
  268. PnpiBiosAddressToIoDescriptor(
  269. IN PUCHAR Data,
  270. IN PIO_RESOURCE_LIST Array[],
  271. IN ULONG ArrayIndex,
  272. IN ULONG Flags
  273. );
  274. NTSTATUS
  275. PnpiBiosAddressDoubleToIoDescriptor(
  276. IN PUCHAR Data,
  277. IN PIO_RESOURCE_LIST Array[],
  278. IN ULONG ArrayIndex,
  279. IN ULONG Flags
  280. );
  281. NTSTATUS
  282. PnpiBiosAddressQuadToIoDescriptor(
  283. IN PUCHAR Data,
  284. IN PIO_RESOURCE_LIST Array[],
  285. IN ULONG ArrayIndex,
  286. IN ULONG Flags
  287. );
  288. NTSTATUS
  289. PnpiBiosDmaToIoDescriptor(
  290. IN PUCHAR Data,
  291. IN UCHAR Channel,
  292. IN PIO_RESOURCE_LIST Array[],
  293. IN ULONG ArrayIndex,
  294. IN USHORT Count,
  295. IN ULONG Flags
  296. );
  297. NTSTATUS
  298. PnpiBiosExtendedIrqToIoDescriptor(
  299. IN PUCHAR Data,
  300. IN UCHAR DataIndex,
  301. IN PIO_RESOURCE_LIST Array[],
  302. IN ULONG ArrayIndex,
  303. IN ULONG Flags
  304. );
  305. NTSTATUS
  306. PnpiBiosIrqToIoDescriptor(
  307. IN PUCHAR Data,
  308. IN USHORT Interrupt,
  309. IN PIO_RESOURCE_LIST Array[],
  310. IN ULONG ArrayIndex,
  311. IN USHORT Count,
  312. IN ULONG Flags
  313. );
  314. NTSTATUS
  315. PnpiBiosMemoryToIoDescriptor(
  316. IN PUCHAR Data,
  317. IN PIO_RESOURCE_LIST Array[],
  318. IN ULONG ArrayIndex,
  319. IN ULONG Flags
  320. );
  321. NTSTATUS
  322. PnpiBiosPortToIoDescriptor (
  323. IN PUCHAR Data,
  324. IN PIO_RESOURCE_LIST Array[],
  325. IN ULONG ArrayIndex,
  326. IN ULONG Flags
  327. );
  328. NTSTATUS
  329. PnpiBiosPortFixedToIoDescriptor(
  330. IN PUCHAR Data,
  331. IN PIO_RESOURCE_LIST Array[],
  332. IN ULONG ArrayIndex,
  333. IN ULONG Flags
  334. );
  335. VOID
  336. PnpiClearAllocatedMemory(
  337. IN PIO_RESOURCE_LIST ResourceArray[],
  338. IN ULONG ResourceArraySize
  339. );
  340. NTSTATUS
  341. PnpiGrowResourceDescriptor(
  342. IN OUT PIO_RESOURCE_LIST *ResourceList
  343. );
  344. NTSTATUS
  345. PnpiGrowResourceList(
  346. IN OUT PIO_RESOURCE_LIST *ResourceListArray[],
  347. IN OUT ULONG *ResourceListArraySize
  348. );
  349. NTSTATUS
  350. PnpiUpdateResourceList(
  351. IN OUT PIO_RESOURCE_LIST *ResourceList,
  352. OUT PIO_RESOURCE_DESCRIPTOR *ResourceDesc
  353. );
  354. NTSTATUS
  355. PnpBiosResourcesToNtResources (
  356. IN PUCHAR BiosData,
  357. IN ULONG Flags,
  358. OUT PIO_RESOURCE_REQUIREMENTS_LIST *List
  359. );
  360. NTSTATUS
  361. PnpCmResourceListToIoResourceList(
  362. IN PCM_RESOURCE_LIST CmList,
  363. IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *IoList
  364. );
  365. NTSTATUS
  366. PnpIoResourceListToCmResourceList(
  367. IN PIO_RESOURCE_REQUIREMENTS_LIST IoList,
  368. IN OUT PCM_RESOURCE_LIST *CmList
  369. );
  370. #endif