3 * PROJECT: ReactOS ACPI bus driver
4 * FILE: acpi/ospm/acpisys.c
5 * PURPOSE: Driver entry
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
8 * 01-05-2001 CSH Created
18 IN PDRIVER_OBJECT DriverObject
,
19 IN PUNICODE_STRING RegistryPath
24 // Make the initialization routines discardable, so that they
27 #pragma alloc_text(init, DriverEntry)
29 #endif /* ALLOC_PRAGMA */
34 ACPIDispatchDeviceControl(
35 IN PDEVICE_OBJECT DeviceObject
,
38 PIO_STACK_LOCATION IrpSp
;
41 DPRINT("Called. IRP is at (0x%X)\n", Irp
);
43 Irp
->IoStatus
.Information
= 0;
45 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
46 switch (IrpSp
->Parameters
.DeviceIoControl
.IoControlCode
) {
48 DPRINT("Unknown IOCTL 0x%X\n", IrpSp
->Parameters
.DeviceIoControl
.IoControlCode
);
49 Status
= STATUS_NOT_IMPLEMENTED
;
53 if (Status
!= STATUS_PENDING
) {
54 Irp
->IoStatus
.Status
= Status
;
56 DPRINT("Completing IRP at 0x%X\n", Irp
);
58 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
61 DPRINT("Leaving. Status 0x%X\n", Status
);
70 IN PDEVICE_OBJECT DeviceObject
,
73 * FUNCTION: Handle Plug and Play IRPs
75 * DeviceObject = Pointer to PDO or FDO
76 * Irp = Pointer to IRP that should be handled
81 PCOMMON_DEVICE_EXTENSION DeviceExtension
;
86 DeviceExtension
= (PCOMMON_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
88 if (DeviceExtension
->IsFDO
) {
89 Status
= FdoPnpControl(DeviceObject
, Irp
);
91 Status
= PdoPnpControl(DeviceObject
, Irp
);
101 IN PDEVICE_OBJECT DeviceObject
,
104 PCOMMON_DEVICE_EXTENSION DeviceExtension
;
109 DeviceExtension
= (PCOMMON_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
111 if (DeviceExtension
->IsFDO
) {
112 Status
= FdoPowerControl(DeviceObject
, Irp
);
114 Status
= PdoPowerControl(DeviceObject
, Irp
);
124 IN PDRIVER_OBJECT DriverObject
,
125 IN PDEVICE_OBJECT PhysicalDeviceObject
)
127 PFDO_DEVICE_EXTENSION DeviceExtension
;
133 if (PhysicalDeviceObject
== NULL
)
134 return STATUS_SUCCESS
;
136 Status
= IoCreateDevice(DriverObject
,
137 sizeof(FDO_DEVICE_EXTENSION
),
140 FILE_DEVICE_SECURE_OPEN
,
143 if (!NT_SUCCESS(Status
))
145 DPRINT("IoCreateDevice() failed with status 0x%X\n", Status
);
149 DeviceExtension
= (PFDO_DEVICE_EXTENSION
)Fdo
->DeviceExtension
;
151 DeviceExtension
->Pdo
= PhysicalDeviceObject
;
152 DeviceExtension
->Common
.IsFDO
= TRUE
;
154 DeviceExtension
->Common
.Ldo
=
155 IoAttachDeviceToDeviceStack(Fdo
, PhysicalDeviceObject
);
157 DeviceExtension
->State
= dsStopped
;
159 Fdo
->Flags
&= ~DO_DEVICE_INITIALIZING
;
161 DPRINT("Done AddDevice\n");
163 return STATUS_SUCCESS
;
170 IN PDRIVER_OBJECT DriverObject
,
171 IN PUNICODE_STRING RegistryPath
)
173 DPRINT("Advanced Configuration and Power Interface Bus Driver\n");
175 DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
] = (PDRIVER_DISPATCH
) ACPIDispatchDeviceControl
;
176 DriverObject
->MajorFunction
[IRP_MJ_PNP
] = (PDRIVER_DISPATCH
) ACPIPnpControl
;
177 DriverObject
->MajorFunction
[IRP_MJ_POWER
] = (PDRIVER_DISPATCH
) ACPIPowerControl
;
178 DriverObject
->DriverExtension
->AddDevice
= ACPIAddDevice
;
180 return STATUS_SUCCESS
;