ReactOS 0.4.15-dev-8222-g9164419
arbiters.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Root arbiters of the PnP manager
5 * COPYRIGHT: Copyright 2020 Vadim Galyant <vgal@rambler.ru>
6 */
7
8/* INCLUDES ******************************************************************/
9
10#include <ntoskrnl.h>
11
12#define NDEBUG
13#include <debug.h>
14
15/* GLOBALS *******************************************************************/
16
22
23/* DATA **********************************************************************/
24
25/* FUNCTIONS *****************************************************************/
26
27/* BusNumber arbiter */
28
29CODE_SEG("PAGE")
33 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
34 _Out_ PUINT64 OutMinimumAddress,
35 _Out_ PUINT64 OutMaximumAddress,
36 _Out_ PUINT32 OutLength,
37 _Out_ PUINT32 OutAlignment)
38{
39 PAGED_CODE();
40
43}
44
45CODE_SEG("PAGE")
49 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
52{
53 PAGED_CODE();
54
57}
58
59CODE_SEG("PAGE")
66{
67 PAGED_CODE();
68
71}
72
73CODE_SEG("PAGE")
77 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
78{
79 PAGED_CODE();
80
82 return 0;
83}
84
85#define ARB_MAX_BUS_NUMBER 0xFF
86
87CODE_SEG("PAGE")
91{
93
94 PAGED_CODE();
95
96 DPRINT("IopRootBusNumberArbiter %p\n", &IopRootBusNumberArbiter);
97
102
104 NULL,
106 L"RootBusNumber",
107 L"Root",
108 NULL);
109 if (!NT_SUCCESS(Status))
110 {
111 DPRINT1("IopBusNumberInitialize: Status %p\n", Status);
112 ASSERT(FALSE);
113 return Status;
114 }
115
118 (UINT64)(-1),
119 0,
120 0,
121 NULL,
122 NULL);
123
124 return Status;
125}
126
127/* Irq arbiter */
128
129CODE_SEG("PAGE")
131NTAPI
133 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
134 _Out_ PUINT64 OutMinimumVector,
135 _Out_ PUINT64 OutMaximumVector,
136 _Out_ PUINT32 OutParam1,
137 _Out_ PUINT32 OutParam2)
138{
139 PAGED_CODE();
140
143}
144
145CODE_SEG("PAGE")
147NTAPI
149 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
152{
153 PAGED_CODE();
154
157}
158
159CODE_SEG("PAGE")
161NTAPI
165 _Out_ PUINT32 OutLength)
166{
167 PAGED_CODE();
168
171}
172
173CODE_SEG("PAGE")
174INT32
175NTAPI
177 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
178{
179 PAGED_CODE();
180
182 return 0;
183}
184
185CODE_SEG("PAGE")
187NTAPI
189 _Out_ PIO_RESOURCE_DESCRIPTOR OutIoDescriptor,
190 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
191{
192 PAGED_CODE();
193
196}
197
198CODE_SEG("PAGE")
200NTAPI
202{
204
205 PAGED_CODE();
206
207 DPRINT("IopRootIrqArbiter %p\n", &IopRootIrqArbiter);
208
213
215 NULL,
217 L"RootIRQ",
218 L"Root",
220 return Status;
221}
222
223/* Dma arbiter */
224
225CODE_SEG("PAGE")
227NTAPI
229 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
230 _Out_ PUINT64 OutMinimumChannel,
231 _Out_ PUINT64 OutMaximumChannel,
232 _Out_ PUINT32 OutParam1,
233 _Out_ PUINT32 OutParam2)
234{
235 PAGED_CODE();
236
239}
240
241CODE_SEG("PAGE")
243NTAPI
245 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
248{
249 PAGED_CODE();
250
253}
254
255CODE_SEG("PAGE")
257NTAPI
261 _Out_ PUINT32 OutLength)
262{
263 PAGED_CODE();
264
267}
268
269CODE_SEG("PAGE")
270INT32
271NTAPI
273 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
274{
275 PAGED_CODE();
276
278 return 0;
279}
280
281CODE_SEG("PAGE")
283NTAPI
285 _In_ PARBITER_INSTANCE Arbiter)
286{
287 PAGED_CODE();
288
291}
292
293CODE_SEG("PAGE")
295NTAPI
297{
299
300 PAGED_CODE();
301
302 DPRINT("IopRootDmaArbiter %p\n", &IopRootDmaArbiter);
303
308
310
312 NULL,
314 L"RootDMA",
315 L"Root",
316 NULL);
317 return Status;
318}
319
320/* Common for Memory and Port arbiters */
321
322CODE_SEG("PAGE")
324NTAPI
326 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
327 _Out_ PUINT64 OutMinimumAddress,
328 _Out_ PUINT64 OutMaximumAddress,
329 _Out_ PUINT32 OutLength,
330 _Out_ PUINT32 OutAlignment)
331{
332 PAGED_CODE();
333
336}
337
338CODE_SEG("PAGE")
340NTAPI
342 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
345{
346 PAGED_CODE();
347
350}
351
352CODE_SEG("PAGE")
354NTAPI
358 _Out_ PUINT32 OutLength)
359{
360 PAGED_CODE();
361
364}
365
366CODE_SEG("PAGE")
367INT32
368NTAPI
370 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
371{
372 PAGED_CODE();
373
375 return 0;
376}
377
378CODE_SEG("PAGE")
380NTAPI
382 _Out_ PIO_RESOURCE_DESCRIPTOR OutIoDescriptor,
383 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
384{
385 PAGED_CODE();
386
389}
390
391/* Memory arbiter */
392
393CODE_SEG("PAGE")
395NTAPI
397 _In_ PARBITER_INSTANCE Arbiter,
399{
400 PAGED_CODE();
401
403 return FALSE;
404}
405
406CODE_SEG("PAGE")
408NTAPI
410{
412
413 PAGED_CODE();
414
415 DPRINT("IopRootMemArbiter %p\n", &IopRootMemArbiter);
416
421
423
425 NULL,
427 L"RootMemory",
428 L"Root",
430 if (!NT_SUCCESS(Status))
431 {
432 DPRINT1("IopMemInitialize: Status %p\n", Status);
433 ASSERT(FALSE);
434 return Status;
435 }
436
438 0,
439 (UINT64)(PAGE_SIZE - 1),
440 0,
441 0,
442 NULL,
443 NULL);
444
445 return Status;
446}
447
448/* Port arbiter */
449
450CODE_SEG("PAGE")
452NTAPI
454 _In_ PARBITER_INSTANCE Arbiter,
456{
457 PAGED_CODE();
458
460 return FALSE;
461}
462
463CODE_SEG("PAGE")
464VOID
465NTAPI
467 _In_ PARBITER_INSTANCE Arbiter,
469{
470 PAGED_CODE();
471
473}
474
475CODE_SEG("PAGE")
476VOID
477NTAPI
479 _In_ PARBITER_INSTANCE Arbiter,
481{
482 PAGED_CODE();
483
485}
486
487CODE_SEG("PAGE")
489NTAPI
491{
493
494 PAGED_CODE();
495
496 DPRINT("IopRootPortArbiter %p\n", &IopRootPortArbiter);
497
502
506
508 NULL,
510 L"RootPort",
511 L"Root",
513 return Status;
514}
#define PAGED_CODE()
#define CODE_SEG(...)
signed int INT32
unsigned char BOOLEAN
unsigned long long UINT64
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: arbiter.c:282
NTSTATUS NTAPI IopPortInitialize(VOID)
Definition: arbiters.c:490
ARBITER_INSTANCE IopRootBusNumberArbiter
Definition: pnpinit.c:23
INT32 NTAPI IopDmaScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbiters.c:272
NTSTATUS NTAPI IopBusNumberUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _Out_ PUINT64 Start, _Out_ PUINT32 Length)
Definition: arbiters.c:62
ARBITER_INSTANCE IopRootIrqArbiter
Definition: pnpinit.c:24
NTSTATUS NTAPI IopGenericTranslateOrdering(_Out_ PIO_RESOURCE_DESCRIPTOR OutIoDescriptor, _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbiters.c:381
NTSTATUS NTAPI IopBusNumberUnpackRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _Out_ PUINT64 OutMinimumAddress, _Out_ PUINT64 OutMaximumAddress, _Out_ PUINT32 OutLength, _Out_ PUINT32 OutAlignment)
Definition: arbiters.c:32
NTSTATUS NTAPI IopDmaPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
Definition: arbiters.c:244
NTSTATUS NTAPI IopGenericPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
Definition: arbiters.c:341
NTSTATUS NTAPI IopDmaOverrideConflict(_In_ PARBITER_INSTANCE Arbiter)
Definition: arbiters.c:284
VOID NTAPI IopPortBacktrackAllocation(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Definition: arbiters.c:478
VOID NTAPI IopPortAddAllocation(_In_ PARBITER_INSTANCE Arbiter, _In_ PARBITER_ALLOCATION_STATE ArbState)
Definition: arbiters.c:466
BOOLEAN NTAPI IopPortFindSuitableRange(_In_ PARBITER_INSTANCE Arbiter, _In_ PARBITER_ALLOCATION_STATE State)
Definition: arbiters.c:453
NTSTATUS NTAPI IopGenericUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor, _Out_ PUINT64 Start, _Out_ PUINT32 OutLength)
Definition: arbiters.c:355
INT32 NTAPI IopBusNumberScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbiters.c:76
#define ARB_MAX_BUS_NUMBER
Definition: arbiters.c:85
NTSTATUS NTAPI IopIrqInitialize(VOID)
Definition: arbiters.c:201
NTSTATUS NTAPI IopGenericUnpackRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _Out_ PUINT64 OutMinimumAddress, _Out_ PUINT64 OutMaximumAddress, _Out_ PUINT32 OutLength, _Out_ PUINT32 OutAlignment)
Definition: arbiters.c:325
NTSTATUS NTAPI IopDmaUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor, _Out_ PUINT64 Start, _Out_ PUINT32 OutLength)
Definition: arbiters.c:258
INT32 NTAPI IopIrqScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbiters.c:176
INT32 NTAPI IopGenericScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbiters.c:369
ARBITER_INSTANCE IopRootPortArbiter
Definition: pnpinit.c:27
ARBITER_INSTANCE IopRootMemArbiter
Definition: pnpinit.c:26
NTSTATUS NTAPI IopDmaInitialize(VOID)
Definition: arbiters.c:296
NTSTATUS NTAPI IopIrqPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
Definition: arbiters.c:148
NTSTATUS NTAPI IopIrqUnpackRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _Out_ PUINT64 OutMinimumVector, _Out_ PUINT64 OutMaximumVector, _Out_ PUINT32 OutParam1, _Out_ PUINT32 OutParam2)
Definition: arbiters.c:132
BOOLEAN NTAPI IopMemFindSuitableRange(_In_ PARBITER_INSTANCE Arbiter, _In_ PARBITER_ALLOCATION_STATE State)
Definition: arbiters.c:396
NTSTATUS NTAPI IopDmaUnpackRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _Out_ PUINT64 OutMinimumChannel, _Out_ PUINT64 OutMaximumChannel, _Out_ PUINT32 OutParam1, _Out_ PUINT32 OutParam2)
Definition: arbiters.c:228
NTSTATUS NTAPI IopIrqTranslateOrdering(_Out_ PIO_RESOURCE_DESCRIPTOR OutIoDescriptor, _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbiters.c:188
NTSTATUS NTAPI IopBusNumberInitialize(VOID)
Definition: arbiters.c:90
NTSTATUS NTAPI IopMemInitialize(VOID)
Definition: arbiters.c:409
NTSTATUS NTAPI IopIrqUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor, _Out_ PUINT64 Start, _Out_ PUINT32 OutLength)
Definition: arbiters.c:162
NTSTATUS NTAPI IopBusNumberPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
Definition: arbiters.c:48
ARBITER_INSTANCE IopRootDmaArbiter
Definition: pnpinit.c:25
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
unsigned int * PUINT32
Definition: basetsd.h:125
unsigned __int64 * PUINT64
Definition: basetsd.h:187
#define UNIMPLEMENTED
Definition: debug.h:118
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Status
Definition: gdiplustypes.h:25
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
#define CmResourceTypeDma
Definition: hwresource.cpp:126
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define CmResourceTypeBusNumber
Definition: hwresource.cpp:128
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define ASSERT(a)
Definition: mode.c:44
#define _Inout_
Definition: ms_sal.h:378
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
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)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define L(x)
Definition: ntvdm.h:50
#define DPRINT
Definition: sndvol32.h:73
PARB_UNPACK_RESOURCE UnpackResource
Definition: arbiter.h:196
PARB_OVERRIDE_CONFLICT OverrideConflict
Definition: arbiter.h:213
PARB_SCORE_REQUIREMENT ScoreRequirement
Definition: arbiter.h:197
PRTL_RANGE_LIST Allocation
Definition: arbiter.h:186
PARB_UNPACK_REQUIREMENT UnpackRequirement
Definition: arbiter.h:194
PARB_FIND_SUITABLE_RANGE FindSuitableRange
Definition: arbiter.h:210
PARB_ADD_ALLOCATION AddAllocation
Definition: arbiter.h:211
PARB_PACK_RESOURCE PackResource
Definition: arbiter.h:195
PARB_BACKTRACK_ALLOCATION BacktrackAllocation
Definition: arbiter.h:212
#define NTAPI
Definition: typedefs.h:36
@ Start
Definition: partlist.h:33
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342