1
0

devres.h 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258
  1. /*++
  2. Copyright (c) 2012 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. devres.h
  9. Abstract:
  10. This header contains definitions for I/O resources.
  11. Author:
  12. Evan Green 2-Dec-2012
  13. --*/
  14. //
  15. // ------------------------------------------------------------------- Includes
  16. //
  17. //
  18. // ---------------------------------------------------------------- Definitions
  19. //
  20. //
  21. // Define resource requirement and allocation flags.
  22. //
  23. //
  24. // Set this bit if the allocation cannot be shared with any other device.
  25. //
  26. #define RESOURCE_FLAG_NOT_SHAREABLE 0x00000001
  27. //
  28. // This bit is set by the arbiter in resource allocations if the allocation was
  29. // a boot allocation. It is ignored if passed in a requirement.
  30. //
  31. #define RESOURCE_FLAG_BOOT 0x00000002
  32. //
  33. // Define interrupt line characteristics.
  34. //
  35. #define INTERRUPT_LINE_EDGE_TRIGGERED 0x00000001
  36. #define INTERRUPT_LINE_ACTIVE_LOW 0x00000002
  37. #define INTERRUPT_LINE_ACTIVE_HIGH 0x00000004
  38. #define INTERRUPT_LINE_WAKE 0x00000008
  39. #define INTERRUPT_LINE_DEBOUNCE 0x00000010
  40. #define INTERRUPT_LINE_SECONDARY 0x00000020
  41. //
  42. // Define interrupt vector characteristics.
  43. //
  44. #define INTERRUPT_VECTOR_EDGE_TRIGGERED 0x00000001
  45. #define INTERRUPT_VECTOR_ACTIVE_LOW 0x00000002
  46. #define INTERRUPT_VECTOR_ACTIVE_HIGH 0x00000004
  47. //
  48. // Define DMA characteristics.
  49. //
  50. #define DMA_TYPE_ISA 0x00000001
  51. #define DMA_TYPE_EISA_A 0x00000002
  52. #define DMA_TYPE_EISA_B 0x00000004
  53. #define DMA_TYPE_EISA_F 0x00000008
  54. #define DMA_BUS_MASTER 0x00000010
  55. #define DMA_TRANSFER_SIZE_8 0x00000020
  56. #define DMA_TRANSFER_SIZE_16 0x00000040
  57. #define DMA_TRANSFER_SIZE_32 0x00000080
  58. #define DMA_TRANSFER_SIZE_64 0x00000100
  59. #define DMA_TRANSFER_SIZE_128 0x00000200
  60. #define DMA_TRANSFER_SIZE_256 0x00000400
  61. #define DMA_TRANSFER_SIZE_CUSTOM 0x00010000
  62. #define RESOURCE_DMA_DATA_VERSION 1
  63. //
  64. // Define memory characteristics.
  65. //
  66. #define MEMORY_CHARACTERISTIC_PREFETCHABLE 0x00000100
  67. //
  68. // Define GPIO characteristics.
  69. //
  70. #define RESOURCE_GPIO_INTERRUPT 0x00000001
  71. #define RESOURCE_GPIO_INPUT 0x00000002
  72. #define RESOURCE_GPIO_OUTPUT 0x00000004
  73. #define RESOURCE_GPIO_WAKE 0x00000008
  74. #define RESOURCE_GPIO_ACTIVE_HIGH 0x00000010
  75. #define RESOURCE_GPIO_ACTIVE_LOW 0x00000020
  76. #define RESOURCE_GPIO_EDGE_TRIGGERED 0x00000040
  77. #define RESOURCE_GPIO_PULL_UP 0x00000080
  78. #define RESOURCE_GPIO_PULL_DOWN 0x00000100
  79. #define RESOURCE_GPIO_PULL_NONE \
  80. (RESOURCE_GPIO_PULL_UP | RESOURCE_GPIO_PULL_DOWN)
  81. #define RESOURCE_GPIO_DATA_VERSION 1
  82. #define RESOURCE_GPIO_DEFAULT_DRIVE_STRENGTH ((ULONG)-1)
  83. #define RESOURCE_GPIO_DEFAULT_DEBOUNCE_TIMEOUT ((ULONG)-1)
  84. //
  85. // Defie Simple Peripheral Bus characteristics.
  86. //
  87. #define RESOURCE_SPB_DATA_VERSION 1
  88. #define RESOURCE_SPB_DATA_SLAVE 0x00000001
  89. #define RESOURCE_SPB_I2C_10_BIT_ADDRESSING 0x00000001
  90. #define RESOURCE_SPB_SPI_DEVICE_SELECT_ACTIVE_HIGH 0x00000001
  91. #define RESOURCE_SPB_SPI_3_WIRES 0x00000002
  92. //
  93. // The CPHA bit determines whether to sample data on the first phase of the
  94. // clock or the second phase of the clock.
  95. //
  96. #define RESOURCE_SPB_SPI_SECOND_PHASE 0x00000004
  97. //
  98. // The CPOL bit determines whether the clock is low or high during the first
  99. // phase.
  100. //
  101. #define RESOURCE_SPB_SPI_START_HIGH 0x00000008
  102. #define RESOURCE_SPB_UART_STOP_BITS_NONE (0x0 << 0)
  103. #define RESOURCE_SPB_UART_STOP_BITS_1 (0x1 << 0)
  104. #define RESOURCE_SPB_UART_STOP_BITS_1_5 (0x2 << 0)
  105. #define RESOURCE_SPB_UART_STOP_BITS_2 (0x3 << 0)
  106. #define RESOURCE_SPB_UART_STOP_BITS_MASK (0x3 << 0)
  107. #define RESOURCE_SPB_UART_FLOW_CONTROL_HARDWARE 0x00000004
  108. #define RESOURCE_SPB_UART_FLOW_CONTROL_SOFTWARE 0x00000008
  109. #define RESOURCE_SPB_UART_PARITY_MASK (0xF << 4)
  110. #define RESOURCE_SPB_UART_PARITY_NONE (0xF << 4)
  111. #define RESOURCE_SPB_UART_PARITY_EVEN (0xF << 4)
  112. #define RESOURCE_SPB_UART_PARITY_ODD (0xF << 4)
  113. #define RESOURCE_SPB_UART_PARITY_MARK (0xF << 4)
  114. #define RESOURCE_SPB_UART_PARITY_SPACE (0xF << 4)
  115. #define RESOURCE_SPB_UART_BIG_ENDIAN 0x00000100
  116. #define RESOURCE_SPB_UART_CONTROL_DTD (1 << 2)
  117. #define RESOURCE_SPB_UART_CONTROL_RI (1 << 3)
  118. #define RESOURCE_SPB_UART_CONTROL_DSR (1 << 4)
  119. #define RESOURCE_SPB_UART_CONTROL_DTR (1 << 5)
  120. #define RESOURCE_SPB_UART_CONTROL_CTS (1 << 6)
  121. #define RESOURCE_SPB_UART_CONTROL_RTS (1 << 7)
  122. //
  123. // ------------------------------------------------------ Data Type Definitions
  124. //
  125. typedef struct _DEVICE DEVICE, *PDEVICE;
  126. typedef enum _RESOURCE_TYPE {
  127. ResourceTypeInvalid,
  128. ResourceTypePhysicalAddressSpace,
  129. ResourceTypeIoPort,
  130. ResourceTypeInterruptLine,
  131. ResourceTypeInterruptVector,
  132. ResourceTypeBusNumber,
  133. ResourceTypeDmaChannel,
  134. ResourceTypeVendorSpecific,
  135. ResourceTypeGpio,
  136. ResourceTypeSimpleBus,
  137. ResourceTypeCount,
  138. } RESOURCE_TYPE, *PRESOURCE_TYPE;
  139. typedef enum _RESOURCE_SPB_BUS_TYPE {
  140. ResourceSpbBusInvalid,
  141. ResourceSpbBusI2c,
  142. ResourceSpbBusSpi,
  143. ResourceSpbBusUart,
  144. ResourceSpbBusTypeCount
  145. } RESOURCE_SPB_BUS_TYPE, *PRESOURCE_SPB_BUS_TYPE;
  146. /*++
  147. Structure Description:
  148. This structure defines a device resource requirement.
  149. Members:
  150. ListEntry - Stores pointers to the next and previous resource requirements
  151. in the resource requirement list.
  152. AlternativeListEntry - Stores pointers to the next and previous alternative
  153. entries that would equivalently satisfy this requirement.
  154. Type - Stores the type of resource being described.
  155. Minimum - Stores the minimum address of the range that can satisfy the
  156. requirement.
  157. Maximum - Stores the maximum address (exclusive) of the range that can
  158. satisfy the requirement. In other words, the first address outside the
  159. range.
  160. Alignment - Stores the byte alignment requirement of the beginning of the
  161. range.
  162. Length - Stores the minimum required length of the resource.
  163. Characteristics - Stores a bitfield of characteristics of the resource
  164. requirement. These are characteristics of the resource and must match.
  165. Flags - Store a bitfield of flags regarding the resource requirement. These
  166. bits represent properties that are not necessarily reflected in the
  167. final selected resource.
  168. OwningRequirement - Stores a pointer to an owning resource requirement
  169. whose allocation influences the allocation of this requirement (e.g.
  170. interrupt vector allocations can depend on interrupt line allocations).
  171. Data - Stores a pointer to the additional data for this requirement. This
  172. data is only required for some resource types (like GPIO).
  173. DataSize - Stores the size of the additional data in bytes.
  174. Provider - Stores an optional pointer to the device that provides the
  175. resource. If NULL, then the provider will be automatically determined
  176. by walking up the device's parents.
  177. --*/
  178. typedef struct _RESOURCE_REQUIREMENT RESOURCE_REQUIREMENT;
  179. typedef struct _RESOURCE_REQUIREMENT *PRESOURCE_REQUIREMENT;
  180. struct _RESOURCE_REQUIREMENT {
  181. LIST_ENTRY ListEntry;
  182. LIST_ENTRY AlternativeListEntry;
  183. RESOURCE_TYPE Type;
  184. ULONGLONG Minimum;
  185. ULONGLONG Maximum;
  186. ULONGLONG Alignment;
  187. ULONGLONG Length;
  188. ULONGLONG Characteristics;
  189. ULONGLONG Flags;
  190. PRESOURCE_REQUIREMENT OwningRequirement;
  191. PVOID Data;
  192. UINTN DataSize;
  193. PDEVICE Provider;
  194. };
  195. /*++
  196. Structure Description:
  197. This structure defines a list of resource requirements that collectively
  198. represent a viable configuration for a device.
  199. Members:
  200. ListEntry - Stores pointers to the next and previous resource requirement
  201. lists in the set.
  202. RequirementListHead - Stores the head of the list of resource requirements.
  203. The type of each entry on the list is a RESOURCE_REQUIREMENT.
  204. --*/
  205. typedef struct _RESOURCE_REQUIREMENT_LIST {
  206. LIST_ENTRY ListEntry;
  207. LIST_ENTRY RequirementListHead;
  208. } RESOURCE_REQUIREMENT_LIST, *PRESOURCE_REQUIREMENT_LIST;
  209. /*++
  210. Structure Description:
  211. This structure defines a list of resource requirements that collectively
  212. represent a viable configuration for a device.
  213. Members:
  214. RequirementListListHead - Stores the list head of possible resource
  215. configurations, ordered by preference (ListHead.Next representing the
  216. most desirable configuration).
  217. --*/
  218. typedef struct _RESOURCE_CONFIGURATION_LIST {
  219. LIST_ENTRY RequirementListListHead;
  220. } RESOURCE_CONFIGURATION_LIST, *PRESOURCE_CONFIGURATION_LIST;
  221. /*++
  222. Structure Description:
  223. This structure defines a resource allocation.
  224. Members:
  225. ListEntry - Stores pointers to the next and previous resource allocations
  226. in the resource allocation list.
  227. Type - Stores the type of resource being described.
  228. Allocation - Stores the base value of the allocation, which can be a
  229. base physical address, I/O port, interrupt pin, etc.
  230. Length - Stores the length of the resource allocation.
  231. Characteristics - Stores a bitfield of characteristics of the resource.
  232. Flags - Store a bitfield of flags regarding the resource.
  233. OwningAllocation - Stores a pointer to an owning resource allocation whose
  234. allocation dictates the allocation of this resource (e.g. interrupt
  235. vector allocations can depend on interrupt line allocations).
  236. Data - Stores a pointer to the additional data for this allocation. This
  237. data is only required for some resource types (like GPIO).
  238. DataSize - Stores the size of the additional data in bytes.
  239. Provider - Stores an optional pointer to the device providing the resource.
  240. If NULL, then the provider will be automatically determined by walking
  241. up the device's parents.
  242. --*/
  243. typedef struct _RESOURCE_ALLOCATION RESOURCE_ALLOCATION, *PRESOURCE_ALLOCATION;
  244. struct _RESOURCE_ALLOCATION {
  245. LIST_ENTRY ListEntry;
  246. RESOURCE_TYPE Type;
  247. ULONGLONG Allocation;
  248. ULONGLONG Length;
  249. ULONGLONG Characteristics;
  250. ULONGLONG Flags;
  251. PRESOURCE_ALLOCATION OwningAllocation;
  252. PVOID Data;
  253. UINTN DataSize;
  254. PDEVICE Provider;
  255. };
  256. /*++
  257. Structure Description:
  258. This structure defines a list of resources allocated to a particular device.
  259. The order of resources in this list will match the order of resource
  260. requirements in the resource requirements list.
  261. Members:
  262. AllocationListHead - Stores the head of the list of allocated resources for
  263. the device. The type of entries on this list is RESOURCE_ALLOCATION.
  264. --*/
  265. typedef struct _RESOURCE_ALLOCATION_LIST {
  266. LIST_ENTRY AllocationListHead;
  267. } RESOURCE_ALLOCATION_LIST, *PRESOURCE_ALLOCATION_LIST;
  268. /*++
  269. Structure Description:
  270. This structure defines the contents of the additional data stored along
  271. with a DMA resource.
  272. Members:
  273. Version - Stores the constant RESOURCE_DMA_DATA_VERSION.
  274. Request - Stores the request line number associated with the allocation,
  275. for controllers whose channels and request lines are mappable. The
  276. channel number is stored in the allocation portion.
  277. Width - Stores the transfer width in bits that the device connected to this
  278. request line supports.
  279. --*/
  280. typedef struct _RESOURCE_DMA_DATA {
  281. ULONG Version;
  282. ULONG Request;
  283. ULONG Width;
  284. } RESOURCE_DMA_DATA, *PRESOURCE_DMA_DATA;
  285. /*++
  286. Structure Description:
  287. This structure defines the contents of the additional data stored along
  288. with a GPIO resource.
  289. Members:
  290. Version - Stores the constant RESOURCE_GPIO_DATA_VERSION.
  291. OutputDriveStrength - Stores the output drive strength for the GPIO
  292. resource in units of microamperes.
  293. DebounceTimeout - Stores the debounce timeout value for the GPIO resource
  294. in units of microseconds.
  295. Flags - Stores the GPIO pin configuration and characteristics. See
  296. RESOURCE_GPIO_* definitions.
  297. VendorDataOffset - Stores the offset from the beginning of this structure
  298. where the vendor data resides.
  299. VendorDataSize - Stores the size of the vendor data for this resource.
  300. --*/
  301. typedef struct _RESOURCE_GPIO_DATA {
  302. ULONG Version;
  303. ULONG OutputDriveStrength;
  304. ULONG DebounceTimeout;
  305. ULONG Flags;
  306. UINTN VendorDataOffset;
  307. UINTN VendorDataSize;
  308. } RESOURCE_GPIO_DATA, *PRESOURCE_GPIO_DATA;
  309. /*++
  310. Structure Description:
  311. This structure defines the contents of the additional data stored along
  312. with a Simple Peripheral Bus resource, or at least the common header of it.
  313. Members:
  314. Version - Stores the constant RESOURCE_SPB_DATA_VERSION.
  315. Size - Stores the total size of the resource data, including this
  316. structure, the parent structure, and the vendor data.
  317. BusType - Stores the bus type for this resource, which determines the
  318. format of the data at the end of this structure.
  319. Flags - Stores generic flags for the bus data. See RESOURCE_SPB_DATA_*
  320. definitions.
  321. VendorDataOffset - Stores the offset from the beginning of this structure
  322. where the vendor data resides.
  323. VendorDataSize - Stores the size of the vendor data for this resource.
  324. --*/
  325. typedef struct _RESOURCE_SPB_DATA {
  326. ULONG Version;
  327. UINTN Size;
  328. RESOURCE_SPB_BUS_TYPE BusType;
  329. ULONG Flags;
  330. UINTN VendorDataOffset;
  331. UINTN VendorDataSize;
  332. } RESOURCE_SPB_DATA, *PRESOURCE_SPB_DATA;
  333. /*++
  334. Structure Description:
  335. This structure defines the contents of the i2C resource data.
  336. Members:
  337. Header - Stores the common header.
  338. Flags - Stores a bitfield of flags. See RESOURCE_SPB_I2C_* definitions.
  339. Speed - Stores the maximum speed of the bus connection in Hertz.
  340. SlaveAddress - Stores the slave address of the device on the i2C bus.
  341. --*/
  342. typedef struct _RESOURCE_SPB_I2C {
  343. RESOURCE_SPB_DATA Header;
  344. ULONG Flags;
  345. ULONG Speed;
  346. USHORT SlaveAddress;
  347. } RESOURCE_SPB_I2C, *PRESOURCE_SPB_I2C;
  348. /*++
  349. Structure Description:
  350. This structure defines the contents of the i2C resource data.
  351. Members:
  352. Header - Stores the common header.
  353. Flags - Stores a bitfield of flags. See RESOURCE_SPB_SPI_* definitions.
  354. Speed - Stores the maximum speed of the bus connection in Hertz.
  355. WordSize - Stores the size of a word in bits on the bus. When dealing with
  356. actual data buffers, this size is rounded up to the nearest power of 2.
  357. DeviceSelect - Stores the device select bitmask needed to address this
  358. device specifically on the SPI bus.
  359. --*/
  360. typedef struct _RESOURCE_SPB_SPI {
  361. RESOURCE_SPB_DATA Header;
  362. ULONG Flags;
  363. ULONG Speed;
  364. ULONG WordSize;
  365. ULONG DeviceSelect;
  366. } RESOURCE_SPB_SPI, *PRESOURCE_SPB_SPI;
  367. /*++
  368. Structure Description:
  369. This structure defines the contents of the UART resource data.
  370. Members:
  371. Header - Stores the common header.
  372. DataBits - Stores the number of bits per byte. Valid values are usually
  373. five through nine.
  374. Flags - Stores a bitfield of flags. See RESOURCE_SPB_UART_* definitions.
  375. BaudRate - Stores the default baud rate of the connection.
  376. RxFifoSize - Stores the maximum size of a receive buffer, in bytes.
  377. TxFifoSize - Stoers the maximum size of a transmit buffer, in bytes.
  378. ControlLines - Stores the control lines to enable. See
  379. RESOURCE_SPB_UART_CONTROL_* definitions.
  380. --*/
  381. typedef struct _RESOURCE_SPB_UART {
  382. RESOURCE_SPB_DATA Header;
  383. ULONG DataBits;
  384. ULONG Flags;
  385. ULONG BaudRate;
  386. USHORT RxFifoSize;
  387. USHORT TxFifoSize;
  388. USHORT ControlLines;
  389. } RESOURCE_SPB_UART, *PRESOURCE_SPB_UART;
  390. //
  391. // -------------------------------------------------------------------- Globals
  392. //
  393. //
  394. // -------------------------------------------------------- Function Prototypes
  395. //
  396. //
  397. // Resource requirement list support routines.
  398. //
  399. KERNEL_API
  400. PRESOURCE_REQUIREMENT_LIST
  401. IoCreateResourceRequirementList (
  402. VOID
  403. );
  404. /*++
  405. Routine Description:
  406. This routine creates a new empty resource requirement list.
  407. Arguments:
  408. None.
  409. Return Value:
  410. Returns a pointer to the new resource requirement list on success.
  411. NULL on allocation failure.
  412. --*/
  413. KERNEL_API
  414. VOID
  415. IoDestroyResourceRequirementList (
  416. PRESOURCE_REQUIREMENT_LIST ResourceRequirementList
  417. );
  418. /*++
  419. Routine Description:
  420. This routine releases the memory associated with a resource requirement
  421. list, and any items on that list.
  422. Arguments:
  423. ResourceRequirementList - Supplies a pointer to the resource requirement
  424. list to destroy.
  425. Return Value:
  426. None.
  427. --*/
  428. KERNEL_API
  429. KSTATUS
  430. IoCreateAndAddResourceRequirement (
  431. PRESOURCE_REQUIREMENT Requirement,
  432. PRESOURCE_REQUIREMENT_LIST ResourceRequirementList,
  433. PRESOURCE_REQUIREMENT *NewRequirement
  434. );
  435. /*++
  436. Routine Description:
  437. This routine creates a new resource requirement from the given template and
  438. inserts it into the given resource requirement list.
  439. Arguments:
  440. Requirement - Supplies a pointer to the resource requirement to use as a
  441. template. The memory passed in will not actually be used, a copy of the
  442. requirement will be created, initialized, and placed on the list.
  443. ResourceRequirementList - Supplies a pointer to the resource requirement
  444. list to add the requirement to.
  445. NewRequirement - Supplies an optional pointer to the resource requirement
  446. that was created. The system owns this memory, the caller should not
  447. attempt to free it directly.
  448. Return Value:
  449. STATUS_SUCCESS on success.
  450. STATUS_INVALID_PARAMETER if parameter validation failed.
  451. STATUS_INSUFFICIENT_RESOURCES if the required memory could not be allocated.
  452. --*/
  453. KERNEL_API
  454. VOID
  455. IoRemoveResourceRequirement (
  456. PRESOURCE_REQUIREMENT Requirement
  457. );
  458. /*++
  459. Routine Description:
  460. This routine removes the given resource descriptor from its resource list
  461. and frees the memory associated with that descriptor.
  462. Arguments:
  463. Requirement - Supplies a pointer to the resource requirement to remove and
  464. destroy.
  465. Return Value:
  466. None.
  467. --*/
  468. KERNEL_API
  469. KSTATUS
  470. IoCreateAndAddResourceRequirementAlternative (
  471. PRESOURCE_REQUIREMENT Alternative,
  472. PRESOURCE_REQUIREMENT Requirement
  473. );
  474. /*++
  475. Routine Description:
  476. This routine creates a new resource requirement alternative from the given
  477. template and inserts it into the given resource requirement alternative
  478. list.
  479. Arguments:
  480. Alternative - Supplies a pointer to the resource requirement to use as a
  481. template. The memory passed in will not actually be used, a copy of the
  482. requirement will be created, initialized, and placed on the list.
  483. Requirement - Supplies a pointer to the resource requirement to add the
  484. alternative to.
  485. Return Value:
  486. STATUS_SUCCESS on success.
  487. STATUS_INVALID_PARAMETER if parameter validation failed.
  488. STATUS_INSUFFICIENT_RESOURCES if the required memory could not be allocated.
  489. --*/
  490. KERNEL_API
  491. VOID
  492. IoRemoveResourceRequirementAlternative (
  493. PRESOURCE_REQUIREMENT Alternative
  494. );
  495. /*++
  496. Routine Description:
  497. This routine removes the given resource requirement alternative from its
  498. resource list and frees the memory associated with that descriptor.
  499. Arguments:
  500. Alternative - Supplies a pointer to the resource requirement alternative
  501. to remove and destroy.
  502. Return Value:
  503. None.
  504. --*/
  505. KERNEL_API
  506. KSTATUS
  507. IoCreateAndAddInterruptVectorsForLines (
  508. PRESOURCE_CONFIGURATION_LIST ConfigurationList,
  509. PRESOURCE_REQUIREMENT VectorTemplate
  510. );
  511. /*++
  512. Routine Description:
  513. This routine creates a new vector resource requirement for each interrupt
  514. line requirement in the given configuration list.
  515. Arguments:
  516. ConfigurationList - Supplies a pointer to the resource configuration list
  517. to iterate through.
  518. VectorTemplate - Supplies a pointer to a template to use when creating the
  519. vector resource requirements.
  520. Return Value:
  521. STATUS_SUCCESS on success.
  522. STATUS_INVALID_PARAMETER if parameter validation failed.
  523. STATUS_INSUFFICIENT_RESOURCES if the required memory could not be allocated.
  524. --*/
  525. KERNEL_API
  526. PRESOURCE_REQUIREMENT
  527. IoGetNextResourceRequirement (
  528. PRESOURCE_REQUIREMENT_LIST ResourceRequirementList,
  529. PRESOURCE_REQUIREMENT CurrentEntry
  530. );
  531. /*++
  532. Routine Description:
  533. This routine returns a pointer to the next resource requirment in the
  534. resource requirement list.
  535. Arguments:
  536. ResourceRequirementList - Supplies a pointer to the resource requirement
  537. list to iterate through.
  538. CurrentEntry - Supplies an optional pointer to the previous resource
  539. requirement. If supplied, the function will return the resource
  540. requirement immediately after this one in the list. If NULL is
  541. supplied, this routine will return the first resource requirement in the
  542. list.
  543. Return Value:
  544. Returns a pointer to the next resource requirement in the given list on
  545. success, or NULL if the last resource requirement was reached.
  546. --*/
  547. KERNEL_API
  548. PRESOURCE_REQUIREMENT
  549. IoGetNextResourceRequirementAlternative (
  550. PRESOURCE_REQUIREMENT ResourceRequirement,
  551. PRESOURCE_REQUIREMENT CurrentEntry
  552. );
  553. /*++
  554. Routine Description:
  555. This routine returns a pointer to the next resource requirment alternative
  556. in the alternative list for the requirement.
  557. Arguments:
  558. ResourceRequirement - Supplies a pointer to the resource requirement at
  559. the head of the list.
  560. CurrentEntry - Supplies an optional pointer to the current requirement
  561. alternative.
  562. Return Value:
  563. Returns a pointer to the next resource requirement alternative in the list
  564. on success, or NULL if the last resource requirement alternative was
  565. reached.
  566. --*/
  567. //
  568. // Resource configuration list routines.
  569. //
  570. KERNEL_API
  571. PRESOURCE_CONFIGURATION_LIST
  572. IoCreateResourceConfigurationList (
  573. PRESOURCE_REQUIREMENT_LIST FirstConfiguration
  574. );
  575. /*++
  576. Routine Description:
  577. This routine creates a new resource configuration list. A resource
  578. configuration list is a collection of resource requirement lists, arranged
  579. from most desirable to least desirable. The system attempts selects the
  580. most desirable resource configuration that can be afforded.
  581. Arguments:
  582. FirstConfiguration - Supplies an optional pointer to the first configuration
  583. to put on the list. If NULL is supplied, an empty resource
  584. configuration list will be created.
  585. Return Value:
  586. Returns a pointer to the new resource configuration list on success.
  587. NULL on allocation failure.
  588. --*/
  589. KERNEL_API
  590. VOID
  591. IoDestroyResourceConfigurationList (
  592. PRESOURCE_CONFIGURATION_LIST ResourceConfigurationList
  593. );
  594. /*++
  595. Routine Description:
  596. This routine releases the memory associated with a resource configuration
  597. list, and any resource requirement lists it may contain.
  598. Arguments:
  599. ResourceConfigurationList - Supplies a pointer to the resource configuration
  600. list to destroy.
  601. Return Value:
  602. None.
  603. --*/
  604. KERNEL_API
  605. KSTATUS
  606. IoAddResourceConfiguration (
  607. PRESOURCE_REQUIREMENT_LIST Configuration,
  608. PRESOURCE_REQUIREMENT_LIST ConfigurationToInsertAfter,
  609. PRESOURCE_CONFIGURATION_LIST ConfigurationList
  610. );
  611. /*++
  612. Routine Description:
  613. This routine inserts an initialized resource configuration into a
  614. configuration list.
  615. Arguments:
  616. Configuration - Supplies a pointer to the resource configuration to insert
  617. into the list.
  618. ConfigurationToInsertAfter - Supplies an optional pointer indicating the
  619. location in the list to insert the configuration. If this pointer is
  620. supplied, the configuration will be inserted immediate after this
  621. parameter in the list. If NULL is supplied, the configuration will be
  622. added to the end of the list.
  623. ConfigurationList - Supplies a pointer to the list to add the configuration
  624. to.
  625. Return Value:
  626. Status code.
  627. --*/
  628. KERNEL_API
  629. VOID
  630. IoRemoveResourceConfiguration (
  631. PRESOURCE_REQUIREMENT_LIST Configuration,
  632. PRESOURCE_CONFIGURATION_LIST ConfigurationList
  633. );
  634. /*++
  635. Routine Description:
  636. This routine removes the given resource descriptor from its resource list.
  637. It does not free the memory associated with the configuration.
  638. Arguments:
  639. Configuration - Supplies a pointer to the configuration to remove.
  640. ConfigurationList - Supplies a pointer to the configuration list to remove
  641. the configuration from.
  642. Return Value:
  643. None.
  644. --*/
  645. KERNEL_API
  646. PRESOURCE_REQUIREMENT_LIST
  647. IoGetNextResourceConfiguration (
  648. PRESOURCE_CONFIGURATION_LIST ConfigurationList,
  649. PRESOURCE_REQUIREMENT_LIST CurrentEntry
  650. );
  651. /*++
  652. Routine Description:
  653. This routine returns a pointer to the next resource configuration in the
  654. resource configuration list.
  655. Arguments:
  656. ConfigurationList - Supplies a pointer to the resource configuration list
  657. to iterate through.
  658. CurrentEntry - Supplies an optional pointer to the previous resource
  659. requirement list. If supplied, the function will return the
  660. configuration immediately after this one in the list. If NULL is
  661. supplied, this routine will return the first configuration in the
  662. list.
  663. Return Value:
  664. Returns a pointer to the next resource configuration in the given list on
  665. success, or NULL if the last resource requirement was reached.
  666. --*/
  667. //
  668. // Resource allocation list support routines.
  669. //
  670. KERNEL_API
  671. PRESOURCE_ALLOCATION_LIST
  672. IoCreateResourceAllocationList (
  673. VOID
  674. );
  675. /*++
  676. Routine Description:
  677. This routine creates a new empty resource allocation list.
  678. Arguments:
  679. None.
  680. Return Value:
  681. Returns a pointer to the new resource allocation list on success.
  682. NULL on allocation failure.
  683. --*/
  684. KERNEL_API
  685. VOID
  686. IoDestroyResourceAllocationList (
  687. PRESOURCE_ALLOCATION_LIST ResourceAllocationList
  688. );
  689. /*++
  690. Routine Description:
  691. This routine releases the memory associated with a resource allocation
  692. list, and any items on that list.
  693. Arguments:
  694. ResourceAllocationList - Supplies a pointer to the resource allocation
  695. list to destroy.
  696. Return Value:
  697. None.
  698. --*/
  699. KERNEL_API
  700. KSTATUS
  701. IoCreateAndAddResourceAllocation (
  702. PRESOURCE_ALLOCATION Allocation,
  703. PRESOURCE_ALLOCATION_LIST ResourceAllocationList
  704. );
  705. /*++
  706. Routine Description:
  707. This routine creates a new resource allocation from the given template and
  708. inserts it into the given resource allocation list.
  709. Arguments:
  710. Allocation - Supplies a pointer to the resource allocation to use as a
  711. template. The memory passed in will not actually be used, a copy of the
  712. allocation will be created, initialized, and placed on the list.
  713. ResourceAllocationList - Supplies a pointer to the resource allocation
  714. list to add the allocation to.
  715. Return Value:
  716. STATUS_SUCCESS on success.
  717. STATUS_INVALID_PARAMETER if parameter validation failed.
  718. STATUS_INSUFFICIENT_RESOURCES if the required memory could not be allocated.
  719. --*/
  720. KERNEL_API
  721. VOID
  722. IoRemoveResourceAllocation (
  723. PRESOURCE_ALLOCATION Allocation,
  724. PRESOURCE_ALLOCATION_LIST ResourceAllocationList
  725. );
  726. /*++
  727. Routine Description:
  728. This routine removes the given resource descriptor from its resource list
  729. and frees the memory associated with that descriptor.
  730. Arguments:
  731. Allocation - Supplies a pointer to the allocation to remove.
  732. ResourceAllocationList - Supplies a pointer to the list to remove the
  733. allocation from.
  734. Return Value:
  735. None.
  736. --*/
  737. KERNEL_API
  738. PRESOURCE_ALLOCATION
  739. IoGetNextResourceAllocation (
  740. PRESOURCE_ALLOCATION_LIST ResourceAllocationList,
  741. PRESOURCE_ALLOCATION CurrentEntry
  742. );
  743. /*++
  744. Routine Description:
  745. This routine returns a pointer to the next resource allocation in the
  746. resource allocation list.
  747. Arguments:
  748. ResourceAllocationList - Supplies a pointer to the resource allocation
  749. list to iterate through.
  750. CurrentEntry - Supplies an optional pointer to the previous resource
  751. allocation. If supplied, the function will return the resource
  752. allocation immediately after this one in the list. If NULL is
  753. supplied, this routine will return the first resource allocation in the
  754. list.
  755. Return Value:
  756. Returns a pointer to the next resource allocation in the given list on
  757. success, or NULL if the last resource allocation was reached.
  758. --*/
  759. KERNEL_API
  760. VOID
  761. IoDebugPrintResourceConfigurationList (
  762. PRESOURCE_CONFIGURATION_LIST ConfigurationList
  763. );
  764. /*++
  765. Routine Description:
  766. This routine prints a resource configuration list out to the debugger.
  767. Arguments:
  768. ConfigurationList - Supplies a pointer to the resource configuration list to
  769. print.
  770. Return Value:
  771. None.
  772. --*/
  773. KERNEL_API
  774. VOID
  775. IoDebugPrintResourceRequirementList (
  776. ULONG IndentationLevel,
  777. PRESOURCE_REQUIREMENT_LIST RequirementList
  778. );
  779. /*++
  780. Routine Description:
  781. This routine prints a resource requirement list out to the debugger.
  782. Arguments:
  783. IndentationLevel - Supplies the indentation level to print this list
  784. at. Supply 0 if this function is called directly.
  785. RequirementList - Supplies a pointer to the resource requirement list to
  786. print.
  787. Return Value:
  788. None.
  789. --*/
  790. KERNEL_API
  791. VOID
  792. IoDebugPrintResourceRequirement (
  793. ULONG IndentationLevel,
  794. PRESOURCE_REQUIREMENT Requirement
  795. );
  796. /*++
  797. Routine Description:
  798. This routine prints a resource requirement out to the debugger.
  799. Arguments:
  800. IndentationLevel - Supplies the indentation level to print this requirement
  801. at. Supply 0 if this function is called directly.
  802. Requirement - Supplies a pointer to the resource requirement to print.
  803. Return Value:
  804. None.
  805. --*/
  806. KERNEL_API
  807. VOID
  808. IoDebugPrintResourceAllocationList (
  809. ULONG IndentationLevel,
  810. PRESOURCE_ALLOCATION_LIST AllocationList
  811. );
  812. /*++
  813. Routine Description:
  814. This routine prints a resource allocation list out to the debugger.
  815. Arguments:
  816. IndentationLevel - Supplies the indentation level to print this list
  817. at. Supply 0 if this function is called directly.
  818. AllocationList - Supplies a pointer to the resource allocation list to
  819. print.
  820. Return Value:
  821. None.
  822. --*/
  823. KERNEL_API
  824. VOID
  825. IoDebugPrintResourceAllocation (
  826. ULONG IndentationLevel,
  827. PRESOURCE_ALLOCATION Allocation
  828. );
  829. /*++
  830. Routine Description:
  831. This routine prints a resource allocation out to the debugger.
  832. Arguments:
  833. IndentationLevel - Supplies the indentation level to print this allocation
  834. at. Supply 0 if this function is called directly.
  835. Allocation - Supplies a pointer to the resource allocation to print.
  836. Return Value:
  837. None.
  838. --*/