1 /* $Id: pnproot.c,v 1.9 2002/09/07 15:12:53 chorns Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/io/pnproot.c
6 * PURPOSE: PnP manager root device
7 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
9 * 16/04/2001 CSH Created
12 /* INCLUDES ******************************************************************/
17 #include <internal/debug.h>
20 /* GLOBALS *******************************************************************/
22 #define ENUM_NAME_ROOT L"Root"
24 /* DATA **********************************************************************/
26 typedef struct _PNPROOT_DEVICE
{
27 // Entry on device list
29 // Physical Device Object of device
32 UNICODE_STRING ServiceName
;
34 UNICODE_STRING DeviceID
;
36 UNICODE_STRING InstanceID
;
38 UNICODE_STRING DeviceDescription
;
39 } PNPROOT_DEVICE
, *PPNPROOT_DEVICE
;
47 } PNPROOT_DEVICE_STATE
;
50 typedef struct _PNPROOT_COMMON_DEVICE_EXTENSION
52 // Pointer to device object, this device extension is associated with
53 PDEVICE_OBJECT DeviceObject
;
54 // Wether this device extension is for an FDO or PDO
56 // Wether the device is removed
58 // Current device power state for the device
59 DEVICE_POWER_STATE DevicePowerState
;
60 } __attribute((packed
)) PNPROOT_COMMON_DEVICE_EXTENSION
, *PPNPROOT_COMMON_DEVICE_EXTENSION
;
62 /* Physical Device Object device extension for a child device */
63 typedef struct _PNPROOT_PDO_DEVICE_EXTENSION
66 PNPROOT_COMMON_DEVICE_EXTENSION Common
;
68 UNICODE_STRING DeviceID
;
70 UNICODE_STRING InstanceID
;
71 } __attribute((packed
)) PNPROOT_PDO_DEVICE_EXTENSION
, *PPNPROOT_PDO_DEVICE_EXTENSION
;
73 /* Functional Device Object device extension for the PCI driver device object */
74 typedef struct _PNPROOT_FDO_DEVICE_EXTENSION
77 PNPROOT_COMMON_DEVICE_EXTENSION Common
;
78 // Physical Device Object
80 // Lower device object
82 // Current state of the driver
83 PNPROOT_DEVICE_STATE State
;
84 // Namespace device list
85 LIST_ENTRY DeviceListHead
;
86 // Number of (not removed) devices in device list
87 ULONG DeviceListCount
;
88 // Lock for namespace device list
89 // FIXME: Use fast mutex instead?
90 KSPIN_LOCK DeviceListLock
;
91 } __attribute((packed
)) PNPROOT_FDO_DEVICE_EXTENSION
, *PPNPROOT_FDO_DEVICE_EXTENSION
;
94 PDEVICE_OBJECT PnpRootDeviceObject
;
97 /* FUNCTIONS *****************************************************************/
99 /* Physical Device Object routines */
103 PDEVICE_OBJECT
*PhysicalDeviceObject
)
105 PPNPROOT_PDO_DEVICE_EXTENSION PdoDeviceExtension
;
106 PPNPROOT_FDO_DEVICE_EXTENSION DeviceExtension
;
107 PPNPROOT_DEVICE Device
;
110 /* This function should be obsoleted soon */
114 DeviceExtension
= (PPNPROOT_FDO_DEVICE_EXTENSION
)PnpRootDeviceObject
->DeviceExtension
;
116 Device
= (PPNPROOT_DEVICE
)ExAllocatePool(PagedPool
, sizeof(PNPROOT_DEVICE
));
118 return STATUS_INSUFFICIENT_RESOURCES
;
120 RtlZeroMemory(Device
, sizeof(PNPROOT_DEVICE
));
122 Status
= IoCreateDevice(
123 PnpRootDeviceObject
->DriverObject
,
124 sizeof(PNPROOT_PDO_DEVICE_EXTENSION
),
126 FILE_DEVICE_CONTROLLER
,
130 if (!NT_SUCCESS(Status
)) {
131 DPRINT("IoCreateDevice() failed with status 0x%X\n", Status
);
136 Device
->Pdo
->Flags
|= DO_BUS_ENUMERATED_DEVICE
;
138 Device
->Pdo
->Flags
&= ~DO_DEVICE_INITIALIZING
;
140 //Device->Pdo->Flags |= DO_POWER_PAGABLE;
142 PdoDeviceExtension
= (PPNPROOT_PDO_DEVICE_EXTENSION
)Device
->Pdo
->DeviceExtension
;
144 RtlZeroMemory(PdoDeviceExtension
, sizeof(PNPROOT_PDO_DEVICE_EXTENSION
));
146 PdoDeviceExtension
->Common
.IsFDO
= FALSE
;
148 PdoDeviceExtension
->Common
.DeviceObject
= Device
->Pdo
;
150 PdoDeviceExtension
->Common
.DevicePowerState
= PowerDeviceD0
;
152 if (!IopCreateUnicodeString(
153 &PdoDeviceExtension
->DeviceID
,
159 DPRINT("IopCreateUnicodeString() failed\n");
162 if (!IopCreateUnicodeString(
163 &PdoDeviceExtension
->InstanceID
,
168 DPRINT("IopCreateUnicodeString() failed\n");
171 ExInterlockedInsertTailList(
172 &DeviceExtension
->DeviceListHead
,
174 &DeviceExtension
->DeviceListLock
);
176 DeviceExtension
->DeviceListCount
++;
178 *PhysicalDeviceObject
= Device
->Pdo
;
180 return STATUS_SUCCESS
;
186 IN PDEVICE_OBJECT DeviceObject
,
188 PIO_STACK_LOCATION IrpSp
)
190 PPNPROOT_PDO_DEVICE_EXTENSION DeviceExtension
;
191 UNICODE_STRING String
;
196 DeviceExtension
= (PPNPROOT_PDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
198 // Irp->IoStatus.Information = 0;
200 Status
= STATUS_SUCCESS
;
202 RtlInitUnicodeString(&String
, NULL
);
204 switch (IrpSp
->Parameters
.QueryId
.IdType
) {
205 case BusQueryDeviceID
:
206 Status
= IopCreateUnicodeString(
208 DeviceExtension
->DeviceID
.Buffer
,
211 DPRINT("DeviceID: %S\n", String
.Buffer
);
213 Irp
->IoStatus
.Information
= (ULONG_PTR
)String
.Buffer
;
216 case BusQueryHardwareIDs
:
217 case BusQueryCompatibleIDs
:
218 Status
= STATUS_NOT_IMPLEMENTED
;
221 case BusQueryInstanceID
:
222 Status
= IopCreateUnicodeString(
224 DeviceExtension
->InstanceID
.Buffer
,
227 DPRINT("InstanceID: %S\n", String
.Buffer
);
229 Irp
->IoStatus
.Information
= (ULONG_PTR
)String
.Buffer
;
232 case BusQueryDeviceSerialNumber
:
234 Status
= STATUS_NOT_IMPLEMENTED
;
242 PnpRootPdoPnpControl(
243 PDEVICE_OBJECT DeviceObject
,
246 * FUNCTION: Handle Plug and Play IRPs for the child device
248 * DeviceObject = Pointer to physical device object of the child device
249 * Irp = Pointer to IRP that should be handled
254 PIO_STACK_LOCATION IrpSp
;
259 Status
= Irp
->IoStatus
.Status
;
261 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
263 switch (IrpSp
->MinorFunction
) {
265 case IRP_MN_CANCEL_REMOVE_DEVICE
:
268 case IRP_MN_CANCEL_STOP_DEVICE
:
271 case IRP_MN_DEVICE_USAGE_NOTIFICATION
:
277 case IRP_MN_QUERY_BUS_INFORMATION
:
280 case IRP_MN_QUERY_CAPABILITIES
:
283 case IRP_MN_QUERY_DEVICE_RELATIONS
:
284 /* FIXME: Possibly handle for RemovalRelations */
287 case IRP_MN_QUERY_DEVICE_TEXT
:
290 case IRP_MN_QUERY_ID
:
291 Status
= PdoQueryId(DeviceObject
, Irp
, IrpSp
);
294 case IRP_MN_QUERY_PNP_DEVICE_STATE
:
297 case IRP_MN_QUERY_REMOVE_DEVICE
:
300 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS
:
303 case IRP_MN_QUERY_RESOURCES
:
306 case IRP_MN_QUERY_STOP_DEVICE
:
309 case IRP_MN_REMOVE_DEVICE
:
312 case IRP_MN_SET_LOCK
:
315 case IRP_MN_START_DEVICE
:
318 case IRP_MN_STOP_DEVICE
:
321 case IRP_MN_SURPRISE_REMOVAL
:
325 DPRINT("Unknown IOCTL 0x%X\n", IrpSp
->MinorFunction
);
329 Irp
->IoStatus
.Status
= Status
;
330 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
332 DPRINT("Leaving. Status 0x%X\n", Status
);
338 PnpRootPdoPowerControl(
339 PDEVICE_OBJECT DeviceObject
,
342 * FUNCTION: Handle power management IRPs for the child device
344 * DeviceObject = Pointer to physical device object of the child device
345 * Irp = Pointer to IRP that should be handled
350 PIO_STACK_LOCATION IrpSp
;
355 Status
= Irp
->IoStatus
.Status
;
357 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
359 switch (IrpSp
->MinorFunction
) {
361 DPRINT("Unknown IOCTL 0x%X\n", IrpSp
->MinorFunction
);
365 Irp
->IoStatus
.Status
= Status
;
366 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
368 DPRINT("Leaving. Status 0x%X\n", Status
);
374 /* Functional Device Object routines */
377 PnpRootFdoReadDeviceInfo(
378 PPNPROOT_DEVICE Device
)
380 RTL_QUERY_REGISTRY_TABLE QueryTable
[2];
381 PUNICODE_STRING DeviceDesc
;
382 WCHAR KeyName
[MAX_PATH
];
388 /* Retrieve configuration from Enum key */
390 DeviceDesc
= &Device
->DeviceDescription
;
392 wcscpy(KeyName
, L
"\\Registry\\Machine\\System\\CurrentControlSet\\Enum\\");
393 wcscat(KeyName
, ENUM_NAME_ROOT
);
394 wcscat(KeyName
, L
"\\");
395 wcscat(KeyName
, Device
->ServiceName
.Buffer
);
396 wcscat(KeyName
, L
"\\");
397 wcscat(KeyName
, Device
->InstanceID
.Buffer
);
399 DPRINT("KeyName %S\n", KeyName
);
401 Status
= RtlpGetRegistryHandle(
402 RTL_REGISTRY_ABSOLUTE
,
406 if (!NT_SUCCESS(Status
))
408 DPRINT("RtlpGetRegistryHandle() failed (Status %x)\n", Status
);
412 RtlZeroMemory(QueryTable
, sizeof(QueryTable
));
414 RtlInitUnicodeString(DeviceDesc
, NULL
);
416 QueryTable
[0].Name
= L
"DeviceDesc";
417 QueryTable
[0].Flags
= RTL_QUERY_REGISTRY_DIRECT
;
418 QueryTable
[0].EntryContext
= DeviceDesc
;
420 Status
= RtlQueryRegistryValues(
429 DPRINT("RtlQueryRegistryValues() returned status %x\n", Status
);
431 if (!NT_SUCCESS(Status
))
436 DPRINT("Got device description: %S\n", DeviceDesc
->Buffer
);
438 return STATUS_SUCCESS
;
443 PnpRootFdoEnumerateDevices(
444 PDEVICE_OBJECT DeviceObject
)
446 PPNPROOT_FDO_DEVICE_EXTENSION DeviceExtension
;
447 OBJECT_ATTRIBUTES ObjectAttributes
;
448 PKEY_BASIC_INFORMATION KeyInfo
;
449 UNICODE_STRING KeyName
;
450 PPNPROOT_DEVICE Device
;
451 WCHAR Buffer
[MAX_PATH
];
460 DeviceExtension
= (PPNPROOT_FDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
462 BufferSize
= sizeof(KEY_BASIC_INFORMATION
) + (MAX_PATH
+1) * sizeof(WCHAR
);
463 KeyInfo
= ExAllocatePool(PagedPool
, BufferSize
);
466 return STATUS_INSUFFICIENT_RESOURCES
;
469 RtlInitUnicodeStringFromLiteral(
471 L
"\\Registry\\Machine\\System\\CurrentControlSet\\Enum\\" \
474 InitializeObjectAttributes(
477 OBJ_CASE_INSENSITIVE
,
481 Status
= NtOpenKey(&KeyHandle
, KEY_ALL_ACCESS
, &ObjectAttributes
);
482 if (!NT_SUCCESS(Status
))
484 DPRINT("NtOpenKey() failed (Status %x)\n", Status
);
489 /* FIXME: Disabled due to still using the old method of auto loading drivers e.g.
490 there are more entries in the list than found in the registry as some
491 drivers are passed on the command line */
492 // DeviceExtension->DeviceListCount = 0;
496 Status
= ZwEnumerateKey(
503 if (!NT_SUCCESS(Status
))
505 DPRINT("ZwEnumerateKey() (Status %x)\n", Status
);
509 /* Terminate the string */
510 KeyInfo
->Name
[KeyInfo
->NameLength
/ sizeof(WCHAR
)] = 0;
512 Device
= (PPNPROOT_DEVICE
)ExAllocatePool(PagedPool
, sizeof(PNPROOT_DEVICE
));
519 RtlZeroMemory(Device
, sizeof(PNPROOT_DEVICE
));
521 if (!IopCreateUnicodeString(&Device
->ServiceName
, KeyInfo
->Name
, PagedPool
))
524 DPRINT("IopCreateUnicodeString() failed\n");
527 wcscpy(Buffer
, ENUM_NAME_ROOT
);
528 wcscat(Buffer
, L
"\\");
529 wcscat(Buffer
, KeyInfo
->Name
);
531 if (!IopCreateUnicodeString(&Device
->DeviceID
, Buffer
, PagedPool
))
534 DPRINT("IopCreateUnicodeString() failed\n");
537 DPRINT("Got entry: %S\n", Device
->DeviceID
.Buffer
);
539 if (!IopCreateUnicodeString(
545 DPRINT("IopCreateUnicodeString() failed\n");
548 Status
= PnpRootFdoReadDeviceInfo(Device
);
549 if (!NT_SUCCESS(Status
))
551 DPRINT("PnpRootFdoReadDeviceInfo() failed with status %x\n", Status
);
555 ExInterlockedInsertTailList(
556 &DeviceExtension
->DeviceListHead
,
558 &DeviceExtension
->DeviceListLock
);
560 DeviceExtension
->DeviceListCount
++;
565 DPRINT("Entries found: %d\n", Index
);
571 return STATUS_SUCCESS
;
576 PnpRootQueryBusRelations(
577 IN PDEVICE_OBJECT DeviceObject
,
579 IN PIO_STACK_LOCATION IrpSp
)
581 PPNPROOT_PDO_DEVICE_EXTENSION PdoDeviceExtension
;
582 PPNPROOT_FDO_DEVICE_EXTENSION DeviceExtension
;
583 PDEVICE_RELATIONS Relations
;
584 PLIST_ENTRY CurrentEntry
;
585 PPNPROOT_DEVICE Device
;
592 Status
= PnpRootFdoEnumerateDevices(DeviceObject
);
593 if (!NT_SUCCESS(Status
))
596 DeviceExtension
= (PPNPROOT_FDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
598 if (Irp
->IoStatus
.Information
)
600 /* FIXME: Another bus driver has already created a DEVICE_RELATIONS
601 structure so we must merge this structure with our own */
604 Size
= sizeof(DEVICE_RELATIONS
) + sizeof(Relations
->Objects
) *
605 (DeviceExtension
->DeviceListCount
- 1);
607 Relations
= (PDEVICE_RELATIONS
)ExAllocatePool(PagedPool
, Size
);
609 return STATUS_INSUFFICIENT_RESOURCES
;
611 Relations
->Count
= DeviceExtension
->DeviceListCount
;
614 CurrentEntry
= DeviceExtension
->DeviceListHead
.Flink
;
615 while (CurrentEntry
!= &DeviceExtension
->DeviceListHead
)
617 Device
= CONTAINING_RECORD(CurrentEntry
, PNPROOT_DEVICE
, ListEntry
);
621 /* Create a physical device object for the
622 device as it does not already have one */
623 Status
= IoCreateDevice(
624 DeviceObject
->DriverObject
,
625 sizeof(PNPROOT_PDO_DEVICE_EXTENSION
),
627 FILE_DEVICE_CONTROLLER
,
631 if (!NT_SUCCESS(Status
))
633 DPRINT("IoCreateDevice() failed with status 0x%X\n", Status
);
634 ExFreePool(Relations
);
638 DPRINT("Created PDO %x\n", Device
->Pdo
);
640 Device
->Pdo
->Flags
|= DO_BUS_ENUMERATED_DEVICE
;
642 Device
->Pdo
->Flags
&= ~DO_DEVICE_INITIALIZING
;
644 //Device->Pdo->Flags |= DO_POWER_PAGABLE;
646 PdoDeviceExtension
= (PPNPROOT_PDO_DEVICE_EXTENSION
)Device
->Pdo
->DeviceExtension
;
648 RtlZeroMemory(PdoDeviceExtension
, sizeof(PNPROOT_PDO_DEVICE_EXTENSION
));
650 PdoDeviceExtension
->Common
.IsFDO
= FALSE
;
652 PdoDeviceExtension
->Common
.DeviceObject
= Device
->Pdo
;
654 PdoDeviceExtension
->Common
.DevicePowerState
= PowerDeviceD0
;
656 if (!IopCreateUnicodeString(
657 &PdoDeviceExtension
->DeviceID
,
658 Device
->DeviceID
.Buffer
,
661 DPRINT("Insufficient resources\n");
665 DPRINT("DeviceID: %S PDO %x\n",
666 PdoDeviceExtension
->DeviceID
.Buffer
,
669 if (!IopCreateUnicodeString(
670 &PdoDeviceExtension
->InstanceID
,
671 Device
->InstanceID
.Buffer
,
674 DPRINT("Insufficient resources\n");
680 /* Reference the physical device object. The PnP manager
681 will dereference it again when it is no longer needed */
682 ObReferenceObject(Device
->Pdo
);
684 Relations
->Objects
[i
] = Device
->Pdo
;
688 CurrentEntry
= CurrentEntry
->Flink
;
691 if (NT_SUCCESS(Status
))
693 Irp
->IoStatus
.Information
= (ULONG_PTR
)Relations
;
697 Irp
->IoStatus
.Information
= 0;
705 PnpRootQueryDeviceRelations(
706 IN PDEVICE_OBJECT DeviceObject
,
708 IN PIO_STACK_LOCATION IrpSp
)
714 switch (IrpSp
->Parameters
.QueryDeviceRelations
.Type
) {
716 Status
= PnpRootQueryBusRelations(DeviceObject
, Irp
, IrpSp
);
720 Status
= STATUS_NOT_IMPLEMENTED
;
729 PnpRootFdoPnpControl(
730 IN PDEVICE_OBJECT DeviceObject
,
733 * FUNCTION: Handle Plug and Play IRPs for the root bus device object
735 * DeviceObject = Pointer to functional device object of the root bus driver
736 * Irp = Pointer to IRP that should be handled
741 PPNPROOT_FDO_DEVICE_EXTENSION DeviceExtension
;
742 PIO_STACK_LOCATION IrpSp
;
747 DeviceExtension
= (PPNPROOT_FDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
749 Status
= Irp
->IoStatus
.Status
;
751 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
753 switch (IrpSp
->MinorFunction
) {
754 case IRP_MN_QUERY_DEVICE_RELATIONS
:
755 Status
= PnpRootQueryDeviceRelations(DeviceObject
, Irp
, IrpSp
);
758 case IRP_MN_START_DEVICE
:
759 DeviceExtension
->State
= dsStarted
;
760 Status
= STATUS_SUCCESS
;
763 case IRP_MN_STOP_DEVICE
:
764 /* Root device cannot be stopped */
765 Status
= STATUS_UNSUCCESSFUL
;
769 DPRINT("Unknown IOCTL 0x%X\n", IrpSp
->MinorFunction
);
770 Status
= STATUS_NOT_IMPLEMENTED
;
774 if (Status
!= STATUS_PENDING
) {
775 Irp
->IoStatus
.Status
= Status
;
776 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
779 DPRINT("Leaving. Status 0x%X\n", Status
);
787 PnpRootFdoPowerControl(
788 IN PDEVICE_OBJECT DeviceObject
,
791 * FUNCTION: Handle power management IRPs for the root bus device object
793 * DeviceObject = Pointer to functional device object of the root bus driver
794 * Irp = Pointer to IRP that should be handled
799 PIO_STACK_LOCATION IrpSp
;
804 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
806 switch (IrpSp
->MinorFunction
) {
808 DPRINT("Unknown IOCTL 0x%X\n", IrpSp
->MinorFunction
);
809 Status
= STATUS_NOT_IMPLEMENTED
;
813 if (Status
!= STATUS_PENDING
) {
814 Irp
->IoStatus
.Status
= Status
;
815 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
818 DPRINT("Leaving. Status 0x%X\n", Status
);
827 IN PDEVICE_OBJECT DeviceObject
,
830 * FUNCTION: Handle Plug and Play IRPs
832 * DeviceObject = Pointer to PDO or FDO
833 * Irp = Pointer to IRP that should be handled
838 PPNPROOT_COMMON_DEVICE_EXTENSION DeviceExtension
;
841 DeviceExtension
= (PPNPROOT_COMMON_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
843 DPRINT("DeviceObject %x DeviceExtension %x IsFDO %d\n",
846 DeviceExtension
->IsFDO
);
848 if (DeviceExtension
->IsFDO
) {
849 Status
= PnpRootFdoPnpControl(DeviceObject
, Irp
);
851 Status
= PnpRootPdoPnpControl(DeviceObject
, Irp
);
861 IN PDEVICE_OBJECT DeviceObject
,
864 * FUNCTION: Handle power management IRPs
866 * DeviceObject = Pointer to PDO or FDO
867 * Irp = Pointer to IRP that should be handled
872 PPNPROOT_COMMON_DEVICE_EXTENSION DeviceExtension
;
875 DeviceExtension
= (PPNPROOT_COMMON_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
877 if (DeviceExtension
->IsFDO
) {
878 Status
= PnpRootFdoPowerControl(DeviceObject
, Irp
);
880 Status
= PnpRootPdoPowerControl(DeviceObject
, Irp
);
890 IN PDRIVER_OBJECT DriverObject
,
891 IN PDEVICE_OBJECT PhysicalDeviceObject
)
893 PPNPROOT_FDO_DEVICE_EXTENSION DeviceExtension
;
898 Status
= IoCreateDevice(
900 sizeof(PNPROOT_FDO_DEVICE_EXTENSION
),
902 FILE_DEVICE_BUS_EXTENDER
,
903 FILE_DEVICE_SECURE_OPEN
,
905 &PnpRootDeviceObject
);
906 if (!NT_SUCCESS(Status
)) {
907 CPRINT("IoCreateDevice() failed with status 0x%X\n", Status
);
908 KeBugCheck(PHASE1_INITIALIZATION_FAILED
);
911 DeviceExtension
= (PPNPROOT_FDO_DEVICE_EXTENSION
)PnpRootDeviceObject
->DeviceExtension
;
913 RtlZeroMemory(DeviceExtension
, sizeof(PNPROOT_FDO_DEVICE_EXTENSION
));
915 DeviceExtension
->Common
.IsFDO
= TRUE
;
917 DeviceExtension
->State
= dsStopped
;
919 DeviceExtension
->Ldo
= IoAttachDeviceToDeviceStack(
921 PhysicalDeviceObject
);
923 if (!PnpRootDeviceObject
) {
924 CPRINT("PnpRootDeviceObject 0x%X\n", PnpRootDeviceObject
);
925 KeBugCheck(PHASE1_INITIALIZATION_FAILED
);
928 if (!PhysicalDeviceObject
) {
929 CPRINT("PhysicalDeviceObject 0x%X\n", PhysicalDeviceObject
);
930 KeBugCheck(PHASE1_INITIALIZATION_FAILED
);
933 InitializeListHead(&DeviceExtension
->DeviceListHead
);
935 DeviceExtension
->DeviceListCount
= 0;
937 KeInitializeSpinLock(&DeviceExtension
->DeviceListLock
);
939 PnpRootDeviceObject
->Flags
&= ~DO_DEVICE_INITIALIZING
;
941 //PnpRootDeviceObject->Flags |= DO_POWER_PAGABLE;
943 DPRINT("Done AddDevice()\n");
945 return STATUS_SUCCESS
;
952 IN PDRIVER_OBJECT DriverObject
,
953 IN PUNICODE_STRING RegistryPath
)
957 DriverObject
->MajorFunction
[IRP_MJ_PNP
] = (PDRIVER_DISPATCH
) PnpRootPnpControl
;
958 DriverObject
->MajorFunction
[IRP_MJ_POWER
] = (PDRIVER_DISPATCH
) PnpRootPowerControl
;
959 DriverObject
->DriverExtension
->AddDevice
= PnpRootAddDevice
;
961 return STATUS_SUCCESS
;