ReactOS 0.4.17-dev-806-gffa4164
pnpinit.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for pnpinit.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI IopArbPortInitialize (VOID)
 Initialize the RootPortArbiter.
 
NTSTATUS NTAPI IopArbMemInitialize (VOID)
 Initialize the RootMemoryArbiter.
 
NTSTATUS NTAPI IopArbDmaInitialize (VOID)
 Initialize the RootDmaArbiter.
 
NTSTATUS NTAPI IopArbIrqInitialize (VOID)
 Initialize the root IRQ arbiter.
 
NTSTATUS NTAPI IopArbBusNumberInitialize (VOID)
 Initialize the RootBusArbiter.
 
INTERFACE_TYPE NTAPI IopDetermineDefaultInterfaceType (VOID)
 
NTSTATUS NTAPI IopInitializeArbiters (VOID)
 
NTSTATUS NTAPI PiInitCacheGroupInformation (VOID)
 
USHORT NTAPI PpInitGetGroupOrderIndex (IN HANDLE ServiceHandle)
 
USHORT NTAPI PipGetDriverTagPriority (IN HANDLE ServiceHandle)
 
NTSTATUS NTAPI IopInitializePlugPlayServices (VOID)
 

Variables

PUNICODE_STRING PiInitGroupOrderTable
 
USHORT PiInitGroupOrderTableCount
 
INTERFACE_TYPE PnpDefaultInterfaceType
 
BOOLEAN PnPBootDriversLoaded = FALSE
 
BOOLEAN PnPBootDriversInitialized = FALSE
 
ARBITER_INSTANCE IopRootBusNumberArbiter
 
ARBITER_INSTANCE IopRootIrqArbiter
 
ARBITER_INSTANCE IopRootDmaArbiter
 
ARBITER_INSTANCE IopRootMemArbiter
 
ARBITER_INSTANCE IopRootPortArbiter
 
KEVENT PiEnumerationFinished
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file pnpinit.c.

Function Documentation

◆ IopArbBusNumberInitialize()

NTSTATUS NTAPI IopArbBusNumberInitialize ( VOID  )

Initialize the RootBusArbiter.

The root bus-number arbiter owns the flat 0..255 bus-number space and hands each bridge a sub-range.

Returns
NTSTATUS
Return values
STATUS_SUCCESS
STATUS_UNSUCCESSFUL
STATUS_INSUFFICIENT_RESOURCES

Definition at line 100 of file arbbus.c.

101{
103
104 PAGED_CODE();
105 IopRootBusNumberArbiter.Name = L"RootBusNumber";
110
112 NULL,
115 L"Root",
116 NULL);
117 if (!NT_SUCCESS(Status))
118 {
119 DPRINT1("IopArbBusNumberInitialize: Failed with %X\n", Status);
120 }
121
122 return Status;
123}
#define PAGED_CODE()
ARBITER_INSTANCE IopRootBusNumberArbiter
Definition: pnpinit.c:23
NTSTATUS NTAPI IopArbBusNumberPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
Definition: arbbus.c:41
NTSTATUS NTAPI IopArbBusNumberUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor, _Out_ PUINT64 Start, _Out_ PUINT64 OutLength)
Definition: arbbus.c:59
NTSTATUS NTAPI IopArbBusNumberUnpackRequirements(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _Out_ PUINT64 OutMinimumAddress, _Out_ PUINT64 OutMaximumAddress, _Out_ PUINT64 OutLength, _Out_ PUINT64 OutAlignment)
Definition: arbbus.c:22
INT32 NTAPI IopArbBusNumberScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbbus.c:74
NTSTATUS NTAPI ArbiterLibInitializeInstance(_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:69
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define L(x)
Definition: resources.c:13
Status
Definition: gdiplustypes.h:24
#define CmResourceTypeBusNumber
Definition: restypes.h:109
PARB_UNPACK_RESOURCE UnpackResource
Definition: arbiter.h:312
PARB_SCORE_REQUIREMENT ScoreRequirement
Definition: arbiter.h:313
PARB_UNPACK_REQUIREMENT UnpackRequirement
Definition: arbiter.h:310
PARB_PACK_RESOURCE PackResource
Definition: arbiter.h:311
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by IopInitializeArbiters().

◆ IopArbDmaInitialize()

NTSTATUS NTAPI IopArbDmaInitialize ( VOID  )

Initialize the RootDmaArbiter.

Returns
NTSTATUS
Return values
STATUS_SUCCESS
STATUS_UNSUCCESSFUL
STATUS_INSUFFICIENT_RESOURCES

Definition at line 134 of file arbdma.c.

135{
137
138 PAGED_CODE();
139 IopRootDmaArbiter.Name = L"RootDMA";
145
147 NULL,
150 L"Root",
151 NULL);
152 if (!NT_SUCCESS(Status))
153 {
154 DPRINT1("IopArbDmaInitialize: Failed with %X\n", Status);
155 }
156
157 return Status;
158}
INT32 NTAPI IopArbDmaScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbdma.c:89
NTSTATUS NTAPI IopArbDmaPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
Definition: arbdma.c:41
NTSTATUS NTAPI IopArbDmaUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor, _Out_ PUINT64 Start, _Out_ PUINT64 OutLength)
Definition: arbdma.c:74
static BOOLEAN NTAPI IopArbDmaOverrideConflict(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
The Root DMA arbiter's OverrideConflict: refuses every conflict.
Definition: arbdma.c:112
NTSTATUS NTAPI IopArbDmaUnpackRequirements(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _Out_ PUINT64 OutMinimumAddress, _Out_ PUINT64 OutMaximumAddress, _Out_ PUINT64 OutLength, _Out_ PUINT64 OutAlignment)
Definition: arbdma.c:22
ARBITER_INSTANCE IopRootDmaArbiter
Definition: pnpinit.c:25
#define CmResourceTypeDma
Definition: restypes.h:107
PARB_OVERRIDE_CONFLICT OverrideConflict
Definition: arbiter.h:329

Referenced by IopInitializeArbiters().

◆ IopArbIrqInitialize()

NTSTATUS NTAPI IopArbIrqInitialize ( VOID  )

Initialize the root IRQ arbiter.

This is the fallback that sits at the top of the tree and takes over when no closer arbiter claims the request, e.g root-enumerated / HAL legacy devices (ISA-style, directly under the root), and platforms or boot paths where no bus driver above the device provides an interrupt arbiter (e.g. no ACPI _PRT routing in effect).

In those cases the arbitrated "vectors" are the legacy ISA IRQ lines, which is why IopArbIrqTranslateOrdering maps the ordering table through HalGetInterruptVector for the ISA bus. Otherwise, such devices would have nowhere to arbitrate their interrupts. (So this is purely for legacy PIC + No ACPI)

Returns
NTSTATUS
Return values
STATUS_SUCCESS
STATUS_UNSUCCESSFUL
STATUS_INSUFFICIENT_RESOURCES

Definition at line 149 of file arbirq.c.

150{
152
153 PAGED_CODE();
154
155 IopRootIrqArbiter.Name = L"RootIRQ";
160
162 NULL,
165 L"Root",
167 if (!NT_SUCCESS(Status))
168 {
169 DPRINT1("IopArbIrqInitialize: Failed with %X\n", Status);
170 }
171
172 return Status;
173}
ARBITER_INSTANCE IopRootIrqArbiter
Definition: pnpinit.c:24
NTSTATUS NTAPI IopArbIrqPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
Definition: arbirq.c:41
INT32 NTAPI IopArbIrqScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbirq.c:76
NTSTATUS NTAPI IopArbIrqUnpackRequirements(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _Out_ PUINT64 OutMinimumAddress, _Out_ PUINT64 OutMaximumAddress, _Out_ PUINT64 OutLength, _Out_ PUINT64 OutAlignment)
Definition: arbirq.c:22
NTSTATUS NTAPI IopArbIrqTranslateOrdering(_Out_ PIO_RESOURCE_DESCRIPTOR OutIoDescriptor, _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbirq.c:87
NTSTATUS NTAPI IopArbIrqUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor, _Out_ PUINT64 Start, _Out_ PUINT64 OutLength)
Definition: arbirq.c:61
#define CmResourceTypeInterrupt
Definition: restypes.h:105

Referenced by IopInitializeArbiters().

◆ IopArbMemInitialize()

NTSTATUS NTAPI IopArbMemInitialize ( VOID  )

Initialize the RootMemoryArbiter.

The root memory arbiter owns CPU physical address space and hands each device the MMIO window it decodes. It is the fallback for every device whose memory no closer arbiter claims.

The physical page 0 is reserved with no attributes at all, so that no availability mask can hand it out: the real-mode interrupt vector table and the BIOS data area live there, and a device decoding over them corrupts the machine rather than merely failing.

Returns
NTSTATUS
Return values
STATUS_SUCCESS
STATUS_UNSUCCESSFUL
STATUS_INSUFFICIENT_RESOURCES

Definition at line 415 of file arbmem.c.

416{
418
419 PAGED_CODE();
420
421 IopRootMemArbiter.Name = L"RootMemory";
427
429 NULL,
432 L"Root",
434 if (!NT_SUCCESS(Status))
435 {
436 DPRINT1("IopArbMemInitialize: Failed with %X\n", Status);
437 return Status;
438 }
439
441 if (!NT_SUCCESS(Status))
442 {
443 DPRINT1("IopArbMemInitialize: Reserving page 0 failed with %X\n", Status);
444 }
445
446 return Status;
447}
static NTSTATUS NTAPI IopArbMemPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
Materialises the arbiter's chosen placement as an assigned CM descriptor. The PackResource callback o...
Definition: arbmem.c:186
static NTSTATUS NTAPI IopArbMemTranslateOrdering(_Out_ PIO_RESOURCE_DESCRIPTOR OutIoDescriptor, _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Translates one registry allocation-ordering window from the bus-relative addresses it is written in i...
Definition: arbmem.c:316
static NTSTATUS NTAPI IopArbMemUnpackRequirements(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _Out_ PUINT64 OutMinimumAddress, _Out_ PUINT64 OutMaximumAddress, _Out_ PUINT64 OutLength, _Out_ PUINT64 OutAlignment)
Extracts the placement window from one memory requirement. The UnpackRequirement callback of the Root...
Definition: arbmem.c:136
ARBITER_INSTANCE IopRootMemArbiter
Definition: pnpinit.c:26
static NTSTATUS NTAPI IopArbMemUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor, _Out_ PUINT64 Start, _Out_ PUINT64 OutLength)
Reads the placement back out of an already-assigned descriptor (a firmware boot configuration,...
Definition: arbmem.c:225
static BOOLEAN NTAPI IopArbMemFindSuitableRange(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
The Root Memory arbiter's FindSuitableRange: the engine search, incremented for a device asking to ke...
Definition: arbmem.c:384
static INT32 NTAPI IopArbMemScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Scores how constrained a requirement is: the number of distinct aligned addresses it could be placed ...
Definition: arbmem.c:260
#define ULL(a, b)
Definition: format_msg.c:27
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)
#define CmResourceTypeMemory
Definition: restypes.h:106
PRTL_RANGE_LIST Allocation
Definition: arbiter.h:302
PARB_FIND_SUITABLE_RANGE FindSuitableRange
Definition: arbiter.h:326

Referenced by IopInitializeArbiters().

◆ IopArbPortInitialize()

NTSTATUS NTAPI IopArbPortInitialize ( VOID  )

Initialize the RootPortArbiter.

The root port arbiter owns the 16-bit x86 I/O port space and hands out sub-ranges of it. It is the fallback for every device whose ports no closer arbiter claims: root-enumerated and HAL-reported legacy hardware above all, which is also the hardware that partially decodes its address lines and so needs the aliasing this arbiter adds.

Returns
NTSTATUS
Return values
STATUS_SUCCESS
STATUS_UNSUCCESSFUL
STATUS_INSUFFICIENT_RESOURCES

Definition at line 557 of file arbport.c.

558{
560
561 PAGED_CODE();
562
563 IopRootPortArbiter.Name = L"RootPort";
568
569 /* Port-specific placement: boot-config leniency and ISA decode aliasing. */
573
575 NULL,
578 L"Root",
580 if (!NT_SUCCESS(Status))
581 {
582 DPRINT1("IopArbPortInitialize: Failed with %X\n", Status);
583 }
584
585 return Status;
586}
static VOID NTAPI IopArbPortAddAllocation(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
The Root Port arbiter's AddAllocation: records the granted range in the tentative allocation,...
Definition: arbport.c:455
static VOID NTAPI IopArbPortBacktrackAllocation(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
The Root Port arbiter's BacktrackAllocation: the exact inverse of IopArbPortAddAllocation.
Definition: arbport.c:516
static NTSTATUS NTAPI IopArbPortPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
Materialises the arbiter's chosen placement as an assigned CM descriptor. The PackResource callback o...
Definition: arbport.c:227
static NTSTATUS NTAPI IopArbPortUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor, _Out_ PUINT64 Start, _Out_ PUINT64 OutLength)
Reads the placement back out of an already-assigned descriptor (a firmware boot configuration,...
Definition: arbport.c:266
static NTSTATUS NTAPI IopArbPortTranslateOrdering(_Out_ PIO_RESOURCE_DESCRIPTOR OutIoDescriptor, _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Translates one registry allocation-ordering window from the bus-relative addresses it is written in i...
Definition: arbport.c:358
ARBITER_INSTANCE IopRootPortArbiter
Definition: pnpinit.c:27
static NTSTATUS NTAPI IopArbPortUnpackRequirements(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _Out_ PUINT64 OutMinimumAddress, _Out_ PUINT64 OutMaximumAddress, _Out_ PUINT64 OutLength, _Out_ PUINT64 OutAlignment)
Extracts the placement window from one I/O port requirement. The UnpackRequirement callback of the Ro...
Definition: arbport.c:185
static INT32 NTAPI IopArbPortScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Scores how constrained a requirement is: the number of distinct aligned addresses it could be placed ...
Definition: arbport.c:302
static BOOLEAN NTAPI IopArbPortFindSuitableRange(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
The Root Port arbiter's FindSuitableRange: the engine search, incremented for a device asking to keep...
Definition: arbport.c:426
#define CmResourceTypePort
Definition: restypes.h:104
PARB_ADD_ALLOCATION AddAllocation
Definition: arbiter.h:327
PARB_BACKTRACK_ALLOCATION BacktrackAllocation
Definition: arbiter.h:328

Referenced by IopInitializeArbiters().

◆ IopDetermineDefaultInterfaceType()

INTERFACE_TYPE NTAPI IopDetermineDefaultInterfaceType ( VOID  )

Definition at line 41 of file pnpinit.c.

42{
43 /* FIXME: ReactOS doesn't support MicroChannel yet */
44 return Isa;
45}
@ Isa
Definition: restypes.h:122

Referenced by IopInitializePlugPlayServices().

◆ IopInitializeArbiters()

NTSTATUS NTAPI IopInitializeArbiters ( VOID  )

Definition at line 49 of file pnpinit.c.

50{
52
54 if (!NT_SUCCESS(Status))
55 {
56 DPRINT1("IopArbPortInitialize() return %X\n", Status);
57 return Status;
58 }
59
61 if (!NT_SUCCESS(Status))
62 {
63 DPRINT1("IopArbMemInitialize() return %X\n", Status);
64 return Status;
65 }
66
68 if (!NT_SUCCESS(Status))
69 {
70 DPRINT1("IopArbDmaInitialize() return %X\n", Status);
71 return Status;
72 }
73
75 if (!NT_SUCCESS(Status))
76 {
77 DPRINT1("IopArbIrqInitialize() return %X\n", Status);
78 return Status;
79 }
80
82 if (!NT_SUCCESS(Status))
83 {
84 DPRINT1("IopArbBusNumberInitialize() return %X\n", Status);
85 }
86
87 return Status;
88}
NTSTATUS NTAPI IopArbDmaInitialize(VOID)
Initialize the RootDmaArbiter.
Definition: arbdma.c:134
NTSTATUS NTAPI IopArbPortInitialize(VOID)
Initialize the RootPortArbiter.
Definition: arbport.c:557
NTSTATUS NTAPI IopArbIrqInitialize(VOID)
Initialize the root IRQ arbiter.
Definition: arbirq.c:149
NTSTATUS NTAPI IopArbBusNumberInitialize(VOID)
Initialize the RootBusArbiter.
Definition: arbbus.c:100
NTSTATUS NTAPI IopArbMemInitialize(VOID)
Initialize the RootMemoryArbiter.
Definition: arbmem.c:415

Referenced by IopInitializePlugPlayServices().

◆ IopInitializePlugPlayServices()

NTSTATUS NTAPI IopInitializePlugPlayServices ( VOID  )

Definition at line 287 of file pnpinit.c.

288{
291 HANDLE KeyHandle, EnumHandle, ParentHandle, TreeHandle, ControlHandle;
292 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET");
293 UNICODE_STRING PnpManagerDriverName = RTL_CONSTANT_STRING(DRIVER_ROOT_NAME L"PnpManager");
295
296 /* Initialize locks and such */
301
302 /* Get the default interface */
304
305#if 0 /* FIXME: Dont even try yet! */
306 /* Initialize arbiters */
308 if (!NT_SUCCESS(Status)) return Status;
309#endif
310
311 /* Setup the group cache */
313 if (!NT_SUCCESS(Status)) return Status;
314
315 /* Open the current control set */
317 NULL,
318 &KeyName,
320 if (!NT_SUCCESS(Status)) return Status;
321
322 /* Create the control key */
323 RtlInitUnicodeString(&KeyName, L"Control");
324 Status = IopCreateRegistryKeyEx(&ControlHandle,
325 KeyHandle,
326 &KeyName,
329 &Disposition);
330 if (!NT_SUCCESS(Status)) return Status;
331
332 /* Check if it's a new key */
334 {
335 HANDLE DeviceClassesHandle;
336
337 /* Create the device classes key */
338 RtlInitUnicodeString(&KeyName, L"DeviceClasses");
339 Status = IopCreateRegistryKeyEx(&DeviceClassesHandle,
340 ControlHandle,
341 &KeyName,
344 &Disposition);
345 if (!NT_SUCCESS(Status)) return Status;
346
347 ZwClose(DeviceClassesHandle);
348 }
349
350 ZwClose(ControlHandle);
351
352 /* Create the enum key */
354 Status = IopCreateRegistryKeyEx(&EnumHandle,
355 KeyHandle,
356 &KeyName,
359 &Disposition);
360 if (!NT_SUCCESS(Status)) return Status;
361
362 /* Check if it's a new key */
364 {
365 /* FIXME: DACLs */
366 }
367
368 /* Create the root key */
369 ParentHandle = EnumHandle;
371 Status = IopCreateRegistryKeyEx(&EnumHandle,
372 ParentHandle,
373 &KeyName,
376 &Disposition);
377 NtClose(ParentHandle);
378 if (!NT_SUCCESS(Status)) return Status;
379 NtClose(EnumHandle);
380
381 /* Open the root key now */
382 RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\ENUM");
383 Status = IopOpenRegistryKeyEx(&EnumHandle,
384 NULL,
385 &KeyName,
387 if (NT_SUCCESS(Status))
388 {
389 /* Create the root dev node */
391 Status = IopCreateRegistryKeyEx(&TreeHandle,
392 EnumHandle,
393 &KeyName,
396 NULL);
397 NtClose(EnumHandle);
398 if (NT_SUCCESS(Status)) NtClose(TreeHandle);
399 }
400
401 /* Create the root driver */
402 Status = IoCreateDriver(&PnpManagerDriverName, PnpRootDriverEntry);
403 if (!NT_SUCCESS(Status))
404 {
405 DPRINT1("IoCreateDriverObject() failed\n");
406 KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
407 }
408
409 /* Create the root PDO */
411 0,
412 NULL,
414 0,
415 FALSE,
416 &Pdo);
417 if (!NT_SUCCESS(Status))
418 {
419 DPRINT1("IoCreateDevice() failed\n");
420 KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
421 }
422
423 /* This is a bus enumerated device */
425
426 /* Create the root device node */
428
429 /* Set flags */
432
433 /* Create instance path */
435 {
436 DPRINT1("RtlCreateUnicodeString() failed\n");
437 KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
438 }
439
441
443
444 /* Initialize PnP-Event notification support */
446 if (!NT_SUCCESS(Status)) return Status;
447
448 /* Initialize the Bus Type GUID List */
456 {
457 DPRINT1("Failed to allocate PnP GUID buffer!\n");
458 KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, STATUS_NO_MEMORY, 0, 0, 0);
459 }
461
462 /* Initialize PnP root relations (this is a syncronous operation) */
464
465 /* Launch the firmware mapper */
467 if (!NT_SUCCESS(Status)) return Status;
468
469 /* Close the handle to the control set */
471
472 /* Initialize PnP root relations (this is a syncronous operation) */
474
475 /* We made it */
476 return STATUS_SUCCESS;
477}
DECLSPEC_NORETURN VOID NTAPI KeBugCheckEx(IN ULONG BugCheckCode, IN ULONG_PTR BugCheckParameter1, IN ULONG_PTR BugCheckParameter2, IN ULONG_PTR BugCheckParameter3, IN ULONG_PTR BugCheckParameter4)
Definition: debug.c:485
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define RTL_CONSTANT_STRING(s)
Definition: combase.c:35
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
#define PagedPool
Definition: env_spec_w32.h:308
#define DRIVER_ROOT_NAME
Definition: ldr.h:5
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
#define DNF_ENUMERATED
Definition: iotypes.h:179
@ DeviceNodeStarted
Definition: iotypes.h:547
#define DNF_NO_RESOURCE_REQUIRED
Definition: iotypes.h:183
#define DNF_IDS_QUERIED
Definition: iotypes.h:180
#define DNF_MADEUP
Definition: iotypes.h:175
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1060
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1087
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3429
@ NotificationEvent
NTSTATUS NTAPI IopOpenRegistryKeyEx(PHANDLE KeyHandle, HANDLE ParentKey, PUNICODE_STRING Name, ACCESS_MASK DesiredAccess)
Definition: pnpmgr.c:885
LIST_ENTRY IopDeviceActionRequestList
Definition: devaction.c:46
KSPIN_LOCK IopDeviceActionLock
Definition: devaction.c:49
@ PiActionEnumRootDevices
Definition: io.h:526
NTSTATUS IopInitPlugPlayEvents(VOID)
Definition: plugplay.c:40
VOID PnpRootInitializeDevExtension(VOID)
Definition: pnproot.c:1440
PDEVICE_NODE PipAllocateDeviceNode(IN PDEVICE_OBJECT PhysicalDeviceObject)
KSPIN_LOCK IopDeviceTreeLock
Definition: devnode.c:19
NTSTATUS NTAPI PnpRootDriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
Definition: pnproot.c:1488
NTSTATUS NTAPI IopUpdateRootKey(VOID)
Definition: pnpmap.c:674
NTSTATUS NTAPI IopCreateRegistryKeyEx(OUT PHANDLE Handle, IN HANDLE BaseHandle OPTIONAL, IN PUNICODE_STRING KeyName, IN ACCESS_MASK DesiredAccess, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
PNP_DEVNODE_STATE PiSetDevNodeState(_In_ PDEVICE_NODE DeviceNode, _In_ PNP_DEVNODE_STATE NewState)
Definition: devnode.c:108
IO_BUS_TYPE_GUID_LIST PnpBusTypeGuidList
Definition: pnpmgr.c:27
PDRIVER_OBJECT IopRootDriverObject
Definition: pnpmgr.c:26
VOID PiQueueDeviceAction(_In_ PDEVICE_OBJECT DeviceObject, _In_ DEVICE_ACTION Action, _In_opt_ PKEVENT CompletionEvent, _Out_opt_ NTSTATUS *CompletionStatus)
Queue a device operation to a worker thread.
Definition: devaction.c:2668
PDEVICE_NODE IopRootDeviceNode
Definition: devnode.c:18
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1036
NTSTATUS NTAPI IoCreateDriver(_In_opt_ PUNICODE_STRING DriverName, _In_ PDRIVER_INITIALIZE InitializationFunction)
Definition: driver.c:1591
NTSTATUS NTAPI IopInitializeArbiters(VOID)
Definition: pnpinit.c:49
KEVENT PiEnumerationFinished
Definition: devaction.c:50
INTERFACE_TYPE NTAPI IopDetermineDefaultInterfaceType(VOID)
Definition: pnpinit.c:41
NTSTATUS NTAPI PiInitCacheGroupInformation(VOID)
Definition: pnpinit.c:94
INTERFACE_TYPE PnpDefaultInterfaceType
Definition: pnpinit.c:19
#define FILE_DEVICE_CONTROLLER
Definition: winioctl.h:49
#define REGSTR_VAL_ROOT_DEVNODE
Definition: regstr.h:405
#define REGSTR_KEY_ROOTENUM
Definition: regstr.h:10
#define REGSTR_KEY_ENUM
Definition: regstr.h:9
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG Flags
Definition: iotypes.h:1012
UNICODE_STRING InstancePath
Definition: iotypes.h:1018
ULONG AllocatedCount
Definition: io.h:418
FAST_MUTEX Lock
Definition: io.h:417
#define TAG_PNP_GUIDS
Definition: tag.h:92
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2705
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT Pdo
Definition: wdfminiport.h:72
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
#define DO_BUS_ENUMERATED_DEVICE

Referenced by IoInitSystem().

◆ PiInitCacheGroupInformation()

NTSTATUS NTAPI PiInitCacheGroupInformation ( VOID  )

Definition at line 94 of file pnpinit.c.

95{
98 PKEY_VALUE_FULL_INFORMATION KeyValueInformation;
99 PUNICODE_STRING GroupTable;
100 ULONG Count;
101 UNICODE_STRING GroupString =
102 RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet"
103 L"\\Control\\ServiceGroupOrder");
104
105 /* Open the registry key */
107 NULL,
108 &GroupString,
109 KEY_READ);
110 if (NT_SUCCESS(Status))
111 {
112 /* Get the list */
113 Status = IopGetRegistryValue(KeyHandle, L"List", &KeyValueInformation);
115
116 /* Make sure we got it */
117 if (NT_SUCCESS(Status))
118 {
119 /* Make sure it's valid */
120 if ((KeyValueInformation->Type == REG_MULTI_SZ) &&
121 (KeyValueInformation->DataLength))
122 {
123 /* Convert it to unicode strings */
124 Status = PnpRegMultiSzToUnicodeStrings(KeyValueInformation,
125 &GroupTable,
126 &Count);
127
128 /* Cache it for later */
129 PiInitGroupOrderTable = GroupTable;
131 }
132 else
133 {
134 /* Fail */
136 }
137
138 /* Free the information */
139 ExFreePool(KeyValueInformation);
140 }
141 }
142
143 /* Return status */
144 return Status;
145}
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
int Count
Definition: noreturn.cpp:7
#define KEY_READ
Definition: nt_native.h:1026
#define REG_MULTI_SZ
Definition: nt_native.h:1504
NTSTATUS NTAPI IopGetRegistryValue(IN HANDLE Handle, IN PWSTR ValueName, OUT PKEY_VALUE_FULL_INFORMATION *Information)
Definition: pnpmgr.c:1036
NTSTATUS NTAPI PnpRegMultiSzToUnicodeStrings(IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation, OUT PUNICODE_STRING *UnicodeStringList, OUT PULONG UnicodeStringCount)
Definition: pnputil.c:47
unsigned short USHORT
Definition: pedump.c:61
PUNICODE_STRING PiInitGroupOrderTable
Definition: pnpinit.c:17
USHORT PiInitGroupOrderTableCount
Definition: pnpinit.c:18

Referenced by IopInitializePlugPlayServices().

◆ PipGetDriverTagPriority()

USHORT NTAPI PipGetDriverTagPriority ( IN HANDLE  ServiceHandle)

Definition at line 192 of file pnpinit.c.

193{
196 PKEY_VALUE_FULL_INFORMATION KeyValueInformation = NULL;
197 PKEY_VALUE_FULL_INFORMATION KeyValueInformationTag;
198 PKEY_VALUE_FULL_INFORMATION KeyValueInformationGroupOrderList;
201 PULONG GroupOrder;
202 ULONG Count, Tag = 0;
203 USHORT i = -1;
204 UNICODE_STRING GroupString =
205 RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet"
206 L"\\Control\\ServiceGroupOrder");
207
208 /* Open the key */
210 if (!NT_SUCCESS(Status)) goto Quickie;
211
212 /* Read the group */
213 Status = IopGetRegistryValue(ServiceHandle, L"Group", &KeyValueInformation);
214 if (!NT_SUCCESS(Status)) goto Quickie;
215
216 /* Make sure we have a group */
217 if ((KeyValueInformation->Type == REG_SZ) &&
218 (KeyValueInformation->DataLength))
219 {
220 /* Convert to unicode string */
221 Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset);
222 PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &Group.Length);
223 Group.MaximumLength = (USHORT)KeyValueInformation->DataLength;
224 Group.Buffer = Buffer;
225 }
226
227 /* Now read the tag */
228 Status = IopGetRegistryValue(ServiceHandle, L"Tag", &KeyValueInformationTag);
229 if (!NT_SUCCESS(Status)) goto Quickie;
230
231 /* Make sure we have a tag */
232 if ((KeyValueInformationTag->Type == REG_DWORD) &&
233 (KeyValueInformationTag->DataLength))
234 {
235 /* Read it */
236 Tag = *(PULONG)((ULONG_PTR)KeyValueInformationTag +
237 KeyValueInformationTag->DataOffset);
238 }
239
240 /* We can get rid of this now */
241 ExFreePool(KeyValueInformationTag);
242
243 /* Now let's read the group's tag order */
245 Group.Buffer,
246 &KeyValueInformationGroupOrderList);
247
248 /* We can get rid of this now */
249Quickie:
250 if (KeyValueInformation) ExFreePool(KeyValueInformation);
252 if (!NT_SUCCESS(Status)) return -1;
253
254 /* We're on the success path -- validate the tag order*/
255 if ((KeyValueInformationGroupOrderList->Type == REG_BINARY) &&
256 (KeyValueInformationGroupOrderList->DataLength))
257 {
258 /* Get the order array */
259 GroupOrder = (PULONG)((ULONG_PTR)KeyValueInformationGroupOrderList +
260 KeyValueInformationGroupOrderList->DataOffset);
261
262 /* Get the count */
263 Count = *GroupOrder;
264 ASSERT(((Count + 1) * sizeof(ULONG)) <=
265 KeyValueInformationGroupOrderList->DataLength);
266
267 /* Now loop each tag */
268 GroupOrder++;
269 for (i = 1; i <= Count; i++)
270 {
271 /* If we found it, we're out */
272 if (Tag == *GroupOrder) break;
273
274 /* Try the next one */
275 GroupOrder++;
276 }
277 }
278
279 /* Last buffer to free */
280 ExFreePool(KeyValueInformationGroupOrderList);
281 return i;
282}
@ Group
Definition: help.c:22
Definition: bufpool.h:45
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define REG_SZ
Definition: layer.c:22
#define ASSERT(a)
Definition: mode.c:44
#define REG_BINARY
Definition: nt_native.h:1499
BOOLEAN NTAPI PnpRegSzToString(IN PWCHAR RegSzData, IN ULONG RegSzLength, OUT PUSHORT StringLength OPTIONAL)
Definition: pnputil.c:171
#define REG_DWORD
Definition: sdbapi.c:615
uint32_t * PULONG
Definition: typedefs.h:59
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4071

Referenced by IopInitializeBootDrivers().

◆ PpInitGetGroupOrderIndex()

USHORT NTAPI PpInitGetGroupOrderIndex ( IN HANDLE  ServiceHandle)

Definition at line 149 of file pnpinit.c.

150{
152 PKEY_VALUE_FULL_INFORMATION KeyValueInformation;
153 USHORT i;
156 PAGED_CODE();
157
158 /* Make sure we have a cache */
159 if (!PiInitGroupOrderTable) return -1;
160
161 /* If we don't have a handle, the rest is easy -- return the count */
162 if (!ServiceHandle) return PiInitGroupOrderTableCount + 1;
163
164 /* Otherwise, get the group value */
165 Status = IopGetRegistryValue(ServiceHandle, L"Group", &KeyValueInformation);
167
168 /* Make sure we have a valid string */
169 ASSERT(KeyValueInformation->Type == REG_SZ);
170 ASSERT(KeyValueInformation->DataLength);
171
172 /* Convert to unicode string */
173 Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset);
174 PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &Group.Length);
175 Group.MaximumLength = (USHORT)KeyValueInformation->DataLength;
176 Group.Buffer = Buffer;
177
178 /* Loop the groups */
180 {
181 /* Try to find a match */
183 }
184
185 /* We're done */
186 ExFreePool(KeyValueInformation);
187 return i;
188}
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
for(i=0;i< sizeof(testsuite)/sizeof(testsuite[0]);++i) ok(call_test(testsuite[i].func)

Referenced by IopInitializeBootDrivers().

Variable Documentation

◆ IopRootBusNumberArbiter

ARBITER_INSTANCE IopRootBusNumberArbiter

Definition at line 23 of file pnpinit.c.

Referenced by IopArbBusNumberInitialize().

◆ IopRootDmaArbiter

ARBITER_INSTANCE IopRootDmaArbiter

Definition at line 25 of file pnpinit.c.

Referenced by IopArbDmaInitialize().

◆ IopRootIrqArbiter

ARBITER_INSTANCE IopRootIrqArbiter

Definition at line 24 of file pnpinit.c.

Referenced by IopArbIrqInitialize().

◆ IopRootMemArbiter

ARBITER_INSTANCE IopRootMemArbiter

Definition at line 26 of file pnpinit.c.

Referenced by IopArbMemInitialize().

◆ IopRootPortArbiter

ARBITER_INSTANCE IopRootPortArbiter

Definition at line 27 of file pnpinit.c.

Referenced by IopArbPortInitialize().

◆ PiEnumerationFinished

KEVENT PiEnumerationFinished
extern

◆ PiInitGroupOrderTable

PUNICODE_STRING PiInitGroupOrderTable

Definition at line 17 of file pnpinit.c.

Referenced by PiInitCacheGroupInformation(), and PpInitGetGroupOrderIndex().

◆ PiInitGroupOrderTableCount

USHORT PiInitGroupOrderTableCount

Definition at line 18 of file pnpinit.c.

Referenced by PiInitCacheGroupInformation(), and PpInitGetGroupOrderIndex().

◆ PnPBootDriversInitialized

BOOLEAN PnPBootDriversInitialized = FALSE

Definition at line 21 of file pnpinit.c.

Referenced by IoInitSystem(), PiDevNodeStateMachine(), and PipDeviceActionWorker().

◆ PnPBootDriversLoaded

BOOLEAN PnPBootDriversLoaded = FALSE

Definition at line 20 of file pnpinit.c.

Referenced by IopInitializeBootDrivers(), and PiQueueDeviceAction().

◆ PnpDefaultInterfaceType

INTERFACE_TYPE PnpDefaultInterfaceType

Definition at line 19 of file pnpinit.c.

Referenced by IopInitializePlugPlayServices().