26276f798ee6d638e6e93c13ef17fc27c25eeee2
[reactos.git] / reactos / hal / halx86 / generic / acpi / halpnpdd.c
1 /*
2 * PROJECT: ReactOS HAL
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
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #include <hal.h>
12 #define NDEBUG
13 #include <debug.h>
14
15 typedef enum _EXTENSION_TYPE
16 {
17 PdoExtensionType = 0xC0,
18 FdoExtensionType
19 } EXTENSION_TYPE;
20
21 typedef enum _PDO_TYPE
22 {
23 AcpiPdo = 0x80,
24 WdPdo
25 } PDO_TYPE;
26
27 typedef struct _FDO_EXTENSION
28 {
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;
35
36 typedef struct _PDO_EXTENSION
37 {
38 EXTENSION_TYPE ExtensionType;
39 struct _PDO_EXTENSION* Next;
40 PDEVICE_OBJECT PhysicalDeviceObject;
41 PFDO_EXTENSION ParentFdoExtension;
42 PDO_TYPE PdoType;
43 PDESCRIPTION_HEADER WdTable;
44 LONG InterfaceReferenceCount;
45 } PDO_EXTENSION, *PPDO_EXTENSION;
46
47 /* GLOBALS ********************************************************************/
48
49 PDRIVER_OBJECT HalpDriverObject;
50
51 /* PRIVATE FUNCTIONS **********************************************************/
52
53 NTSTATUS
54 NTAPI
55 HalpAddDevice(IN PDRIVER_OBJECT DriverObject,
56 IN PDEVICE_OBJECT TargetDevice)
57 {
58 NTSTATUS Status;
59 PFDO_EXTENSION FdoExtension;
60 PPDO_EXTENSION PdoExtension;
61 PDEVICE_OBJECT DeviceObject, PdoDeviceObject, AttachedDevice;
62 PDESCRIPTION_HEADER Wdrt;
63 DbgPrint("HAL: PnP Driver ADD!\n");
64
65 /* Create the FDO */
66 Status = IoCreateDevice(DriverObject,
67 sizeof(FDO_EXTENSION),
68 NULL,
69 FILE_DEVICE_BUS_EXTENDER,
70 0,
71 FALSE,
72 &DeviceObject);
73 if (!NT_SUCCESS(Status))
74 {
75 /* Should not happen */
76 DbgBreakPoint();
77 return Status;
78 }
79
80 /* Setup the FDO extension */
81 FdoExtension = DeviceObject->DeviceExtension;
82 FdoExtension->ExtensionType = FdoExtensionType;
83 FdoExtension->PhysicalDeviceObject = TargetDevice;
84 FdoExtension->FunctionalDeviceObject = DeviceObject;
85
86 /* FDO is done initializing */
87 DeviceObject->Flags &= DO_DEVICE_INITIALIZING;
88
89 /* Attach to the physical device object (the bus) */
90 AttachedDevice = IoAttachDeviceToDeviceStack(DeviceObject, TargetDevice);
91 if (!AttachedDevice)
92 {
93 /* Failed, undo everything */
94 IoDeleteDevice(DeviceObject);
95 return STATUS_NO_SUCH_DEVICE;
96 }
97
98 /* Save the attachment */
99 FdoExtension->AttachedDeviceObject = AttachedDevice;
100
101 /* Create the PDO */
102 Status = IoCreateDevice(DriverObject,
103 sizeof(PDO_EXTENSION),
104 NULL,
105 FILE_DEVICE_BUS_EXTENDER,
106 FILE_AUTOGENERATED_DEVICE_NAME,
107 FALSE,
108 &PdoDeviceObject);
109 if (!NT_SUCCESS(Status))
110 {
111 /* Fail */
112 DbgPrint("HAL: Could not create ACPI device object status=0x%08x\n", Status);
113 return Status;
114 }
115
116 /* Setup the PDO device extension */
117 PdoExtension = PdoDeviceObject->DeviceExtension;
118 PdoExtension->Next = NULL;
119 PdoExtension->ExtensionType = PdoExtensionType;
120 PdoExtension->PhysicalDeviceObject = PdoDeviceObject;
121 PdoExtension->ParentFdoExtension = FdoExtension;
122 PdoExtension->PdoType = AcpiPdo;
123
124 /* Find the ACPI watchdog table */
125 Wdrt = HalAcpiGetTable(0, 'TRDW');
126 if (!Wdrt)
127 {
128 /* None exists, there is nothing to do more */
129 PdoDeviceObject->Flags &= DO_DEVICE_INITIALIZING;
130 FdoExtension->ChildPdoList = PdoExtension;
131 }
132 else
133 {
134 /* FIXME: TODO */
135 DPRINT1("You have an ACPI Watchdog. That's great! You should be proud ;-)\n");
136 PdoDeviceObject->Flags &= DO_DEVICE_INITIALIZING;
137 FdoExtension->ChildPdoList = PdoExtension;
138 }
139
140 /* Return status */
141 DPRINT1("Device added %lx\n", Status);
142 return Status;
143 }
144
145 NTSTATUS
146 NTAPI
147 HalpQueryInterface(IN PDEVICE_OBJECT DeviceObject,
148 IN CONST GUID* InterfaceType,
149 IN USHORT Version,
150 IN PVOID InterfaceSpecificData,
151 IN ULONG InterfaceBufferSize,
152 IN PINTERFACE Interface,
153 OUT PULONG Length)
154 {
155 UNIMPLEMENTED;
156 while (TRUE);
157 return STATUS_NO_SUCH_DEVICE;
158 }
159
160 NTSTATUS
161 NTAPI
162 HalpQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject,
163 IN DEVICE_RELATION_TYPE RelationType,
164 OUT PDEVICE_RELATIONS* DeviceRelations)
165 {
166 EXTENSION_TYPE ExtensionType;
167 PPDO_EXTENSION PdoExtension;
168 PFDO_EXTENSION FdoExtension;
169 PDEVICE_RELATIONS PdoRelations, FdoRelations;
170 PDEVICE_OBJECT* ObjectEntry;
171 ULONG i = 0, PdoCount = 0;
172
173 /* Get FDO device extension and PDO count */
174 FdoExtension = DeviceObject->DeviceExtension;
175 ExtensionType = FdoExtension->ExtensionType;
176
177 /* What do they want? */
178 if (RelationType == BusRelations)
179 {
180 /* This better be an FDO */
181 if (ExtensionType == FdoExtensionType)
182 {
183 /* Count how many PDOs we have */
184 PdoExtension = FdoExtension->ChildPdoList;
185 while (PdoExtension)
186 {
187 /* Next one */
188 PdoExtension = PdoExtension->Next;
189 PdoCount++;
190 }
191
192 /* Allocate our structure */
193 FdoRelations = ExAllocatePoolWithTag(PagedPool,
194 FIELD_OFFSET(DEVICE_RELATIONS,
195 Objects) +
196 4 * PdoCount,
197 ' laH');
198 if (!FdoRelations) return STATUS_INSUFFICIENT_RESOURCES;
199
200 /* Save our count */
201 FdoRelations->Count = PdoCount;
202
203 /* Query existing relations */
204 ObjectEntry = FdoRelations->Objects;
205 if (*DeviceRelations)
206 {
207 /* Check if there were any */
208 if ((*DeviceRelations)->Count)
209 {
210 /* Loop them all */
211 do
212 {
213 /* Copy into our structure */
214 *ObjectEntry++ = (*DeviceRelations)->Objects[i];
215 }
216 while (++i < (*DeviceRelations)->Count);
217 }
218
219 /* Free existing structure */
220 ExFreePoolWithTag(*DeviceRelations, 0);
221 }
222
223 /* Now check if we have a PDO list */
224 PdoExtension = FdoExtension->ChildPdoList;
225 if (PdoExtension)
226 {
227 /* Loop the PDOs */
228 do
229 {
230 /* Save our own PDO and reference it */
231 *ObjectEntry++ = PdoExtension->PhysicalDeviceObject;
232 ObfReferenceObject(PdoExtension->PhysicalDeviceObject);
233
234 /* Go to our next PDO */
235 PdoExtension = PdoExtension->Next;
236 }
237 while (PdoExtension);
238 }
239
240 /* Return the new structure */
241 *DeviceRelations = FdoRelations;
242 return STATUS_SUCCESS;
243 }
244 }
245 else
246 {
247 /* The only other thing we support is a target relation for the PDO */
248 if ((RelationType == TargetDeviceRelation) &&
249 (ExtensionType == PdoExtensionType))
250 {
251 /* Only one entry */
252 PdoRelations = ExAllocatePoolWithTag(PagedPool,
253 sizeof(DEVICE_RELATIONS),
254 ' laH');
255 if (!PdoRelations) return STATUS_INSUFFICIENT_RESOURCES;
256
257 /* Fill it out and reference us */
258 PdoRelations->Count = 1;
259 PdoRelations->Objects[0] = DeviceObject;
260 ObfReferenceObject(DeviceObject);
261
262 /* Return it */
263 *DeviceRelations = PdoRelations;
264 return STATUS_SUCCESS;
265 }
266 }
267
268 /* We don't support anything else */
269 return STATUS_NOT_SUPPORTED;
270 }
271
272 NTSTATUS
273 NTAPI
274 HalpQueryCapabilities(IN PDEVICE_OBJECT DeviceObject,
275 OUT PDEVICE_CAPABILITIES Capabilities)
276 {
277 PPDO_EXTENSION PdoExtension;
278 NTSTATUS Status;
279 PAGED_CODE();
280
281 /* Get the extension and check for valid version */
282 PdoExtension = DeviceObject->DeviceExtension;
283 ASSERT(Capabilities->Version == 1);
284 if (Capabilities->Version == 1)
285 {
286 /* Can't lock or eject us */
287 Capabilities->LockSupported = FALSE;
288 Capabilities->EjectSupported = FALSE;
289
290 /* Can't remove or dock us */
291 Capabilities->Removable = FALSE;
292 Capabilities->DockDevice = FALSE;
293
294 /* Can't access us raw */
295 Capabilities->RawDeviceOK = FALSE;
296
297 /* We have a unique ID, and don't bother the user */
298 Capabilities->UniqueID = TRUE;
299 Capabilities->SilentInstall = TRUE;
300
301 /* Fill out the adress */
302 Capabilities->Address = InterfaceTypeUndefined;
303 Capabilities->UINumber = InterfaceTypeUndefined;
304
305 /* Fill out latencies */
306 Capabilities->D1Latency = 0;
307 Capabilities->D2Latency = 0;
308 Capabilities->D3Latency = 0;
309
310 /* Fill out supported device states */
311 Capabilities->DeviceState[PowerSystemWorking] = PowerDeviceD0;
312 Capabilities->DeviceState[PowerSystemHibernate] = PowerDeviceD3;
313 Capabilities->DeviceState[PowerSystemShutdown] = PowerDeviceD3;
314 Capabilities->DeviceState[PowerSystemSleeping3] = PowerDeviceD3;
315
316 /* Done */
317 Status = STATUS_SUCCESS;
318 }
319 else
320 {
321 /* Fail */
322 Status = STATUS_NOT_SUPPORTED;
323 }
324
325 /* Return status */
326 return Status;
327 }
328
329 NTSTATUS
330 NTAPI
331 HalpQueryResources(IN PDEVICE_OBJECT DeviceObject,
332 OUT PCM_RESOURCE_LIST *Resources)
333 {
334 UNIMPLEMENTED;
335 while (TRUE);
336 return STATUS_NO_SUCH_DEVICE;
337 }
338
339 NTSTATUS
340 NTAPI
341 HalpQueryResourceRequirements(IN PDEVICE_OBJECT DeviceObject,
342 OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requirements)
343 {
344 PPDO_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
345 NTSTATUS Status;
346 PAGED_CODE();
347
348 /* Only the ACPI PDO has requirements */
349 if (DeviceExtension->PdoType == AcpiPdo)
350 {
351 /* Query ACPI requirements */
352 Status = HalpQueryAcpiResourceRequirements(Requirements);
353 }
354 else if (DeviceExtension->PdoType == WdPdo)
355 {
356 /* Watchdog doesn't */
357 return STATUS_NOT_SUPPORTED;
358 }
359 else
360 {
361 /* This shouldn't happen */
362 return STATUS_UNSUCCESSFUL;
363 }
364
365 /* Return the status */
366 return Status;
367 }
368
369 NTSTATUS
370 NTAPI
371 HalpQueryIdPdo(IN PDEVICE_OBJECT DeviceObject,
372 IN BUS_QUERY_ID_TYPE IdType,
373 OUT PUSHORT *BusQueryId)
374 {
375 PPDO_EXTENSION PdoExtension;
376 PDO_TYPE PdoType;
377 PWCHAR Id;
378 NTSTATUS Status;
379 ULONG Length;
380 PWCHAR Buffer;
381
382 /* Get the PDO type */
383 PdoExtension = DeviceObject->DeviceExtension;
384 PdoType = PdoExtension->PdoType;
385
386 /* What kind of ID is being requested? */
387 DPRINT("ID: %d\n", IdType);
388 switch (IdType)
389 {
390 case BusQueryDeviceID:
391 case BusQueryHardwareIDs:
392
393 /* What kind of PDO is this? */
394 if (PdoType == AcpiPdo)
395 {
396 /* PCI ID */
397 Id = L"ACPI_HAL\\PNP0C08";
398 }
399 else if (PdoType == WdPdo)
400 {
401 /* WatchDog ID */
402 Id = L"ACPI_HAL\\PNP0C18";
403 }
404 else
405 {
406 /* Unknown */
407 return STATUS_NOT_SUPPORTED;
408 }
409
410 /* Static length */
411 Length = 32;
412 break;
413
414 case BusQueryInstanceID:
415
416 /* And our instance ID */
417 Id = L"0";
418 Length = sizeof(L"0") + sizeof(UNICODE_NULL);
419 break;
420
421 case BusQueryCompatibleIDs:
422 default:
423
424 /* We don't support anything else */
425 return STATUS_NOT_SUPPORTED;
426 }
427
428 /* Allocate the buffer */
429 Buffer = ExAllocatePoolWithTag(PagedPool,
430 Length + sizeof(UNICODE_NULL),
431 ' laH');
432 if (Buffer)
433 {
434 /* Copy the string and null-terminate it */
435 RtlCopyMemory(Buffer, Id, Length);
436 Buffer[Length / sizeof(WCHAR)] = UNICODE_NULL;
437
438 /* Return string */
439 *BusQueryId = Buffer;
440 Status = STATUS_SUCCESS;
441 DPRINT("Returning: %S\n", *BusQueryId);
442 }
443 else
444 {
445 /* Fail */
446 Status = STATUS_INSUFFICIENT_RESOURCES;
447 }
448
449 /* Return status */
450 return Status;
451 }
452
453 NTSTATUS
454 NTAPI
455 HalpQueryIdFdo(IN PDEVICE_OBJECT DeviceObject,
456 IN BUS_QUERY_ID_TYPE IdType,
457 OUT PUSHORT *BusQueryId)
458 {
459 NTSTATUS Status;
460 ULONG Length;
461 PWCHAR Id;
462 PWCHAR Buffer;
463
464 /* What kind of ID is being requested? */
465 DPRINT("ID: %d\n", IdType);
466 switch (IdType)
467 {
468 case BusQueryDeviceID:
469 case BusQueryHardwareIDs:
470
471 /* This is our hardware ID */
472 Id = HalHardwareIdString;
473 Length = wcslen(HalHardwareIdString) + sizeof(UNICODE_NULL);
474 break;
475
476 case BusQueryInstanceID:
477
478 /* And our instance ID */
479 Id = L"0";
480 Length = sizeof(L"0") + sizeof(UNICODE_NULL);
481 break;
482
483 default:
484
485 /* We don't support anything else */
486 return STATUS_NOT_SUPPORTED;
487 }
488
489 /* Allocate the buffer */
490 Buffer = ExAllocatePoolWithTag(PagedPool,
491 Length + sizeof(UNICODE_NULL),
492 ' laH');
493 if (Buffer)
494 {
495 /* Copy the string and null-terminate it */
496 RtlCopyMemory(Buffer, Id, Length);
497 Buffer[Length / sizeof(WCHAR)] = UNICODE_NULL;
498
499 /* Return string */
500 *BusQueryId = Buffer;
501 Status = STATUS_SUCCESS;
502 DPRINT("Returning: %S\n", *BusQueryId);
503 }
504 else
505 {
506 /* Fail */
507 Status = STATUS_INSUFFICIENT_RESOURCES;
508 }
509
510 /* Return status */
511 return Status;
512 }
513
514 NTSTATUS
515 NTAPI
516 HalpPassIrpFromFdoToPdo(IN PDEVICE_OBJECT DeviceObject,
517 IN PIRP Irp)
518 {
519 PFDO_EXTENSION FdoExtension;
520
521 /* Get the extension */
522 FdoExtension = DeviceObject->DeviceExtension;
523
524 /* Pass it to the attached device (our PDO) */
525 IoSkipCurrentIrpStackLocation(Irp);
526 return IoCallDriver(FdoExtension->AttachedDeviceObject, Irp);
527 }
528
529 NTSTATUS
530 NTAPI
531 HalpDispatchPnp(IN PDEVICE_OBJECT DeviceObject,
532 IN PIRP Irp)
533 {
534 PIO_STACK_LOCATION IoStackLocation;
535 PPDO_EXTENSION PdoExtension;
536 PFDO_EXTENSION FdoExtension;
537 NTSTATUS Status;
538 UCHAR Minor;
539
540 /* Get the device extension and stack location */
541 FdoExtension = DeviceObject->DeviceExtension;
542 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
543 Minor = IoStackLocation->MinorFunction;
544
545 /* FDO? */
546 if (FdoExtension->ExtensionType == FdoExtensionType)
547 {
548 /* Query the IRP type */
549 switch (Minor)
550 {
551 case IRP_MN_QUERY_DEVICE_RELATIONS:
552
553 /* Call the worker */
554 DPRINT("Querying device relations for FDO\n");
555 Status = HalpQueryDeviceRelations(DeviceObject,
556 IoStackLocation->Parameters.QueryDeviceRelations.Type,
557 (PVOID)&Irp->IoStatus.Information);
558 break;
559
560 case IRP_MN_QUERY_INTERFACE:
561
562 /* Call the worker */
563 DPRINT("Querying interface for FDO\n");
564 Status = HalpQueryInterface(DeviceObject,
565 IoStackLocation->Parameters.QueryInterface.InterfaceType,
566 IoStackLocation->Parameters.QueryInterface.Size,
567 IoStackLocation->Parameters.QueryInterface.InterfaceSpecificData,
568 IoStackLocation->Parameters.QueryInterface.Version,
569 IoStackLocation->Parameters.QueryInterface.Interface,
570 (PVOID)&Irp->IoStatus.Information);
571 break;
572
573
574 case IRP_MN_QUERY_ID:
575
576 /* Call the worker */
577 DPRINT("Querying ID for FDO\n");
578 Status = HalpQueryIdFdo(DeviceObject,
579 IoStackLocation->Parameters.QueryId.IdType,
580 (PVOID)&Irp->IoStatus.Information);
581 break;
582
583 default:
584
585 /* Pass it to the PDO */
586 DPRINT("Other IRP: %lx\n", Minor);
587 return HalpPassIrpFromFdoToPdo(DeviceObject, Irp);
588 }
589
590 /* What happpened? */
591 if ((NT_SUCCESS(Status)) || (Status == STATUS_NOT_SUPPORTED))
592 {
593 /* Set the IRP status, unless this isn't understood */
594 if (Status != STATUS_NOT_SUPPORTED) Irp->IoStatus.Status = Status;
595
596 /* Pass it on */
597 DPRINT("Passing IRP to PDO\n");
598 return HalpPassIrpFromFdoToPdo(DeviceObject, Irp);
599 }
600
601 /* Otherwise, we failed, so set the status and complete the request */
602 DPRINT1("IRP failed with status: %lx\n", Status);
603 Irp->IoStatus.Status = Status;
604 IoCompleteRequest(Irp, IO_NO_INCREMENT);
605 return Status;
606 }
607 else
608 {
609 /* This is a PDO instead */
610 ASSERT(FdoExtension->ExtensionType == PdoExtensionType);
611 PdoExtension = (PPDO_EXTENSION)FdoExtension;
612
613 /* Query the IRP type */
614 Status = STATUS_SUCCESS;
615 switch (Minor)
616 {
617 case IRP_MN_START_DEVICE:
618
619 /* We only care about a PCI PDO */
620 DPRINT1("Start device received\n");
621 /* Complete the IRP normally */
622 break;
623
624 case IRP_MN_REMOVE_DEVICE:
625
626 /* Check if this is a PCI device */
627 DPRINT1("Remove device received\n");
628
629 /* We're done */
630 Status = STATUS_SUCCESS;
631 break;
632
633 case IRP_MN_SURPRISE_REMOVAL:
634
635 /* Inherit whatever status we had */
636 DPRINT1("Surprise removal IRP\n");
637 Status = Irp->IoStatus.Status;
638 break;
639
640 case IRP_MN_QUERY_DEVICE_RELATIONS:
641
642 /* Query the device relations */
643 DPRINT("Querying PDO relations\n");
644 Status = HalpQueryDeviceRelations(DeviceObject,
645 IoStackLocation->Parameters.QueryDeviceRelations.Type,
646 (PVOID)&Irp->IoStatus.Information);
647 break;
648
649 case IRP_MN_QUERY_INTERFACE:
650
651 /* Call the worker */
652 DPRINT("Querying interface for PDO\n");
653 Status = HalpQueryInterface(DeviceObject,
654 IoStackLocation->Parameters.QueryInterface.InterfaceType,
655 IoStackLocation->Parameters.QueryInterface.Size,
656 IoStackLocation->Parameters.QueryInterface.InterfaceSpecificData,
657 IoStackLocation->Parameters.QueryInterface.Version,
658 IoStackLocation->Parameters.QueryInterface.Interface,
659 (PVOID)&Irp->IoStatus.Information);
660 break;
661
662 case IRP_MN_QUERY_CAPABILITIES:
663
664 /* Call the worker */
665 DPRINT("Querying the capabilities for the PDO\n");
666 Status = HalpQueryCapabilities(DeviceObject,
667 IoStackLocation->Parameters.DeviceCapabilities.Capabilities);
668 break;
669
670 case IRP_MN_QUERY_RESOURCES:
671
672 /* Call the worker */
673 DPRINT("Querying the resources for the PDO\n");
674 Status = HalpQueryResources(DeviceObject, (PVOID)&Irp->IoStatus.Information);
675 break;
676
677 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
678
679 /* Call the worker */
680 DPRINT("Querying the resource requirements for the PDO\n");
681 Status = HalpQueryResourceRequirements(DeviceObject,
682 (PVOID)&Irp->IoStatus.Information);
683 break;
684
685 case IRP_MN_QUERY_ID:
686
687 /* Call the worker */
688 DPRINT("Query the ID for the PDO\n");
689 Status = HalpQueryIdPdo(DeviceObject,
690 IoStackLocation->Parameters.QueryId.IdType,
691 (PVOID)&Irp->IoStatus.Information);
692 break;
693
694 default:
695
696 /* We don't handle anything else, so inherit the old state */
697 DPRINT("Illegal IRP: %lx\n", Minor);
698 Status = Irp->IoStatus.Status;
699 break;
700 }
701
702 /* If it's not supported, inherit the old status */
703 if (Status == STATUS_NOT_SUPPORTED) Status = Irp->IoStatus.Status;
704
705 /* Complete the IRP */
706 DPRINT("IRP completed with status: %lx\n", Status);
707 Irp->IoStatus.Status = Status;
708 IoCompleteRequest(Irp, IO_NO_INCREMENT);
709 return Status;
710 }
711 }
712
713 NTSTATUS
714 NTAPI
715 HalpDispatchWmi(IN PDEVICE_OBJECT DeviceObject,
716 IN PIRP Irp)
717 {
718 DbgPrint("HAL: PnP Driver WMI!\n");
719 while (TRUE);
720 return STATUS_SUCCESS;
721 }
722
723 NTSTATUS
724 NTAPI
725 HalpDispatchPower(IN PDEVICE_OBJECT DeviceObject,
726 IN PIRP Irp)
727 {
728 DbgPrint("HAL: PnP Driver Power!\n");
729 while (TRUE);
730 return STATUS_SUCCESS;
731 }
732
733 NTSTATUS
734 NTAPI
735 HalpDriverEntry(IN PDRIVER_OBJECT DriverObject,
736 IN PUNICODE_STRING RegistryPath)
737 {
738 NTSTATUS Status;
739 PDEVICE_OBJECT TargetDevice = NULL;
740 DPRINT("HAL: PnP Driver ENTRY!\n");
741
742 /* This is us */
743 HalpDriverObject = DriverObject;
744
745 /* Set up add device */
746 DriverObject->DriverExtension->AddDevice = HalpAddDevice;
747
748 /* Set up the callouts */
749 DriverObject->MajorFunction[IRP_MJ_PNP] = HalpDispatchPnp;
750 DriverObject->MajorFunction[IRP_MJ_POWER] = HalpDispatchPower;
751 DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = HalpDispatchWmi;
752
753 /* Tell the PnP about us */
754 Status = IoReportDetectedDevice(DriverObject,
755 InterfaceTypeUndefined,
756 -1,
757 -1,
758 NULL,
759 NULL,
760 FALSE,
761 &TargetDevice);
762
763 /* Now add us */
764 if (NT_SUCCESS(Status)) Status = HalpAddDevice(DriverObject, TargetDevice);
765
766 /* Force re-enumeration??? */
767 IoInvalidateDeviceRelations(TargetDevice, 0);
768
769 /* Return to kernel */
770 return Status;
771 }
772
773 NTSTATUS
774 NTAPI
775 HaliInitPnpDriver(VOID)
776 {
777 NTSTATUS Status;
778 UNICODE_STRING DriverString;
779 PAGED_CODE();
780
781 /* Create the driver */
782 RtlInitUnicodeString(&DriverString, L"\\Driver\\ACPI_HAL");
783 Status = IoCreateDriver(&DriverString, HalpDriverEntry);
784
785 /* Return status */
786 return Status;
787 }
788
789 /* EOF */