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 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
;
132 /* Find the ACPI watchdog table */
133 Wdrt
= HalAcpiGetTable(0, 'TRDW');
137 DPRINT1("You have an ACPI Watchdog. That's great! You should be proud ;-)\n");
141 /* Invalidate device relations since we added a new device */
142 IoInvalidateDeviceRelations(TargetDevice
, BusRelations
);
145 DPRINT("Device added %lx\n", Status
);
151 HalpQueryInterface(IN PDEVICE_OBJECT DeviceObject
,
152 IN CONST GUID
* InterfaceType
,
154 IN PVOID InterfaceSpecificData
,
155 IN ULONG InterfaceBufferSize
,
156 IN PINTERFACE Interface
,
161 return STATUS_NO_SUCH_DEVICE
;
166 HalpQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject
,
167 IN DEVICE_RELATION_TYPE RelationType
,
168 OUT PDEVICE_RELATIONS
* DeviceRelations
)
170 EXTENSION_TYPE ExtensionType
;
171 PPDO_EXTENSION PdoExtension
;
172 PFDO_EXTENSION FdoExtension
;
173 PDEVICE_RELATIONS PdoRelations
, FdoRelations
;
174 PDEVICE_OBJECT
* ObjectEntry
;
175 ULONG i
= 0, PdoCount
= 0;
177 /* Get FDO device extension and PDO count */
178 FdoExtension
= DeviceObject
->DeviceExtension
;
179 ExtensionType
= FdoExtension
->ExtensionType
;
181 /* What do they want? */
182 if (RelationType
== BusRelations
)
184 /* This better be an FDO */
185 if (ExtensionType
== FdoExtensionType
)
187 /* Count how many PDOs we have */
188 PdoExtension
= FdoExtension
->ChildPdoList
;
192 PdoExtension
= PdoExtension
->Next
;
196 /* Add the PDOs that already exist in the device relations */
197 if (*DeviceRelations
)
199 PdoCount
+= (*DeviceRelations
)->Count
;
202 /* Allocate our structure */
203 FdoRelations
= ExAllocatePoolWithTag(PagedPool
,
204 FIELD_OFFSET(DEVICE_RELATIONS
,
206 sizeof(PDEVICE_OBJECT
) * PdoCount
,
208 if (!FdoRelations
) return STATUS_INSUFFICIENT_RESOURCES
;
211 FdoRelations
->Count
= PdoCount
;
213 /* Query existing relations */
214 ObjectEntry
= FdoRelations
->Objects
;
215 if (*DeviceRelations
)
217 /* Check if there were any */
218 if ((*DeviceRelations
)->Count
)
223 /* Copy into our structure */
224 *ObjectEntry
++ = (*DeviceRelations
)->Objects
[i
];
226 while (++i
< (*DeviceRelations
)->Count
);
229 /* Free existing structure */
230 ExFreePool(*DeviceRelations
);
233 /* Now check if we have a PDO list */
234 PdoExtension
= FdoExtension
->ChildPdoList
;
240 /* Save our own PDO and reference it */
241 *ObjectEntry
++ = PdoExtension
->PhysicalDeviceObject
;
242 ObfReferenceObject(PdoExtension
->PhysicalDeviceObject
);
244 /* Go to our next PDO */
245 PdoExtension
= PdoExtension
->Next
;
247 while (PdoExtension
);
250 /* Return the new structure */
251 *DeviceRelations
= FdoRelations
;
252 return STATUS_SUCCESS
;
257 /* The only other thing we support is a target relation for the PDO */
258 if ((RelationType
== TargetDeviceRelation
) &&
259 (ExtensionType
== PdoExtensionType
))
262 PdoRelations
= ExAllocatePoolWithTag(PagedPool
,
263 sizeof(DEVICE_RELATIONS
),
265 if (!PdoRelations
) return STATUS_INSUFFICIENT_RESOURCES
;
267 /* Fill it out and reference us */
268 PdoRelations
->Count
= 1;
269 PdoRelations
->Objects
[0] = DeviceObject
;
270 ObfReferenceObject(DeviceObject
);
273 *DeviceRelations
= PdoRelations
;
274 return STATUS_SUCCESS
;
278 /* We don't support anything else */
279 return STATUS_NOT_SUPPORTED
;
284 HalpQueryCapabilities(IN PDEVICE_OBJECT DeviceObject
,
285 OUT PDEVICE_CAPABILITIES Capabilities
)
287 PPDO_EXTENSION PdoExtension
;
291 /* Get the extension and check for valid version */
292 PdoExtension
= DeviceObject
->DeviceExtension
;
293 ASSERT(Capabilities
->Version
== 1);
294 if (Capabilities
->Version
== 1)
296 /* Can't lock or eject us */
297 Capabilities
->LockSupported
= FALSE
;
298 Capabilities
->EjectSupported
= FALSE
;
300 /* Can't remove or dock us */
301 Capabilities
->Removable
= FALSE
;
302 Capabilities
->DockDevice
= FALSE
;
304 /* Can't access us raw */
305 Capabilities
->RawDeviceOK
= FALSE
;
307 /* We have a unique ID, and don't bother the user */
308 Capabilities
->UniqueID
= TRUE
;
309 Capabilities
->SilentInstall
= TRUE
;
311 /* Fill out the adress */
312 Capabilities
->Address
= InterfaceTypeUndefined
;
313 Capabilities
->UINumber
= InterfaceTypeUndefined
;
315 /* Fill out latencies */
316 Capabilities
->D1Latency
= 0;
317 Capabilities
->D2Latency
= 0;
318 Capabilities
->D3Latency
= 0;
320 /* Fill out supported device states */
321 Capabilities
->DeviceState
[PowerSystemWorking
] = PowerDeviceD0
;
322 Capabilities
->DeviceState
[PowerSystemHibernate
] = PowerDeviceD3
;
323 Capabilities
->DeviceState
[PowerSystemShutdown
] = PowerDeviceD3
;
324 Capabilities
->DeviceState
[PowerSystemSleeping3
] = PowerDeviceD3
;
327 Status
= STATUS_SUCCESS
;
332 Status
= STATUS_NOT_SUPPORTED
;
341 HalpQueryResources(IN PDEVICE_OBJECT DeviceObject
,
342 OUT PCM_RESOURCE_LIST
*Resources
)
344 PPDO_EXTENSION DeviceExtension
= DeviceObject
->DeviceExtension
;
346 PCM_RESOURCE_LIST ResourceList
;
347 // PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
348 // PIO_RESOURCE_DESCRIPTOR Descriptor;
349 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDesc
;
353 /* Only the ACPI PDO has requirements */
354 if (DeviceExtension
->PdoType
== AcpiPdo
)
357 /* Query ACPI requirements */
358 Status
= HalpQueryAcpiResourceRequirements(&RequirementsList
);
359 if (!NT_SUCCESS(Status
)) return Status
;
361 ASSERT(RequirementsList
->AlternativeLists
== 1);
364 /* Allocate the resourcel ist */
365 ResourceList
= ExAllocatePoolWithTag(PagedPool
,
366 sizeof(CM_RESOURCE_LIST
),
370 /* Fail, no memory */
371 Status
= STATUS_INSUFFICIENT_RESOURCES
;
372 // ExFreePoolWithTag(RequirementsList, ' laH');
377 RtlZeroMemory(ResourceList
, sizeof(CM_RESOURCE_LIST
));
378 ResourceList
->Count
= 1;
380 /* Setup the list fields */
381 ResourceList
->List
[0].BusNumber
= -1;
382 ResourceList
->List
[0].InterfaceType
= PNPBus
;
383 ResourceList
->List
[0].PartialResourceList
.Version
= 1;
384 ResourceList
->List
[0].PartialResourceList
.Revision
= 1;
385 ResourceList
->List
[0].PartialResourceList
.Count
= 0;
387 /* Setup the first descriptor */
388 PartialDesc
= ResourceList
->List
[0].PartialResourceList
.PartialDescriptors
;
390 /* Find the requirement descriptor for the SCI */
392 for (i
= 0; i
< RequirementsList
->List
[0].Count
; i
++)
394 /* Get this descriptor */
395 Descriptor
= &RequirementsList
->List
[0].Descriptors
[i
];
396 if (Descriptor
->Type
== CmResourceTypeInterrupt
)
398 /* Copy requirements descriptor into resource descriptor */
399 PartialDesc
->Type
= CmResourceTypeInterrupt
;
400 PartialDesc
->ShareDisposition
= Descriptor
->ShareDisposition
;
401 PartialDesc
->Flags
= Descriptor
->Flags
;
402 ASSERT(Descriptor
->u
.Interrupt
.MinimumVector
==
403 Descriptor
->u
.Interrupt
.MaximumVector
);
404 PartialDesc
->u
.Interrupt
.Vector
= Descriptor
->u
.Interrupt
.MinimumVector
;
405 PartialDesc
->u
.Interrupt
.Level
= Descriptor
->u
.Interrupt
.MinimumVector
;
406 PartialDesc
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
408 ResourceList
->List
[0].PartialResourceList
.Count
++;
415 /* Return resources and success */
416 *Resources
= ResourceList
;
418 // ExFreePoolWithTag(RequirementsList, ' laH');
420 return STATUS_SUCCESS
;
422 else if (DeviceExtension
->PdoType
== WdPdo
)
424 /* Watchdog doesn't */
425 return STATUS_NOT_SUPPORTED
;
429 /* This shouldn't happen */
430 return STATUS_UNSUCCESSFUL
;
436 HalpQueryResourceRequirements(IN PDEVICE_OBJECT DeviceObject
,
437 OUT PIO_RESOURCE_REQUIREMENTS_LIST
*Requirements
)
439 PPDO_EXTENSION DeviceExtension
= DeviceObject
->DeviceExtension
;
442 /* Only the ACPI PDO has requirements */
443 if (DeviceExtension
->PdoType
== AcpiPdo
)
445 /* Query ACPI requirements */
446 // return HalpQueryAcpiResourceRequirements(Requirements);
447 return STATUS_SUCCESS
;
449 else if (DeviceExtension
->PdoType
== WdPdo
)
451 /* Watchdog doesn't */
452 return STATUS_NOT_SUPPORTED
;
456 /* This shouldn't happen */
457 return STATUS_UNSUCCESSFUL
;
463 HalpQueryIdPdo(IN PDEVICE_OBJECT DeviceObject
,
464 IN BUS_QUERY_ID_TYPE IdType
,
465 OUT PUSHORT
*BusQueryId
)
467 PPDO_EXTENSION PdoExtension
;
475 /* Get the PDO type */
476 PdoExtension
= DeviceObject
->DeviceExtension
;
477 PdoType
= PdoExtension
->PdoType
;
479 /* What kind of ID is being requested? */
480 DPRINT("ID: %d\n", IdType
);
483 case BusQueryDeviceID
:
484 case BusQueryHardwareIDs
:
486 /* What kind of PDO is this? */
487 if (PdoType
== AcpiPdo
)
490 CurrentId
= L
"PCI_HAL\\PNP0A03";
491 RtlCopyMemory(Id
, CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
492 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
494 CurrentId
= L
"*PNP0A03";
495 RtlCopyMemory(&Id
[wcslen(Id
) + 1], CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
496 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
499 else if (PdoType
== WdPdo
)
502 CurrentId
= L
"ACPI_HAL\\PNP0C18";
503 RtlCopyMemory(Id
, CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
504 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
506 CurrentId
= L
"*PNP0C18";
507 RtlCopyMemory(&Id
[wcslen(Id
) + 1], CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
508 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
514 return STATUS_NOT_SUPPORTED
;
518 case BusQueryInstanceID
:
522 RtlCopyMemory(Id
, CurrentId
, (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
));
523 Length
+= (wcslen(CurrentId
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
526 case BusQueryCompatibleIDs
:
529 /* We don't support anything else */
530 return STATUS_NOT_SUPPORTED
;
533 /* Allocate the buffer */
534 Buffer
= ExAllocatePoolWithTag(PagedPool
,
535 Length
+ sizeof(UNICODE_NULL
),
539 /* Copy the string and null-terminate it */
540 RtlCopyMemory(Buffer
, Id
, Length
);
541 Buffer
[Length
/ sizeof(WCHAR
)] = UNICODE_NULL
;
544 *BusQueryId
= Buffer
;
545 Status
= STATUS_SUCCESS
;
546 DPRINT("Returning: %S\n", *BusQueryId
);
551 Status
= STATUS_INSUFFICIENT_RESOURCES
;
560 HalpQueryIdFdo(IN PDEVICE_OBJECT DeviceObject
,
561 IN BUS_QUERY_ID_TYPE IdType
,
562 OUT PUSHORT
*BusQueryId
)
569 /* What kind of ID is being requested? */
570 DPRINT("ID: %d\n", IdType
);
573 case BusQueryDeviceID
:
575 Id
= L
"Root\\PCI_HAL";
578 case BusQueryHardwareIDs
:
580 /* This is our hardware ID */
581 Id
= HalHardwareIdString
;
584 case BusQueryInstanceID
:
586 /* And our instance ID */
592 /* We don't support anything else */
593 return STATUS_NOT_SUPPORTED
;
596 /* Calculate the length */
597 Length
= (wcslen(Id
) * sizeof(WCHAR
)) + sizeof(UNICODE_NULL
);
599 /* Allocate the buffer */
600 Buffer
= ExAllocatePoolWithTag(PagedPool
,
601 Length
+ sizeof(UNICODE_NULL
),
605 /* Copy the string and null-terminate it */
606 RtlCopyMemory(Buffer
, Id
, Length
);
607 Buffer
[Length
/ sizeof(WCHAR
)] = UNICODE_NULL
;
610 *BusQueryId
= Buffer
;
611 Status
= STATUS_SUCCESS
;
612 DPRINT("Returning: %S\n", *BusQueryId
);
617 Status
= STATUS_INSUFFICIENT_RESOURCES
;
626 HalpDispatchPnp(IN PDEVICE_OBJECT DeviceObject
,
629 PIO_STACK_LOCATION IoStackLocation
;
630 PPDO_EXTENSION PdoExtension
;
631 PFDO_EXTENSION FdoExtension
;
635 /* Get the device extension and stack location */
636 FdoExtension
= DeviceObject
->DeviceExtension
;
637 IoStackLocation
= IoGetCurrentIrpStackLocation(Irp
);
638 Minor
= IoStackLocation
->MinorFunction
;
641 if (FdoExtension
->ExtensionType
== FdoExtensionType
)
643 /* Query the IRP type */
646 case IRP_MN_QUERY_DEVICE_RELATIONS
:
648 /* Call the worker */
649 DPRINT("Querying device relations for FDO\n");
650 Status
= HalpQueryDeviceRelations(DeviceObject
,
651 IoStackLocation
->Parameters
.QueryDeviceRelations
.Type
,
652 (PVOID
)&Irp
->IoStatus
.Information
);
655 case IRP_MN_QUERY_INTERFACE
:
657 /* Call the worker */
658 DPRINT("Querying interface for FDO\n");
659 Status
= HalpQueryInterface(DeviceObject
,
660 IoStackLocation
->Parameters
.QueryInterface
.InterfaceType
,
661 IoStackLocation
->Parameters
.QueryInterface
.Size
,
662 IoStackLocation
->Parameters
.QueryInterface
.InterfaceSpecificData
,
663 IoStackLocation
->Parameters
.QueryInterface
.Version
,
664 IoStackLocation
->Parameters
.QueryInterface
.Interface
,
665 (PVOID
)&Irp
->IoStatus
.Information
);
668 case IRP_MN_QUERY_ID
:
670 /* Call the worker */
671 DPRINT("Querying ID for FDO\n");
672 Status
= HalpQueryIdFdo(DeviceObject
,
673 IoStackLocation
->Parameters
.QueryId
.IdType
,
674 (PVOID
)&Irp
->IoStatus
.Information
);
677 case IRP_MN_QUERY_CAPABILITIES
:
679 /* Call the worker */
680 DPRINT("Querying the capabilities for the FDO\n");
681 Status
= HalpQueryCapabilities(DeviceObject
,
682 IoStackLocation
->Parameters
.DeviceCapabilities
.Capabilities
);
687 DPRINT("Other IRP: %lx\n", Minor
);
688 Status
= Irp
->IoStatus
.Status
;
692 /* Nowhere for the IRP to go since we also own the PDO */
693 Irp
->IoStatus
.Status
= Status
;
694 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
699 /* This is a PDO instead */
700 ASSERT(FdoExtension
->ExtensionType
== PdoExtensionType
);
701 PdoExtension
= (PPDO_EXTENSION
)FdoExtension
;
703 /* Query the IRP type */
704 Status
= STATUS_SUCCESS
;
707 case IRP_MN_START_DEVICE
:
709 /* We only care about a PCI PDO */
710 DPRINT1("Start device received\n");
711 /* Complete the IRP normally */
714 case IRP_MN_REMOVE_DEVICE
:
716 /* Check if this is a PCI device */
717 DPRINT1("Remove device received\n");
720 Status
= STATUS_SUCCESS
;
723 case IRP_MN_SURPRISE_REMOVAL
:
725 /* Inherit whatever status we had */
726 DPRINT1("Surprise removal IRP\n");
727 Status
= Irp
->IoStatus
.Status
;
730 case IRP_MN_QUERY_DEVICE_RELATIONS
:
732 /* Query the device relations */
733 DPRINT("Querying PDO relations\n");
734 Status
= HalpQueryDeviceRelations(DeviceObject
,
735 IoStackLocation
->Parameters
.QueryDeviceRelations
.Type
,
736 (PVOID
)&Irp
->IoStatus
.Information
);
739 case IRP_MN_QUERY_INTERFACE
:
741 /* Call the worker */
742 DPRINT("Querying interface for PDO\n");
743 Status
= HalpQueryInterface(DeviceObject
,
744 IoStackLocation
->Parameters
.QueryInterface
.InterfaceType
,
745 IoStackLocation
->Parameters
.QueryInterface
.Size
,
746 IoStackLocation
->Parameters
.QueryInterface
.InterfaceSpecificData
,
747 IoStackLocation
->Parameters
.QueryInterface
.Version
,
748 IoStackLocation
->Parameters
.QueryInterface
.Interface
,
749 (PVOID
)&Irp
->IoStatus
.Information
);
752 case IRP_MN_QUERY_CAPABILITIES
:
754 /* Call the worker */
755 DPRINT("Querying the capabilities for the PDO\n");
756 Status
= HalpQueryCapabilities(DeviceObject
,
757 IoStackLocation
->Parameters
.DeviceCapabilities
.Capabilities
);
760 case IRP_MN_QUERY_RESOURCES
:
762 /* Call the worker */
763 DPRINT("Querying the resources for the PDO\n");
764 Status
= HalpQueryResources(DeviceObject
, (PVOID
)&Irp
->IoStatus
.Information
);
767 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS
:
769 /* Call the worker */
770 DPRINT("Querying the resource requirements for the PDO\n");
771 Status
= HalpQueryResourceRequirements(DeviceObject
,
772 (PVOID
)&Irp
->IoStatus
.Information
);
775 case IRP_MN_QUERY_ID
:
777 /* Call the worker */
778 DPRINT("Query the ID for the PDO\n");
779 Status
= HalpQueryIdPdo(DeviceObject
,
780 IoStackLocation
->Parameters
.QueryId
.IdType
,
781 (PVOID
)&Irp
->IoStatus
.Information
);
786 /* We don't handle anything else, so inherit the old state */
787 DPRINT("Illegal IRP: %lx\n", Minor
);
788 Status
= Irp
->IoStatus
.Status
;
792 /* If it's not supported, inherit the old status */
793 if (Status
== STATUS_NOT_SUPPORTED
) Status
= Irp
->IoStatus
.Status
;
795 /* Complete the IRP */
796 DPRINT("IRP completed with status: %lx\n", Status
);
797 Irp
->IoStatus
.Status
= Status
;
798 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
805 HalpDispatchWmi(IN PDEVICE_OBJECT DeviceObject
,
808 DPRINT1("HAL: PnP Driver WMI!\n");
810 return STATUS_SUCCESS
;
815 HalpDispatchPower(IN PDEVICE_OBJECT DeviceObject
,
818 DPRINT1("HAL: PnP Driver Power!\n");
819 return STATUS_SUCCESS
;
824 HalpDriverEntry(IN PDRIVER_OBJECT DriverObject
,
825 IN PUNICODE_STRING RegistryPath
)
828 PDEVICE_OBJECT TargetDevice
= NULL
;
830 DPRINT("HAL: PnP Driver ENTRY!\n");
833 HalpDriverObject
= DriverObject
;
835 /* Set up add device */
836 DriverObject
->DriverExtension
->AddDevice
= HalpAddDevice
;
838 /* Set up the callouts */
839 DriverObject
->MajorFunction
[IRP_MJ_PNP
] = HalpDispatchPnp
;
840 DriverObject
->MajorFunction
[IRP_MJ_POWER
] = HalpDispatchPower
;
841 DriverObject
->MajorFunction
[IRP_MJ_SYSTEM_CONTROL
] = HalpDispatchWmi
;
844 Status
= IoCreateDevice(DriverObject
,
847 FILE_DEVICE_CONTROLLER
,
851 if (!NT_SUCCESS(Status
))
854 TargetDevice
->Flags
&= ~DO_DEVICE_INITIALIZING
;
856 /* Set up the device stack */
857 Status
= HalpAddDevice(DriverObject
, TargetDevice
);
858 if (!NT_SUCCESS(Status
))
860 IoDeleteDevice(TargetDevice
);
864 /* Tell the PnP manager about us */
865 Status
= IoReportDetectedDevice(DriverObject
,
866 InterfaceTypeUndefined
,
874 /* Return to kernel */
880 HaliInitPnpDriver(VOID
)
883 UNICODE_STRING DriverString
;
886 /* Create the driver */
887 RtlInitUnicodeString(&DriverString
, L
"\\Driver\\PCI_HAL");
888 Status
= IoCreateDriver(&DriverString
, HalpDriverEntry
);