61 Ordering = Arbiter->OrderingList.Orderings;
73 if (
Index >= Arbiter->OrderingList.Count)
79 Ordering = &Arbiter->OrderingList.Orderings[
Index + 1];
82 End = &Arbiter->OrderingList.Orderings[Arbiter->OrderingList.Count];
83 for (; Ordering < End; ++Ordering)
87 if (Ordering->
Start > Alternative->Maximum ||
88 Alternative->Minimum > Ordering->
End)
94 RangeEnd =
min(Alternative->Maximum, Ordering->
End);
96 if ((RangeEnd -
Start + 1) >= Alternative->Length)
98 INT32 NewPriority = (
INT32)(Ordering - Arbiter->OrderingList.Orderings) + 1;
99 Alternative->Priority = Preferred ? -NewPriority : NewPriority;
172 for (
A = DeviceA->AttachedDevice;
A !=
NULL;
A =
A->AttachedDevice)
174 for (
B = DeviceB->AttachedDevice;
B !=
NULL;
B =
B->AttachedDevice)
176 if (
A->DriverObject ==
B->DriverObject)
228 ArbState->CurrentAlternative ==
NULL)
233 Requester =
Entry->PhysicalDeviceObject;
239 while (Range !=
NULL)
245 if (Range->
Start <= ArbState->CurrentMaximum &&
246 Range->
End >= ArbState->CurrentMinimum &&
247 !(Range->
Attributes & ArbState->RangeAvailableAttributes) &&
263 ArbState->Start = ArbState->CurrentMinimum;
264 ArbState->End = ArbState->CurrentMaximum;
265 if (ArbState->CurrentAlternative->Descriptor->ShareDisposition ==
336 while (Range !=
NULL)
339 Range->
Start >= ArbState->CurrentMinimum &&
340 Range->
Start <= ArbState->CurrentMaximum &&
341 Range->
End <= ArbState->CurrentMaximum &&
344 ArbState->Start = Range->
Start;
345 ArbState->End = Range->
Start + Alternative->
Length - 1;
389 if (ArbState->AlternativeCount == 0)
395 if (ArbState->CurrentAlternative !=
NULL)
401 for (Alternative = ArbState->Alternatives;
402 Alternative < &ArbState->Alternatives[ArbState->AlternativeCount];
411 Lowest = ArbState->Alternatives;
412 for (Alternative = ArbState->Alternatives + 1;
413 Alternative < &ArbState->Alternatives[ArbState->AlternativeCount];
417 Lowest = Alternative;
435 if (
Index >= Arbiter->OrderingList.Count)
440 Ordering = &Arbiter->OrderingList.Orderings[
Index];
458 if (Minimum > Maximum || LengthMinusOne > Maximum - Minimum)
460 ArbState->CurrentAlternative = Lowest;
464 AlignedMax = Maximum - LengthMinusOne;
466 if (AlignedMax < Minimum)
468 ArbState->CurrentAlternative = Lowest;
471 Maximum = AlignedMax + LengthMinusOne;
479 if (Minimum != ArbState->CurrentMinimum ||
480 Maximum != ArbState->CurrentMaximum ||
481 ArbState->CurrentAlternative != Lowest)
483 ArbState->CurrentMinimum = Minimum;
484 ArbState->CurrentMaximum = Maximum;
485 ArbState->CurrentAlternative = Lowest;
489 ArbState->CurrentAlternative = Lowest;
530 if (Alternative ==
NULL)
533 if (ArbState->CurrentMinimum > ArbState->CurrentMaximum)
536 if (Alternative->
Length == 0)
538 ArbState->Start = ArbState->CurrentMinimum;
539 ArbState->End = ArbState->CurrentMinimum;
551 if (ArbState->Entry !=
NULL &&
564 ArbState->CurrentMinimum,
565 ArbState->CurrentMaximum,
569 ArbState->RangeAvailableAttributes,
570 Arbiter->ConflictCallbackContext,
571 Arbiter->ConflictCallback,
585 if (Arbiter->OverrideConflict !=
NULL &&
586 Arbiter->OverrideConflict(Arbiter, ArbState))
593 ArbState->End = ArbState->Start + Alternative->
Length - 1;
626 if (ArbState->CurrentAlternative !=
NULL &&
635 ArbState->RangeAttributes,
638 ArbState->Entry ? ArbState->Entry->PhysicalDeviceObject :
NULL);
665 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_PRIORITY_PREFERRED_RESERVED
#define ARBITER_RANGE_SHARED_DRIVER
#define ARBITER_ALTERNATIVE_FLAG_FIXED
#define ARBITER_RANGE_BOOT_ALLOCATED
#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_ ULONG Length, _In_ ULONG 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...
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...
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 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
_Must_inspect_result_ _In_ ULONG Flags
@ CmResourceShareDriverExclusive
@ ArbiterRequestLegacyAssigned
@ ArbiterRequestLegacyReported
@ DevicePropertyEnumeratorName
#define IO_RESOURCE_PREFERRED