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 HalpAddDevice(IN PDRIVER_OBJECT DriverObject
,
56 IN PDEVICE_OBJECT TargetDevice
)
59 PFDO_EXTENSION FdoExtension
;
60 PPDO_EXTENSION PdoExtension
;
61 PDEVICE_OBJECT DeviceObject
, PdoDeviceObject
, AttachedDevice
;
62 PDESCRIPTION_HEADER Wdrt
;
63 DPRINT("HAL: PnP Driver ADD!\n");
66 Status
= IoCreateDevice(DriverObject
,
67 sizeof(FDO_EXTENSION
),
69 FILE_DEVICE_BUS_EXTENDER
,
73 if (!NT_SUCCESS(Status
))
75 /* Should not happen */
80 /* Setup the FDO extension */
81 FdoExtension
= DeviceObject
->DeviceExtension
;
82 FdoExtension
->ExtensionType
= FdoExtensionType
;
83 FdoExtension
->PhysicalDeviceObject
= TargetDevice
;
84 FdoExtension
->FunctionalDeviceObject
= DeviceObject
;
85 FdoExtension
->ChildPdoList
= NULL
;
87 /* FDO is done initializing */
88 DeviceObject
->Flags
&= ~DO_DEVICE_INITIALIZING
;
90 /* Attach to the physical device object (the bus) */
91 AttachedDevice
= IoAttachDeviceToDeviceStack(DeviceObject
, TargetDevice
);
94 /* Failed, undo everything */
95 IoDeleteDevice(DeviceObject
);
96 return STATUS_NO_SUCH_DEVICE
;
99 /* Save the attachment */
100 FdoExtension
->AttachedDeviceObject
= AttachedDevice
;
103 Status
= IoCreateDevice(DriverObject
,
104 sizeof(PDO_EXTENSION
),
106 FILE_DEVICE_BUS_EXTENDER
,
107 FILE_AUTOGENERATED_DEVICE_NAME
,
110 if (!NT_SUCCESS(Status
))
113 DPRINT1("HAL: Could not create ACPI device object status=0x%08x\n", Status
);
117 /* Setup the PDO device extension */
118 PdoExtension
= PdoDeviceObject
->DeviceExtension
;
119 PdoExtension
->ExtensionType
= PdoExtensionType
;
120 PdoExtension
->PhysicalDeviceObject
= PdoDeviceObject
;
121 PdoExtension
->ParentFdoExtension
= FdoExtension
;
122 PdoExtension
->PdoType
= AcpiPdo
;
124 /* Add the PDO to the head of the list */
125 PdoExtension
->Next
= FdoExtension
->ChildPdoList
;
126 FdoExtension
->ChildPdoList
= PdoExtension
;
128 /* Initialization is finished */
129 PdoDeviceObject
->Flags
&= ~DO_DEVICE_INITIALIZING
;
131 /* Find the ACPI watchdog table */
132 Wdrt
= HalAcpiGetTable(0, 'TRDW');
136 DPRINT1("You have an ACPI Watchdog. That's great! You should be proud ;-)\n");
139 /* Invalidate device relations since we added a new device */
140 IoInvalidateDeviceRelations(TargetDevice
, BusRelations
);
143 DPRINT("Device added %lx\n", Status
);
149 HalpQueryInterface(IN PDEVICE_OBJECT DeviceObject
,
150 IN CONST GUID
* InterfaceType
,
152 IN PVOID InterfaceSpecificData
,
153 IN ULONG InterfaceBufferSize
,
154 IN PINTERFACE Interface
,
159 return STATUS_NO_SUCH_DEVICE
;
164 HalpQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject
,
165 IN DEVICE_RELATION_TYPE RelationType
,
166 OUT PDEVICE_RELATIONS
* DeviceRelations
)
168 EXTENSION_TYPE ExtensionType
;
169 PPDO_EXTENSION PdoExtension
;
170 PFDO_EXTENSION FdoExtension
;
171 PDEVICE_RELATIONS PdoRelations
, FdoRelations
;
172 PDEVICE_OBJECT
* ObjectEntry
;
173 ULONG i
= 0, PdoCount
= 0;
175 /* Get FDO device extension and PDO count */
176 FdoExtension
= DeviceObject
->DeviceExtension
;
177 ExtensionType
= FdoExtension
->ExtensionType
;
179 /* What do they want? */
180 if (RelationType
== BusRelations
)
182 /* This better be an FDO */
183 if (ExtensionType
== FdoExtensionType
)
185 /* Count how many PDOs we have */
186 PdoExtension
= FdoExtension
->ChildPdoList
;
190 PdoExtension
= PdoExtension
->Next
;
194 /* Add the PDOs that already exist in the device relations */
195 if (*DeviceRelations
)
197 PdoCount
+= (*DeviceRelations
)->Count
;
200 /* Allocate our structure */
201 FdoRelations
= ExAllocatePoolWithTag(PagedPool
,
202 FIELD_OFFSET(DEVICE_RELATIONS
,
204 sizeof(PDEVICE_OBJECT
) * PdoCount
,
206 if (!FdoRelations
) return STATUS_INSUFFICIENT_RESOURCES
;
209 FdoRelations
->Count
= PdoCount
;
211 /* Query existing relations */
212 ObjectEntry
= FdoRelations
->Objects
;
213 if (*DeviceRelations
)
215 /* Check if there were any */
216 if ((*DeviceRelations
)->Count
)
221 /* Copy into our structure */
222 *ObjectEntry
++ = (*DeviceRelations
)->Objects
[i
];
224 while (++i
< (*DeviceRelations
)->Count
);
227 /* Free existing structure */
228 ExFreePool(*DeviceRelations
);
231 /* Now check if we have a PDO list */
232 PdoExtension
= FdoExtension
->ChildPdoList
;
238 /* Save our own PDO and reference it */
239 *ObjectEntry
++ = PdoExtension
->PhysicalDeviceObject
;
240 ObfReferenceObject(PdoExtension
->PhysicalDeviceObject
);
242 /* Go to our next PDO */
243 PdoExtension
= PdoExtension
->Next
;
245 while (PdoExtension
);
248 /* Return the new structure */
249 *DeviceRelations
= FdoRelations
;
250 return STATUS_SUCCESS
;
255 /* The only other thing we support is a target relation for the PDO */
256 if ((RelationType
== TargetDeviceRelation
) &&
257 (ExtensionType
== PdoExtensionType
))
260 PdoRelations
= ExAllocatePoolWithTag(PagedPool
,
261 sizeof(DEVICE_RELATIONS
),
263 if (!PdoRelations
) return STATUS_INSUFFICIENT_RESOURCES
;
265 /* Fill it out and reference us */
266 PdoRelations
->Count
= 1;
267 PdoRelations
->Objects
[0] = DeviceObject
;
268 ObfReferenceObject(DeviceObject
);
271 *DeviceRelations
= PdoRelations
;
272 return STATUS_SUCCESS
;
276 /* We don't support anything else */
277 return STATUS_NOT_SUPPORTED
;
282 HalpQueryCapabilities(IN PDEVICE_OBJECT DeviceObject
,
283 OUT PDEVICE_CAPABILITIES Capabilities
)
285 //PPDO_EXTENSION PdoExtension;
289 /* Get the extension and check for valid version */
290 //PdoExtension = DeviceObject->DeviceExtension;
291 ASSERT(Capabilities
->Version
== 1);
292 if (Capabilities
->Version
== 1)
294 /* Can't lock or eject us */
295 Capabilities
->LockSupported
= FALSE
;
296 Capabilities
->EjectSupported
= FALSE
;
298 /* Can't remove or dock us */
299 Capabilities
->Removable
= FALSE
;
300 Capabilities
->DockDevice
= FALSE
;
302 /* Can't access us raw */
303 Capabilities
->RawDeviceOK
= FALSE
;
305 /* We have a unique ID, and don't bother the user */
306 Capabilities
->UniqueID
= TRUE
;
307 Capabilities
->SilentInstall
= TRUE
;
309 /* Fill out the adress */
310 Capabilities
->Address
= InterfaceTypeUndefined
;
311 Capabilities
->UINumber
= InterfaceTypeUndefined
;
313 /* Fill out latencies */
314 Capabilities
->D1Latency
= 0;
315 Capabilities
->D2Latency
= 0;
316 Capabilities
->D3Latency
= 0;
318 /* Fill out supported device states */
319 Capabilities
->DeviceState
[PowerSystemWorking
] = PowerDeviceD0
;
320 Capabilities
->DeviceState
[PowerSystemHibernate
] = PowerDeviceD3
;
321 Capabilities
->DeviceState
[PowerSystemShutdown
] = PowerDeviceD3
;
322 Capabilities
->DeviceState
[PowerSystemSleeping3
] = PowerDeviceD3
;
325 Status
= STATUS_SUCCESS
;
330 Status
= STATUS_NOT_SUPPORTED
;
339 HalpQueryResources(IN PDEVICE_OBJECT DeviceObject
,
340 OUT PCM_RESOURCE_LIST
*Resources
)
342 PPDO_EXTENSION DeviceExtension
= DeviceObject
->DeviceExtension
;
344 PCM_RESOURCE_LIST ResourceList
;
345 PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList
;
346 PIO_RESOURCE_DESCRIPTOR Descriptor
;
347 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDesc
;
351 /* Only the ACPI PDO has requirements */
352 if (DeviceExtension
->PdoType
== AcpiPdo
)
354 /* Query ACPI requirements */
355 Status
= HalpQueryAcpiResourceRequirements(&RequirementsList
);
356 if (!NT_SUCCESS(Status
)) return Status
;
358 ASSERT(RequirementsList
->AlternativeLists
== 1);
360 /* Allocate the resourcel ist */
361 ResourceList
= ExAllocatePoolWithTag(PagedPool
,
362 sizeof(CM_RESOURCE_LIST
),
366 /* Fail, no memory */
367 Status
= STATUS_INSUFFICIENT_RESOURCES
;
368 ExFreePoolWithTag(RequirementsList
, ' laH');
373 RtlZeroMemory(ResourceList
, sizeof(CM_RESOURCE_LIST
));
374 ResourceList
->Count
= 1;
376 /* Setup the list fields */
377 ResourceList
->List
[0].BusNumber
= -1;
378 ResourceList
->List
[0].InterfaceType
= PNPBus
;
379 ResourceList
->List
[0].PartialResourceList
.Version
= 1;
380 ResourceList
->List
[0].PartialResourceList
.Revision
= 1;
381 ResourceList
->List
[0].PartialResourceList
.Count
= 0;
383 /* Setup the first descriptor */
384 PartialDesc
= ResourceList
->List
[0].PartialResourceList
.PartialDescriptors
;
386 /* Find the requirement descriptor for the SCI */
387 for (i
= 0; i
< RequirementsList
->List
[0].Count
; i
++)
389 /* Get this descriptor */
390 Descriptor
= &RequirementsList
->List
[0].Descriptors
[i
];
391 if (Descriptor
->Type
== CmResourceTypeInterrupt
)
393 /* Copy requirements descriptor into resource descriptor */
394 PartialDesc
->Type
= CmResourceTypeInterrupt
;
395 PartialDesc
->ShareDisposition
= Descriptor
->ShareDisposition
;
396 PartialDesc
->Flags
= Descriptor
->Flags
;
397 ASSERT(Descriptor
->u
.Interrupt
.MinimumVector
==
398 Descriptor
->u
.Interrupt
.MaximumVector
);
399 PartialDesc
->u
.Interrupt
.Vector
= Descriptor
->u
.Interrupt
.MinimumVector
;
400 PartialDesc
->u
.Interrupt
.Level
= Descriptor
->u
.Interrupt
.MinimumVector
;
401 PartialDesc
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
403 ResourceList
->List
[0].PartialResourceList
.Count
++;
409 /* Return resources and success */
410 *Resources
= ResourceList
;
412 ExFreePoolWithTag(RequirementsList
, ' laH');
414 return STATUS_SUCCESS
;
416 else if (DeviceExtension
->PdoType
== WdPdo
)
418 /* Watchdog doesn't */
419 return STATUS_NOT_SUPPORTED
;
423 /* This shouldn't happen */
424 return STATUS_UNSUCCESSFUL
;
430 HalpQueryResourceRequirements(IN PDEVICE_OBJECT DeviceObject
,
431 OUT PIO_RESOURCE_REQUIREMENTS_LIST
*Requirements
)
433 PPDO_EXTENSION DeviceExtension
= DeviceObject
->DeviceExtension
;
436 /* Only the ACPI PDO has requirements */
437 if (DeviceExtension
->PdoType
== AcpiPdo
)
439 /* Query ACPI requirements */
440 return HalpQueryAcpiResourceRequirements(Requirements
);
442 else if (DeviceExtension
->PdoType
== WdPdo
)
444 /* Watchdog doesn't */
445 return STATUS_NOT_SUPPORTED
;
449 /* This shouldn't happen */
450 return STATUS_UNSUCCESSFUL
;
456 HalpQueryIdPdo(IN PDEVICE_OBJECT DeviceObject
,
457 IN BUS_QUERY_ID_TYPE IdType
,
458 OUT PUSHORT
*BusQueryId
)
460 PPDO_EXTENSION PdoExtension
;
468 /* Get the PDO type */
469 PdoExtension
= DeviceObject
->DeviceExtension
;
470 PdoType
= PdoExtension
->PdoType
;
472 /* What kind of ID is being requested? */
473 DPRINT("ID: %d\n", IdType
);
476 case BusQueryDeviceID
:
477 case BusQueryHardwareIDs
:
479 /* What kind of PDO is this? */
480 if (PdoType
== AcpiPdo
)
483 CurrentId
= L
"ACPI_HAL\\PNP0C08";
484 RtlCopyMemory(Id
, CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
485 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
487 CurrentId
= L
"*PNP0C08";
488 RtlCopyMemory(&Id
[wcslen(Id
) + 1], CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
489 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
491 else if (PdoType
== WdPdo
)
494 CurrentId
= L
"ACPI_HAL\\PNP0C18";
495 RtlCopyMemory(Id
, CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
496 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
498 CurrentId
= L
"*PNP0C18";
499 RtlCopyMemory(&Id
[wcslen(Id
) + 1], CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
500 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
505 return STATUS_NOT_SUPPORTED
;
509 case BusQueryInstanceID
:
513 RtlCopyMemory(Id
, CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
514 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
517 case BusQueryCompatibleIDs
:
520 /* We don't support anything else */
521 return STATUS_NOT_SUPPORTED
;
525 /* Allocate the buffer */
526 Buffer
= ExAllocatePoolWithTag(PagedPool
,
527 Length
+ sizeof(UNICODE_NULL
),
531 /* Copy the string and null-terminate it */
532 RtlCopyMemory(Buffer
, Id
, Length
);
533 Buffer
[Length
/ sizeof(WCHAR
)] = UNICODE_NULL
;
536 *BusQueryId
= Buffer
;
537 Status
= STATUS_SUCCESS
;
538 DPRINT("Returning: %S\n", *BusQueryId
);
543 Status
= STATUS_INSUFFICIENT_RESOURCES
;
552 HalpQueryIdFdo(IN PDEVICE_OBJECT DeviceObject
,
553 IN BUS_QUERY_ID_TYPE IdType
,
554 OUT PUSHORT
*BusQueryId
)
561 /* What kind of ID is being requested? */
562 DPRINT("ID: %d\n", IdType
);
565 case BusQueryDeviceID
:
567 Id
= L
"Root\\ACPI_HAL";
570 case BusQueryHardwareIDs
:
572 /* This is our hardware ID */
573 Id
= HalHardwareIdString
;
576 case BusQueryInstanceID
:
578 /* And our instance ID */
584 /* We don't support anything else */
585 return STATUS_NOT_SUPPORTED
;
588 /* Calculate the length */
589 Length
= (wcslen(Id
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
591 /* Allocate the buffer */
592 Buffer
= ExAllocatePoolWithTag(PagedPool
,
593 Length
+ sizeof(UNICODE_NULL
),
597 /* Copy the string and null-terminate it */
598 RtlCopyMemory(Buffer
, Id
, Length
);
599 Buffer
[Length
/ sizeof(WCHAR
)] = UNICODE_NULL
;
602 *BusQueryId
= Buffer
;
603 Status
= STATUS_SUCCESS
;
604 DPRINT("Returning: %S\n", *BusQueryId
);
609 Status
= STATUS_INSUFFICIENT_RESOURCES
;
618 HalpDispatchPnp(IN PDEVICE_OBJECT DeviceObject
,
621 PIO_STACK_LOCATION IoStackLocation
;
622 //PPDO_EXTENSION PdoExtension;
623 PFDO_EXTENSION FdoExtension
;
627 /* Get the device extension and stack location */
628 FdoExtension
= DeviceObject
->DeviceExtension
;
629 IoStackLocation
= IoGetCurrentIrpStackLocation(Irp
);
630 Minor
= IoStackLocation
->MinorFunction
;
633 if (FdoExtension
->ExtensionType
== FdoExtensionType
)
635 /* Query the IRP type */
638 case IRP_MN_QUERY_DEVICE_RELATIONS
:
640 /* Call the worker */
641 DPRINT("Querying device relations for FDO\n");
642 Status
= HalpQueryDeviceRelations(DeviceObject
,
643 IoStackLocation
->Parameters
.QueryDeviceRelations
.Type
,
644 (PVOID
)&Irp
->IoStatus
.Information
);
647 case IRP_MN_QUERY_INTERFACE
:
649 /* Call the worker */
650 DPRINT("Querying interface for FDO\n");
651 Status
= HalpQueryInterface(DeviceObject
,
652 IoStackLocation
->Parameters
.QueryInterface
.InterfaceType
,
653 IoStackLocation
->Parameters
.QueryInterface
.Size
,
654 IoStackLocation
->Parameters
.QueryInterface
.InterfaceSpecificData
,
655 IoStackLocation
->Parameters
.QueryInterface
.Version
,
656 IoStackLocation
->Parameters
.QueryInterface
.Interface
,
657 (PVOID
)&Irp
->IoStatus
.Information
);
661 case IRP_MN_QUERY_ID
:
663 /* Call the worker */
664 DPRINT("Querying ID for FDO\n");
665 Status
= HalpQueryIdFdo(DeviceObject
,
666 IoStackLocation
->Parameters
.QueryId
.IdType
,
667 (PVOID
)&Irp
->IoStatus
.Information
);
670 case IRP_MN_QUERY_CAPABILITIES
:
672 /* Call the worker */
673 DPRINT("Querying the capabilities for the FDO\n");
674 Status
= HalpQueryCapabilities(DeviceObject
,
675 IoStackLocation
->Parameters
.DeviceCapabilities
.Capabilities
);
680 DPRINT("Other IRP: %lx\n", Minor
);
681 Status
= Irp
->IoStatus
.Status
;
685 /* Nowhere for the IRP to go since we also own the PDO */
686 Irp
->IoStatus
.Status
= Status
;
687 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
692 /* This is a PDO instead */
693 ASSERT(FdoExtension
->ExtensionType
== PdoExtensionType
);
694 //PdoExtension = (PPDO_EXTENSION)FdoExtension;
695 /* Query the IRP type */
696 Status
= STATUS_SUCCESS
;
699 case IRP_MN_START_DEVICE
:
701 /* We only care about a PCI PDO */
702 DPRINT1("Start device received\n");
703 /* Complete the IRP normally */
706 case IRP_MN_REMOVE_DEVICE
:
708 /* Check if this is a PCI device */
709 DPRINT1("Remove device received\n");
712 Status
= STATUS_SUCCESS
;
715 case IRP_MN_SURPRISE_REMOVAL
:
717 /* Inherit whatever status we had */
718 DPRINT1("Surprise removal IRP\n");
719 Status
= Irp
->IoStatus
.Status
;
722 case IRP_MN_QUERY_DEVICE_RELATIONS
:
724 /* Query the device relations */
725 DPRINT("Querying PDO relations\n");
726 Status
= HalpQueryDeviceRelations(DeviceObject
,
727 IoStackLocation
->Parameters
.QueryDeviceRelations
.Type
,
728 (PVOID
)&Irp
->IoStatus
.Information
);
731 case IRP_MN_QUERY_INTERFACE
:
733 /* Call the worker */
734 DPRINT("Querying interface for PDO\n");
735 Status
= HalpQueryInterface(DeviceObject
,
736 IoStackLocation
->Parameters
.QueryInterface
.InterfaceType
,
737 IoStackLocation
->Parameters
.QueryInterface
.Size
,
738 IoStackLocation
->Parameters
.QueryInterface
.InterfaceSpecificData
,
739 IoStackLocation
->Parameters
.QueryInterface
.Version
,
740 IoStackLocation
->Parameters
.QueryInterface
.Interface
,
741 (PVOID
)&Irp
->IoStatus
.Information
);
744 case IRP_MN_QUERY_CAPABILITIES
:
746 /* Call the worker */
747 DPRINT("Querying the capabilities for the PDO\n");
748 Status
= HalpQueryCapabilities(DeviceObject
,
749 IoStackLocation
->Parameters
.DeviceCapabilities
.Capabilities
);
752 case IRP_MN_QUERY_RESOURCES
:
754 /* Call the worker */
755 DPRINT("Querying the resources for the PDO\n");
756 Status
= HalpQueryResources(DeviceObject
, (PVOID
)&Irp
->IoStatus
.Information
);
759 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS
:
761 /* Call the worker */
762 DPRINT("Querying the resource requirements for the PDO\n");
763 Status
= HalpQueryResourceRequirements(DeviceObject
,
764 (PVOID
)&Irp
->IoStatus
.Information
);
767 case IRP_MN_QUERY_ID
:
769 /* Call the worker */
770 DPRINT("Query the ID for the PDO\n");
771 Status
= HalpQueryIdPdo(DeviceObject
,
772 IoStackLocation
->Parameters
.QueryId
.IdType
,
773 (PVOID
)&Irp
->IoStatus
.Information
);
778 /* We don't handle anything else, so inherit the old state */
779 DPRINT("Illegal IRP: %lx\n", Minor
);
780 Status
= Irp
->IoStatus
.Status
;
784 /* If it's not supported, inherit the old status */
785 if (Status
== STATUS_NOT_SUPPORTED
) Status
= Irp
->IoStatus
.Status
;
787 /* Complete the IRP */
788 DPRINT("IRP completed with status: %lx\n", Status
);
789 Irp
->IoStatus
.Status
= Status
;
790 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
797 HalpDispatchWmi(IN PDEVICE_OBJECT DeviceObject
,
800 DPRINT1("HAL: PnP Driver WMI!\n");
802 return STATUS_SUCCESS
;
807 HalpDispatchPower(IN PDEVICE_OBJECT DeviceObject
,
810 DPRINT1("HAL: PnP Driver Power!\n");
811 return STATUS_SUCCESS
;
816 HalpDriverEntry(IN PDRIVER_OBJECT DriverObject
,
817 IN PUNICODE_STRING RegistryPath
)
820 PDEVICE_OBJECT TargetDevice
= NULL
;
822 DPRINT("HAL: PnP Driver ENTRY!\n");
825 HalpDriverObject
= DriverObject
;
827 /* Set up add device */
828 DriverObject
->DriverExtension
->AddDevice
= HalpAddDevice
;
830 /* Set up the callouts */
831 DriverObject
->MajorFunction
[IRP_MJ_PNP
] = HalpDispatchPnp
;
832 DriverObject
->MajorFunction
[IRP_MJ_POWER
] = HalpDispatchPower
;
833 DriverObject
->MajorFunction
[IRP_MJ_SYSTEM_CONTROL
] = HalpDispatchWmi
;
836 Status
= IoCreateDevice(DriverObject
,
839 FILE_DEVICE_CONTROLLER
,
843 if (!NT_SUCCESS(Status
))
846 TargetDevice
->Flags
&= ~DO_DEVICE_INITIALIZING
;
848 /* Set up the device stack */
849 Status
= HalpAddDevice(DriverObject
, TargetDevice
);
850 if (!NT_SUCCESS(Status
))
852 IoDeleteDevice(TargetDevice
);
856 /* Tell the PnP manager about us */
857 Status
= IoReportDetectedDevice(DriverObject
,
858 InterfaceTypeUndefined
,
866 /* Return to kernel */
872 HaliInitPnpDriver(VOID
)
875 UNICODE_STRING DriverString
;
878 /* Create the driver */
879 RtlInitUnicodeString(&DriverString
, L
"\\Driver\\ACPI_HAL");
880 Status
= IoCreateDriver(&DriverString
, HalpDriverEntry
);