arb.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /*++
  2. Copyright (c) 2012 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. arb.h
  5. Abstract:
  6. This header contains internal definitions for the resource arbiters.
  7. Author:
  8. Evan Green 12-Dec-2012
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. //
  14. // --------------------------------------------------------------------- Macros
  15. //
  16. //
  17. // The arbiters themselves are doubly indirected because a deduplicated
  18. // array of arbiters is needed.
  19. //
  20. #define IOP_GET_ARBITER_DATA(_Context, _RequirementData) \
  21. (&((_Context)->ArbiterData[(_RequirementData)->ArbiterIndex]))
  22. #define IOP_ARBITER_GET_ARBITER(_Context, _RequirementData) \
  23. (IOP_GET_ARBITER_DATA(_Context, _RequirementData)->Arbiter)
  24. #define IOP_ARBITER_GET_DEVICE(_Context, _RequirementData) \
  25. ((_Context)->Device[(_RequirementData)->DeviceIndex])
  26. //
  27. // ---------------------------------------------------------------- Definitions
  28. //
  29. #define ARBITER_ALLOCATION_TAG 0x21627241 // '!brA'
  30. //
  31. // ------------------------------------------------------ Data Type Definitions
  32. //
  33. typedef enum _ARBITER_TYPE {
  34. ArbiterTypeInvalid = ResourceTypeInvalid,
  35. ArbiterTypePhysicalAddressSpace = ResourceTypePhysicalAddressSpace,
  36. ArbiterTypeIoPort = ResourceTypeIoPort,
  37. ArbiterTypeInterruptLine = ResourceTypeInterruptLine,
  38. ArbiterTypeInterruptVector = ResourceTypeInterruptVector,
  39. ArbiterTypeBusNumber = ResourceTypeBusNumber,
  40. ArbiterTypeVendorSpecific = ResourceTypeVendorSpecific,
  41. ArbiterTypeGpio = ResourceTypeGpio,
  42. ArbiterTypeSimpleBus = ResourceTypeSimpleBus,
  43. ArbiterTypeCount
  44. } ARBITER_TYPE, *PARBITER_TYPE;
  45. typedef enum _ARBITER_SPACE_TYPE {
  46. ArbiterSpaceInvalid,
  47. ArbiterSpaceFree,
  48. ArbiterSpaceReserved,
  49. ArbiterSpaceAllocated
  50. } ARBITER_SPACE_TYPE, *PARBITER_SPACE_TYPE;
  51. /*++
  52. Structure Description:
  53. This structure defines an entry in the resource arbiter.
  54. Members:
  55. ListEntry - Stores pointers to the next and previous arbiter entries in the
  56. arbiter.
  57. ConfigurationListEntry - Stores pointers to the next and previous arbiter
  58. allocations in the potential resource configuration. This allows all
  59. resources allocated to a device to be chained together. In all
  60. likelihood these will point to allocations in different arbiters.
  61. Type - Stores the nature of the allocation (free, occupied, etc.)
  62. Device - Stores a pointer to the device that this entry was allocated to.
  63. CorrespondingRequirement - Stores a pointer to the root requirement that is
  64. utiliizing this resource.
  65. Allocation - Stores the starting value of the allocation.
  66. Length - Stores the length of the allocation.
  67. Characteristics - Stores the characteristics of the allocation.
  68. FreeCharacteristics - Stores the characteristics of the region when it was
  69. free.
  70. Flags - Stores a bitfield about the allocation. See ARBITER_ENTRY_FLAG_*
  71. definitions.
  72. SourceAllocation - Stores an optional pointer to the resource that this
  73. allocation is derived from.
  74. TranslationOffset - Stores the offset that must be added to this allocation
  75. to get an allocation in the source allocation space.
  76. DependentEntry - Stores a pointer to an arbiter entry that is dependent on
  77. this entry in some way. For example, an interrupt vector arbiter entry
  78. may be dependent on an interrupt line arbiter entry because the same
  79. line cannot be allocated to more than one vector. Once a line arbiter
  80. allocation is made, the vector allocation depends on the result of the
  81. line entry.
  82. --*/
  83. typedef struct _ARBITER_ENTRY ARBITER_ENTRY, *PARBITER_ENTRY;
  84. struct _ARBITER_ENTRY {
  85. LIST_ENTRY ListEntry;
  86. LIST_ENTRY ConfigurationListEntry;
  87. ARBITER_SPACE_TYPE Type;
  88. PDEVICE Device;
  89. PRESOURCE_REQUIREMENT CorrespondingRequirement;
  90. ULONGLONG Allocation;
  91. ULONGLONG Length;
  92. ULONGLONG Characteristics;
  93. ULONGLONG FreeCharacteristics;
  94. ULONG Flags;
  95. PRESOURCE_ALLOCATION SourceAllocation;
  96. ULONGLONG TranslationOffset;
  97. PARBITER_ENTRY DependentEntry;
  98. };
  99. /*++
  100. Structure Description:
  101. This structure defines a resource arbiter.
  102. Members:
  103. ListEntry - Stores pointers to the next and previous arbiters in the
  104. device's arbiter list.
  105. OwningDevice - Stores a pointer to the device that manages this arbiter.
  106. ResourceType - Stores the type of resource that this arbiter manages.
  107. Flags - Stores a bitmask of flags about this arbiter. See ARBITER_FLAG_*
  108. definitions.
  109. EntryListHead - Stores the head of the arbiter entry list.
  110. --*/
  111. typedef struct _RESOURCE_ARBITER {
  112. LIST_ENTRY ListEntry;
  113. PDEVICE OwningDevice;
  114. RESOURCE_TYPE ResourceType;
  115. ULONG Flags;
  116. LIST_ENTRY EntryListHead;
  117. } RESOURCE_ARBITER, *PRESOURCE_ARBITER;
  118. /*++
  119. Structure Description:
  120. This structure defines the data associated with an arbiter during an
  121. allocation proceeding.
  122. Members:
  123. Arbiter - Stores a pointer to the arbiter itself.
  124. AmountNotAllocated - Stores the amount that could not be allocated from
  125. this arbiter during an allocation.
  126. --*/
  127. typedef struct _ARBITER_ALLOCATION_ARBITER_DATA {
  128. PRESOURCE_ARBITER Arbiter;
  129. ULONGLONG AmountNotAllocated;
  130. } ARBITER_ALLOCATION_ARBITER_DATA, *PARBITER_ALLOCATION_ARBITER_DATA;
  131. /*++
  132. Structure Description:
  133. This structure defines the data associated with a resource requirement
  134. during an arbiter allocation session.
  135. Members:
  136. Requirement - Stores a pointer to the actual resource requirement.
  137. DeviceIndex - Stores the index into the array of context devices for the
  138. device that generated this requirement.
  139. Allocation - Stores a pointer to the arbiter allocation for the requirement.
  140. ArbiterIndex - Stores the index into the arbiter data array where the
  141. arbiter for this requirement can be found.
  142. --*/
  143. typedef struct _ARBITER_ALLOCATION_REQUIREMENT {
  144. PRESOURCE_REQUIREMENT Requirement;
  145. ULONG DeviceIndex;
  146. PARBITER_ENTRY Allocation;
  147. ULONG ArbiterIndex;
  148. } ARBITER_ALLOCATION_REQUIREMENT, *PARBITER_ALLOCATION_REQUIREMENT;
  149. /*++
  150. Structure Description:
  151. This structure defines an arbiter allocation context, a scratchpad of
  152. state used when trying to satisfy allocations of one or more devices.
  153. Members:
  154. ArbiterData - Stores an array of arbiter data structures, one for each
  155. arbiter involved in this allocation. This array is always deduplicated.
  156. Its capacity is always the resource requirement count for the worst
  157. case where every requirement is a different arbiter.
  158. ArbiterCount - Stores the number of valid elements currently in the
  159. arbiters array.
  160. Device - Stores an array of pointers to devices. These represent the
  161. devices involved in this set of allocations.
  162. CurrentDeviceConfiguration - Supplies an array of pointers to device
  163. configurations. For each device, this represents which of the
  164. possible configurations is being worked on.
  165. DeviceCount - Stores the number of elements in the device and current
  166. configuration arrays.
  167. Requirements - Stores an array of resource requirements and their
  168. associated data.
  169. RequirementCount - Stores the number of elements in the requirement and
  170. requirement device arrays.
  171. --*/
  172. typedef struct _ARBITER_ALLOCATION_CONTEXT {
  173. PARBITER_ALLOCATION_ARBITER_DATA ArbiterData;
  174. ULONG ArbiterCount;
  175. PDEVICE *Device;
  176. PRESOURCE_REQUIREMENT_LIST *CurrentDeviceConfiguration;
  177. ULONG DeviceCount;
  178. PARBITER_ALLOCATION_REQUIREMENT Requirements;
  179. ULONG RequirementCount;
  180. } ARBITER_ALLOCATION_CONTEXT, *PARBITER_ALLOCATION_CONTEXT;
  181. //
  182. // -------------------------------------------------------------------- Globals
  183. //
  184. //
  185. // -------------------------------------------------------- Function Prototypes
  186. //