3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: hal/halx86/generic/legacy/halpnpdd.c
5 * PURPOSE: HAL Plug and Play Device Driver
6 * PROGRAMMERS: ReactOS Portable Systems Group
9 /* INCLUDES *******************************************************************/
15 typedef enum _EXTENSION_TYPE
17 PdoExtensionType
= 0xC0,
21 typedef enum _PDO_TYPE
27 typedef struct _FDO_EXTENSION
29 EXTENSION_TYPE ExtensionType
;
30 struct _PDO_EXTENSION
* ChildPdoList
;
31 PDEVICE_OBJECT PhysicalDeviceObject
;
32 PDEVICE_OBJECT FunctionalDeviceObject
;
33 PDEVICE_OBJECT AttachedDeviceObject
;
34 } FDO_EXTENSION
, *PFDO_EXTENSION
;
36 typedef struct _PDO_EXTENSION
38 EXTENSION_TYPE ExtensionType
;
39 struct _PDO_EXTENSION
* Next
;
40 PDEVICE_OBJECT PhysicalDeviceObject
;
41 PFDO_EXTENSION ParentFdoExtension
;
43 PDESCRIPTION_HEADER WdTable
;
44 LONG InterfaceReferenceCount
;
45 } PDO_EXTENSION
, *PPDO_EXTENSION
;
47 /* GLOBALS ********************************************************************/
49 PDRIVER_OBJECT HalpDriverObject
;
51 /* PRIVATE FUNCTIONS **********************************************************/
55 HalpReportDetectedDevices(IN PDRIVER_OBJECT DriverObject
,
59 PFDO_EXTENSION FdoExtension
= Context
;
60 PPDO_EXTENSION PdoExtension
;
61 PDEVICE_OBJECT PdoDeviceObject
;
65 Status
= IoCreateDevice(DriverObject
,
66 sizeof(PDO_EXTENSION
),
68 FILE_DEVICE_BUS_EXTENDER
,
69 FILE_AUTOGENERATED_DEVICE_NAME
,
72 if (!NT_SUCCESS(Status
))
75 DPRINT1("HAL: Could not create ACPI device object status=0x%08x\n", Status
);
79 /* Setup the PDO device extension */
80 PdoExtension
= PdoDeviceObject
->DeviceExtension
;
81 PdoExtension
->ExtensionType
= PdoExtensionType
;
82 PdoExtension
->PhysicalDeviceObject
= PdoDeviceObject
;
83 PdoExtension
->ParentFdoExtension
= FdoExtension
;
84 PdoExtension
->PdoType
= AcpiPdo
;
86 /* Add the PDO to the head of the list */
87 PdoExtension
->Next
= FdoExtension
->ChildPdoList
;
88 FdoExtension
->ChildPdoList
= PdoExtension
;
90 /* Initialization is finished */
91 PdoDeviceObject
->Flags
&= ~DO_DEVICE_INITIALIZING
;
93 /* Invalidate device relations since we added a new device */
94 IoSynchronousInvalidateDeviceRelations(FdoExtension
->PhysicalDeviceObject
, BusRelations
);
99 HalpAddDevice(IN PDRIVER_OBJECT DriverObject
,
100 IN PDEVICE_OBJECT TargetDevice
)
103 PFDO_EXTENSION FdoExtension
;
104 PDEVICE_OBJECT DeviceObject
, AttachedDevice
;
105 // PDESCRIPTION_HEADER Wdrt;
107 DPRINT("HAL: PnP Driver ADD!\n");
110 Status
= IoCreateDevice(DriverObject
,
111 sizeof(FDO_EXTENSION
),
113 FILE_DEVICE_BUS_EXTENDER
,
117 if (!NT_SUCCESS(Status
))
119 /* Should not happen */
124 /* Setup the FDO extension */
125 FdoExtension
= DeviceObject
->DeviceExtension
;
126 FdoExtension
->ExtensionType
= FdoExtensionType
;
127 FdoExtension
->PhysicalDeviceObject
= TargetDevice
;
128 FdoExtension
->FunctionalDeviceObject
= DeviceObject
;
129 FdoExtension
->ChildPdoList
= NULL
;
131 /* FDO is done initializing */
132 DeviceObject
->Flags
&= ~DO_DEVICE_INITIALIZING
;
134 /* Attach to the physical device object (the bus) */
135 AttachedDevice
= IoAttachDeviceToDeviceStack(DeviceObject
, TargetDevice
);
138 /* Failed, undo everything */
139 IoDeleteDevice(DeviceObject
);
140 return STATUS_NO_SUCH_DEVICE
;
143 /* Save the attachment */
144 FdoExtension
->AttachedDeviceObject
= AttachedDevice
;
146 /* Register for reinitialization to report devices later */
147 IoRegisterBootDriverReinitialization(DriverObject
,
148 HalpReportDetectedDevices
,
152 DPRINT("Device added %lx\n", Status
);
158 HalpQueryInterface(IN PDEVICE_OBJECT DeviceObject
,
159 IN CONST GUID
* InterfaceType
,
161 IN PVOID InterfaceSpecificData
,
162 IN ULONG InterfaceBufferSize
,
163 IN PINTERFACE Interface
,
167 return STATUS_NOT_SUPPORTED
;
172 HalpQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject
,
173 IN DEVICE_RELATION_TYPE RelationType
,
174 OUT PDEVICE_RELATIONS
* DeviceRelations
)
176 EXTENSION_TYPE ExtensionType
;
177 PPDO_EXTENSION PdoExtension
;
178 PFDO_EXTENSION FdoExtension
;
179 PDEVICE_RELATIONS PdoRelations
, FdoRelations
;
180 PDEVICE_OBJECT
* ObjectEntry
;
181 ULONG i
= 0, PdoCount
= 0;
183 /* Get FDO device extension and PDO count */
184 FdoExtension
= DeviceObject
->DeviceExtension
;
185 ExtensionType
= FdoExtension
->ExtensionType
;
187 /* What do they want? */
188 if (RelationType
== BusRelations
)
190 /* This better be an FDO */
191 if (ExtensionType
== FdoExtensionType
)
193 /* Count how many PDOs we have */
194 PdoExtension
= FdoExtension
->ChildPdoList
;
198 PdoExtension
= PdoExtension
->Next
;
202 /* Add the PDOs that already exist in the device relations */
203 if (*DeviceRelations
)
205 PdoCount
+= (*DeviceRelations
)->Count
;
208 /* Allocate our structure */
209 FdoRelations
= ExAllocatePoolWithTag(PagedPool
,
210 FIELD_OFFSET(DEVICE_RELATIONS
,
212 sizeof(PDEVICE_OBJECT
) * PdoCount
,
214 if (!FdoRelations
) return STATUS_INSUFFICIENT_RESOURCES
;
217 FdoRelations
->Count
= PdoCount
;
219 /* Query existing relations */
220 ObjectEntry
= FdoRelations
->Objects
;
221 if (*DeviceRelations
)
223 /* Check if there were any */
224 if ((*DeviceRelations
)->Count
)
229 /* Copy into our structure */
230 *ObjectEntry
++ = (*DeviceRelations
)->Objects
[i
];
232 while (++i
< (*DeviceRelations
)->Count
);
235 /* Free existing structure */
236 ExFreePool(*DeviceRelations
);
239 /* Now check if we have a PDO list */
240 PdoExtension
= FdoExtension
->ChildPdoList
;
246 /* Save our own PDO and reference it */
247 *ObjectEntry
++ = PdoExtension
->PhysicalDeviceObject
;
248 ObReferenceObject(PdoExtension
->PhysicalDeviceObject
);
250 /* Go to our next PDO */
251 PdoExtension
= PdoExtension
->Next
;
253 while (PdoExtension
);
256 /* Return the new structure */
257 *DeviceRelations
= FdoRelations
;
258 return STATUS_SUCCESS
;
263 /* The only other thing we support is a target relation for the PDO */
264 if ((RelationType
== TargetDeviceRelation
) &&
265 (ExtensionType
== PdoExtensionType
))
268 PdoRelations
= ExAllocatePoolWithTag(PagedPool
,
269 sizeof(DEVICE_RELATIONS
),
271 if (!PdoRelations
) return STATUS_INSUFFICIENT_RESOURCES
;
273 /* Fill it out and reference us */
274 PdoRelations
->Count
= 1;
275 PdoRelations
->Objects
[0] = DeviceObject
;
276 ObReferenceObject(DeviceObject
);
279 *DeviceRelations
= PdoRelations
;
280 return STATUS_SUCCESS
;
284 /* We don't support anything else */
285 return STATUS_NOT_SUPPORTED
;
290 HalpQueryCapabilities(IN PDEVICE_OBJECT DeviceObject
,
291 OUT PDEVICE_CAPABILITIES Capabilities
)
293 //PPDO_EXTENSION PdoExtension;
297 /* Get the extension and check for valid version */
298 //PdoExtension = DeviceObject->DeviceExtension;
299 ASSERT(Capabilities
->Version
== 1);
300 if (Capabilities
->Version
== 1)
302 /* Can't lock or eject us */
303 Capabilities
->LockSupported
= FALSE
;
304 Capabilities
->EjectSupported
= FALSE
;
306 /* Can't remove or dock us */
307 Capabilities
->Removable
= FALSE
;
308 Capabilities
->DockDevice
= FALSE
;
310 /* Can't access us raw */
311 Capabilities
->RawDeviceOK
= FALSE
;
313 /* We have a unique ID, and don't bother the user */
314 Capabilities
->UniqueID
= TRUE
;
315 Capabilities
->SilentInstall
= TRUE
;
317 /* Fill out the adress */
318 Capabilities
->Address
= InterfaceTypeUndefined
;
319 Capabilities
->UINumber
= InterfaceTypeUndefined
;
321 /* Fill out latencies */
322 Capabilities
->D1Latency
= 0;
323 Capabilities
->D2Latency
= 0;
324 Capabilities
->D3Latency
= 0;
326 /* Fill out supported device states */
327 Capabilities
->DeviceState
[PowerSystemWorking
] = PowerDeviceD0
;
328 Capabilities
->DeviceState
[PowerSystemHibernate
] = PowerDeviceD3
;
329 Capabilities
->DeviceState
[PowerSystemShutdown
] = PowerDeviceD3
;
330 Capabilities
->DeviceState
[PowerSystemSleeping3
] = PowerDeviceD3
;
333 Status
= STATUS_SUCCESS
;
338 Status
= STATUS_NOT_SUPPORTED
;
347 HalpQueryResources(IN PDEVICE_OBJECT DeviceObject
,
348 OUT PCM_RESOURCE_LIST
*Resources
)
350 PPDO_EXTENSION DeviceExtension
= DeviceObject
->DeviceExtension
;
352 PCM_RESOURCE_LIST ResourceList
;
353 // PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
354 // PIO_RESOURCE_DESCRIPTOR Descriptor;
355 // PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDesc;
359 /* Only the ACPI PDO has requirements */
360 if (DeviceExtension
->PdoType
== AcpiPdo
)
363 /* Query ACPI requirements */
364 Status
= HalpQueryAcpiResourceRequirements(&RequirementsList
);
365 if (!NT_SUCCESS(Status
)) return Status
;
367 ASSERT(RequirementsList
->AlternativeLists
== 1);
370 /* Allocate the resourcel ist */
371 ResourceList
= ExAllocatePoolWithTag(PagedPool
,
372 sizeof(CM_RESOURCE_LIST
),
376 /* Fail, no memory */
377 Status
= STATUS_INSUFFICIENT_RESOURCES
;
378 // ExFreePoolWithTag(RequirementsList, TAG_HAL);
383 RtlZeroMemory(ResourceList
, sizeof(CM_RESOURCE_LIST
));
384 ResourceList
->Count
= 1;
386 /* Setup the list fields */
387 ResourceList
->List
[0].BusNumber
= 0;
388 ResourceList
->List
[0].InterfaceType
= PCIBus
;
389 ResourceList
->List
[0].PartialResourceList
.Version
= 1;
390 ResourceList
->List
[0].PartialResourceList
.Revision
= 1;
391 ResourceList
->List
[0].PartialResourceList
.Count
= 0;
393 /* Setup the first descriptor */
394 //PartialDesc = ResourceList->List[0].PartialResourceList.PartialDescriptors;
396 /* Find the requirement descriptor for the SCI */
398 for (i
= 0; i
< RequirementsList
->List
[0].Count
; i
++)
400 /* Get this descriptor */
401 Descriptor
= &RequirementsList
->List
[0].Descriptors
[i
];
402 if (Descriptor
->Type
== CmResourceTypeInterrupt
)
404 /* Copy requirements descriptor into resource descriptor */
405 PartialDesc
->Type
= CmResourceTypeInterrupt
;
406 PartialDesc
->ShareDisposition
= Descriptor
->ShareDisposition
;
407 PartialDesc
->Flags
= Descriptor
->Flags
;
408 ASSERT(Descriptor
->u
.Interrupt
.MinimumVector
==
409 Descriptor
->u
.Interrupt
.MaximumVector
);
410 PartialDesc
->u
.Interrupt
.Vector
= Descriptor
->u
.Interrupt
.MinimumVector
;
411 PartialDesc
->u
.Interrupt
.Level
= Descriptor
->u
.Interrupt
.MinimumVector
;
412 PartialDesc
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
414 ResourceList
->List
[0].PartialResourceList
.Count
++;
421 /* Return resources and success */
422 *Resources
= ResourceList
;
424 // ExFreePoolWithTag(RequirementsList, TAG_HAL);
426 return STATUS_SUCCESS
;
428 else if (DeviceExtension
->PdoType
== WdPdo
)
430 /* Watchdog doesn't */
431 return STATUS_NOT_SUPPORTED
;
435 /* This shouldn't happen */
436 return STATUS_UNSUCCESSFUL
;
442 HalpQueryResourceRequirements(IN PDEVICE_OBJECT DeviceObject
,
443 OUT PIO_RESOURCE_REQUIREMENTS_LIST
*Requirements
)
445 PPDO_EXTENSION DeviceExtension
= DeviceObject
->DeviceExtension
;
448 /* Only the ACPI PDO has requirements */
449 if (DeviceExtension
->PdoType
== AcpiPdo
)
451 /* Query ACPI requirements */
452 // return HalpQueryAcpiResourceRequirements(Requirements);
453 return STATUS_SUCCESS
;
455 else if (DeviceExtension
->PdoType
== WdPdo
)
457 /* Watchdog doesn't */
458 return STATUS_NOT_SUPPORTED
;
462 /* This shouldn't happen */
463 return STATUS_UNSUCCESSFUL
;
469 HalpQueryIdPdo(IN PDEVICE_OBJECT DeviceObject
,
470 IN BUS_QUERY_ID_TYPE IdType
,
471 OUT PUSHORT
*BusQueryId
)
473 PPDO_EXTENSION PdoExtension
;
481 /* Get the PDO type */
482 PdoExtension
= DeviceObject
->DeviceExtension
;
483 PdoType
= PdoExtension
->PdoType
;
485 /* What kind of ID is being requested? */
486 DPRINT("ID: %d\n", IdType
);
489 case BusQueryDeviceID
:
490 case BusQueryHardwareIDs
:
492 /* What kind of PDO is this? */
493 if (PdoType
== AcpiPdo
)
496 CurrentId
= L
"PCI_HAL\\PNP0A03";
497 RtlCopyMemory(Id
, CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
498 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
500 CurrentId
= L
"*PNP0A03";
501 RtlCopyMemory(&Id
[wcslen(Id
) + 1], CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
502 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
505 else if (PdoType
== WdPdo
)
508 CurrentId
= L
"ACPI_HAL\\PNP0C18";
509 RtlCopyMemory(Id
, CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
510 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
512 CurrentId
= L
"*PNP0C18";
513 RtlCopyMemory(&Id
[wcslen(Id
) + 1], CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
514 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
520 return STATUS_NOT_SUPPORTED
;
524 case BusQueryInstanceID
:
528 RtlCopyMemory(Id
, CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
529 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
532 case BusQueryCompatibleIDs
:
535 /* We don't support anything else */
536 return STATUS_NOT_SUPPORTED
;
539 /* Allocate the buffer */
540 Buffer
= ExAllocatePoolWithTag(PagedPool
,
541 Length
+ sizeof(UNICODE_NULL
),
545 /* Copy the string and null-terminate it */
546 RtlCopyMemory(Buffer
, Id
, Length
);
547 Buffer
[Length
/ sizeof(WCHAR
)] = UNICODE_NULL
;
550 *BusQueryId
= Buffer
;
551 Status
= STATUS_SUCCESS
;
552 DPRINT("Returning: %S\n", *BusQueryId
);
557 Status
= STATUS_INSUFFICIENT_RESOURCES
;
566 HalpQueryIdFdo(IN PDEVICE_OBJECT DeviceObject
,
567 IN BUS_QUERY_ID_TYPE IdType
,
568 OUT PUSHORT
*BusQueryId
)
575 /* What kind of ID is being requested? */
576 DPRINT("ID: %d\n", IdType
);
579 case BusQueryDeviceID
:
581 Id
= L
"Root\\PCI_HAL";
584 case BusQueryHardwareIDs
:
586 /* This is our hardware ID */
587 Id
= HalHardwareIdString
;
590 case BusQueryInstanceID
:
592 /* And our instance ID */
598 /* We don't support anything else */
599 return STATUS_NOT_SUPPORTED
;
602 /* Calculate the length */
603 Length
= (wcslen(Id
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
605 /* Allocate the buffer */
606 Buffer
= ExAllocatePoolWithTag(PagedPool
,
607 Length
+ sizeof(UNICODE_NULL
),
611 /* Copy the string and null-terminate it */
612 RtlCopyMemory(Buffer
, Id
, Length
);
613 Buffer
[Length
/ sizeof(WCHAR
)] = UNICODE_NULL
;
616 *BusQueryId
= Buffer
;
617 Status
= STATUS_SUCCESS
;
618 DPRINT("Returning: %S\n", *BusQueryId
);
623 Status
= STATUS_INSUFFICIENT_RESOURCES
;
632 HalpDispatchPnp(IN PDEVICE_OBJECT DeviceObject
,
635 PIO_STACK_LOCATION IoStackLocation
;
636 //PPDO_EXTENSION PdoExtension;
637 PFDO_EXTENSION FdoExtension
;
641 /* Get the device extension and stack location */
642 FdoExtension
= DeviceObject
->DeviceExtension
;
643 IoStackLocation
= IoGetCurrentIrpStackLocation(Irp
);
644 Minor
= IoStackLocation
->MinorFunction
;
647 if (FdoExtension
->ExtensionType
== FdoExtensionType
)
649 /* Query the IRP type */
652 case IRP_MN_QUERY_DEVICE_RELATIONS
:
654 /* Call the worker */
655 DPRINT("Querying device relations for FDO\n");
656 Status
= HalpQueryDeviceRelations(DeviceObject
,
657 IoStackLocation
->Parameters
.QueryDeviceRelations
.Type
,
658 (PVOID
)&Irp
->IoStatus
.Information
);
661 case IRP_MN_QUERY_INTERFACE
:
663 /* Call the worker */
664 DPRINT("Querying interface for FDO\n");
665 Status
= HalpQueryInterface(DeviceObject
,
666 IoStackLocation
->Parameters
.QueryInterface
.InterfaceType
,
667 IoStackLocation
->Parameters
.QueryInterface
.Size
,
668 IoStackLocation
->Parameters
.QueryInterface
.InterfaceSpecificData
,
669 IoStackLocation
->Parameters
.QueryInterface
.Version
,
670 IoStackLocation
->Parameters
.QueryInterface
.Interface
,
671 (PVOID
)&Irp
->IoStatus
.Information
);
674 case IRP_MN_QUERY_ID
:
676 /* Call the worker */
677 DPRINT("Querying ID for FDO\n");
678 Status
= HalpQueryIdFdo(DeviceObject
,
679 IoStackLocation
->Parameters
.QueryId
.IdType
,
680 (PVOID
)&Irp
->IoStatus
.Information
);
683 case IRP_MN_QUERY_CAPABILITIES
:
685 /* Call the worker */
686 DPRINT("Querying the capabilities for the FDO\n");
687 Status
= HalpQueryCapabilities(DeviceObject
,
688 IoStackLocation
->Parameters
.DeviceCapabilities
.Capabilities
);
693 DPRINT("Other IRP: %lx\n", Minor
);
694 Status
= Irp
->IoStatus
.Status
;
698 /* Nowhere for the IRP to go since we also own the PDO */
699 Irp
->IoStatus
.Status
= Status
;
700 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
705 /* This is a PDO instead */
706 ASSERT(FdoExtension
->ExtensionType
== PdoExtensionType
);
707 //PdoExtension = (PPDO_EXTENSION)FdoExtension;
709 /* Query the IRP type */
710 Status
= STATUS_SUCCESS
;
713 case IRP_MN_START_DEVICE
:
715 /* We only care about a PCI PDO */
716 DPRINT("Start device received\n");
717 /* Complete the IRP normally */
720 case IRP_MN_REMOVE_DEVICE
:
722 /* Check if this is a PCI device */
723 DPRINT("Remove device received\n");
726 Status
= STATUS_SUCCESS
;
729 case IRP_MN_SURPRISE_REMOVAL
:
731 /* Inherit whatever status we had */
732 DPRINT("Surprise removal IRP\n");
733 Status
= Irp
->IoStatus
.Status
;
736 case IRP_MN_QUERY_DEVICE_RELATIONS
:
738 /* Query the device relations */
739 DPRINT("Querying PDO relations\n");
740 Status
= HalpQueryDeviceRelations(DeviceObject
,
741 IoStackLocation
->Parameters
.QueryDeviceRelations
.Type
,
742 (PVOID
)&Irp
->IoStatus
.Information
);
745 case IRP_MN_QUERY_INTERFACE
:
747 /* Call the worker */
748 DPRINT("Querying interface for PDO\n");
749 Status
= HalpQueryInterface(DeviceObject
,
750 IoStackLocation
->Parameters
.QueryInterface
.InterfaceType
,
751 IoStackLocation
->Parameters
.QueryInterface
.Size
,
752 IoStackLocation
->Parameters
.QueryInterface
.InterfaceSpecificData
,
753 IoStackLocation
->Parameters
.QueryInterface
.Version
,
754 IoStackLocation
->Parameters
.QueryInterface
.Interface
,
755 (PVOID
)&Irp
->IoStatus
.Information
);
758 case IRP_MN_QUERY_CAPABILITIES
:
760 /* Call the worker */
761 DPRINT("Querying the capabilities for the PDO\n");
762 Status
= HalpQueryCapabilities(DeviceObject
,
763 IoStackLocation
->Parameters
.DeviceCapabilities
.Capabilities
);
766 case IRP_MN_QUERY_RESOURCES
:
768 /* Call the worker */
769 DPRINT("Querying the resources for the PDO\n");
770 Status
= HalpQueryResources(DeviceObject
, (PVOID
)&Irp
->IoStatus
.Information
);
773 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS
:
775 /* Call the worker */
776 DPRINT("Querying the resource requirements for the PDO\n");
777 Status
= HalpQueryResourceRequirements(DeviceObject
,
778 (PVOID
)&Irp
->IoStatus
.Information
);
781 case IRP_MN_QUERY_ID
:
783 /* Call the worker */
784 DPRINT("Query the ID for the PDO\n");
785 Status
= HalpQueryIdPdo(DeviceObject
,
786 IoStackLocation
->Parameters
.QueryId
.IdType
,
787 (PVOID
)&Irp
->IoStatus
.Information
);
792 /* We don't handle anything else, so inherit the old state */
793 DPRINT1("Illegal IRP: %lx\n", Minor
);
794 Status
= Irp
->IoStatus
.Status
;
798 /* If it's not supported, inherit the old status */
799 if (Status
== STATUS_NOT_SUPPORTED
) Status
= Irp
->IoStatus
.Status
;
801 /* Complete the IRP */
802 DPRINT("IRP completed with status: %lx\n", Status
);
803 Irp
->IoStatus
.Status
= Status
;
804 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
811 HalpDispatchWmi(IN PDEVICE_OBJECT DeviceObject
,
814 UNIMPLEMENTED_DBGBREAK("HAL: PnP Driver WMI!\n");
815 return STATUS_SUCCESS
;
820 HalpDispatchPower(IN PDEVICE_OBJECT DeviceObject
,
823 PFDO_EXTENSION FdoExtension
;
825 DPRINT1("HAL: PnP Driver Power!\n");
826 FdoExtension
= DeviceObject
->DeviceExtension
;
827 if (FdoExtension
->ExtensionType
== FdoExtensionType
)
829 PoStartNextPowerIrp(Irp
);
830 IoSkipCurrentIrpStackLocation(Irp
);
831 return PoCallDriver(FdoExtension
->AttachedDeviceObject
, Irp
);
835 PoStartNextPowerIrp(Irp
);
836 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
837 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
838 return STATUS_SUCCESS
;
844 HalpDriverEntry(IN PDRIVER_OBJECT DriverObject
,
845 IN PUNICODE_STRING RegistryPath
)
848 PDEVICE_OBJECT TargetDevice
= NULL
;
850 DPRINT("HAL: PnP Driver ENTRY!\n");
853 HalpDriverObject
= DriverObject
;
855 /* Set up add device */
856 DriverObject
->DriverExtension
->AddDevice
= HalpAddDevice
;
858 /* Set up the callouts */
859 DriverObject
->MajorFunction
[IRP_MJ_PNP
] = HalpDispatchPnp
;
860 DriverObject
->MajorFunction
[IRP_MJ_POWER
] = HalpDispatchPower
;
861 DriverObject
->MajorFunction
[IRP_MJ_SYSTEM_CONTROL
] = HalpDispatchWmi
;
864 Status
= IoCreateDevice(DriverObject
,
867 FILE_DEVICE_CONTROLLER
,
871 if (!NT_SUCCESS(Status
))
874 TargetDevice
->Flags
&= ~DO_DEVICE_INITIALIZING
;
876 /* Set up the device stack */
877 Status
= HalpAddDevice(DriverObject
, TargetDevice
);
878 if (!NT_SUCCESS(Status
))
880 IoDeleteDevice(TargetDevice
);
884 /* Tell the PnP manager about us */
885 Status
= IoReportDetectedDevice(DriverObject
,
886 InterfaceTypeUndefined
,
894 /* Return to kernel */
900 HaliInitPnpDriver(VOID
)
903 UNICODE_STRING DriverString
;
906 /* Create the driver */
907 RtlInitUnicodeString(&DriverString
, L
"\\Driver\\PCI_HAL");
908 Status
= IoCreateDriver(&DriverString
, HalpDriverEntry
);