ReactOS  0.4.15-dev-4872-g8a3db97
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 
29 CODE_SEG("PAGE")
31 NTAPI
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 
45 CODE_SEG("PAGE")
47 NTAPI
49  _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
52 {
53  PAGED_CODE();
54 
57 }
58 
59 CODE_SEG("PAGE")
61 NTAPI
66 {
67  PAGED_CODE();
68 
71 }
72 
73 CODE_SEG("PAGE")
74 INT32
75 NTAPI
77  _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
78 {
79  PAGED_CODE();
80 
82  return 0;
83 }
84 
85 #define ARB_MAX_BUS_NUMBER 0xFF
86 
87 CODE_SEG("PAGE")
89 NTAPI
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 
117  (UINT64)(ARB_MAX_BUS_NUMBER + 1),
118  (UINT64)(-1),
119  0,
120  0,
121  NULL,
122  NULL);
123 
124  return Status;
125 }
126 
127 /* Irq arbiter */
128 
129 CODE_SEG("PAGE")
130 NTSTATUS
131 NTAPI
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 
142  return STATUS_NOT_IMPLEMENTED;
143 }
144 
145 CODE_SEG("PAGE")
146 NTSTATUS
147 NTAPI
149  _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
150  _In_ UINT64 Start,
152 {
153  PAGED_CODE();
154 
156  return STATUS_NOT_IMPLEMENTED;
157 }
158 
159 CODE_SEG("PAGE")
160 NTSTATUS
161 NTAPI
165  _Out_ PUINT32 OutLength)
166 {
167  PAGED_CODE();
168 
170  return STATUS_NOT_IMPLEMENTED;
171 }
172 
173 CODE_SEG("PAGE")
174 INT32
175 NTAPI
177  _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
178 {
179  PAGED_CODE();
180 
182  return 0;
183 }
184 
185 CODE_SEG("PAGE")
186 NTSTATUS
187 NTAPI
189  _Out_ PIO_RESOURCE_DESCRIPTOR OutIoDescriptor,
190  _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
191 {
192  PAGED_CODE();
193 
195  return STATUS_NOT_IMPLEMENTED;
196 }
197 
198 CODE_SEG("PAGE")
199 NTSTATUS
200 NTAPI
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 
225 CODE_SEG("PAGE")
226 NTSTATUS
227 NTAPI
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 
238  return STATUS_NOT_IMPLEMENTED;
239 }
240 
241 CODE_SEG("PAGE")
242 NTSTATUS
243 NTAPI
245  _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
246  _In_ UINT64 Start,
248 {
249  PAGED_CODE();
250 
252  return STATUS_NOT_IMPLEMENTED;
253 }
254 
255 CODE_SEG("PAGE")
256 NTSTATUS
257 NTAPI
261  _Out_ PUINT32 OutLength)
262 {
263  PAGED_CODE();
264 
266  return STATUS_NOT_IMPLEMENTED;
267 }
268 
269 CODE_SEG("PAGE")
270 INT32
271 NTAPI
273  _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
274 {
275  PAGED_CODE();
276 
278  return 0;
279 }
280 
281 CODE_SEG("PAGE")
282 NTSTATUS
283 NTAPI
285  _In_ PARBITER_INSTANCE Arbiter)
286 {
287  PAGED_CODE();
288 
290  return STATUS_NOT_IMPLEMENTED;
291 }
292 
293 CODE_SEG("PAGE")
294 NTSTATUS
295 NTAPI
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 
322 CODE_SEG("PAGE")
323 NTSTATUS
324 NTAPI
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 
335  return STATUS_NOT_IMPLEMENTED;
336 }
337 
338 CODE_SEG("PAGE")
339 NTSTATUS
340 NTAPI
342  _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
343  _In_ UINT64 Start,
345 {
346  PAGED_CODE();
347 
349  return STATUS_NOT_IMPLEMENTED;
350 }
351 
352 CODE_SEG("PAGE")
353 NTSTATUS
354 NTAPI
358  _Out_ PUINT32 OutLength)
359 {
360  PAGED_CODE();
361 
363  return STATUS_NOT_IMPLEMENTED;
364 }
365 
366 CODE_SEG("PAGE")
367 INT32
368 NTAPI
370  _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
371 {
372  PAGED_CODE();
373 
375  return 0;
376 }
377 
378 CODE_SEG("PAGE")
379 NTSTATUS
380 NTAPI
382  _Out_ PIO_RESOURCE_DESCRIPTOR OutIoDescriptor,
383  _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
384 {
385  PAGED_CODE();
386 
388  return STATUS_NOT_IMPLEMENTED;
389 }
390 
391 /* Memory arbiter */
392 
393 CODE_SEG("PAGE")
394 BOOLEAN
395 NTAPI
397  _In_ PARBITER_INSTANCE Arbiter,
399 {
400  PAGED_CODE();
401 
403  return FALSE;
404 }
405 
406 CODE_SEG("PAGE")
407 NTSTATUS
408 NTAPI
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 
450 CODE_SEG("PAGE")
451 BOOLEAN
452 NTAPI
454  _In_ PARBITER_INSTANCE Arbiter,
456 {
457  PAGED_CODE();
458 
460  return FALSE;
461 }
462 
463 CODE_SEG("PAGE")
464 VOID
465 NTAPI
467  _In_ PARBITER_INSTANCE Arbiter,
469 {
470  PAGED_CODE();
471 
473 }
474 
475 CODE_SEG("PAGE")
476 VOID
477 NTAPI
479  _In_ PARBITER_INSTANCE Arbiter,
481 {
482  PAGED_CODE();
483 
485 }
486 
487 CODE_SEG("PAGE")
488 NTSTATUS
489 NTAPI
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 }
NTSTATUS NTAPI IopBusNumberUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _Out_ PUINT64 Start, _Out_ PUINT32 Length)
Definition: arbiters.c:62
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
NTSTATUS NTAPI IopIrqTranslateOrdering(_Out_ PIO_RESOURCE_DESCRIPTOR OutIoDescriptor, _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbiters.c:188
NTSTATUS NTAPI IopIrqUnpackRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _Out_ PUINT64 OutMinimumVector, _Out_ PUINT64 OutMaximumVector, _Out_ PUINT32 OutParam1, _Out_ PUINT32 OutParam2)
Definition: arbiters.c:132
#define _Inout_
Definition: ms_sal.h:378
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
#define _Out_
Definition: ms_sal.h:345
NTSTATUS NTAPI IopBusNumberPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
Definition: arbiters.c:48
unsigned int * PUINT32
Definition: basetsd.h:127
NTSTATUS NTAPI IopIrqPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
Definition: arbiters.c:148
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IopDmaPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
Definition: arbiters.c:244
NTSTATUS NTAPI IopPortInitialize(VOID)
Definition: arbiters.c:490
NTSTATUS NTAPI IopDmaUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor, _Out_ PUINT64 Start, _Out_ PUINT32 OutLength)
Definition: arbiters.c:258
ARBITER_INSTANCE IopRootDmaArbiter
Definition: pnpinit.c:31
NTSTATUS NTAPI IopIrqInitialize(VOID)
Definition: arbiters.c:201
ARBITER_INSTANCE IopRootIrqArbiter
Definition: pnpinit.c:30
PARB_ADD_ALLOCATION AddAllocation
Definition: arbiter.h:211
#define CmResourceTypePort
Definition: hwresource.cpp:123
ARBITER_INSTANCE IopRootBusNumberArbiter
Definition: pnpinit.c:29
PRTL_RANGE_LIST Allocation
Definition: arbiter.h:186
return STATUS_NOT_IMPLEMENTED
PARB_BACKTRACK_ALLOCATION BacktrackAllocation
Definition: arbiter.h:212
#define L(x)
Definition: ntvdm.h:50
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
PARB_SCORE_REQUIREMENT ScoreRequirement
Definition: arbiter.h:197
BOOLEAN NTAPI IopPortFindSuitableRange(_In_ PARBITER_INSTANCE Arbiter, _In_ PARBITER_ALLOCATION_STATE State)
Definition: arbiters.c:453
unsigned char BOOLEAN
INT32 NTAPI IopGenericScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbiters.c:369
INT32 NTAPI IopDmaScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbiters.c:272
#define _In_
Definition: ms_sal.h:308
ARBITER_INSTANCE IopRootMemArbiter
Definition: pnpinit.c:32
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)
NTSTATUS NTAPI IopBusNumberInitialize(VOID)
Definition: arbiters.c:90
VOID NTAPI IopPortBacktrackAllocation(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Definition: arbiters.c:478
NTSTATUS NTAPI IopMemInitialize(VOID)
Definition: arbiters.c:409
Status
Definition: gdiplustypes.h:24
PARB_UNPACK_REQUIREMENT UnpackRequirement
Definition: arbiter.h:194
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
INT32 NTAPI IopBusNumberScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbiters.c:76
NTSTATUS NTAPI IopDmaInitialize(VOID)
Definition: arbiters.c:296
VOID NTAPI IopPortAddAllocation(_In_ PARBITER_INSTANCE Arbiter, _In_ PARBITER_ALLOCATION_STATE ArbState)
Definition: arbiters.c:466
NTSTATUS NTAPI IopDmaOverrideConflict(_In_ PARBITER_INSTANCE Arbiter)
Definition: arbiters.c:284
NTSTATUS NTAPI IopGenericTranslateOrdering(_Out_ PIO_RESOURCE_DESCRIPTOR OutIoDescriptor, _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbiters.c:381
Definition: partlist.h:33
NTSTATUS NTAPI IopDmaUnpackRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _Out_ PUINT64 OutMinimumChannel, _Out_ PUINT64 OutMaximumChannel, _Out_ PUINT32 OutParam1, _Out_ PUINT32 OutParam2)
Definition: arbiters.c:228
#define PAGE_SIZE
Definition: env_spec_w32.h:49
PARB_PACK_RESOURCE PackResource
Definition: arbiter.h:195
#define ARB_MAX_BUS_NUMBER
Definition: arbiters.c:85
ARBITER_INSTANCE IopRootPortArbiter
Definition: pnpinit.c:33
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 IopIrqUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor, _Out_ PUINT64 Start, _Out_ PUINT32 OutLength)
Definition: arbiters.c:162
NTSTATUS NTAPI IopGenericUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor, _Out_ PUINT64 Start, _Out_ PUINT32 OutLength)
Definition: arbiters.c:355
#define NULL
Definition: types.h:112
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define DPRINT1
Definition: precomp.h:8
BOOLEAN NTAPI IopMemFindSuitableRange(_In_ PARBITER_INSTANCE Arbiter, _In_ PARBITER_ALLOCATION_STATE State)
Definition: arbiters.c:396
PARB_OVERRIDE_CONFLICT OverrideConflict
Definition: arbiter.h:213
signed int INT32
#define UNIMPLEMENTED
Definition: debug.h:115
#define CmResourceTypeBusNumber
Definition: hwresource.cpp:128
unsigned long long UINT64
#define DPRINT
Definition: sndvol32.h:71
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
PARB_FIND_SUITABLE_RANGE FindSuitableRange
Definition: arbiter.h:210
static CODE_SEG("PAGE")
Definition: isapnp.c:1482
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 IopGenericPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
Definition: arbiters.c:341
unsigned __int64 * PUINT64
Definition: basetsd.h:189
#define CmResourceTypeDma
Definition: hwresource.cpp:126
INT32 NTAPI IopIrqScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbiters.c:176
PARB_UNPACK_RESOURCE UnpackResource
Definition: arbiter.h:196
#define PAGED_CODE()