ReactOS 0.4.15-dev-7934-g1dc8d80
halpnpdd.c File Reference
#include <hal.h>
#include <initguid.h>
#include <wdmguid.h>
#include <debug.h>
Include dependency graph for halpnpdd.c:

Go to the source code of this file.

Classes

struct  _FDO_EXTENSION
 
struct  _PDO_EXTENSION
 

Macros

#define NDEBUG
 

Typedefs

typedef enum _EXTENSION_TYPE EXTENSION_TYPE
 
typedef enum _PDO_TYPE PDO_TYPE
 
typedef struct _FDO_EXTENSION FDO_EXTENSION
 
typedef struct _FDO_EXTENSIONPFDO_EXTENSION
 
typedef struct _PDO_EXTENSION PDO_EXTENSION
 
typedef struct _PDO_EXTENSIONPPDO_EXTENSION
 

Enumerations

enum  _EXTENSION_TYPE { PdoExtensionType = 0xC0 , FdoExtensionType , PdoExtensionType = 0xC0 , FdoExtensionType }
 
enum  _PDO_TYPE {
  AcpiPdo = 0x80 , WdPdo , AcpiPdo = 0x80 , WdPdo ,
  PDO_TYPE_UNDEFINED = 0 , PDO_TYPE_DISK , PDO_TYPE_CONTROL , PDO_TYPE_SILO ,
  PDO_TYPE_THIS = 256
}
 

Functions

NTSTATUS NTAPI HalpAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT TargetDevice)
 
NTSTATUS NTAPI HalpQueryInterface (IN PDEVICE_OBJECT DeviceObject, IN CONST GUID *InterfaceType, IN USHORT Version, IN PVOID InterfaceSpecificData, IN ULONG InterfaceBufferSize, IN PINTERFACE Interface, OUT PULONG Length)
 
NTSTATUS NTAPI HalpQueryDeviceRelations (IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE RelationType, OUT PDEVICE_RELATIONS *DeviceRelations)
 
NTSTATUS NTAPI HalpQueryCapabilities (IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_CAPABILITIES Capabilities)
 
NTSTATUS NTAPI HalpQueryResources (IN PDEVICE_OBJECT DeviceObject, OUT PCM_RESOURCE_LIST *Resources)
 
NTSTATUS NTAPI HalpQueryResourceRequirements (IN PDEVICE_OBJECT DeviceObject, OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requirements)
 
NTSTATUS NTAPI HalpQueryIdPdo (IN PDEVICE_OBJECT DeviceObject, IN BUS_QUERY_ID_TYPE IdType, OUT PUSHORT *BusQueryId)
 
NTSTATUS NTAPI HalpQueryIdFdo (IN PDEVICE_OBJECT DeviceObject, IN BUS_QUERY_ID_TYPE IdType, OUT PUSHORT *BusQueryId)
 
NTSTATUS NTAPI HalpDispatchPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI HalpDispatchWmi (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI HalpDispatchPower (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI HalpDriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 
NTSTATUS NTAPI HaliInitPnpDriver (VOID)
 

Variables

PDRIVER_OBJECT HalpDriverObject
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file halpnpdd.c.

Typedef Documentation

◆ EXTENSION_TYPE

◆ FDO_EXTENSION

◆ PDO_EXTENSION

◆ PDO_TYPE

◆ PFDO_EXTENSION

◆ PPDO_EXTENSION

Enumeration Type Documentation

◆ _EXTENSION_TYPE

Enumerator
PdoExtensionType 
FdoExtensionType 
PdoExtensionType 
FdoExtensionType 

Definition at line 19 of file halpnpdd.c.

20{
21 PdoExtensionType = 0xC0,
@ PdoExtensionType
Definition: halpnpdd.c:21
@ FdoExtensionType
Definition: halpnpdd.c:22
enum _EXTENSION_TYPE EXTENSION_TYPE

◆ _PDO_TYPE

Enumerator
AcpiPdo 
WdPdo 
AcpiPdo 
WdPdo 
PDO_TYPE_UNDEFINED 
PDO_TYPE_DISK 
PDO_TYPE_CONTROL 
PDO_TYPE_SILO 
PDO_TYPE_THIS 

Definition at line 25 of file halpnpdd.c.

26{
27 AcpiPdo = 0x80,
28 WdPdo
29} PDO_TYPE;
enum _PDO_TYPE PDO_TYPE
@ AcpiPdo
Definition: halpnpdd.c:27
@ WdPdo
Definition: halpnpdd.c:28

Function Documentation

◆ HaliInitPnpDriver()

NTSTATUS NTAPI HaliInitPnpDriver ( VOID  )

Definition at line 906 of file halpnpdd.c.

907{
909 UNICODE_STRING DriverString;
910 PAGED_CODE();
911
912 /* Create the driver */
913 RtlInitUnicodeString(&DriverString, L"\\Driver\\ACPI_HAL");
914 Status = IoCreateDriver(&DriverString, HalpDriverEntry);
915
916 /* Return status */
917 return Status;
918}
#define PAGED_CODE()
NTSTATUS NTAPI HalpDriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
Definition: halpnpdd.c:859
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI IoCreateDriver(_In_opt_ PUNICODE_STRING DriverName, _In_ PDRIVER_INITIALIZE InitializationFunction)
Definition: driver.c:1576
#define L(x)
Definition: ntvdm.h:50

Referenced by HalInitSystem().

◆ HalpAddDevice()

NTSTATUS NTAPI HalpAddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  TargetDevice 
)

Definition at line 59 of file halpnpdd.c.

61{
65 PDEVICE_OBJECT DeviceObject, AttachedDevice;
68
69 DPRINT("HAL: PnP Driver ADD!\n");
70
71 /* Create the FDO */
73 sizeof(FDO_EXTENSION),
74 NULL,
76 0,
77 FALSE,
79 if (!NT_SUCCESS(Status))
80 {
81 /* Should not happen */
83 return Status;
84 }
85
86 /* Setup the FDO extension */
87 FdoExtension = DeviceObject->DeviceExtension;
88 FdoExtension->ExtensionType = FdoExtensionType;
89 FdoExtension->PhysicalDeviceObject = TargetDevice;
90 FdoExtension->FunctionalDeviceObject = DeviceObject;
91 FdoExtension->ChildPdoList = NULL;
92
93 /* FDO is done initializing */
94 DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
95
96 /* Attach to the physical device object (the bus) */
98 if (!AttachedDevice)
99 {
100 /* Failed, undo everything */
103 }
104
105 /* Save the attachment */
106 FdoExtension->AttachedDeviceObject = AttachedDevice;
107
108 /* Create the PDO */
110 sizeof(PDO_EXTENSION),
111 NULL,
114 FALSE,
116 if (!NT_SUCCESS(Status))
117 {
118 /* Fail */
119 DPRINT1("HAL: Could not create ACPI device object status=0x%08x\n", Status);
120 return Status;
121 }
122
123 /* Setup the PDO device extension */
124 PdoExtension = PdoDeviceObject->DeviceExtension;
125 PdoExtension->ExtensionType = PdoExtensionType;
126 PdoExtension->PhysicalDeviceObject = PdoDeviceObject;
127 PdoExtension->ParentFdoExtension = FdoExtension;
128 PdoExtension->PdoType = AcpiPdo;
129
130 /* Add the PDO to the head of the list */
131 PdoExtension->Next = FdoExtension->ChildPdoList;
132 FdoExtension->ChildPdoList = PdoExtension;
133
134 /* Initialization is finished */
135 PdoDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
136
137 /* Find the ACPI watchdog table */
138 Wdrt = HalAcpiGetTable(0, 'TRDW');
139 if (Wdrt)
140 {
141 /* FIXME: TODO */
142 DPRINT1("You have an ACPI Watchdog. That's great! You should be proud ;-)\n");
143 }
144
145 /* Return status */
146 DPRINT("Device added %lx\n", Status);
147 return Status;
148}
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
@ PdoExtension
Definition: precomp.h:49
@ FdoExtension
Definition: precomp.h:48
PVOID NTAPI HalAcpiGetTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
Definition: halacpi.c:446
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT _In_ PUSB_PORT_PATH _Out_ PUSB_CD_ERROR_INFORMATION _In_ USHORT _In_ PDEVICE_OBJECT PdoDeviceObject
Definition: hubbusif.h:95
NTSYSAPI void WINAPI DbgBreakPoint(void)
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:138
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define FILE_DEVICE_BUS_EXTENDER
Definition: winioctl.h:148
#define DPRINT
Definition: sndvol32.h:71
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT _In_ PDEVICE_OBJECT TargetDevice
Definition: iofuncs.h:691

Referenced by HalpDriverEntry().

◆ HalpDispatchPnp()

NTSTATUS NTAPI HalpDispatchPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 632 of file halpnpdd.c.

634{
635 PIO_STACK_LOCATION IoStackLocation;
636 //PPDO_EXTENSION PdoExtension;
639 UCHAR Minor;
640
641 /* Get the device extension and stack location */
642 FdoExtension = DeviceObject->DeviceExtension;
643 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
644 Minor = IoStackLocation->MinorFunction;
645
646 /* FDO? */
647 if (FdoExtension->ExtensionType == FdoExtensionType)
648 {
649 /* Query the IRP type */
650 switch (Minor)
651 {
653
654 /* Call the worker */
655 DPRINT("Querying device relations for FDO\n");
657 IoStackLocation->Parameters.QueryDeviceRelations.Type,
658 (PVOID)&Irp->IoStatus.Information);
659 break;
660
662
663 /* Call the worker */
664 DPRINT("Querying interface for FDO\n");
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);
672 break;
673
674
675 case IRP_MN_QUERY_ID:
676
677 /* Call the worker */
678 DPRINT("Querying ID for FDO\n");
680 IoStackLocation->Parameters.QueryId.IdType,
681 (PVOID)&Irp->IoStatus.Information);
682 break;
683
685
686 /* Call the worker */
687 DPRINT("Querying the capabilities for the FDO\n");
689 IoStackLocation->Parameters.DeviceCapabilities.Capabilities);
690 break;
691
692 default:
693
694 DPRINT("Other IRP: %lx\n", Minor);
696 break;
697 }
698
699 /* What happpened? */
701 {
702 /* Set the IRP status, unless this isn't understood */
704 {
705 Irp->IoStatus.Status = Status;
706 }
707
708 /* Pass it on */
710 return IoCallDriver(FdoExtension->AttachedDeviceObject, Irp);
711 }
712
713 /* Otherwise, we failed, so set the status and complete the request */
714 DPRINT1("IRP failed with status: %lx\n", Status);
715 Irp->IoStatus.Status = Status;
717 return Status;
718 }
719 else
720 {
721 /* This is a PDO instead */
722 ASSERT(FdoExtension->ExtensionType == PdoExtensionType);
723 //PdoExtension = (PPDO_EXTENSION)FdoExtension;
724 /* Query the IRP type */
726 switch (Minor)
727 {
729
730 /* We only care about a PCI PDO */
731 DPRINT1("Start device received\n");
732 /* Complete the IRP normally */
733 break;
734
736
737 /* Check if this is a PCI device */
738 DPRINT1("Remove device received\n");
739
740 /* We're done */
742 break;
743
745
746 /* Inherit whatever status we had */
747 DPRINT1("Surprise removal IRP\n");
748 Status = Irp->IoStatus.Status;
749 break;
750
752
753 /* Query the device relations */
754 DPRINT("Querying PDO relations\n");
756 IoStackLocation->Parameters.QueryDeviceRelations.Type,
757 (PVOID)&Irp->IoStatus.Information);
758 break;
759
761
762 /* Call the worker */
763 DPRINT("Querying interface for PDO\n");
765 IoStackLocation->Parameters.QueryInterface.InterfaceType,
766 IoStackLocation->Parameters.QueryInterface.Size,
767 IoStackLocation->Parameters.QueryInterface.InterfaceSpecificData,
768 IoStackLocation->Parameters.QueryInterface.Version,
769 IoStackLocation->Parameters.QueryInterface.Interface,
770 (PVOID)&Irp->IoStatus.Information);
771 break;
772
774
775 /* Call the worker */
776 DPRINT("Querying the capabilities for the PDO\n");
778 IoStackLocation->Parameters.DeviceCapabilities.Capabilities);
779 break;
780
782
783 /* Call the worker */
784 DPRINT("Querying the resources for the PDO\n");
785 Status = HalpQueryResources(DeviceObject, (PVOID)&Irp->IoStatus.Information);
786 break;
787
789
790 /* Call the worker */
791 DPRINT("Querying the resource requirements for the PDO\n");
793 (PVOID)&Irp->IoStatus.Information);
794 break;
795
796 case IRP_MN_QUERY_ID:
797
798 /* Call the worker */
799 DPRINT("Query the ID for the PDO\n");
801 IoStackLocation->Parameters.QueryId.IdType,
802 (PVOID)&Irp->IoStatus.Information);
803 break;
804
805 default:
806
807 /* We don't handle anything else, so inherit the old state */
808 DPRINT("Illegal IRP: %lx\n", Minor);
809 Status = Irp->IoStatus.Status;
810 break;
811 }
812
813 /* If it's not supported, inherit the old status */
814 if (Status == STATUS_NOT_SUPPORTED) Status = Irp->IoStatus.Status;
815
816 /* Complete the IRP */
817 DPRINT("IRP completed with status: %lx\n", Status);
818 Irp->IoStatus.Status = Status;
820 return Status;
821 }
822}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
NTSTATUS NTAPI HalpQueryResources(IN PDEVICE_OBJECT DeviceObject, OUT PCM_RESOURCE_LIST *Resources)
Definition: halpnpdd.c:357
NTSTATUS NTAPI HalpQueryResourceRequirements(IN PDEVICE_OBJECT DeviceObject, OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requirements)
Definition: halpnpdd.c:448
NTSTATUS NTAPI HalpQueryInterface(IN PDEVICE_OBJECT DeviceObject, IN CONST GUID *InterfaceType, IN USHORT Version, IN PVOID InterfaceSpecificData, IN ULONG InterfaceBufferSize, IN PINTERFACE Interface, OUT PULONG Length)
Definition: halpnpdd.c:152
NTSTATUS NTAPI HalpQueryIdPdo(IN PDEVICE_OBJECT DeviceObject, IN BUS_QUERY_ID_TYPE IdType, OUT PUSHORT *BusQueryId)
Definition: halpnpdd.c:474
NTSTATUS NTAPI HalpQueryIdFdo(IN PDEVICE_OBJECT DeviceObject, IN BUS_QUERY_ID_TYPE IdType, OUT PUSHORT *BusQueryId)
Definition: halpnpdd.c:570
NTSTATUS NTAPI HalpQueryCapabilities(IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_CAPABILITIES Capabilities)
Definition: halpnpdd.c:300
NTSTATUS NTAPI HalpQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE RelationType, OUT PDEVICE_RELATIONS *DeviceRelations)
Definition: halpnpdd.c:182
_In_ PIRP Irp
Definition: csq.h:116
#define ASSERT(a)
Definition: mode.c:44
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCompleteRequest
Definition: irp.c:1240
#define IoCallDriver
Definition: irp.c:1225
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define STATUS_SUCCESS
Definition: shellext.h:65
union _IO_STACK_LOCATION::@1564 Parameters
struct _IO_STACK_LOCATION::@3978::@4003 QueryDeviceRelations
struct _IO_STACK_LOCATION::@3978::@4004 QueryInterface
struct _IO_STACK_LOCATION::@3978::@4005 DeviceCapabilities
struct _IO_STACK_LOCATION::@3978::@4009 QueryId
_Out_opt_ PULONG Minor
Definition: cmfuncs.h:44
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_QUERY_INTERFACE
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_ID
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_CAPABILITIES
#define IRP_MN_QUERY_RESOURCES
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by HalpDriverEntry().

◆ HalpDispatchPower()

NTSTATUS NTAPI HalpDispatchPower ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 835 of file halpnpdd.c.

837{
839
840 DPRINT("HAL: PnP Driver Power!\n");
841 FdoExtension = DeviceObject->DeviceExtension;
842 if (FdoExtension->ExtensionType == FdoExtensionType)
843 {
846 return PoCallDriver(FdoExtension->AttachedDeviceObject, Irp);
847 }
848 else
849 {
851 Irp->IoStatus.Status = STATUS_SUCCESS;
853 return STATUS_SUCCESS;
854 }
855}
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:758

Referenced by HalpDriverEntry().

◆ HalpDispatchWmi()

NTSTATUS NTAPI HalpDispatchWmi ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 826 of file halpnpdd.c.

828{
829 UNIMPLEMENTED_DBGBREAK("HAL: PnP Driver WMI!\n");
830 return STATUS_SUCCESS;
831}
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57

Referenced by HalpDriverEntry().

◆ HalpDriverEntry()

NTSTATUS NTAPI HalpDriverEntry ( IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegistryPath 
)

Definition at line 859 of file halpnpdd.c.

861{
864
865 DPRINT("HAL: PnP Driver ENTRY!\n");
866
867 /* This is us */
869
870 /* Set up add device */
872
873 /* Set up the callouts */
874 DriverObject->MajorFunction[IRP_MJ_PNP] = HalpDispatchPnp;
877
878 /* Create the PDO and tell the PnP manager about us*/
881 -1,
882 -1,
883 NULL,
884 NULL,
885 FALSE,
886 &TargetDevice);
887 if (!NT_SUCCESS(Status))
888 return Status;
889
890 TargetDevice->Flags &= ~DO_DEVICE_INITIALIZING;
891
892 /* Set up the device stack */
894 if (!NT_SUCCESS(Status))
895 {
897 return Status;
898 }
899
900 /* Return to kernel */
901 return Status;
902}
NTSTATUS NTAPI HalpDispatchPower(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: halpnpdd.c:835
NTSTATUS NTAPI HalpDispatchWmi(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: halpnpdd.c:826
NTSTATUS NTAPI HalpAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT TargetDevice)
Definition: halpnpdd.c:59
PDRIVER_OBJECT HalpDriverObject
Definition: halpnpdd.c:53
NTSTATUS NTAPI HalpDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: halpnpdd.c:632
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
@ InterfaceTypeUndefined
Definition: hwresource.cpp:136
NTSTATUS NTAPI IoReportDetectedDevice(_In_ PDRIVER_OBJECT DriverObject, _In_ INTERFACE_TYPE LegacyBusType, _In_ ULONG BusNumber, _In_ ULONG SlotNumber, _In_opt_ PCM_RESOURCE_LIST ResourceList, _In_opt_ PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements, _In_ BOOLEAN ResourceAssigned, _Inout_ PDEVICE_OBJECT *DeviceObject)
Definition: pnpreport.c:148
PDRIVER_ADD_DEVICE AddDevice
Definition: iotypes.h:2220
PDRIVER_EXTENSION DriverExtension
Definition: iotypes.h:2282
#define IRP_MJ_SYSTEM_CONTROL
#define IRP_MJ_POWER

Referenced by HaliInitPnpDriver().

◆ HalpQueryCapabilities()

NTSTATUS NTAPI HalpQueryCapabilities ( IN PDEVICE_OBJECT  DeviceObject,
OUT PDEVICE_CAPABILITIES  Capabilities 
)

Definition at line 300 of file halpnpdd.c.

302{
303 //PPDO_EXTENSION PdoExtension;
305 PAGED_CODE();
306
307 /* Get the extension and check for valid version */
308 //PdoExtension = DeviceObject->DeviceExtension;
309 ASSERT(Capabilities->Version == 1);
310 if (Capabilities->Version == 1)
311 {
312 /* Can't lock or eject us */
313 Capabilities->LockSupported = FALSE;
314 Capabilities->EjectSupported = FALSE;
315
316 /* Can't remove or dock us */
317 Capabilities->Removable = FALSE;
318 Capabilities->DockDevice = FALSE;
319
320 /* Can't access us raw */
321 Capabilities->RawDeviceOK = FALSE;
322
323 /* We have a unique ID, and don't bother the user */
324 Capabilities->UniqueID = TRUE;
325 Capabilities->SilentInstall = TRUE;
326
327 /* Fill out the address */
330
331 /* Fill out latencies */
332 Capabilities->D1Latency = 0;
333 Capabilities->D2Latency = 0;
334 Capabilities->D3Latency = 0;
335
336 /* Fill out supported device states */
341
342 /* Done */
344 }
345 else
346 {
347 /* Fail */
349 }
350
351 /* Return status */
352 return Status;
353}
#define TRUE
Definition: types.h:120
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
@ PowerSystemSleeping3
Definition: ntpoapi.h:39
@ PowerSystemShutdown
Definition: ntpoapi.h:41
@ PowerSystemWorking
Definition: ntpoapi.h:36
@ PowerSystemHibernate
Definition: ntpoapi.h:40
@ PowerDeviceD0
Definition: ntpoapi.h:49
@ PowerDeviceD3
Definition: ntpoapi.h:52

Referenced by HalpDispatchPnp().

◆ HalpQueryDeviceRelations()

NTSTATUS NTAPI HalpQueryDeviceRelations ( IN PDEVICE_OBJECT  DeviceObject,
IN DEVICE_RELATION_TYPE  RelationType,
OUT PDEVICE_RELATIONS DeviceRelations 
)

Definition at line 182 of file halpnpdd.c.

185{
186 EXTENSION_TYPE ExtensionType;
189 PDEVICE_RELATIONS PdoRelations, FdoRelations;
190 PDEVICE_OBJECT* ObjectEntry;
191 ULONG i = 0, PdoCount = 0;
192
193 /* Get FDO device extension and PDO count */
194 FdoExtension = DeviceObject->DeviceExtension;
195 ExtensionType = FdoExtension->ExtensionType;
196
197 /* What do they want? */
199 {
200 /* This better be an FDO */
201 if (ExtensionType == FdoExtensionType)
202 {
203 /* Count how many PDOs we have */
204 PdoExtension = FdoExtension->ChildPdoList;
205 while (PdoExtension)
206 {
207 /* Next one */
209 PdoCount++;
210 }
211
212 /* Add the PDOs that already exist in the device relations */
213 if (*DeviceRelations)
214 {
215 PdoCount += (*DeviceRelations)->Count;
216 }
217
218 /* Allocate our structure */
219 FdoRelations = ExAllocatePoolWithTag(PagedPool,
221 Objects) +
222 sizeof(PDEVICE_OBJECT) * PdoCount,
223 TAG_HAL);
224 if (!FdoRelations) return STATUS_INSUFFICIENT_RESOURCES;
225
226 /* Save our count */
227 FdoRelations->Count = PdoCount;
228
229 /* Query existing relations */
230 ObjectEntry = FdoRelations->Objects;
231 if (*DeviceRelations)
232 {
233 /* Check if there were any */
234 if ((*DeviceRelations)->Count)
235 {
236 /* Loop them all */
237 do
238 {
239 /* Copy into our structure */
240 *ObjectEntry++ = (*DeviceRelations)->Objects[i];
241 }
242 while (++i < (*DeviceRelations)->Count);
243 }
244
245 /* Free existing structure */
246 ExFreePool(*DeviceRelations);
247 }
248
249 /* Now check if we have a PDO list */
250 PdoExtension = FdoExtension->ChildPdoList;
251 if (PdoExtension)
252 {
253 /* Loop the PDOs */
254 do
255 {
256 /* Save our own PDO and reference it */
257 *ObjectEntry++ = PdoExtension->PhysicalDeviceObject;
258 ObReferenceObject(PdoExtension->PhysicalDeviceObject);
259
260 /* Go to our next PDO */
262 }
263 while (PdoExtension);
264 }
265
266 /* Return the new structure */
267 *DeviceRelations = FdoRelations;
268 return STATUS_SUCCESS;
269 }
270 }
271 else
272 {
273 /* The only other thing we support is a target relation for the PDO */
275 (ExtensionType == PdoExtensionType))
276 {
277 /* Only one entry */
278 PdoRelations = ExAllocatePoolWithTag(PagedPool,
279 sizeof(DEVICE_RELATIONS),
280 TAG_HAL);
281 if (!PdoRelations) return STATUS_INSUFFICIENT_RESOURCES;
282
283 /* Fill it out and reference us */
284 PdoRelations->Count = 1;
285 PdoRelations->Objects[0] = DeviceObject;
287
288 /* Return it */
289 *DeviceRelations = PdoRelations;
290 return STATUS_SUCCESS;
291 }
292 }
293
294 /* We don't support anything else */
296}
EXTENSION_TYPE
Definition: precomp.h:45
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define PagedPool
Definition: env_spec_w32.h:308
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define TAG_HAL
Definition: hal.h:61
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ DEVICE_RELATION_TYPE RelationType
Definition: wdfdevice.h:1059
@ BusRelations
Definition: iotypes.h:2152
@ TargetDeviceRelation
Definition: iotypes.h:2156
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by HalpDispatchPnp().

◆ HalpQueryIdFdo()

NTSTATUS NTAPI HalpQueryIdFdo ( IN PDEVICE_OBJECT  DeviceObject,
IN BUS_QUERY_ID_TYPE  IdType,
OUT PUSHORT BusQueryId 
)

Definition at line 570 of file halpnpdd.c.

573{
576 PWCHAR Id;
578
579 /* What kind of ID is being requested? */
580 DPRINT("ID: %d\n", IdType);
581 switch (IdType)
582 {
583 case BusQueryDeviceID:
585
586 /* This is our hardware ID */
588 break;
589
591
592 /* And our instance ID */
593 Id = L"0";
594 break;
595
596 default:
597
598 /* We don't support anything else */
600 }
601
602 /* Calculate the length */
603 Length = (wcslen(Id) * sizeof(WCHAR)) + sizeof(UNICODE_NULL);
604
605 /* Allocate the buffer */
607 Length + sizeof(UNICODE_NULL),
608 TAG_HAL);
609 if (Buffer)
610 {
611 /* Copy the string and null-terminate it */
613 Buffer[Length / sizeof(WCHAR)] = UNICODE_NULL;
614
615 /* Return string */
616 *BusQueryId = Buffer;
618 DPRINT("Returning: %S\n", *BusQueryId);
619 }
620 else
621 {
622 /* Fail */
624 }
625
626 /* Return status */
627 return Status;
628}
DWORD Id
Definition: bufpool.h:45
_In_ BUS_QUERY_ID_TYPE IdType
Definition: classpnp.h:374
PWCHAR HalHardwareIdString
Definition: halacpi.c:44
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define UNICODE_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint16_t * PWCHAR
Definition: typedefs.h:56
@ BusQueryInstanceID
Definition: iotypes.h:2939
@ BusQueryDeviceID
Definition: iotypes.h:2936
@ BusQueryHardwareIDs
Definition: iotypes.h:2937
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by HalpDispatchPnp().

◆ HalpQueryIdPdo()

NTSTATUS NTAPI HalpQueryIdPdo ( IN PDEVICE_OBJECT  DeviceObject,
IN BUS_QUERY_ID_TYPE  IdType,
OUT PUSHORT BusQueryId 
)

Definition at line 474 of file halpnpdd.c.

477{
479 PDO_TYPE PdoType;
480 PWCHAR CurrentId;
481 WCHAR Id[100];
483 SIZE_T Length = 0;
485
486 /* Get the PDO type */
487 PdoExtension = DeviceObject->DeviceExtension;
488 PdoType = PdoExtension->PdoType;
489
490 /* What kind of ID is being requested? */
491 DPRINT("ID: %d\n", IdType);
492 switch (IdType)
493 {
494 case BusQueryDeviceID:
496
497 /* What kind of PDO is this? */
498 if (PdoType == AcpiPdo)
499 {
500 /* ACPI ID */
501 CurrentId = L"ACPI_HAL\\PNP0C08";
502 RtlCopyMemory(Id, CurrentId, (wcslen(CurrentId) * sizeof(WCHAR)) + sizeof(UNICODE_NULL));
503 Length += (wcslen(CurrentId) * sizeof(WCHAR)) + sizeof(UNICODE_NULL);
504
505 CurrentId = L"*PNP0C08";
506 RtlCopyMemory(&Id[wcslen(Id) + 1], CurrentId, (wcslen(CurrentId) * sizeof(WCHAR)) + sizeof(UNICODE_NULL));
507 Length += (wcslen(CurrentId) * sizeof(WCHAR)) + sizeof(UNICODE_NULL);
508 }
509 else if (PdoType == WdPdo)
510 {
511 /* WatchDog ID */
512 CurrentId = L"ACPI_HAL\\PNP0C18";
513 RtlCopyMemory(Id, CurrentId, (wcslen(CurrentId) * sizeof(WCHAR)) + sizeof(UNICODE_NULL));
514 Length += (wcslen(CurrentId) * sizeof(WCHAR)) + sizeof(UNICODE_NULL);
515
516 CurrentId = L"*PNP0C18";
517 RtlCopyMemory(&Id[wcslen(Id) + 1], CurrentId, (wcslen(CurrentId) * sizeof(WCHAR)) + sizeof(UNICODE_NULL));
518 Length += (wcslen(CurrentId) * sizeof(WCHAR)) + sizeof(UNICODE_NULL);
519 }
520 else
521 {
522 /* Unknown */
524 }
525 break;
526
528
529 /* Instance ID */
530 CurrentId = L"0";
531 RtlCopyMemory(Id, CurrentId, (wcslen(CurrentId) * sizeof(WCHAR)) + sizeof(UNICODE_NULL));
532 Length += (wcslen(CurrentId) * sizeof(WCHAR)) + sizeof(UNICODE_NULL);
533 break;
534
536 default:
537
538 /* We don't support anything else */
540 }
541
542
543 /* Allocate the buffer */
545 Length + sizeof(UNICODE_NULL),
546 TAG_HAL);
547 if (Buffer)
548 {
549 /* Copy the string and null-terminate it */
551 Buffer[Length / sizeof(WCHAR)] = UNICODE_NULL;
552
553 /* Return string */
554 *BusQueryId = Buffer;
556 DPRINT("Returning: %S\n", *BusQueryId);
557 }
558 else
559 {
560 /* Fail */
562 }
563
564 /* Return status */
565 return Status;
566}
@ BusQueryCompatibleIDs
Definition: iotypes.h:2938

Referenced by HalpDispatchPnp().

◆ HalpQueryInterface()

NTSTATUS NTAPI HalpQueryInterface ( IN PDEVICE_OBJECT  DeviceObject,
IN CONST GUID InterfaceType,
IN USHORT  Version,
IN PVOID  InterfaceSpecificData,
IN ULONG  InterfaceBufferSize,
IN PINTERFACE  Interface,
OUT PULONG  Length 
)

Definition at line 152 of file halpnpdd.c.

159{
160 if (IsEqualIID(InterfaceType, &GUID_ACPI_REGS_INTERFACE_STANDARD))
161 {
162 DPRINT1("HalpQueryInterface(GUID_ACPI_REGS_INTERFACE_STANDARD) is UNIMPLEMENTED\n");
163 }
164 else if (IsEqualIID(InterfaceType, &GUID_ACPI_PORT_RANGES_INTERFACE_STANDARD))
165 {
166 DPRINT1("HalpQueryInterface(GUID_ACPI_PORT_RANGES_INTERFACE_STANDARD) is UNIMPLEMENTED\n");
167 }
168 else
169 {
170 DPRINT1("HalpQueryInterface({%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}) is UNIMPLEMENTED\n",
171 InterfaceType->Data1, InterfaceType->Data2, InterfaceType->Data3,
172 InterfaceType->Data4[0], InterfaceType->Data4[1],
173 InterfaceType->Data4[2], InterfaceType->Data4[3],
174 InterfaceType->Data4[4], InterfaceType->Data4[5],
175 InterfaceType->Data4[6], InterfaceType->Data4[7]);
176 }
178}
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463

Referenced by HalpDispatchPnp().

◆ HalpQueryResourceRequirements()

NTSTATUS NTAPI HalpQueryResourceRequirements ( IN PDEVICE_OBJECT  DeviceObject,
OUT PIO_RESOURCE_REQUIREMENTS_LIST Requirements 
)

Definition at line 448 of file halpnpdd.c.

450{
451 PPDO_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
452 PAGED_CODE();
453
454 /* Only the ACPI PDO has requirements */
455 if (DeviceExtension->PdoType == AcpiPdo)
456 {
457 /* Query ACPI requirements */
458 return HalpQueryAcpiResourceRequirements(Requirements);
459 }
460 else if (DeviceExtension->PdoType == WdPdo)
461 {
462 /* Watchdog doesn't */
464 }
465 else
466 {
467 /* This shouldn't happen */
468 return STATUS_UNSUCCESSFUL;
469 }
470}
NTSTATUS NTAPI HalpQueryAcpiResourceRequirements(OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requirements)
Definition: halacpi.c:1016
PDO_TYPE PdoType
Definition: halpnpdd.c:46
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by HalpDispatchPnp().

◆ HalpQueryResources()

NTSTATUS NTAPI HalpQueryResources ( IN PDEVICE_OBJECT  DeviceObject,
OUT PCM_RESOURCE_LIST Resources 
)

Definition at line 357 of file halpnpdd.c.

359{
360 PPDO_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
366 ULONG i;
367 PAGED_CODE();
368
369 /* Only the ACPI PDO has requirements */
370 if (DeviceExtension->PdoType == AcpiPdo)
371 {
372 /* Query ACPI requirements */
374 if (!NT_SUCCESS(Status)) return Status;
375
376 ASSERT(RequirementsList->AlternativeLists == 1);
377
378 /* Allocate the resourcel ist */
380 sizeof(CM_RESOURCE_LIST),
381 TAG_HAL);
382 if (!ResourceList )
383 {
384 /* Fail, no memory */
387 return Status;
388 }
389
390 /* Initialize it */
392 ResourceList->Count = 1;
393
394 /* Setup the list fields */
395 ResourceList->List[0].BusNumber = -1;
396 ResourceList->List[0].InterfaceType = PNPBus;
397 ResourceList->List[0].PartialResourceList.Version = 1;
398 ResourceList->List[0].PartialResourceList.Revision = 1;
399 ResourceList->List[0].PartialResourceList.Count = 0;
400
401 /* Setup the first descriptor */
402 PartialDesc = ResourceList->List[0].PartialResourceList.PartialDescriptors;
403
404 /* Find the requirement descriptor for the SCI */
405 for (i = 0; i < RequirementsList->List[0].Count; i++)
406 {
407 /* Get this descriptor */
408 Descriptor = &RequirementsList->List[0].Descriptors[i];
410 {
411 /* Copy requirements descriptor into resource descriptor */
412 PartialDesc->Type = CmResourceTypeInterrupt;
413 PartialDesc->ShareDisposition = Descriptor->ShareDisposition;
414 PartialDesc->Flags = Descriptor->Flags;
415 ASSERT(Descriptor->u.Interrupt.MinimumVector ==
416 Descriptor->u.Interrupt.MaximumVector);
417 PartialDesc->u.Interrupt.Vector = Descriptor->u.Interrupt.MinimumVector;
418 PartialDesc->u.Interrupt.Level = Descriptor->u.Interrupt.MinimumVector;
419 PartialDesc->u.Interrupt.Affinity = 0xFFFFFFFF;
420
421 ResourceList->List[0].PartialResourceList.Count++;
422
423 break;
424 }
425 }
426
427 /* Return resources and success */
429
431
432 return STATUS_SUCCESS;
433 }
434 else if (DeviceExtension->PdoType == WdPdo)
435 {
436 /* Watchdog doesn't */
438 }
439 else
440 {
441 /* This shouldn't happen */
442 return STATUS_UNSUCCESSFUL;
443 }
444}
@ PNPBus
Definition: hwresource.cpp:152
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@393 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@393::@396 Interrupt
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
_In_ WDFIORESREQLIST RequirementsList
Definition: wdfresource.h:65
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342

Referenced by HalpDispatchPnp().

Variable Documentation

◆ HalpDriverObject

PDRIVER_OBJECT HalpDriverObject

Definition at line 53 of file halpnpdd.c.

Referenced by HalpDriverEntry().