1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258 |
- /*++
- Copyright (c) 2012 Minoca Corp.
- This file is licensed under the terms of the GNU General Public License
- version 3. Alternative licensing terms are available. Contact
- info@minocacorp.com for details. See the LICENSE file at the root of this
- project for complete licensing information.
- Module Name:
- devres.h
- Abstract:
- This header contains definitions for I/O resources.
- Author:
- Evan Green 2-Dec-2012
- --*/
- //
- // ------------------------------------------------------------------- Includes
- //
- //
- // ---------------------------------------------------------------- Definitions
- //
- //
- // Define resource requirement and allocation flags.
- //
- //
- // Set this bit if the allocation cannot be shared with any other device.
- //
- #define RESOURCE_FLAG_NOT_SHAREABLE 0x00000001
- //
- // This bit is set by the arbiter in resource allocations if the allocation was
- // a boot allocation. It is ignored if passed in a requirement.
- //
- #define RESOURCE_FLAG_BOOT 0x00000002
- //
- // Define interrupt line characteristics.
- //
- #define INTERRUPT_LINE_EDGE_TRIGGERED 0x00000001
- #define INTERRUPT_LINE_ACTIVE_LOW 0x00000002
- #define INTERRUPT_LINE_ACTIVE_HIGH 0x00000004
- #define INTERRUPT_LINE_WAKE 0x00000008
- #define INTERRUPT_LINE_DEBOUNCE 0x00000010
- #define INTERRUPT_LINE_SECONDARY 0x00000020
- //
- // Define interrupt vector characteristics.
- //
- #define INTERRUPT_VECTOR_EDGE_TRIGGERED 0x00000001
- #define INTERRUPT_VECTOR_ACTIVE_LOW 0x00000002
- #define INTERRUPT_VECTOR_ACTIVE_HIGH 0x00000004
- //
- // Define DMA characteristics.
- //
- #define DMA_TYPE_ISA 0x00000001
- #define DMA_TYPE_EISA_A 0x00000002
- #define DMA_TYPE_EISA_B 0x00000004
- #define DMA_TYPE_EISA_F 0x00000008
- #define DMA_BUS_MASTER 0x00000010
- #define DMA_TRANSFER_SIZE_8 0x00000020
- #define DMA_TRANSFER_SIZE_16 0x00000040
- #define DMA_TRANSFER_SIZE_32 0x00000080
- #define DMA_TRANSFER_SIZE_64 0x00000100
- #define DMA_TRANSFER_SIZE_128 0x00000200
- #define DMA_TRANSFER_SIZE_256 0x00000400
- #define DMA_TRANSFER_SIZE_CUSTOM 0x00010000
- #define RESOURCE_DMA_DATA_VERSION 1
- //
- // Define memory characteristics.
- //
- #define MEMORY_CHARACTERISTIC_PREFETCHABLE 0x00000100
- //
- // Define GPIO characteristics.
- //
- #define RESOURCE_GPIO_INTERRUPT 0x00000001
- #define RESOURCE_GPIO_INPUT 0x00000002
- #define RESOURCE_GPIO_OUTPUT 0x00000004
- #define RESOURCE_GPIO_WAKE 0x00000008
- #define RESOURCE_GPIO_ACTIVE_HIGH 0x00000010
- #define RESOURCE_GPIO_ACTIVE_LOW 0x00000020
- #define RESOURCE_GPIO_EDGE_TRIGGERED 0x00000040
- #define RESOURCE_GPIO_PULL_UP 0x00000080
- #define RESOURCE_GPIO_PULL_DOWN 0x00000100
- #define RESOURCE_GPIO_PULL_NONE \
- (RESOURCE_GPIO_PULL_UP | RESOURCE_GPIO_PULL_DOWN)
- #define RESOURCE_GPIO_DATA_VERSION 1
- #define RESOURCE_GPIO_DEFAULT_DRIVE_STRENGTH ((ULONG)-1)
- #define RESOURCE_GPIO_DEFAULT_DEBOUNCE_TIMEOUT ((ULONG)-1)
- //
- // Defie Simple Peripheral Bus characteristics.
- //
- #define RESOURCE_SPB_DATA_VERSION 1
- #define RESOURCE_SPB_DATA_SLAVE 0x00000001
- #define RESOURCE_SPB_I2C_10_BIT_ADDRESSING 0x00000001
- #define RESOURCE_SPB_SPI_DEVICE_SELECT_ACTIVE_HIGH 0x00000001
- #define RESOURCE_SPB_SPI_3_WIRES 0x00000002
- //
- // The CPHA bit determines whether to sample data on the first phase of the
- // clock or the second phase of the clock.
- //
- #define RESOURCE_SPB_SPI_SECOND_PHASE 0x00000004
- //
- // The CPOL bit determines whether the clock is low or high during the first
- // phase.
- //
- #define RESOURCE_SPB_SPI_START_HIGH 0x00000008
- #define RESOURCE_SPB_UART_STOP_BITS_NONE (0x0 << 0)
- #define RESOURCE_SPB_UART_STOP_BITS_1 (0x1 << 0)
- #define RESOURCE_SPB_UART_STOP_BITS_1_5 (0x2 << 0)
- #define RESOURCE_SPB_UART_STOP_BITS_2 (0x3 << 0)
- #define RESOURCE_SPB_UART_STOP_BITS_MASK (0x3 << 0)
- #define RESOURCE_SPB_UART_FLOW_CONTROL_HARDWARE 0x00000004
- #define RESOURCE_SPB_UART_FLOW_CONTROL_SOFTWARE 0x00000008
- #define RESOURCE_SPB_UART_PARITY_MASK (0xF << 4)
- #define RESOURCE_SPB_UART_PARITY_NONE (0xF << 4)
- #define RESOURCE_SPB_UART_PARITY_EVEN (0xF << 4)
- #define RESOURCE_SPB_UART_PARITY_ODD (0xF << 4)
- #define RESOURCE_SPB_UART_PARITY_MARK (0xF << 4)
- #define RESOURCE_SPB_UART_PARITY_SPACE (0xF << 4)
- #define RESOURCE_SPB_UART_BIG_ENDIAN 0x00000100
- #define RESOURCE_SPB_UART_CONTROL_DTD (1 << 2)
- #define RESOURCE_SPB_UART_CONTROL_RI (1 << 3)
- #define RESOURCE_SPB_UART_CONTROL_DSR (1 << 4)
- #define RESOURCE_SPB_UART_CONTROL_DTR (1 << 5)
- #define RESOURCE_SPB_UART_CONTROL_CTS (1 << 6)
- #define RESOURCE_SPB_UART_CONTROL_RTS (1 << 7)
- //
- // ------------------------------------------------------ Data Type Definitions
- //
- typedef struct _DEVICE DEVICE, *PDEVICE;
- typedef enum _RESOURCE_TYPE {
- ResourceTypeInvalid,
- ResourceTypePhysicalAddressSpace,
- ResourceTypeIoPort,
- ResourceTypeInterruptLine,
- ResourceTypeInterruptVector,
- ResourceTypeBusNumber,
- ResourceTypeDmaChannel,
- ResourceTypeVendorSpecific,
- ResourceTypeGpio,
- ResourceTypeSimpleBus,
- ResourceTypeCount,
- } RESOURCE_TYPE, *PRESOURCE_TYPE;
- typedef enum _RESOURCE_SPB_BUS_TYPE {
- ResourceSpbBusInvalid,
- ResourceSpbBusI2c,
- ResourceSpbBusSpi,
- ResourceSpbBusUart,
- ResourceSpbBusTypeCount
- } RESOURCE_SPB_BUS_TYPE, *PRESOURCE_SPB_BUS_TYPE;
- /*++
- Structure Description:
- This structure defines a device resource requirement.
- Members:
- ListEntry - Stores pointers to the next and previous resource requirements
- in the resource requirement list.
- AlternativeListEntry - Stores pointers to the next and previous alternative
- entries that would equivalently satisfy this requirement.
- Type - Stores the type of resource being described.
- Minimum - Stores the minimum address of the range that can satisfy the
- requirement.
- Maximum - Stores the maximum address (exclusive) of the range that can
- satisfy the requirement. In other words, the first address outside the
- range.
- Alignment - Stores the byte alignment requirement of the beginning of the
- range.
- Length - Stores the minimum required length of the resource.
- Characteristics - Stores a bitfield of characteristics of the resource
- requirement. These are characteristics of the resource and must match.
- Flags - Store a bitfield of flags regarding the resource requirement. These
- bits represent properties that are not necessarily reflected in the
- final selected resource.
- OwningRequirement - Stores a pointer to an owning resource requirement
- whose allocation influences the allocation of this requirement (e.g.
- interrupt vector allocations can depend on interrupt line allocations).
- Data - Stores a pointer to the additional data for this requirement. This
- data is only required for some resource types (like GPIO).
- DataSize - Stores the size of the additional data in bytes.
- Provider - Stores an optional pointer to the device that provides the
- resource. If NULL, then the provider will be automatically determined
- by walking up the device's parents.
- --*/
- typedef struct _RESOURCE_REQUIREMENT RESOURCE_REQUIREMENT;
- typedef struct _RESOURCE_REQUIREMENT *PRESOURCE_REQUIREMENT;
- struct _RESOURCE_REQUIREMENT {
- LIST_ENTRY ListEntry;
- LIST_ENTRY AlternativeListEntry;
- RESOURCE_TYPE Type;
- ULONGLONG Minimum;
- ULONGLONG Maximum;
- ULONGLONG Alignment;
- ULONGLONG Length;
- ULONGLONG Characteristics;
- ULONGLONG Flags;
- PRESOURCE_REQUIREMENT OwningRequirement;
- PVOID Data;
- UINTN DataSize;
- PDEVICE Provider;
- };
- /*++
- Structure Description:
- This structure defines a list of resource requirements that collectively
- represent a viable configuration for a device.
- Members:
- ListEntry - Stores pointers to the next and previous resource requirement
- lists in the set.
- RequirementListHead - Stores the head of the list of resource requirements.
- The type of each entry on the list is a RESOURCE_REQUIREMENT.
- --*/
- typedef struct _RESOURCE_REQUIREMENT_LIST {
- LIST_ENTRY ListEntry;
- LIST_ENTRY RequirementListHead;
- } RESOURCE_REQUIREMENT_LIST, *PRESOURCE_REQUIREMENT_LIST;
- /*++
- Structure Description:
- This structure defines a list of resource requirements that collectively
- represent a viable configuration for a device.
- Members:
- RequirementListListHead - Stores the list head of possible resource
- configurations, ordered by preference (ListHead.Next representing the
- most desirable configuration).
- --*/
- typedef struct _RESOURCE_CONFIGURATION_LIST {
- LIST_ENTRY RequirementListListHead;
- } RESOURCE_CONFIGURATION_LIST, *PRESOURCE_CONFIGURATION_LIST;
- /*++
- Structure Description:
- This structure defines a resource allocation.
- Members:
- ListEntry - Stores pointers to the next and previous resource allocations
- in the resource allocation list.
- Type - Stores the type of resource being described.
- Allocation - Stores the base value of the allocation, which can be a
- base physical address, I/O port, interrupt pin, etc.
- Length - Stores the length of the resource allocation.
- Characteristics - Stores a bitfield of characteristics of the resource.
- Flags - Store a bitfield of flags regarding the resource.
- OwningAllocation - Stores a pointer to an owning resource allocation whose
- allocation dictates the allocation of this resource (e.g. interrupt
- vector allocations can depend on interrupt line allocations).
- Data - Stores a pointer to the additional data for this allocation. This
- data is only required for some resource types (like GPIO).
- DataSize - Stores the size of the additional data in bytes.
- Provider - Stores an optional pointer to the device providing the resource.
- If NULL, then the provider will be automatically determined by walking
- up the device's parents.
- --*/
- typedef struct _RESOURCE_ALLOCATION RESOURCE_ALLOCATION, *PRESOURCE_ALLOCATION;
- struct _RESOURCE_ALLOCATION {
- LIST_ENTRY ListEntry;
- RESOURCE_TYPE Type;
- ULONGLONG Allocation;
- ULONGLONG Length;
- ULONGLONG Characteristics;
- ULONGLONG Flags;
- PRESOURCE_ALLOCATION OwningAllocation;
- PVOID Data;
- UINTN DataSize;
- PDEVICE Provider;
- };
- /*++
- Structure Description:
- This structure defines a list of resources allocated to a particular device.
- The order of resources in this list will match the order of resource
- requirements in the resource requirements list.
- Members:
- AllocationListHead - Stores the head of the list of allocated resources for
- the device. The type of entries on this list is RESOURCE_ALLOCATION.
- --*/
- typedef struct _RESOURCE_ALLOCATION_LIST {
- LIST_ENTRY AllocationListHead;
- } RESOURCE_ALLOCATION_LIST, *PRESOURCE_ALLOCATION_LIST;
- /*++
- Structure Description:
- This structure defines the contents of the additional data stored along
- with a DMA resource.
- Members:
- Version - Stores the constant RESOURCE_DMA_DATA_VERSION.
- Request - Stores the request line number associated with the allocation,
- for controllers whose channels and request lines are mappable. The
- channel number is stored in the allocation portion.
- Width - Stores the transfer width in bits that the device connected to this
- request line supports.
- --*/
- typedef struct _RESOURCE_DMA_DATA {
- ULONG Version;
- ULONG Request;
- ULONG Width;
- } RESOURCE_DMA_DATA, *PRESOURCE_DMA_DATA;
- /*++
- Structure Description:
- This structure defines the contents of the additional data stored along
- with a GPIO resource.
- Members:
- Version - Stores the constant RESOURCE_GPIO_DATA_VERSION.
- OutputDriveStrength - Stores the output drive strength for the GPIO
- resource in units of microamperes.
- DebounceTimeout - Stores the debounce timeout value for the GPIO resource
- in units of microseconds.
- Flags - Stores the GPIO pin configuration and characteristics. See
- RESOURCE_GPIO_* definitions.
- VendorDataOffset - Stores the offset from the beginning of this structure
- where the vendor data resides.
- VendorDataSize - Stores the size of the vendor data for this resource.
- --*/
- typedef struct _RESOURCE_GPIO_DATA {
- ULONG Version;
- ULONG OutputDriveStrength;
- ULONG DebounceTimeout;
- ULONG Flags;
- UINTN VendorDataOffset;
- UINTN VendorDataSize;
- } RESOURCE_GPIO_DATA, *PRESOURCE_GPIO_DATA;
- /*++
- Structure Description:
- This structure defines the contents of the additional data stored along
- with a Simple Peripheral Bus resource, or at least the common header of it.
- Members:
- Version - Stores the constant RESOURCE_SPB_DATA_VERSION.
- Size - Stores the total size of the resource data, including this
- structure, the parent structure, and the vendor data.
- BusType - Stores the bus type for this resource, which determines the
- format of the data at the end of this structure.
- Flags - Stores generic flags for the bus data. See RESOURCE_SPB_DATA_*
- definitions.
- VendorDataOffset - Stores the offset from the beginning of this structure
- where the vendor data resides.
- VendorDataSize - Stores the size of the vendor data for this resource.
- --*/
- typedef struct _RESOURCE_SPB_DATA {
- ULONG Version;
- UINTN Size;
- RESOURCE_SPB_BUS_TYPE BusType;
- ULONG Flags;
- UINTN VendorDataOffset;
- UINTN VendorDataSize;
- } RESOURCE_SPB_DATA, *PRESOURCE_SPB_DATA;
- /*++
- Structure Description:
- This structure defines the contents of the i2C resource data.
- Members:
- Header - Stores the common header.
- Flags - Stores a bitfield of flags. See RESOURCE_SPB_I2C_* definitions.
- Speed - Stores the maximum speed of the bus connection in Hertz.
- SlaveAddress - Stores the slave address of the device on the i2C bus.
- --*/
- typedef struct _RESOURCE_SPB_I2C {
- RESOURCE_SPB_DATA Header;
- ULONG Flags;
- ULONG Speed;
- USHORT SlaveAddress;
- } RESOURCE_SPB_I2C, *PRESOURCE_SPB_I2C;
- /*++
- Structure Description:
- This structure defines the contents of the i2C resource data.
- Members:
- Header - Stores the common header.
- Flags - Stores a bitfield of flags. See RESOURCE_SPB_SPI_* definitions.
- Speed - Stores the maximum speed of the bus connection in Hertz.
- WordSize - Stores the size of a word in bits on the bus. When dealing with
- actual data buffers, this size is rounded up to the nearest power of 2.
- DeviceSelect - Stores the device select bitmask needed to address this
- device specifically on the SPI bus.
- --*/
- typedef struct _RESOURCE_SPB_SPI {
- RESOURCE_SPB_DATA Header;
- ULONG Flags;
- ULONG Speed;
- ULONG WordSize;
- ULONG DeviceSelect;
- } RESOURCE_SPB_SPI, *PRESOURCE_SPB_SPI;
- /*++
- Structure Description:
- This structure defines the contents of the UART resource data.
- Members:
- Header - Stores the common header.
- DataBits - Stores the number of bits per byte. Valid values are usually
- five through nine.
- Flags - Stores a bitfield of flags. See RESOURCE_SPB_UART_* definitions.
- BaudRate - Stores the default baud rate of the connection.
- RxFifoSize - Stores the maximum size of a receive buffer, in bytes.
- TxFifoSize - Stoers the maximum size of a transmit buffer, in bytes.
- ControlLines - Stores the control lines to enable. See
- RESOURCE_SPB_UART_CONTROL_* definitions.
- --*/
- typedef struct _RESOURCE_SPB_UART {
- RESOURCE_SPB_DATA Header;
- ULONG DataBits;
- ULONG Flags;
- ULONG BaudRate;
- USHORT RxFifoSize;
- USHORT TxFifoSize;
- USHORT ControlLines;
- } RESOURCE_SPB_UART, *PRESOURCE_SPB_UART;
- //
- // -------------------------------------------------------------------- Globals
- //
- //
- // -------------------------------------------------------- Function Prototypes
- //
- //
- // Resource requirement list support routines.
- //
- KERNEL_API
- PRESOURCE_REQUIREMENT_LIST
- IoCreateResourceRequirementList (
- VOID
- );
- /*++
- Routine Description:
- This routine creates a new empty resource requirement list.
- Arguments:
- None.
- Return Value:
- Returns a pointer to the new resource requirement list on success.
- NULL on allocation failure.
- --*/
- KERNEL_API
- VOID
- IoDestroyResourceRequirementList (
- PRESOURCE_REQUIREMENT_LIST ResourceRequirementList
- );
- /*++
- Routine Description:
- This routine releases the memory associated with a resource requirement
- list, and any items on that list.
- Arguments:
- ResourceRequirementList - Supplies a pointer to the resource requirement
- list to destroy.
- Return Value:
- None.
- --*/
- KERNEL_API
- KSTATUS
- IoCreateAndAddResourceRequirement (
- PRESOURCE_REQUIREMENT Requirement,
- PRESOURCE_REQUIREMENT_LIST ResourceRequirementList,
- PRESOURCE_REQUIREMENT *NewRequirement
- );
- /*++
- Routine Description:
- This routine creates a new resource requirement from the given template and
- inserts it into the given resource requirement list.
- Arguments:
- Requirement - Supplies a pointer to the resource requirement to use as a
- template. The memory passed in will not actually be used, a copy of the
- requirement will be created, initialized, and placed on the list.
- ResourceRequirementList - Supplies a pointer to the resource requirement
- list to add the requirement to.
- NewRequirement - Supplies an optional pointer to the resource requirement
- that was created. The system owns this memory, the caller should not
- attempt to free it directly.
- Return Value:
- STATUS_SUCCESS on success.
- STATUS_INVALID_PARAMETER if parameter validation failed.
- STATUS_INSUFFICIENT_RESOURCES if the required memory could not be allocated.
- --*/
- KERNEL_API
- VOID
- IoRemoveResourceRequirement (
- PRESOURCE_REQUIREMENT Requirement
- );
- /*++
- Routine Description:
- This routine removes the given resource descriptor from its resource list
- and frees the memory associated with that descriptor.
- Arguments:
- Requirement - Supplies a pointer to the resource requirement to remove and
- destroy.
- Return Value:
- None.
- --*/
- KERNEL_API
- KSTATUS
- IoCreateAndAddResourceRequirementAlternative (
- PRESOURCE_REQUIREMENT Alternative,
- PRESOURCE_REQUIREMENT Requirement
- );
- /*++
- Routine Description:
- This routine creates a new resource requirement alternative from the given
- template and inserts it into the given resource requirement alternative
- list.
- Arguments:
- Alternative - Supplies a pointer to the resource requirement to use as a
- template. The memory passed in will not actually be used, a copy of the
- requirement will be created, initialized, and placed on the list.
- Requirement - Supplies a pointer to the resource requirement to add the
- alternative to.
- Return Value:
- STATUS_SUCCESS on success.
- STATUS_INVALID_PARAMETER if parameter validation failed.
- STATUS_INSUFFICIENT_RESOURCES if the required memory could not be allocated.
- --*/
- KERNEL_API
- VOID
- IoRemoveResourceRequirementAlternative (
- PRESOURCE_REQUIREMENT Alternative
- );
- /*++
- Routine Description:
- This routine removes the given resource requirement alternative from its
- resource list and frees the memory associated with that descriptor.
- Arguments:
- Alternative - Supplies a pointer to the resource requirement alternative
- to remove and destroy.
- Return Value:
- None.
- --*/
- KERNEL_API
- KSTATUS
- IoCreateAndAddInterruptVectorsForLines (
- PRESOURCE_CONFIGURATION_LIST ConfigurationList,
- PRESOURCE_REQUIREMENT VectorTemplate
- );
- /*++
- Routine Description:
- This routine creates a new vector resource requirement for each interrupt
- line requirement in the given configuration list.
- Arguments:
- ConfigurationList - Supplies a pointer to the resource configuration list
- to iterate through.
- VectorTemplate - Supplies a pointer to a template to use when creating the
- vector resource requirements.
- Return Value:
- STATUS_SUCCESS on success.
- STATUS_INVALID_PARAMETER if parameter validation failed.
- STATUS_INSUFFICIENT_RESOURCES if the required memory could not be allocated.
- --*/
- KERNEL_API
- PRESOURCE_REQUIREMENT
- IoGetNextResourceRequirement (
- PRESOURCE_REQUIREMENT_LIST ResourceRequirementList,
- PRESOURCE_REQUIREMENT CurrentEntry
- );
- /*++
- Routine Description:
- This routine returns a pointer to the next resource requirment in the
- resource requirement list.
- Arguments:
- ResourceRequirementList - Supplies a pointer to the resource requirement
- list to iterate through.
- CurrentEntry - Supplies an optional pointer to the previous resource
- requirement. If supplied, the function will return the resource
- requirement immediately after this one in the list. If NULL is
- supplied, this routine will return the first resource requirement in the
- list.
- Return Value:
- Returns a pointer to the next resource requirement in the given list on
- success, or NULL if the last resource requirement was reached.
- --*/
- KERNEL_API
- PRESOURCE_REQUIREMENT
- IoGetNextResourceRequirementAlternative (
- PRESOURCE_REQUIREMENT ResourceRequirement,
- PRESOURCE_REQUIREMENT CurrentEntry
- );
- /*++
- Routine Description:
- This routine returns a pointer to the next resource requirment alternative
- in the alternative list for the requirement.
- Arguments:
- ResourceRequirement - Supplies a pointer to the resource requirement at
- the head of the list.
- CurrentEntry - Supplies an optional pointer to the current requirement
- alternative.
- Return Value:
- Returns a pointer to the next resource requirement alternative in the list
- on success, or NULL if the last resource requirement alternative was
- reached.
- --*/
- //
- // Resource configuration list routines.
- //
- KERNEL_API
- PRESOURCE_CONFIGURATION_LIST
- IoCreateResourceConfigurationList (
- PRESOURCE_REQUIREMENT_LIST FirstConfiguration
- );
- /*++
- Routine Description:
- This routine creates a new resource configuration list. A resource
- configuration list is a collection of resource requirement lists, arranged
- from most desirable to least desirable. The system attempts selects the
- most desirable resource configuration that can be afforded.
- Arguments:
- FirstConfiguration - Supplies an optional pointer to the first configuration
- to put on the list. If NULL is supplied, an empty resource
- configuration list will be created.
- Return Value:
- Returns a pointer to the new resource configuration list on success.
- NULL on allocation failure.
- --*/
- KERNEL_API
- VOID
- IoDestroyResourceConfigurationList (
- PRESOURCE_CONFIGURATION_LIST ResourceConfigurationList
- );
- /*++
- Routine Description:
- This routine releases the memory associated with a resource configuration
- list, and any resource requirement lists it may contain.
- Arguments:
- ResourceConfigurationList - Supplies a pointer to the resource configuration
- list to destroy.
- Return Value:
- None.
- --*/
- KERNEL_API
- KSTATUS
- IoAddResourceConfiguration (
- PRESOURCE_REQUIREMENT_LIST Configuration,
- PRESOURCE_REQUIREMENT_LIST ConfigurationToInsertAfter,
- PRESOURCE_CONFIGURATION_LIST ConfigurationList
- );
- /*++
- Routine Description:
- This routine inserts an initialized resource configuration into a
- configuration list.
- Arguments:
- Configuration - Supplies a pointer to the resource configuration to insert
- into the list.
- ConfigurationToInsertAfter - Supplies an optional pointer indicating the
- location in the list to insert the configuration. If this pointer is
- supplied, the configuration will be inserted immediate after this
- parameter in the list. If NULL is supplied, the configuration will be
- added to the end of the list.
- ConfigurationList - Supplies a pointer to the list to add the configuration
- to.
- Return Value:
- Status code.
- --*/
- KERNEL_API
- VOID
- IoRemoveResourceConfiguration (
- PRESOURCE_REQUIREMENT_LIST Configuration,
- PRESOURCE_CONFIGURATION_LIST ConfigurationList
- );
- /*++
- Routine Description:
- This routine removes the given resource descriptor from its resource list.
- It does not free the memory associated with the configuration.
- Arguments:
- Configuration - Supplies a pointer to the configuration to remove.
- ConfigurationList - Supplies a pointer to the configuration list to remove
- the configuration from.
- Return Value:
- None.
- --*/
- KERNEL_API
- PRESOURCE_REQUIREMENT_LIST
- IoGetNextResourceConfiguration (
- PRESOURCE_CONFIGURATION_LIST ConfigurationList,
- PRESOURCE_REQUIREMENT_LIST CurrentEntry
- );
- /*++
- Routine Description:
- This routine returns a pointer to the next resource configuration in the
- resource configuration list.
- Arguments:
- ConfigurationList - Supplies a pointer to the resource configuration list
- to iterate through.
- CurrentEntry - Supplies an optional pointer to the previous resource
- requirement list. If supplied, the function will return the
- configuration immediately after this one in the list. If NULL is
- supplied, this routine will return the first configuration in the
- list.
- Return Value:
- Returns a pointer to the next resource configuration in the given list on
- success, or NULL if the last resource requirement was reached.
- --*/
- //
- // Resource allocation list support routines.
- //
- KERNEL_API
- PRESOURCE_ALLOCATION_LIST
- IoCreateResourceAllocationList (
- VOID
- );
- /*++
- Routine Description:
- This routine creates a new empty resource allocation list.
- Arguments:
- None.
- Return Value:
- Returns a pointer to the new resource allocation list on success.
- NULL on allocation failure.
- --*/
- KERNEL_API
- VOID
- IoDestroyResourceAllocationList (
- PRESOURCE_ALLOCATION_LIST ResourceAllocationList
- );
- /*++
- Routine Description:
- This routine releases the memory associated with a resource allocation
- list, and any items on that list.
- Arguments:
- ResourceAllocationList - Supplies a pointer to the resource allocation
- list to destroy.
- Return Value:
- None.
- --*/
- KERNEL_API
- KSTATUS
- IoCreateAndAddResourceAllocation (
- PRESOURCE_ALLOCATION Allocation,
- PRESOURCE_ALLOCATION_LIST ResourceAllocationList
- );
- /*++
- Routine Description:
- This routine creates a new resource allocation from the given template and
- inserts it into the given resource allocation list.
- Arguments:
- Allocation - Supplies a pointer to the resource allocation to use as a
- template. The memory passed in will not actually be used, a copy of the
- allocation will be created, initialized, and placed on the list.
- ResourceAllocationList - Supplies a pointer to the resource allocation
- list to add the allocation to.
- Return Value:
- STATUS_SUCCESS on success.
- STATUS_INVALID_PARAMETER if parameter validation failed.
- STATUS_INSUFFICIENT_RESOURCES if the required memory could not be allocated.
- --*/
- KERNEL_API
- VOID
- IoRemoveResourceAllocation (
- PRESOURCE_ALLOCATION Allocation,
- PRESOURCE_ALLOCATION_LIST ResourceAllocationList
- );
- /*++
- Routine Description:
- This routine removes the given resource descriptor from its resource list
- and frees the memory associated with that descriptor.
- Arguments:
- Allocation - Supplies a pointer to the allocation to remove.
- ResourceAllocationList - Supplies a pointer to the list to remove the
- allocation from.
- Return Value:
- None.
- --*/
- KERNEL_API
- PRESOURCE_ALLOCATION
- IoGetNextResourceAllocation (
- PRESOURCE_ALLOCATION_LIST ResourceAllocationList,
- PRESOURCE_ALLOCATION CurrentEntry
- );
- /*++
- Routine Description:
- This routine returns a pointer to the next resource allocation in the
- resource allocation list.
- Arguments:
- ResourceAllocationList - Supplies a pointer to the resource allocation
- list to iterate through.
- CurrentEntry - Supplies an optional pointer to the previous resource
- allocation. If supplied, the function will return the resource
- allocation immediately after this one in the list. If NULL is
- supplied, this routine will return the first resource allocation in the
- list.
- Return Value:
- Returns a pointer to the next resource allocation in the given list on
- success, or NULL if the last resource allocation was reached.
- --*/
- KERNEL_API
- VOID
- IoDebugPrintResourceConfigurationList (
- PRESOURCE_CONFIGURATION_LIST ConfigurationList
- );
- /*++
- Routine Description:
- This routine prints a resource configuration list out to the debugger.
- Arguments:
- ConfigurationList - Supplies a pointer to the resource configuration list to
- print.
- Return Value:
- None.
- --*/
- KERNEL_API
- VOID
- IoDebugPrintResourceRequirementList (
- ULONG IndentationLevel,
- PRESOURCE_REQUIREMENT_LIST RequirementList
- );
- /*++
- Routine Description:
- This routine prints a resource requirement list out to the debugger.
- Arguments:
- IndentationLevel - Supplies the indentation level to print this list
- at. Supply 0 if this function is called directly.
- RequirementList - Supplies a pointer to the resource requirement list to
- print.
- Return Value:
- None.
- --*/
- KERNEL_API
- VOID
- IoDebugPrintResourceRequirement (
- ULONG IndentationLevel,
- PRESOURCE_REQUIREMENT Requirement
- );
- /*++
- Routine Description:
- This routine prints a resource requirement out to the debugger.
- Arguments:
- IndentationLevel - Supplies the indentation level to print this requirement
- at. Supply 0 if this function is called directly.
- Requirement - Supplies a pointer to the resource requirement to print.
- Return Value:
- None.
- --*/
- KERNEL_API
- VOID
- IoDebugPrintResourceAllocationList (
- ULONG IndentationLevel,
- PRESOURCE_ALLOCATION_LIST AllocationList
- );
- /*++
- Routine Description:
- This routine prints a resource allocation list out to the debugger.
- Arguments:
- IndentationLevel - Supplies the indentation level to print this list
- at. Supply 0 if this function is called directly.
- AllocationList - Supplies a pointer to the resource allocation list to
- print.
- Return Value:
- None.
- --*/
- KERNEL_API
- VOID
- IoDebugPrintResourceAllocation (
- ULONG IndentationLevel,
- PRESOURCE_ALLOCATION Allocation
- );
- /*++
- Routine Description:
- This routine prints a resource allocation out to the debugger.
- Arguments:
- IndentationLevel - Supplies the indentation level to print this allocation
- at. Supply 0 if this function is called directly.
- Allocation - Supplies a pointer to the resource allocation to print.
- Return Value:
- None.
- --*/
|