1
0

devres.h 30 KB

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