3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: hal/halx86/generic/acpi/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
;
62 PDESCRIPTION_HEADER Wdrt
;
66 Status
= IoCreateDevice(DriverObject
,
67 sizeof(PDO_EXTENSION
),
69 FILE_DEVICE_BUS_EXTENDER
,
70 FILE_AUTOGENERATED_DEVICE_NAME
,
73 if (!NT_SUCCESS(Status
))
76 DPRINT1("HAL: Could not create ACPI device object status=0x%08x\n", Status
);
80 /* Setup the PDO device extension */
81 PdoExtension
= PdoDeviceObject
->DeviceExtension
;
82 PdoExtension
->ExtensionType
= PdoExtensionType
;
83 PdoExtension
->PhysicalDeviceObject
= PdoDeviceObject
;
84 PdoExtension
->ParentFdoExtension
= FdoExtension
;
85 PdoExtension
->PdoType
= AcpiPdo
;
87 /* Add the PDO to the head of the list */
88 PdoExtension
->Next
= FdoExtension
->ChildPdoList
;
89 FdoExtension
->ChildPdoList
= PdoExtension
;
91 /* Initialization is finished */
92 PdoDeviceObject
->Flags
&= ~DO_DEVICE_INITIALIZING
;
94 /* Find the ACPI watchdog table */
95 Wdrt
= HalAcpiGetTable(0, 'TRDW');
99 DPRINT1("You have an ACPI Watchdog. That's great! You should be proud ;-)\n");
102 /* This will synchronously load the ACPI driver (needed because we're critical for boot) */
103 IoSynchronousInvalidateDeviceRelations(FdoExtension
->PhysicalDeviceObject
, BusRelations
);
108 HalpAddDevice(IN PDRIVER_OBJECT DriverObject
,
109 IN PDEVICE_OBJECT TargetDevice
)
112 PFDO_EXTENSION FdoExtension
;
113 PDEVICE_OBJECT DeviceObject
, AttachedDevice
;
115 DPRINT("HAL: PnP Driver ADD!\n");
118 Status
= IoCreateDevice(DriverObject
,
119 sizeof(FDO_EXTENSION
),
121 FILE_DEVICE_BUS_EXTENDER
,
125 if (!NT_SUCCESS(Status
))
127 /* Should not happen */
132 /* Setup the FDO extension */
133 FdoExtension
= DeviceObject
->DeviceExtension
;
134 FdoExtension
->ExtensionType
= FdoExtensionType
;
135 FdoExtension
->PhysicalDeviceObject
= TargetDevice
;
136 FdoExtension
->FunctionalDeviceObject
= DeviceObject
;
137 FdoExtension
->ChildPdoList
= NULL
;
139 /* FDO is done initializing */
140 DeviceObject
->Flags
&= ~DO_DEVICE_INITIALIZING
;
142 /* Attach to the physical device object (the bus) */
143 AttachedDevice
= IoAttachDeviceToDeviceStack(DeviceObject
, TargetDevice
);
146 /* Failed, undo everything */
147 IoDeleteDevice(DeviceObject
);
148 return STATUS_NO_SUCH_DEVICE
;
151 /* Save the attachment */
152 FdoExtension
->AttachedDeviceObject
= AttachedDevice
;
154 /* Register for reinitialization to report devices later */
155 IoRegisterBootDriverReinitialization(DriverObject
,
156 HalpReportDetectedDevices
,
160 DPRINT("Device added %lx\n", Status
);
166 HalpQueryInterface(IN PDEVICE_OBJECT DeviceObject
,
167 IN CONST GUID
* InterfaceType
,
169 IN PVOID InterfaceSpecificData
,
170 IN ULONG InterfaceBufferSize
,
171 IN PINTERFACE Interface
,
176 return STATUS_NO_SUCH_DEVICE
;
181 HalpQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject
,
182 IN DEVICE_RELATION_TYPE RelationType
,
183 OUT PDEVICE_RELATIONS
* DeviceRelations
)
185 EXTENSION_TYPE ExtensionType
;
186 PPDO_EXTENSION PdoExtension
;
187 PFDO_EXTENSION FdoExtension
;
188 PDEVICE_RELATIONS PdoRelations
, FdoRelations
;
189 PDEVICE_OBJECT
* ObjectEntry
;
190 ULONG i
= 0, PdoCount
= 0;
192 /* Get FDO device extension and PDO count */
193 FdoExtension
= DeviceObject
->DeviceExtension
;
194 ExtensionType
= FdoExtension
->ExtensionType
;
196 /* What do they want? */
197 if (RelationType
== BusRelations
)
199 /* This better be an FDO */
200 if (ExtensionType
== FdoExtensionType
)
202 /* Count how many PDOs we have */
203 PdoExtension
= FdoExtension
->ChildPdoList
;
207 PdoExtension
= PdoExtension
->Next
;
211 /* Add the PDOs that already exist in the device relations */
212 if (*DeviceRelations
)
214 PdoCount
+= (*DeviceRelations
)->Count
;
217 /* Allocate our structure */
218 FdoRelations
= ExAllocatePoolWithTag(PagedPool
,
219 FIELD_OFFSET(DEVICE_RELATIONS
,
221 sizeof(PDEVICE_OBJECT
) * PdoCount
,
223 if (!FdoRelations
) return STATUS_INSUFFICIENT_RESOURCES
;
226 FdoRelations
->Count
= PdoCount
;
228 /* Query existing relations */
229 ObjectEntry
= FdoRelations
->Objects
;
230 if (*DeviceRelations
)
232 /* Check if there were any */
233 if ((*DeviceRelations
)->Count
)
238 /* Copy into our structure */
239 *ObjectEntry
++ = (*DeviceRelations
)->Objects
[i
];
241 while (++i
< (*DeviceRelations
)->Count
);
244 /* Free existing structure */
245 ExFreePool(*DeviceRelations
);
248 /* Now check if we have a PDO list */
249 PdoExtension
= FdoExtension
->ChildPdoList
;
255 /* Save our own PDO and reference it */
256 *ObjectEntry
++ = PdoExtension
->PhysicalDeviceObject
;
257 ObfReferenceObject(PdoExtension
->PhysicalDeviceObject
);
259 /* Go to our next PDO */
260 PdoExtension
= PdoExtension
->Next
;
262 while (PdoExtension
);
265 /* Return the new structure */
266 *DeviceRelations
= FdoRelations
;
267 return STATUS_SUCCESS
;
272 /* The only other thing we support is a target relation for the PDO */
273 if ((RelationType
== TargetDeviceRelation
) &&
274 (ExtensionType
== PdoExtensionType
))
277 PdoRelations
= ExAllocatePoolWithTag(PagedPool
,
278 sizeof(DEVICE_RELATIONS
),
280 if (!PdoRelations
) return STATUS_INSUFFICIENT_RESOURCES
;
282 /* Fill it out and reference us */
283 PdoRelations
->Count
= 1;
284 PdoRelations
->Objects
[0] = DeviceObject
;
285 ObfReferenceObject(DeviceObject
);
288 *DeviceRelations
= PdoRelations
;
289 return STATUS_SUCCESS
;
293 /* We don't support anything else */
294 return STATUS_NOT_SUPPORTED
;
299 HalpQueryCapabilities(IN PDEVICE_OBJECT DeviceObject
,
300 OUT PDEVICE_CAPABILITIES Capabilities
)
302 //PPDO_EXTENSION PdoExtension;
306 /* Get the extension and check for valid version */
307 //PdoExtension = DeviceObject->DeviceExtension;
308 ASSERT(Capabilities
->Version
== 1);
309 if (Capabilities
->Version
== 1)
311 /* Can't lock or eject us */
312 Capabilities
->LockSupported
= FALSE
;
313 Capabilities
->EjectSupported
= FALSE
;
315 /* Can't remove or dock us */
316 Capabilities
->Removable
= FALSE
;
317 Capabilities
->DockDevice
= FALSE
;
319 /* Can't access us raw */
320 Capabilities
->RawDeviceOK
= FALSE
;
322 /* We have a unique ID, and don't bother the user */
323 Capabilities
->UniqueID
= TRUE
;
324 Capabilities
->SilentInstall
= TRUE
;
326 /* Fill out the adress */
327 Capabilities
->Address
= InterfaceTypeUndefined
;
328 Capabilities
->UINumber
= InterfaceTypeUndefined
;
330 /* Fill out latencies */
331 Capabilities
->D1Latency
= 0;
332 Capabilities
->D2Latency
= 0;
333 Capabilities
->D3Latency
= 0;
335 /* Fill out supported device states */
336 Capabilities
->DeviceState
[PowerSystemWorking
] = PowerDeviceD0
;
337 Capabilities
->DeviceState
[PowerSystemHibernate
] = PowerDeviceD3
;
338 Capabilities
->DeviceState
[PowerSystemShutdown
] = PowerDeviceD3
;
339 Capabilities
->DeviceState
[PowerSystemSleeping3
] = PowerDeviceD3
;
342 Status
= STATUS_SUCCESS
;
347 Status
= STATUS_NOT_SUPPORTED
;
356 HalpQueryResources(IN PDEVICE_OBJECT DeviceObject
,
357 OUT PCM_RESOURCE_LIST
*Resources
)
359 PPDO_EXTENSION DeviceExtension
= DeviceObject
->DeviceExtension
;
361 PCM_RESOURCE_LIST ResourceList
;
362 PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList
;
363 PIO_RESOURCE_DESCRIPTOR Descriptor
;
364 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDesc
;
368 /* Only the ACPI PDO has requirements */
369 if (DeviceExtension
->PdoType
== AcpiPdo
)
371 /* Query ACPI requirements */
372 Status
= HalpQueryAcpiResourceRequirements(&RequirementsList
);
373 if (!NT_SUCCESS(Status
)) return Status
;
375 ASSERT(RequirementsList
->AlternativeLists
== 1);
377 /* Allocate the resourcel ist */
378 ResourceList
= ExAllocatePoolWithTag(PagedPool
,
379 sizeof(CM_RESOURCE_LIST
),
383 /* Fail, no memory */
384 Status
= STATUS_INSUFFICIENT_RESOURCES
;
385 ExFreePoolWithTag(RequirementsList
, ' laH');
390 RtlZeroMemory(ResourceList
, sizeof(CM_RESOURCE_LIST
));
391 ResourceList
->Count
= 1;
393 /* Setup the list fields */
394 ResourceList
->List
[0].BusNumber
= -1;
395 ResourceList
->List
[0].InterfaceType
= PNPBus
;
396 ResourceList
->List
[0].PartialResourceList
.Version
= 1;
397 ResourceList
->List
[0].PartialResourceList
.Revision
= 1;
398 ResourceList
->List
[0].PartialResourceList
.Count
= 0;
400 /* Setup the first descriptor */
401 PartialDesc
= ResourceList
->List
[0].PartialResourceList
.PartialDescriptors
;
403 /* Find the requirement descriptor for the SCI */
404 for (i
= 0; i
< RequirementsList
->List
[0].Count
; i
++)
406 /* Get this descriptor */
407 Descriptor
= &RequirementsList
->List
[0].Descriptors
[i
];
408 if (Descriptor
->Type
== CmResourceTypeInterrupt
)
410 /* Copy requirements descriptor into resource descriptor */
411 PartialDesc
->Type
= CmResourceTypeInterrupt
;
412 PartialDesc
->ShareDisposition
= Descriptor
->ShareDisposition
;
413 PartialDesc
->Flags
= Descriptor
->Flags
;
414 ASSERT(Descriptor
->u
.Interrupt
.MinimumVector
==
415 Descriptor
->u
.Interrupt
.MaximumVector
);
416 PartialDesc
->u
.Interrupt
.Vector
= Descriptor
->u
.Interrupt
.MinimumVector
;
417 PartialDesc
->u
.Interrupt
.Level
= Descriptor
->u
.Interrupt
.MinimumVector
;
418 PartialDesc
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
420 ResourceList
->List
[0].PartialResourceList
.Count
++;
426 /* Return resources and success */
427 *Resources
= ResourceList
;
429 ExFreePoolWithTag(RequirementsList
, ' laH');
431 return STATUS_SUCCESS
;
433 else if (DeviceExtension
->PdoType
== WdPdo
)
435 /* Watchdog doesn't */
436 return STATUS_NOT_SUPPORTED
;
440 /* This shouldn't happen */
441 return STATUS_UNSUCCESSFUL
;
447 HalpQueryResourceRequirements(IN PDEVICE_OBJECT DeviceObject
,
448 OUT PIO_RESOURCE_REQUIREMENTS_LIST
*Requirements
)
450 PPDO_EXTENSION DeviceExtension
= DeviceObject
->DeviceExtension
;
453 /* Only the ACPI PDO has requirements */
454 if (DeviceExtension
->PdoType
== AcpiPdo
)
456 /* Query ACPI requirements */
457 return HalpQueryAcpiResourceRequirements(Requirements
);
459 else if (DeviceExtension
->PdoType
== WdPdo
)
461 /* Watchdog doesn't */
462 return STATUS_NOT_SUPPORTED
;
466 /* This shouldn't happen */
467 return STATUS_UNSUCCESSFUL
;
473 HalpQueryIdPdo(IN PDEVICE_OBJECT DeviceObject
,
474 IN BUS_QUERY_ID_TYPE IdType
,
475 OUT PUSHORT
*BusQueryId
)
477 PPDO_EXTENSION PdoExtension
;
485 /* Get the PDO type */
486 PdoExtension
= DeviceObject
->DeviceExtension
;
487 PdoType
= PdoExtension
->PdoType
;
489 /* What kind of ID is being requested? */
490 DPRINT("ID: %d\n", IdType
);
493 case BusQueryDeviceID
:
494 case BusQueryHardwareIDs
:
496 /* What kind of PDO is this? */
497 if (PdoType
== AcpiPdo
)
500 CurrentId
= L
"ACPI_HAL\\PNP0C08";
501 RtlCopyMemory(Id
, CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
502 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
504 CurrentId
= L
"*PNP0C08";
505 RtlCopyMemory(&Id
[wcslen(Id
) + 1], CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
506 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
508 else if (PdoType
== WdPdo
)
511 CurrentId
= L
"ACPI_HAL\\PNP0C18";
512 RtlCopyMemory(Id
, CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
513 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
515 CurrentId
= L
"*PNP0C18";
516 RtlCopyMemory(&Id
[wcslen(Id
) + 1], CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
517 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
522 return STATUS_NOT_SUPPORTED
;
526 case BusQueryInstanceID
:
530 RtlCopyMemory(Id
, CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
531 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
534 case BusQueryCompatibleIDs
:
537 /* We don't support anything else */
538 return STATUS_NOT_SUPPORTED
;
542 /* Allocate the buffer */
543 Buffer
= ExAllocatePoolWithTag(PagedPool
,
544 Length
+ sizeof(UNICODE_NULL
),
548 /* Copy the string and null-terminate it */
549 RtlCopyMemory(Buffer
, Id
, Length
);
550 Buffer
[Length
/ sizeof(WCHAR
)] = UNICODE_NULL
;
553 *BusQueryId
= Buffer
;
554 Status
= STATUS_SUCCESS
;
555 DPRINT("Returning: %S\n", *BusQueryId
);
560 Status
= STATUS_INSUFFICIENT_RESOURCES
;
569 HalpQueryIdFdo(IN PDEVICE_OBJECT DeviceObject
,
570 IN BUS_QUERY_ID_TYPE IdType
,
571 OUT PUSHORT
*BusQueryId
)
578 /* What kind of ID is being requested? */
579 DPRINT("ID: %d\n", IdType
);
582 case BusQueryDeviceID
:
584 Id
= L
"Root\\ACPI_HAL";
587 case BusQueryHardwareIDs
:
589 /* This is our hardware ID */
590 Id
= HalHardwareIdString
;
593 case BusQueryInstanceID
:
595 /* And our instance ID */
601 /* We don't support anything else */
602 return STATUS_NOT_SUPPORTED
;
605 /* Calculate the length */
606 Length
= (wcslen(Id
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
608 /* Allocate the buffer */
609 Buffer
= ExAllocatePoolWithTag(PagedPool
,
610 Length
+ sizeof(UNICODE_NULL
),
614 /* Copy the string and null-terminate it */
615 RtlCopyMemory(Buffer
, Id
, Length
);
616 Buffer
[Length
/ sizeof(WCHAR
)] = UNICODE_NULL
;
619 *BusQueryId
= Buffer
;
620 Status
= STATUS_SUCCESS
;
621 DPRINT("Returning: %S\n", *BusQueryId
);
626 Status
= STATUS_INSUFFICIENT_RESOURCES
;
635 HalpDispatchPnp(IN PDEVICE_OBJECT DeviceObject
,
638 PIO_STACK_LOCATION IoStackLocation
;
639 //PPDO_EXTENSION PdoExtension;
640 PFDO_EXTENSION FdoExtension
;
644 /* Get the device extension and stack location */
645 FdoExtension
= DeviceObject
->DeviceExtension
;
646 IoStackLocation
= IoGetCurrentIrpStackLocation(Irp
);
647 Minor
= IoStackLocation
->MinorFunction
;
650 if (FdoExtension
->ExtensionType
== FdoExtensionType
)
652 /* Query the IRP type */
655 case IRP_MN_QUERY_DEVICE_RELATIONS
:
657 /* Call the worker */
658 DPRINT("Querying device relations for FDO\n");
659 Status
= HalpQueryDeviceRelations(DeviceObject
,
660 IoStackLocation
->Parameters
.QueryDeviceRelations
.Type
,
661 (PVOID
)&Irp
->IoStatus
.Information
);
664 case IRP_MN_QUERY_INTERFACE
:
666 /* Call the worker */
667 DPRINT("Querying interface for FDO\n");
668 Status
= HalpQueryInterface(DeviceObject
,
669 IoStackLocation
->Parameters
.QueryInterface
.InterfaceType
,
670 IoStackLocation
->Parameters
.QueryInterface
.Size
,
671 IoStackLocation
->Parameters
.QueryInterface
.InterfaceSpecificData
,
672 IoStackLocation
->Parameters
.QueryInterface
.Version
,
673 IoStackLocation
->Parameters
.QueryInterface
.Interface
,
674 (PVOID
)&Irp
->IoStatus
.Information
);
678 case IRP_MN_QUERY_ID
:
680 /* Call the worker */
681 DPRINT("Querying ID for FDO\n");
682 Status
= HalpQueryIdFdo(DeviceObject
,
683 IoStackLocation
->Parameters
.QueryId
.IdType
,
684 (PVOID
)&Irp
->IoStatus
.Information
);
687 case IRP_MN_QUERY_CAPABILITIES
:
689 /* Call the worker */
690 DPRINT("Querying the capabilities for the FDO\n");
691 Status
= HalpQueryCapabilities(DeviceObject
,
692 IoStackLocation
->Parameters
.DeviceCapabilities
.Capabilities
);
697 DPRINT("Other IRP: %lx\n", Minor
);
698 Status
= Irp
->IoStatus
.Status
;
702 /* Nowhere for the IRP to go since we also own the PDO */
703 Irp
->IoStatus
.Status
= Status
;
704 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
709 /* This is a PDO instead */
710 ASSERT(FdoExtension
->ExtensionType
== PdoExtensionType
);
711 //PdoExtension = (PPDO_EXTENSION)FdoExtension;
712 /* Query the IRP type */
713 Status
= STATUS_SUCCESS
;
716 case IRP_MN_START_DEVICE
:
718 /* We only care about a PCI PDO */
719 DPRINT1("Start device received\n");
720 /* Complete the IRP normally */
723 case IRP_MN_REMOVE_DEVICE
:
725 /* Check if this is a PCI device */
726 DPRINT1("Remove device received\n");
729 Status
= STATUS_SUCCESS
;
732 case IRP_MN_SURPRISE_REMOVAL
:
734 /* Inherit whatever status we had */
735 DPRINT1("Surprise removal IRP\n");
736 Status
= Irp
->IoStatus
.Status
;
739 case IRP_MN_QUERY_DEVICE_RELATIONS
:
741 /* Query the device relations */
742 DPRINT("Querying PDO relations\n");
743 Status
= HalpQueryDeviceRelations(DeviceObject
,
744 IoStackLocation
->Parameters
.QueryDeviceRelations
.Type
,
745 (PVOID
)&Irp
->IoStatus
.Information
);
748 case IRP_MN_QUERY_INTERFACE
:
750 /* Call the worker */
751 DPRINT("Querying interface for PDO\n");
752 Status
= HalpQueryInterface(DeviceObject
,
753 IoStackLocation
->Parameters
.QueryInterface
.InterfaceType
,
754 IoStackLocation
->Parameters
.QueryInterface
.Size
,
755 IoStackLocation
->Parameters
.QueryInterface
.InterfaceSpecificData
,
756 IoStackLocation
->Parameters
.QueryInterface
.Version
,
757 IoStackLocation
->Parameters
.QueryInterface
.Interface
,
758 (PVOID
)&Irp
->IoStatus
.Information
);
761 case IRP_MN_QUERY_CAPABILITIES
:
763 /* Call the worker */
764 DPRINT("Querying the capabilities for the PDO\n");
765 Status
= HalpQueryCapabilities(DeviceObject
,
766 IoStackLocation
->Parameters
.DeviceCapabilities
.Capabilities
);
769 case IRP_MN_QUERY_RESOURCES
:
771 /* Call the worker */
772 DPRINT("Querying the resources for the PDO\n");
773 Status
= HalpQueryResources(DeviceObject
, (PVOID
)&Irp
->IoStatus
.Information
);
776 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS
:
778 /* Call the worker */
779 DPRINT("Querying the resource requirements for the PDO\n");
780 Status
= HalpQueryResourceRequirements(DeviceObject
,
781 (PVOID
)&Irp
->IoStatus
.Information
);
784 case IRP_MN_QUERY_ID
:
786 /* Call the worker */
787 DPRINT("Query the ID for the PDO\n");
788 Status
= HalpQueryIdPdo(DeviceObject
,
789 IoStackLocation
->Parameters
.QueryId
.IdType
,
790 (PVOID
)&Irp
->IoStatus
.Information
);
795 /* We don't handle anything else, so inherit the old state */
796 DPRINT("Illegal IRP: %lx\n", Minor
);
797 Status
= Irp
->IoStatus
.Status
;
801 /* If it's not supported, inherit the old status */
802 if (Status
== STATUS_NOT_SUPPORTED
) Status
= Irp
->IoStatus
.Status
;
804 /* Complete the IRP */
805 DPRINT("IRP completed with status: %lx\n", Status
);
806 Irp
->IoStatus
.Status
= Status
;
807 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
814 HalpDispatchWmi(IN PDEVICE_OBJECT DeviceObject
,
817 DPRINT1("HAL: PnP Driver WMI!\n");
819 return STATUS_SUCCESS
;
824 HalpDispatchPower(IN PDEVICE_OBJECT DeviceObject
,
827 DPRINT1("HAL: PnP Driver Power!\n");
828 return STATUS_SUCCESS
;
833 HalpDriverEntry(IN PDRIVER_OBJECT DriverObject
,
834 IN PUNICODE_STRING RegistryPath
)
837 PDEVICE_OBJECT TargetDevice
= NULL
;
839 DPRINT("HAL: PnP Driver ENTRY!\n");
842 HalpDriverObject
= DriverObject
;
844 /* Set up add device */
845 DriverObject
->DriverExtension
->AddDevice
= HalpAddDevice
;
847 /* Set up the callouts */
848 DriverObject
->MajorFunction
[IRP_MJ_PNP
] = HalpDispatchPnp
;
849 DriverObject
->MajorFunction
[IRP_MJ_POWER
] = HalpDispatchPower
;
850 DriverObject
->MajorFunction
[IRP_MJ_SYSTEM_CONTROL
] = HalpDispatchWmi
;
853 Status
= IoCreateDevice(DriverObject
,
856 FILE_DEVICE_CONTROLLER
,
860 if (!NT_SUCCESS(Status
))
863 TargetDevice
->Flags
&= ~DO_DEVICE_INITIALIZING
;
865 /* Set up the device stack */
866 Status
= HalpAddDevice(DriverObject
, TargetDevice
);
867 if (!NT_SUCCESS(Status
))
869 IoDeleteDevice(TargetDevice
);
873 /* Tell the PnP manager about us */
874 Status
= IoReportDetectedDevice(DriverObject
,
875 InterfaceTypeUndefined
,
883 /* Return to kernel */
889 HaliInitPnpDriver(VOID
)
892 UNICODE_STRING DriverString
;
895 /* Create the driver */
896 RtlInitUnicodeString(&DriverString
, L
"\\Driver\\ACPI_HAL");
897 Status
= IoCreateDriver(&DriverString
, HalpDriverEntry
);