1374f2b4dSVadim Galyant /*
2*fec440d8SVadim Galyant * PROJECT: ReactOS Kernel&Driver SDK
3*fec440d8SVadim Galyant * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4374f2b4dSVadim Galyant * PURPOSE: Hardware Resources Arbiter Library
5*fec440d8SVadim Galyant * COPYRIGHT: Copyright 2020 Vadim Galyant <vgal@rambler.ru>
6374f2b4dSVadim Galyant */
7374f2b4dSVadim Galyant
8374f2b4dSVadim Galyant /* INCLUDES *******************************************************************/
9374f2b4dSVadim Galyant
106f671326SHermès Bélusca-Maïto #include <ntifs.h>
11*fec440d8SVadim Galyant #include <ndk/rtlfuncs.h>
12374f2b4dSVadim Galyant #include "arbiter.h"
13374f2b4dSVadim Galyant
146f671326SHermès Bélusca-Maïto #define NDEBUG
156f671326SHermès Bélusca-Maïto #include <debug.h>
166f671326SHermès Bélusca-Maïto
17374f2b4dSVadim Galyant /* GLOBALS ********************************************************************/
18374f2b4dSVadim Galyant
19374f2b4dSVadim Galyant /* DATA **********************************************************************/
20374f2b4dSVadim Galyant
21374f2b4dSVadim Galyant /* FUNCTIONS ******************************************************************/
22374f2b4dSVadim Galyant
23*fec440d8SVadim Galyant CODE_SEG("PAGE")
24*fec440d8SVadim Galyant NTSTATUS
25*fec440d8SVadim Galyant NTAPI
ArbTestAllocation(_In_ PARBITER_INSTANCE Arbiter,_In_ PLIST_ENTRY ArbitrationList)26*fec440d8SVadim Galyant ArbTestAllocation(
27*fec440d8SVadim Galyant _In_ PARBITER_INSTANCE Arbiter,
28*fec440d8SVadim Galyant _In_ PLIST_ENTRY ArbitrationList)
29*fec440d8SVadim Galyant {
30*fec440d8SVadim Galyant PAGED_CODE();
31*fec440d8SVadim Galyant
32*fec440d8SVadim Galyant UNIMPLEMENTED;
33*fec440d8SVadim Galyant return STATUS_NOT_IMPLEMENTED;
34*fec440d8SVadim Galyant }
35*fec440d8SVadim Galyant
36*fec440d8SVadim Galyant CODE_SEG("PAGE")
37*fec440d8SVadim Galyant NTSTATUS
38*fec440d8SVadim Galyant NTAPI
ArbRetestAllocation(_In_ PARBITER_INSTANCE Arbiter,_In_ PLIST_ENTRY ArbitrationList)39*fec440d8SVadim Galyant ArbRetestAllocation(
40*fec440d8SVadim Galyant _In_ PARBITER_INSTANCE Arbiter,
41*fec440d8SVadim Galyant _In_ PLIST_ENTRY ArbitrationList)
42*fec440d8SVadim Galyant {
43*fec440d8SVadim Galyant PAGED_CODE();
44*fec440d8SVadim Galyant
45*fec440d8SVadim Galyant UNIMPLEMENTED;
46*fec440d8SVadim Galyant return STATUS_NOT_IMPLEMENTED;
47*fec440d8SVadim Galyant }
48*fec440d8SVadim Galyant
49*fec440d8SVadim Galyant CODE_SEG("PAGE")
50*fec440d8SVadim Galyant NTSTATUS
51*fec440d8SVadim Galyant NTAPI
ArbCommitAllocation(_In_ PARBITER_INSTANCE Arbiter)52*fec440d8SVadim Galyant ArbCommitAllocation(
53*fec440d8SVadim Galyant _In_ PARBITER_INSTANCE Arbiter)
54*fec440d8SVadim Galyant {
55*fec440d8SVadim Galyant PAGED_CODE();
56*fec440d8SVadim Galyant
57*fec440d8SVadim Galyant UNIMPLEMENTED;
58*fec440d8SVadim Galyant return STATUS_NOT_IMPLEMENTED;
59*fec440d8SVadim Galyant }
60*fec440d8SVadim Galyant
61*fec440d8SVadim Galyant CODE_SEG("PAGE")
62*fec440d8SVadim Galyant NTSTATUS
63*fec440d8SVadim Galyant NTAPI
ArbRollbackAllocation(_In_ PARBITER_INSTANCE Arbiter)64*fec440d8SVadim Galyant ArbRollbackAllocation(
65*fec440d8SVadim Galyant _In_ PARBITER_INSTANCE Arbiter)
66*fec440d8SVadim Galyant {
67*fec440d8SVadim Galyant PAGED_CODE();
68*fec440d8SVadim Galyant
69*fec440d8SVadim Galyant UNIMPLEMENTED;
70*fec440d8SVadim Galyant return STATUS_NOT_IMPLEMENTED;
71*fec440d8SVadim Galyant }
72*fec440d8SVadim Galyant
73*fec440d8SVadim Galyant /* FIXME: the prototype is not correct yet. */
74*fec440d8SVadim Galyant CODE_SEG("PAGE")
75*fec440d8SVadim Galyant NTSTATUS
76*fec440d8SVadim Galyant NTAPI
ArbAddReserved(_In_ PARBITER_INSTANCE Arbiter)77*fec440d8SVadim Galyant ArbAddReserved(
78*fec440d8SVadim Galyant _In_ PARBITER_INSTANCE Arbiter)
79*fec440d8SVadim Galyant {
80*fec440d8SVadim Galyant PAGED_CODE();
81*fec440d8SVadim Galyant
82*fec440d8SVadim Galyant UNIMPLEMENTED;
83*fec440d8SVadim Galyant return STATUS_NOT_IMPLEMENTED;
84*fec440d8SVadim Galyant }
85*fec440d8SVadim Galyant
86*fec440d8SVadim Galyant CODE_SEG("PAGE")
87*fec440d8SVadim Galyant NTSTATUS
88*fec440d8SVadim Galyant NTAPI
ArbPreprocessEntry(_In_ PARBITER_INSTANCE Arbiter,_Inout_ PARBITER_ALLOCATION_STATE ArbState)89*fec440d8SVadim Galyant ArbPreprocessEntry(
90*fec440d8SVadim Galyant _In_ PARBITER_INSTANCE Arbiter,
91*fec440d8SVadim Galyant _Inout_ PARBITER_ALLOCATION_STATE ArbState)
92*fec440d8SVadim Galyant {
93*fec440d8SVadim Galyant PAGED_CODE();
94*fec440d8SVadim Galyant
95*fec440d8SVadim Galyant return STATUS_SUCCESS;
96*fec440d8SVadim Galyant }
97*fec440d8SVadim Galyant
98*fec440d8SVadim Galyant CODE_SEG("PAGE")
99*fec440d8SVadim Galyant NTSTATUS
100*fec440d8SVadim Galyant NTAPI
ArbAllocateEntry(_In_ PARBITER_INSTANCE Arbiter,_Inout_ PARBITER_ALLOCATION_STATE ArbState)101*fec440d8SVadim Galyant ArbAllocateEntry(
102*fec440d8SVadim Galyant _In_ PARBITER_INSTANCE Arbiter,
103*fec440d8SVadim Galyant _Inout_ PARBITER_ALLOCATION_STATE ArbState)
104*fec440d8SVadim Galyant {
105*fec440d8SVadim Galyant PAGED_CODE();
106*fec440d8SVadim Galyant
107*fec440d8SVadim Galyant UNIMPLEMENTED;
108*fec440d8SVadim Galyant return STATUS_NOT_IMPLEMENTED;
109*fec440d8SVadim Galyant }
110*fec440d8SVadim Galyant
111*fec440d8SVadim Galyant CODE_SEG("PAGE")
112*fec440d8SVadim Galyant BOOLEAN
113*fec440d8SVadim Galyant NTAPI
ArbGetNextAllocationRange(_In_ PARBITER_INSTANCE Arbiter,_Inout_ PARBITER_ALLOCATION_STATE ArbState)114*fec440d8SVadim Galyant ArbGetNextAllocationRange(
115*fec440d8SVadim Galyant _In_ PARBITER_INSTANCE Arbiter,
116*fec440d8SVadim Galyant _Inout_ PARBITER_ALLOCATION_STATE ArbState)
117*fec440d8SVadim Galyant {
118*fec440d8SVadim Galyant PAGED_CODE();
119*fec440d8SVadim Galyant
120*fec440d8SVadim Galyant UNIMPLEMENTED;
121*fec440d8SVadim Galyant return FALSE;
122*fec440d8SVadim Galyant }
123*fec440d8SVadim Galyant
124*fec440d8SVadim Galyant CODE_SEG("PAGE")
125*fec440d8SVadim Galyant BOOLEAN
126*fec440d8SVadim Galyant NTAPI
ArbFindSuitableRange(_In_ PARBITER_INSTANCE Arbiter,_Inout_ PARBITER_ALLOCATION_STATE ArbState)127*fec440d8SVadim Galyant ArbFindSuitableRange(
128*fec440d8SVadim Galyant _In_ PARBITER_INSTANCE Arbiter,
129*fec440d8SVadim Galyant _Inout_ PARBITER_ALLOCATION_STATE ArbState)
130*fec440d8SVadim Galyant {
131*fec440d8SVadim Galyant PAGED_CODE();
132*fec440d8SVadim Galyant
133*fec440d8SVadim Galyant UNIMPLEMENTED;
134*fec440d8SVadim Galyant return FALSE;
135*fec440d8SVadim Galyant }
136*fec440d8SVadim Galyant
137*fec440d8SVadim Galyant CODE_SEG("PAGE")
138*fec440d8SVadim Galyant VOID
139*fec440d8SVadim Galyant NTAPI
ArbAddAllocation(_In_ PARBITER_INSTANCE Arbiter,_Inout_ PARBITER_ALLOCATION_STATE ArbState)140*fec440d8SVadim Galyant ArbAddAllocation(
141*fec440d8SVadim Galyant _In_ PARBITER_INSTANCE Arbiter,
142*fec440d8SVadim Galyant _Inout_ PARBITER_ALLOCATION_STATE ArbState)
143*fec440d8SVadim Galyant {
144*fec440d8SVadim Galyant PAGED_CODE();
145*fec440d8SVadim Galyant
146*fec440d8SVadim Galyant UNIMPLEMENTED;
147*fec440d8SVadim Galyant }
148*fec440d8SVadim Galyant
149*fec440d8SVadim Galyant CODE_SEG("PAGE")
150*fec440d8SVadim Galyant VOID
151*fec440d8SVadim Galyant NTAPI
ArbBacktrackAllocation(_In_ PARBITER_INSTANCE Arbiter,_Inout_ PARBITER_ALLOCATION_STATE ArbState)152*fec440d8SVadim Galyant ArbBacktrackAllocation(
153*fec440d8SVadim Galyant _In_ PARBITER_INSTANCE Arbiter,
154*fec440d8SVadim Galyant _Inout_ PARBITER_ALLOCATION_STATE ArbState)
155*fec440d8SVadim Galyant {
156*fec440d8SVadim Galyant PAGED_CODE();
157*fec440d8SVadim Galyant
158*fec440d8SVadim Galyant UNIMPLEMENTED;
159*fec440d8SVadim Galyant }
160*fec440d8SVadim Galyant
161*fec440d8SVadim Galyant /* FIXME: the prototype is not correct yet. */
162*fec440d8SVadim Galyant CODE_SEG("PAGE")
163*fec440d8SVadim Galyant NTSTATUS
164*fec440d8SVadim Galyant NTAPI
ArbOverrideConflict(_In_ PARBITER_INSTANCE Arbiter)165*fec440d8SVadim Galyant ArbOverrideConflict(
166*fec440d8SVadim Galyant _In_ PARBITER_INSTANCE Arbiter)
167*fec440d8SVadim Galyant {
168*fec440d8SVadim Galyant PAGED_CODE();
169*fec440d8SVadim Galyant
170*fec440d8SVadim Galyant UNIMPLEMENTED;
171*fec440d8SVadim Galyant return STATUS_NOT_IMPLEMENTED;
172*fec440d8SVadim Galyant }
173*fec440d8SVadim Galyant
174*fec440d8SVadim Galyant CODE_SEG("PAGE")
175*fec440d8SVadim Galyant NTSTATUS
176*fec440d8SVadim Galyant NTAPI
ArbBootAllocation(_In_ PARBITER_INSTANCE Arbiter,_In_ PLIST_ENTRY ArbitrationList)177*fec440d8SVadim Galyant ArbBootAllocation(
178*fec440d8SVadim Galyant _In_ PARBITER_INSTANCE Arbiter,
179*fec440d8SVadim Galyant _In_ PLIST_ENTRY ArbitrationList)
180*fec440d8SVadim Galyant {
181*fec440d8SVadim Galyant PAGED_CODE();
182*fec440d8SVadim Galyant
183*fec440d8SVadim Galyant UNIMPLEMENTED;
184*fec440d8SVadim Galyant return STATUS_NOT_IMPLEMENTED;
185*fec440d8SVadim Galyant }
186*fec440d8SVadim Galyant
187*fec440d8SVadim Galyant /* FIXME: the prototype is not correct yet. */
188*fec440d8SVadim Galyant CODE_SEG("PAGE")
189*fec440d8SVadim Galyant NTSTATUS
190*fec440d8SVadim Galyant NTAPI
ArbQueryConflict(_In_ PARBITER_INSTANCE Arbiter)191*fec440d8SVadim Galyant ArbQueryConflict(
192*fec440d8SVadim Galyant _In_ PARBITER_INSTANCE Arbiter)
193*fec440d8SVadim Galyant {
194*fec440d8SVadim Galyant PAGED_CODE();
195*fec440d8SVadim Galyant
196*fec440d8SVadim Galyant UNIMPLEMENTED;
197*fec440d8SVadim Galyant return STATUS_NOT_IMPLEMENTED;
198*fec440d8SVadim Galyant }
199*fec440d8SVadim Galyant
200*fec440d8SVadim Galyant /* FIXME: the prototype is not correct yet. */
201*fec440d8SVadim Galyant CODE_SEG("PAGE")
202*fec440d8SVadim Galyant NTSTATUS
203*fec440d8SVadim Galyant NTAPI
ArbStartArbiter(_In_ PARBITER_INSTANCE Arbiter)204*fec440d8SVadim Galyant ArbStartArbiter(
205*fec440d8SVadim Galyant _In_ PARBITER_INSTANCE Arbiter)
206*fec440d8SVadim Galyant {
207*fec440d8SVadim Galyant PAGED_CODE();
208*fec440d8SVadim Galyant
209*fec440d8SVadim Galyant UNIMPLEMENTED;
210*fec440d8SVadim Galyant return STATUS_NOT_IMPLEMENTED;
211*fec440d8SVadim Galyant }
212*fec440d8SVadim Galyant
213*fec440d8SVadim Galyant CODE_SEG("PAGE")
214*fec440d8SVadim Galyant NTSTATUS
215*fec440d8SVadim Galyant NTAPI
ArbAddOrdering(_Out_ PARBITER_ORDERING_LIST OrderList,_In_ UINT64 MinimumAddress,_In_ UINT64 MaximumAddress)216*fec440d8SVadim Galyant ArbAddOrdering(
217*fec440d8SVadim Galyant _Out_ PARBITER_ORDERING_LIST OrderList,
218*fec440d8SVadim Galyant _In_ UINT64 MinimumAddress,
219*fec440d8SVadim Galyant _In_ UINT64 MaximumAddress)
220*fec440d8SVadim Galyant {
221*fec440d8SVadim Galyant PAGED_CODE();
222*fec440d8SVadim Galyant
223*fec440d8SVadim Galyant UNIMPLEMENTED;
224*fec440d8SVadim Galyant return STATUS_NOT_IMPLEMENTED;
225*fec440d8SVadim Galyant }
226*fec440d8SVadim Galyant
227*fec440d8SVadim Galyant CODE_SEG("PAGE")
228*fec440d8SVadim Galyant NTSTATUS
229*fec440d8SVadim Galyant NTAPI
ArbPruneOrdering(_Out_ PARBITER_ORDERING_LIST OrderingList,_In_ UINT64 MinimumAddress,_In_ UINT64 MaximumAddress)230*fec440d8SVadim Galyant ArbPruneOrdering(
231*fec440d8SVadim Galyant _Out_ PARBITER_ORDERING_LIST OrderingList,
232*fec440d8SVadim Galyant _In_ UINT64 MinimumAddress,
233*fec440d8SVadim Galyant _In_ UINT64 MaximumAddress)
234*fec440d8SVadim Galyant {
235*fec440d8SVadim Galyant PAGED_CODE();
236*fec440d8SVadim Galyant
237*fec440d8SVadim Galyant UNIMPLEMENTED;
238*fec440d8SVadim Galyant return STATUS_NOT_IMPLEMENTED;
239*fec440d8SVadim Galyant }
240*fec440d8SVadim Galyant
241*fec440d8SVadim Galyant CODE_SEG("PAGE")
242*fec440d8SVadim Galyant NTSTATUS
243*fec440d8SVadim Galyant NTAPI
ArbInitializeOrderingList(_Out_ PARBITER_ORDERING_LIST OrderList)244*fec440d8SVadim Galyant ArbInitializeOrderingList(
245*fec440d8SVadim Galyant _Out_ PARBITER_ORDERING_LIST OrderList)
246*fec440d8SVadim Galyant {
247*fec440d8SVadim Galyant PAGED_CODE();
248*fec440d8SVadim Galyant
249*fec440d8SVadim Galyant UNIMPLEMENTED;
250*fec440d8SVadim Galyant return STATUS_NOT_IMPLEMENTED;
251*fec440d8SVadim Galyant }
252*fec440d8SVadim Galyant
253*fec440d8SVadim Galyant CODE_SEG("PAGE")
254*fec440d8SVadim Galyant VOID
255*fec440d8SVadim Galyant NTAPI
ArbFreeOrderingList(_Out_ PARBITER_ORDERING_LIST OrderList)256*fec440d8SVadim Galyant ArbFreeOrderingList(
257*fec440d8SVadim Galyant _Out_ PARBITER_ORDERING_LIST OrderList)
258*fec440d8SVadim Galyant {
259*fec440d8SVadim Galyant PAGED_CODE();
260*fec440d8SVadim Galyant
261*fec440d8SVadim Galyant UNIMPLEMENTED;
262*fec440d8SVadim Galyant }
263*fec440d8SVadim Galyant
264*fec440d8SVadim Galyant CODE_SEG("PAGE")
265*fec440d8SVadim Galyant NTSTATUS
266*fec440d8SVadim Galyant NTAPI
ArbBuildAssignmentOrdering(_Inout_ PARBITER_INSTANCE ArbInstance,_In_ PCWSTR OrderName,_In_ PCWSTR ReservedOrderName,_In_ PARB_TRANSLATE_ORDERING TranslateOrderingFunction)267*fec440d8SVadim Galyant ArbBuildAssignmentOrdering(
268*fec440d8SVadim Galyant _Inout_ PARBITER_INSTANCE ArbInstance,
269*fec440d8SVadim Galyant _In_ PCWSTR OrderName,
270*fec440d8SVadim Galyant _In_ PCWSTR ReservedOrderName,
271*fec440d8SVadim Galyant _In_ PARB_TRANSLATE_ORDERING TranslateOrderingFunction)
272*fec440d8SVadim Galyant {
273*fec440d8SVadim Galyant PAGED_CODE();
274*fec440d8SVadim Galyant
275*fec440d8SVadim Galyant UNIMPLEMENTED;
276*fec440d8SVadim Galyant return STATUS_SUCCESS;
277*fec440d8SVadim Galyant }
278*fec440d8SVadim Galyant
279*fec440d8SVadim Galyant CODE_SEG("PAGE")
280374f2b4dSVadim Galyant NTSTATUS
281374f2b4dSVadim Galyant NTAPI
ArbInitializeArbiterInstance(_Inout_ PARBITER_INSTANCE Arbiter,_In_ PDEVICE_OBJECT BusDeviceObject,_In_ CM_RESOURCE_TYPE ResourceType,_In_ PCWSTR ArbiterName,_In_ PCWSTR OrderName,_In_ PARB_TRANSLATE_ORDERING TranslateOrderingFunction)282374f2b4dSVadim Galyant ArbInitializeArbiterInstance(
283374f2b4dSVadim Galyant _Inout_ PARBITER_INSTANCE Arbiter,
284374f2b4dSVadim Galyant _In_ PDEVICE_OBJECT BusDeviceObject,
285374f2b4dSVadim Galyant _In_ CM_RESOURCE_TYPE ResourceType,
286374f2b4dSVadim Galyant _In_ PCWSTR ArbiterName,
287374f2b4dSVadim Galyant _In_ PCWSTR OrderName,
288374f2b4dSVadim Galyant _In_ PARB_TRANSLATE_ORDERING TranslateOrderingFunction)
289374f2b4dSVadim Galyant {
290374f2b4dSVadim Galyant NTSTATUS Status;
291374f2b4dSVadim Galyant
292*fec440d8SVadim Galyant PAGED_CODE();
293374f2b4dSVadim Galyant
294*fec440d8SVadim Galyant DPRINT("ArbInitializeArbiterInstance: '%S'\n", ArbiterName);
295*fec440d8SVadim Galyant
296*fec440d8SVadim Galyant ASSERT(Arbiter->UnpackRequirement != NULL);
297*fec440d8SVadim Galyant ASSERT(Arbiter->PackResource != NULL);
298*fec440d8SVadim Galyant ASSERT(Arbiter->UnpackResource != NULL);
299*fec440d8SVadim Galyant ASSERT(Arbiter->MutexEvent == NULL);
300*fec440d8SVadim Galyant ASSERT(Arbiter->Allocation == NULL);
301*fec440d8SVadim Galyant ASSERT(Arbiter->PossibleAllocation == NULL);
302*fec440d8SVadim Galyant ASSERT(Arbiter->AllocationStack == NULL);
303*fec440d8SVadim Galyant
304*fec440d8SVadim Galyant Arbiter->Signature = ARBITER_SIGNATURE;
305*fec440d8SVadim Galyant Arbiter->BusDeviceObject = BusDeviceObject;
306*fec440d8SVadim Galyant
307*fec440d8SVadim Galyant Arbiter->MutexEvent = ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), TAG_ARBITER);
308*fec440d8SVadim Galyant if (!Arbiter->MutexEvent)
309*fec440d8SVadim Galyant {
310*fec440d8SVadim Galyant DPRINT1("ArbInitializeArbiterInstance: STATUS_INSUFFICIENT_RESOURCES\n");
311*fec440d8SVadim Galyant return STATUS_INSUFFICIENT_RESOURCES;
312374f2b4dSVadim Galyant }
313374f2b4dSVadim Galyant
314*fec440d8SVadim Galyant KeInitializeEvent(Arbiter->MutexEvent, SynchronizationEvent, TRUE);
315*fec440d8SVadim Galyant
316*fec440d8SVadim Galyant Arbiter->AllocationStack = ExAllocatePoolWithTag(PagedPool, PAGE_SIZE, TAG_ARB_ALLOCATION);
317*fec440d8SVadim Galyant if (!Arbiter->AllocationStack)
318*fec440d8SVadim Galyant {
319*fec440d8SVadim Galyant DPRINT1("ArbInitializeArbiterInstance: STATUS_INSUFFICIENT_RESOURCES\n");
320*fec440d8SVadim Galyant ExFreePoolWithTag(Arbiter->MutexEvent, TAG_ARBITER);
321*fec440d8SVadim Galyant return STATUS_INSUFFICIENT_RESOURCES;
322*fec440d8SVadim Galyant }
323*fec440d8SVadim Galyant
324*fec440d8SVadim Galyant Arbiter->AllocationStackMaxSize = PAGE_SIZE;
325*fec440d8SVadim Galyant
326*fec440d8SVadim Galyant Arbiter->Allocation = ExAllocatePoolWithTag(PagedPool, sizeof(RTL_RANGE_LIST), TAG_ARB_RANGE);
327*fec440d8SVadim Galyant if (!Arbiter->Allocation)
328*fec440d8SVadim Galyant {
329*fec440d8SVadim Galyant DPRINT1("ArbInitializeArbiterInstance: STATUS_INSUFFICIENT_RESOURCES\n");
330*fec440d8SVadim Galyant ExFreePoolWithTag(Arbiter->AllocationStack, TAG_ARB_ALLOCATION);
331*fec440d8SVadim Galyant ExFreePoolWithTag(Arbiter->MutexEvent, TAG_ARBITER);
332*fec440d8SVadim Galyant return STATUS_INSUFFICIENT_RESOURCES;
333*fec440d8SVadim Galyant }
334*fec440d8SVadim Galyant
335*fec440d8SVadim Galyant Arbiter->PossibleAllocation = ExAllocatePoolWithTag(PagedPool, sizeof(RTL_RANGE_LIST), TAG_ARB_RANGE);
336*fec440d8SVadim Galyant if (!Arbiter->PossibleAllocation)
337*fec440d8SVadim Galyant {
338*fec440d8SVadim Galyant DPRINT1("ArbInitializeArbiterInstance: STATUS_INSUFFICIENT_RESOURCES\n");
339*fec440d8SVadim Galyant ExFreePoolWithTag(Arbiter->Allocation, TAG_ARB_RANGE);
340*fec440d8SVadim Galyant ExFreePoolWithTag(Arbiter->AllocationStack, TAG_ARB_ALLOCATION);
341*fec440d8SVadim Galyant ExFreePoolWithTag(Arbiter->MutexEvent, TAG_ARBITER);
342*fec440d8SVadim Galyant return STATUS_INSUFFICIENT_RESOURCES;
343*fec440d8SVadim Galyant }
344*fec440d8SVadim Galyant
345*fec440d8SVadim Galyant RtlInitializeRangeList(Arbiter->Allocation);
346*fec440d8SVadim Galyant RtlInitializeRangeList(Arbiter->PossibleAllocation);
347*fec440d8SVadim Galyant
348*fec440d8SVadim Galyant Arbiter->Name = ArbiterName;
349*fec440d8SVadim Galyant Arbiter->ResourceType = ResourceType;
350*fec440d8SVadim Galyant Arbiter->TransactionInProgress = FALSE;
351*fec440d8SVadim Galyant
352*fec440d8SVadim Galyant if (!Arbiter->TestAllocation)
353*fec440d8SVadim Galyant Arbiter->TestAllocation = ArbTestAllocation;
354*fec440d8SVadim Galyant
355*fec440d8SVadim Galyant if (!Arbiter->RetestAllocation)
356*fec440d8SVadim Galyant Arbiter->RetestAllocation = ArbRetestAllocation;
357*fec440d8SVadim Galyant
358*fec440d8SVadim Galyant if (!Arbiter->CommitAllocation)
359*fec440d8SVadim Galyant Arbiter->CommitAllocation = ArbCommitAllocation;
360*fec440d8SVadim Galyant
361*fec440d8SVadim Galyant if (!Arbiter->RollbackAllocation)
362*fec440d8SVadim Galyant Arbiter->RollbackAllocation = ArbRollbackAllocation;
363*fec440d8SVadim Galyant
364*fec440d8SVadim Galyant if (!Arbiter->AddReserved)
365*fec440d8SVadim Galyant Arbiter->AddReserved = ArbAddReserved;
366*fec440d8SVadim Galyant
367*fec440d8SVadim Galyant if (!Arbiter->PreprocessEntry)
368*fec440d8SVadim Galyant Arbiter->PreprocessEntry = ArbPreprocessEntry;
369*fec440d8SVadim Galyant
370*fec440d8SVadim Galyant if (!Arbiter->AllocateEntry)
371*fec440d8SVadim Galyant Arbiter->AllocateEntry = ArbAllocateEntry;
372*fec440d8SVadim Galyant
373*fec440d8SVadim Galyant if (!Arbiter->GetNextAllocationRange)
374*fec440d8SVadim Galyant Arbiter->GetNextAllocationRange = ArbGetNextAllocationRange;
375*fec440d8SVadim Galyant
376*fec440d8SVadim Galyant if (!Arbiter->FindSuitableRange)
377*fec440d8SVadim Galyant Arbiter->FindSuitableRange = ArbFindSuitableRange;
378*fec440d8SVadim Galyant
379*fec440d8SVadim Galyant if (!Arbiter->AddAllocation)
380*fec440d8SVadim Galyant Arbiter->AddAllocation = ArbAddAllocation;
381*fec440d8SVadim Galyant
382*fec440d8SVadim Galyant if (!Arbiter->BacktrackAllocation)
383*fec440d8SVadim Galyant Arbiter->BacktrackAllocation = ArbBacktrackAllocation;
384*fec440d8SVadim Galyant
385*fec440d8SVadim Galyant if (!Arbiter->OverrideConflict)
386*fec440d8SVadim Galyant Arbiter->OverrideConflict = ArbOverrideConflict;
387*fec440d8SVadim Galyant
388*fec440d8SVadim Galyant if (!Arbiter->BootAllocation)
389*fec440d8SVadim Galyant Arbiter->BootAllocation = ArbBootAllocation;
390*fec440d8SVadim Galyant
391*fec440d8SVadim Galyant if (!Arbiter->QueryConflict)
392*fec440d8SVadim Galyant Arbiter->QueryConflict = ArbQueryConflict;
393*fec440d8SVadim Galyant
394*fec440d8SVadim Galyant if (!Arbiter->StartArbiter)
395*fec440d8SVadim Galyant Arbiter->StartArbiter = ArbStartArbiter;
396*fec440d8SVadim Galyant
397*fec440d8SVadim Galyant Status = ArbBuildAssignmentOrdering(Arbiter, OrderName, OrderName, TranslateOrderingFunction);
398*fec440d8SVadim Galyant if (NT_SUCCESS(Status))
399*fec440d8SVadim Galyant {
400*fec440d8SVadim Galyant return STATUS_SUCCESS;
401*fec440d8SVadim Galyant }
402*fec440d8SVadim Galyant
403*fec440d8SVadim Galyant DPRINT1("ArbInitializeArbiterInstance: Status %X\n", Status);
404*fec440d8SVadim Galyant
405*fec440d8SVadim Galyant return Status;
406*fec440d8SVadim Galyant }
407