ReactOS  0.4.15-dev-4870-g846c9aa
arbiter.c File Reference
#include <ntifs.h>
#include <ndk/rtlfuncs.h>
#include "arbiter.h"
#include <debug.h>
Include dependency graph for arbiter.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI ArbTestAllocation (_In_ PARBITER_INSTANCE Arbiter, _In_ PLIST_ENTRY ArbitrationList)
 
NTSTATUS NTAPI ArbRetestAllocation (_In_ PARBITER_INSTANCE Arbiter, _In_ PLIST_ENTRY ArbitrationList)
 
NTSTATUS NTAPI ArbCommitAllocation (_In_ PARBITER_INSTANCE Arbiter)
 
NTSTATUS NTAPI ArbRollbackAllocation (_In_ PARBITER_INSTANCE Arbiter)
 
NTSTATUS NTAPI ArbAddReserved (_In_ PARBITER_INSTANCE Arbiter)
 
NTSTATUS NTAPI ArbPreprocessEntry (_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
 
NTSTATUS NTAPI ArbAllocateEntry (_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
 
BOOLEAN NTAPI ArbGetNextAllocationRange (_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
 
BOOLEAN NTAPI ArbFindSuitableRange (_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
 
VOID NTAPI ArbAddAllocation (_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
 
VOID NTAPI ArbBacktrackAllocation (_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
 
NTSTATUS NTAPI ArbOverrideConflict (_In_ PARBITER_INSTANCE Arbiter)
 
NTSTATUS NTAPI ArbBootAllocation (_In_ PARBITER_INSTANCE Arbiter, _In_ PLIST_ENTRY ArbitrationList)
 
NTSTATUS NTAPI ArbQueryConflict (_In_ PARBITER_INSTANCE Arbiter)
 
NTSTATUS NTAPI ArbStartArbiter (_In_ PARBITER_INSTANCE Arbiter)
 
NTSTATUS NTAPI ArbAddOrdering (_Out_ PARBITER_ORDERING_LIST OrderList, _In_ UINT64 MinimumAddress, _In_ UINT64 MaximumAddress)
 
NTSTATUS NTAPI ArbPruneOrdering (_Out_ PARBITER_ORDERING_LIST OrderingList, _In_ UINT64 MinimumAddress, _In_ UINT64 MaximumAddress)
 
NTSTATUS NTAPI ArbInitializeOrderingList (_Out_ PARBITER_ORDERING_LIST OrderList)
 
VOID NTAPI ArbFreeOrderingList (_Out_ PARBITER_ORDERING_LIST OrderList)
 
NTSTATUS NTAPI ArbBuildAssignmentOrdering (_Inout_ PARBITER_INSTANCE ArbInstance, _In_ PCWSTR OrderName, _In_ PCWSTR ReservedOrderName, _In_ PARB_TRANSLATE_ORDERING TranslateOrderingFunction)
 
NTSTATUS 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)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file arbiter.c.

Function Documentation

◆ ArbAddAllocation()

VOID NTAPI ArbAddAllocation ( _In_ PARBITER_INSTANCE  Arbiter,
_Inout_ PARBITER_ALLOCATION_STATE  ArbState 
)

Definition at line 140 of file arbiter.c.

143 {
144  PAGED_CODE();
145 
147 }
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance().

◆ ArbAddOrdering()

NTSTATUS NTAPI ArbAddOrdering ( _Out_ PARBITER_ORDERING_LIST  OrderList,
_In_ UINT64  MinimumAddress,
_In_ UINT64  MaximumAddress 
)

Definition at line 216 of file arbiter.c.

220 {
221  PAGED_CODE();
222 
224  return STATUS_NOT_IMPLEMENTED;
225 }
return STATUS_NOT_IMPLEMENTED
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

◆ ArbAddReserved()

NTSTATUS NTAPI ArbAddReserved ( _In_ PARBITER_INSTANCE  Arbiter)

Definition at line 77 of file arbiter.c.

79 {
80  PAGED_CODE();
81 
84 }
return STATUS_NOT_IMPLEMENTED
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance().

◆ ArbAllocateEntry()

NTSTATUS NTAPI ArbAllocateEntry ( _In_ PARBITER_INSTANCE  Arbiter,
_Inout_ PARBITER_ALLOCATION_STATE  ArbState 
)

Definition at line 101 of file arbiter.c.

104 {
105  PAGED_CODE();
106 
108  return STATUS_NOT_IMPLEMENTED;
109 }
return STATUS_NOT_IMPLEMENTED
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance().

◆ ArbBacktrackAllocation()

VOID NTAPI ArbBacktrackAllocation ( _In_ PARBITER_INSTANCE  Arbiter,
_Inout_ PARBITER_ALLOCATION_STATE  ArbState 
)

Definition at line 152 of file arbiter.c.

155 {
156  PAGED_CODE();
157 
159 }
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance().

◆ ArbBootAllocation()

NTSTATUS NTAPI ArbBootAllocation ( _In_ PARBITER_INSTANCE  Arbiter,
_In_ PLIST_ENTRY  ArbitrationList 
)

Definition at line 177 of file arbiter.c.

180 {
181  PAGED_CODE();
182 
184  return STATUS_NOT_IMPLEMENTED;
185 }
return STATUS_NOT_IMPLEMENTED
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance().

◆ ArbBuildAssignmentOrdering()

NTSTATUS NTAPI ArbBuildAssignmentOrdering ( _Inout_ PARBITER_INSTANCE  ArbInstance,
_In_ PCWSTR  OrderName,
_In_ PCWSTR  ReservedOrderName,
_In_ PARB_TRANSLATE_ORDERING  TranslateOrderingFunction 
)

Definition at line 267 of file arbiter.c.

272 {
273  PAGED_CODE();
274 
276  return STATUS_SUCCESS;
277 }
#define UNIMPLEMENTED
Definition: debug.h:115
#define STATUS_SUCCESS
Definition: shellext.h:65
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance(), and ario_ApplyBrokenVideoHack().

◆ ArbCommitAllocation()

NTSTATUS NTAPI ArbCommitAllocation ( _In_ PARBITER_INSTANCE  Arbiter)

Definition at line 52 of file arbiter.c.

54 {
55  PAGED_CODE();
56 
59 }
return STATUS_NOT_IMPLEMENTED
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance().

◆ ArbFindSuitableRange()

BOOLEAN NTAPI ArbFindSuitableRange ( _In_ PARBITER_INSTANCE  Arbiter,
_Inout_ PARBITER_ALLOCATION_STATE  ArbState 
)

Definition at line 127 of file arbiter.c.

130 {
131  PAGED_CODE();
132 
134  return FALSE;
135 }
#define FALSE
Definition: types.h:117
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance().

◆ ArbFreeOrderingList()

VOID NTAPI ArbFreeOrderingList ( _Out_ PARBITER_ORDERING_LIST  OrderList)

Definition at line 256 of file arbiter.c.

258 {
259  PAGED_CODE();
260 
262 }
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

Referenced by ario_ApplyBrokenVideoHack().

◆ ArbGetNextAllocationRange()

BOOLEAN NTAPI ArbGetNextAllocationRange ( _In_ PARBITER_INSTANCE  Arbiter,
_Inout_ PARBITER_ALLOCATION_STATE  ArbState 
)

Definition at line 114 of file arbiter.c.

117 {
118  PAGED_CODE();
119 
121  return FALSE;
122 }
#define FALSE
Definition: types.h:117
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance().

◆ ArbInitializeArbiterInstance()

NTSTATUS 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 
)

Definition at line 282 of file arbiter.c.

289 {
291 
292  PAGED_CODE();
293 
294  DPRINT("ArbInitializeArbiterInstance: '%S'\n", ArbiterName);
295 
296  ASSERT(Arbiter->UnpackRequirement != NULL);
297  ASSERT(Arbiter->PackResource != NULL);
298  ASSERT(Arbiter->UnpackResource != NULL);
299  ASSERT(Arbiter->MutexEvent == NULL);
300  ASSERT(Arbiter->Allocation == NULL);
301  ASSERT(Arbiter->PossibleAllocation == NULL);
302  ASSERT(Arbiter->AllocationStack == NULL);
303 
304  Arbiter->Signature = ARBITER_SIGNATURE;
305  Arbiter->BusDeviceObject = BusDeviceObject;
306 
307  Arbiter->MutexEvent = ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), TAG_ARBITER);
308  if (!Arbiter->MutexEvent)
309  {
310  DPRINT1("ArbInitializeArbiterInstance: STATUS_INSUFFICIENT_RESOURCES\n");
312  }
313 
314  KeInitializeEvent(Arbiter->MutexEvent, SynchronizationEvent, TRUE);
315 
316  Arbiter->AllocationStack = ExAllocatePoolWithTag(PagedPool, PAGE_SIZE, TAG_ARB_ALLOCATION);
317  if (!Arbiter->AllocationStack)
318  {
319  DPRINT1("ArbInitializeArbiterInstance: STATUS_INSUFFICIENT_RESOURCES\n");
320  ExFreePoolWithTag(Arbiter->MutexEvent, TAG_ARBITER);
322  }
323 
324  Arbiter->AllocationStackMaxSize = PAGE_SIZE;
325 
326  Arbiter->Allocation = ExAllocatePoolWithTag(PagedPool, sizeof(RTL_RANGE_LIST), TAG_ARB_RANGE);
327  if (!Arbiter->Allocation)
328  {
329  DPRINT1("ArbInitializeArbiterInstance: STATUS_INSUFFICIENT_RESOURCES\n");
330  ExFreePoolWithTag(Arbiter->AllocationStack, TAG_ARB_ALLOCATION);
331  ExFreePoolWithTag(Arbiter->MutexEvent, TAG_ARBITER);
333  }
334 
335  Arbiter->PossibleAllocation = ExAllocatePoolWithTag(PagedPool, sizeof(RTL_RANGE_LIST), TAG_ARB_RANGE);
336  if (!Arbiter->PossibleAllocation)
337  {
338  DPRINT1("ArbInitializeArbiterInstance: STATUS_INSUFFICIENT_RESOURCES\n");
339  ExFreePoolWithTag(Arbiter->Allocation, TAG_ARB_RANGE);
340  ExFreePoolWithTag(Arbiter->AllocationStack, TAG_ARB_ALLOCATION);
341  ExFreePoolWithTag(Arbiter->MutexEvent, TAG_ARBITER);
343  }
344 
345  RtlInitializeRangeList(Arbiter->Allocation);
346  RtlInitializeRangeList(Arbiter->PossibleAllocation);
347 
348  Arbiter->Name = ArbiterName;
349  Arbiter->ResourceType = ResourceType;
350  Arbiter->TransactionInProgress = FALSE;
351 
352  if (!Arbiter->TestAllocation)
353  Arbiter->TestAllocation = ArbTestAllocation;
354 
355  if (!Arbiter->RetestAllocation)
356  Arbiter->RetestAllocation = ArbRetestAllocation;
357 
358  if (!Arbiter->CommitAllocation)
359  Arbiter->CommitAllocation = ArbCommitAllocation;
360 
361  if (!Arbiter->RollbackAllocation)
362  Arbiter->RollbackAllocation = ArbRollbackAllocation;
363 
364  if (!Arbiter->AddReserved)
365  Arbiter->AddReserved = ArbAddReserved;
366 
367  if (!Arbiter->PreprocessEntry)
368  Arbiter->PreprocessEntry = ArbPreprocessEntry;
369 
370  if (!Arbiter->AllocateEntry)
371  Arbiter->AllocateEntry = ArbAllocateEntry;
372 
373  if (!Arbiter->GetNextAllocationRange)
374  Arbiter->GetNextAllocationRange = ArbGetNextAllocationRange;
375 
376  if (!Arbiter->FindSuitableRange)
377  Arbiter->FindSuitableRange = ArbFindSuitableRange;
378 
379  if (!Arbiter->AddAllocation)
380  Arbiter->AddAllocation = ArbAddAllocation;
381 
382  if (!Arbiter->BacktrackAllocation)
383  Arbiter->BacktrackAllocation = ArbBacktrackAllocation;
384 
385  if (!Arbiter->OverrideConflict)
386  Arbiter->OverrideConflict = ArbOverrideConflict;
387 
388  if (!Arbiter->BootAllocation)
389  Arbiter->BootAllocation = ArbBootAllocation;
390 
391  if (!Arbiter->QueryConflict)
392  Arbiter->QueryConflict = ArbQueryConflict;
393 
394  if (!Arbiter->StartArbiter)
395  Arbiter->StartArbiter = ArbStartArbiter;
396 
397  Status = ArbBuildAssignmentOrdering(Arbiter, OrderName, OrderName, TranslateOrderingFunction);
398  if (NT_SUCCESS(Status))
399  {
400  return STATUS_SUCCESS;
401  }
402 
403  DPRINT1("ArbInitializeArbiterInstance: Status %X\n", Status);
404 
405  return Status;
406 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
BOOLEAN NTAPI ArbGetNextAllocationRange(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Definition: arbiter.c:114
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI ArbAllocateEntry(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Definition: arbiter.c:101
#define ARBITER_SIGNATURE
Definition: arbiter.h:10
#define TAG_ARBITER
Definition: arbiter.h:11
NTSTATUS NTAPI ArbStartArbiter(_In_ PARBITER_INSTANCE Arbiter)
Definition: arbiter.c:204
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI ArbTestAllocation(_In_ PARBITER_INSTANCE Arbiter, _In_ PLIST_ENTRY ArbitrationList)
Definition: arbiter.c:26
NTSTATUS NTAPI ArbRollbackAllocation(_In_ PARBITER_INSTANCE Arbiter)
Definition: arbiter.c:64
NTSTATUS NTAPI ArbCommitAllocation(_In_ PARBITER_INSTANCE Arbiter)
Definition: arbiter.c:52
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI ArbAddAllocation(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Definition: arbiter.c:140
VOID NTAPI ArbBacktrackAllocation(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Definition: arbiter.c:152
NTSTATUS NTAPI ArbBootAllocation(_In_ PARBITER_INSTANCE Arbiter, _In_ PLIST_ENTRY ArbitrationList)
Definition: arbiter.c:177
NTSTATUS NTAPI ArbQueryConflict(_In_ PARBITER_INSTANCE Arbiter)
Definition: arbiter.c:191
NTSTATUS NTAPI ArbRetestAllocation(_In_ PARBITER_INSTANCE Arbiter, _In_ PLIST_ENTRY ArbitrationList)
Definition: arbiter.c:39
#define TAG_ARB_ALLOCATION
Definition: arbiter.h:12
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS NTAPI ArbBuildAssignmentOrdering(_Inout_ PARBITER_INSTANCE ArbInstance, _In_ PCWSTR OrderName, _In_ PCWSTR ReservedOrderName, _In_ PARB_TRANSLATE_ORDERING TranslateOrderingFunction)
Definition: arbiter.c:267
#define PAGE_SIZE
Definition: env_spec_w32.h:49
NTSTATUS NTAPI ArbAddReserved(_In_ PARBITER_INSTANCE Arbiter)
Definition: arbiter.c:77
#define TAG_ARB_RANGE
Definition: arbiter.h:13
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define NULL
Definition: types.h:112
NTSTATUS NTAPI ArbPreprocessEntry(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Definition: arbiter.c:89
#define DPRINT1
Definition: precomp.h:8
NTSTATUS NTAPI ArbOverrideConflict(_In_ PARBITER_INSTANCE Arbiter)
Definition: arbiter.c:165
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
NTSYSAPI VOID NTAPI RtlInitializeRangeList(_Out_ PRTL_RANGE_LIST RangeList)
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
BOOLEAN NTAPI ArbFindSuitableRange(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Definition: arbiter.c:127
#define PAGED_CODE()

Referenced by arbusno_Initializer(), IopBusNumberInitialize(), IopDmaInitialize(), IopIrqInitialize(), IopMemInitialize(), and IopPortInitialize().

◆ ArbInitializeOrderingList()

NTSTATUS NTAPI ArbInitializeOrderingList ( _Out_ PARBITER_ORDERING_LIST  OrderList)

Definition at line 244 of file arbiter.c.

246 {
247  PAGED_CODE();
248 
250  return STATUS_NOT_IMPLEMENTED;
251 }
return STATUS_NOT_IMPLEMENTED
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

◆ ArbOverrideConflict()

NTSTATUS NTAPI ArbOverrideConflict ( _In_ PARBITER_INSTANCE  Arbiter)

Definition at line 165 of file arbiter.c.

167 {
168  PAGED_CODE();
169 
171  return STATUS_NOT_IMPLEMENTED;
172 }
return STATUS_NOT_IMPLEMENTED
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance().

◆ ArbPreprocessEntry()

NTSTATUS NTAPI ArbPreprocessEntry ( _In_ PARBITER_INSTANCE  Arbiter,
_Inout_ PARBITER_ALLOCATION_STATE  ArbState 
)

Definition at line 89 of file arbiter.c.

92 {
93  PAGED_CODE();
94 
95  return STATUS_SUCCESS;
96 }
#define STATUS_SUCCESS
Definition: shellext.h:65
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance().

◆ ArbPruneOrdering()

NTSTATUS NTAPI ArbPruneOrdering ( _Out_ PARBITER_ORDERING_LIST  OrderingList,
_In_ UINT64  MinimumAddress,
_In_ UINT64  MaximumAddress 
)

Definition at line 230 of file arbiter.c.

234 {
235  PAGED_CODE();
236 
238  return STATUS_NOT_IMPLEMENTED;
239 }
return STATUS_NOT_IMPLEMENTED
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

◆ ArbQueryConflict()

NTSTATUS NTAPI ArbQueryConflict ( _In_ PARBITER_INSTANCE  Arbiter)

Definition at line 191 of file arbiter.c.

193 {
194  PAGED_CODE();
195 
197  return STATUS_NOT_IMPLEMENTED;
198 }
return STATUS_NOT_IMPLEMENTED
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance().

◆ ArbRetestAllocation()

NTSTATUS NTAPI ArbRetestAllocation ( _In_ PARBITER_INSTANCE  Arbiter,
_In_ PLIST_ENTRY  ArbitrationList 
)

Definition at line 39 of file arbiter.c.

42 {
43  PAGED_CODE();
44 
47 }
return STATUS_NOT_IMPLEMENTED
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance().

◆ ArbRollbackAllocation()

NTSTATUS NTAPI ArbRollbackAllocation ( _In_ PARBITER_INSTANCE  Arbiter)

Definition at line 64 of file arbiter.c.

66 {
67  PAGED_CODE();
68 
71 }
return STATUS_NOT_IMPLEMENTED
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance().

◆ ArbStartArbiter()

NTSTATUS NTAPI ArbStartArbiter ( _In_ PARBITER_INSTANCE  Arbiter)

Definition at line 204 of file arbiter.c.

206 {
207  PAGED_CODE();
208 
210  return STATUS_NOT_IMPLEMENTED;
211 }
return STATUS_NOT_IMPLEMENTED
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance().

◆ ArbTestAllocation()

NTSTATUS NTAPI ArbTestAllocation ( _In_ PARBITER_INSTANCE  Arbiter,
_In_ PLIST_ENTRY  ArbitrationList 
)

Definition at line 26 of file arbiter.c.

29 {
30  PAGED_CODE();
31 
34 }
return STATUS_NOT_IMPLEMENTED
#define UNIMPLEMENTED
Definition: debug.h:115
#define PAGED_CODE()

Referenced by ArbInitializeArbiterInstance().