19#define ARBITER_RESERVED_PASS_DONE 0xFFFFFFFF
63 if (ArbState->CurrentAlternative ==
NULL ||
69 if (ArbState->Entry ==
NULL || ArbState->Entry->PhysicalDeviceObject ==
NULL)
78 if (Range->
Start <= ArbState->CurrentMaximum &&
79 Range->
End >= ArbState->CurrentMinimum &&
80 !(Range->
Attributes & ArbState->RangeAvailableAttributes))
85 SelfConflictOnly =
TRUE;
86 ArbState->Start = ArbState->CurrentMinimum;
87 ArbState->End = ArbState->CurrentMaximum;
94 return SelfConflictOnly;
144 Ordering = Arbiter->OrderingList.Orderings;
156 if (
Index >= Arbiter->OrderingList.Count)
158 Alternative->Reserved[0] = 0;
163 Ordering = &Arbiter->OrderingList.Orderings[
Index + 1];
166 End = &Arbiter->OrderingList.Orderings[Arbiter->OrderingList.Count];
167 for (; Ordering < End; ++Ordering)
171 if (Ordering->
Start > Alternative->Maximum ||
172 Alternative->Minimum > Ordering->
End)
178 RangeEnd =
min(Alternative->Maximum, Ordering->
End);
180 if ((RangeEnd -
Start + 1) >= Alternative->Length)
182 INT32 NewPriority = (
INT32)(Ordering - Arbiter->OrderingList.Orderings) + 1;
183 Alternative->Priority = Preferred ? -NewPriority : NewPriority;
188 Alternative->Reserved[0] = 0;
257 for (
A = DeviceA->AttachedDevice;
A !=
NULL;
A =
A->AttachedDevice)
259 for (
B = DeviceB->AttachedDevice;
B !=
NULL;
B =
B->AttachedDevice)
261 if (
A->DriverObject ==
B->DriverObject)
313 ArbState->CurrentAlternative ==
NULL)
318 Requester =
Entry->PhysicalDeviceObject;
324 while (Range !=
NULL)
330 if (Range->
Start <= ArbState->CurrentMaximum &&
331 Range->
End >= ArbState->CurrentMinimum &&
332 !(Range->
Attributes & ArbState->RangeAvailableAttributes) &&
348 ArbState->Start = ArbState->CurrentMinimum;
349 ArbState->End = ArbState->CurrentMaximum;
350 if (ArbState->CurrentAlternative->Descriptor->ShareDisposition ==
421 while (Range !=
NULL)
424 Range->
Start >= ArbState->CurrentMinimum &&
425 Range->
Start <= ArbState->CurrentMaximum &&
426 Range->
End <= ArbState->CurrentMaximum &&
429 ArbState->Start = Range->
Start;
430 ArbState->End = Range->
Start + Alternative->
Length - 1;
485 for (
Index = Alternative->Reserved[0];
486 Index < Arbiter->ReservedList.Count;
492 if (
Window->Start > Alternative->Maximum ||
493 Alternative->Minimum >
Window->End)
498 Lo =
max(Alternative->Minimum,
Window->Start);
499 Hi =
min(Alternative->Maximum,
Window->End);
500 if ((Hi - Lo + 1) < Alternative->Length)
503 Alternative->Reserved[0] =
Index + 1;
531 *Minimum = Alternative->Minimum;
532 *Maximum = Alternative->Maximum;
572 if (ArbState->AlternativeCount == 0)
578 if (ArbState->CurrentAlternative !=
NULL)
584 for (Alternative = ArbState->Alternatives;
585 Alternative < &ArbState->Alternatives[ArbState->AlternativeCount];
594 Lowest = ArbState->Alternatives;
595 for (Alternative = ArbState->Alternatives + 1;
596 Alternative < &ArbState->Alternatives[ArbState->AlternativeCount];
600 Lowest = Alternative;
622 ArbState->CurrentAlternative = Lowest;
631 if (
Index >= Arbiter->OrderingList.Count)
634 ArbState->CurrentAlternative = Lowest;
637 Ordering = &Arbiter->OrderingList.Orderings[
Index];
655 if (Minimum > Maximum || LengthMinusOne > Maximum - Minimum)
657 ArbState->CurrentAlternative = Lowest;
661 AlignedMax = Maximum - LengthMinusOne;
663 if (AlignedMax < Minimum)
665 ArbState->CurrentAlternative = Lowest;
668 Maximum = AlignedMax + LengthMinusOne;
676 if (Minimum != ArbState->CurrentMinimum ||
677 Maximum != ArbState->CurrentMaximum ||
678 ArbState->CurrentAlternative != Lowest)
680 ArbState->CurrentMinimum = Minimum;
681 ArbState->CurrentMaximum = Maximum;
682 ArbState->CurrentAlternative = Lowest;
686 ArbState->CurrentAlternative = Lowest;
727 if (Alternative ==
NULL)
730 if (ArbState->CurrentMinimum > ArbState->CurrentMaximum)
733 if (Alternative->
Length == 0)
735 ArbState->Start = ArbState->CurrentMinimum;
736 ArbState->End = ArbState->CurrentMinimum;
748 if (ArbState->Entry !=
NULL &&
763 ArbState->CurrentMinimum,
764 ArbState->CurrentMaximum,
768 ArbState->RangeAvailableAttributes,
769 Arbiter->ConflictCallbackContext,
770 Arbiter->ConflictCallback,
784 if (Arbiter->OverrideConflict !=
NULL &&
785 Arbiter->OverrideConflict(Arbiter, ArbState))
795 ArbState->CurrentMaximum))
803 ArbState->End = ArbState->Start + Alternative->
Length - 1;
836 if (ArbState->CurrentAlternative !=
NULL &&
845 ArbState->RangeAttributes,
848 ArbState->Entry ? ArbState->Entry->PhysicalDeviceObject :
NULL);
875 ArbState->Entry ? ArbState->Entry->PhysicalDeviceObject :
NULL);
static _Out_opt_ PULONGLONG Start
COMPILER_DEPENDENT_UINT64 UINT64
#define ARBITER_STATE_FLAG_NULL_CONFLICT_OK
#define ARBITER_ALTERNATIVE_FLAG_SHARED
#define ARBITER_PRIORITY_NULL
#define ARBITER_PRIORITY_RESERVED
#define ARBITER_PRIORITY_EXHAUSTED
#define ARBITER_STATE_FLAG_MCFG_CONFLICT
#define ARBITER_RANGE_INACCESSIBLE
#define ARBITER_ALTERNATIVE_FLAG_INACCESSIBLE_OK
#define ARBITER_PRIORITY_PREFERRED_RESERVED
BOOLEAN NTAPI ArbiterLibIsConflictWithMmConfigRange(_In_ ULONGLONG Start, _In_ ULONGLONG End)
Determines whether a range overlaps the recorded MMCONFIG window.
#define ARBITER_RANGE_SHARED_DRIVER
#define ARBITER_ALTERNATIVE_FLAG_FIXED
#define ARBITER_RANGE_BOOT_ALLOCATED
unsigned __int64 * PUINT64
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
#define NT_SUCCESS(StatCode)
#define RTL_CONSTANT_STRING(s)
struct _DEVICE_OBJECT * PDEVICE_OBJECT
union Alignment_ Alignment
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ SaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ OwnerSize PSID Owner
NTSYSAPI NTSTATUS NTAPI RtlDeleteRange(_Inout_ PRTL_RANGE_LIST RangeList, _In_ ULONGLONG Start, _In_ ULONGLONG End, _In_ PVOID Owner)
NTSYSAPI NTSTATUS NTAPI RtlAddRange(_Inout_ PRTL_RANGE_LIST RangeList, _In_ ULONGLONG Start, _In_ ULONGLONG End, _In_ UCHAR Attributes, _In_ ULONG Flags, _In_opt_ PVOID UserData, _In_opt_ PVOID Owner)
NTSYSAPI NTSTATUS NTAPI RtlFindRange(_In_ PRTL_RANGE_LIST RangeList, _In_ ULONGLONG Minimum, _In_ ULONGLONG Maximum, _In_ ULONGLONG Length, _In_ ULONGLONG Alignment, _In_ ULONG Flags, _In_ UCHAR AttributeAvailableMask, _In_opt_ PVOID Context, _In_opt_ PRTL_CONFLICT_RANGE_CALLBACK Callback, _Out_ PULONGLONG Start)
NTSYSAPI NTSTATUS NTAPI RtlGetNextRange(_Inout_ PRTL_RANGE_LIST_ITERATOR Iterator, _Outptr_ PRTL_RANGE *Range, _In_ BOOLEAN MoveForwards)
NTSYSAPI NTSTATUS NTAPI RtlGetFirstRange(_In_ PRTL_RANGE_LIST RangeList, _Out_ PRTL_RANGE_LIST_ITERATOR Iterator, _Outptr_ PRTL_RANGE *Range)
#define RTL_RANGE_LIST_ADD_IF_CONFLICT
#define RTL_RANGE_LIST_ADD_SHARED
#define RTL_RANGE_LIST_NULL_CONFLICT_OK
#define RTL_RANGE_LIST_SHARED_OK
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
_In_ ULONG _In_ ULONG _In_ ULONG Length
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
BOOLEAN NTAPI ArbiterLibGetNextAllocationRange(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Moves the working window to the next candidate range, walking the entry's alternatives in priority or...
static BOOLEAN ArbpTakeReservedWindow(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALTERNATIVE Alternative, _Out_ PUINT64 Minimum, _Out_ PUINT64 Maximum)
Takes the next window of the reserved (last-resort) pass for an alternative: each ReservedList range ...
VOID NTAPI ArbiterLibBacktrackAllocation(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Undoes the last AddAllocation performed for this entry.
BOOLEAN NTAPI ArbiterLibFindSuitableRange(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Finds a free range of the current candidate window in the arbiter's tentative allocation list.
static VOID ArbpWritePriority(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALTERNATIVE Alternative)
Writes an alternative's priority to the next ordering-list range it can be satisfied from.
static BOOLEAN ArbpSharesDriverStack(_In_ PDEVICE_OBJECT DeviceA, _In_ PDEVICE_OBJECT DeviceB)
Determines whether a common driver is loaded on both device stacks, above the physical device objects...
static BOOLEAN ArbpShareDriverExclusive(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Attempts last-chance sharing for a CmResourceShareDriverExclusive requirement whose window RtlFindRan...
BOOLEAN NTAPI ArbiterLibOverrideConflict(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
The OverrideConflict default, the last of the conflict escapes: grants a FIXED requirement whose wind...
VOID NTAPI ArbiterLibAddAllocation(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Records the chosen placement in the arbiter's tentative allocation list, owned by the requesting devi...
static BOOLEAN ArbpReuseOwnedInterrupt(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Hands a device back its own already routed IRQ instead of searching for a fresh one,...
static BOOLEAN ArbpIsRootEnumerated(_In_ PDEVICE_OBJECT DeviceObject)
Determines whether a device is enumerated by the root enumerator.
#define ARBITER_RESERVED_PASS_DONE
#define CmResourceTypeInterrupt
_In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR Iterator
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ PDEVICE_OBJECT DeviceObject
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
@ CmResourceShareDriverExclusive
@ ArbiterRequestLegacyAssigned
@ ArbiterRequestLegacyReported
@ DevicePropertyEnumeratorName
#define IO_RESOURCE_PREFERRED