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
19 // Make the initialization routines discardable, so that they
22 #pragma alloc_text(init, DriverEntry)
24 #endif /* ALLOC_PRAGMA */
29 ACPIDispatchDeviceControl(
30 IN PDEVICE_OBJECT DeviceObject
,
33 PIO_STACK_LOCATION IrpSp
;
36 DPRINT("Called. IRP is at (0x%X)\n", Irp
);
38 Irp
->IoStatus
.Information
= 0;
40 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
41 switch (IrpSp
->Parameters
.DeviceIoControl
.IoControlCode
) {
43 DPRINT("Unknown IOCTL 0x%X\n", IrpSp
->Parameters
.DeviceIoControl
.IoControlCode
);
44 Status
= STATUS_NOT_IMPLEMENTED
;
48 if (Status
!= STATUS_PENDING
) {
49 Irp
->IoStatus
.Status
= Status
;
51 DPRINT("Completing IRP at 0x%X\n", Irp
);
53 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
56 DPRINT("Leaving. Status 0x%X\n", Status
);
65 IN PDEVICE_OBJECT DeviceObject
,
68 * FUNCTION: Handle Plug and Play IRPs
70 * DeviceObject = Pointer to PDO or FDO
71 * Irp = Pointer to IRP that should be handled
76 PCOMMON_DEVICE_EXTENSION DeviceExtension
;
81 DeviceExtension
= (PCOMMON_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
83 if (DeviceExtension
->IsFDO
) {
84 Status
= FdoPnpControl(DeviceObject
, Irp
);
86 Status
= PdoPnpControl(DeviceObject
, Irp
);
96 IN PDEVICE_OBJECT DeviceObject
,
99 PCOMMON_DEVICE_EXTENSION DeviceExtension
;
104 DeviceExtension
= (PCOMMON_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
106 if (DeviceExtension
->IsFDO
) {
107 Status
= FdoPowerControl(DeviceObject
, Irp
);
109 Status
= PdoPowerControl(DeviceObject
, Irp
);
119 IN PDRIVER_OBJECT DriverObject
,
120 IN PDEVICE_OBJECT PhysicalDeviceObject
)
122 PFDO_DEVICE_EXTENSION DeviceExtension
;
128 Status
= IoCreateDevice(DriverObject
,
129 sizeof(FDO_DEVICE_EXTENSION
),
132 FILE_DEVICE_SECURE_OPEN
,
135 if (!NT_SUCCESS(Status
))
137 DPRINT("IoCreateDevice() failed with status 0x%X\n", Status
);
141 DeviceExtension
= (PFDO_DEVICE_EXTENSION
)Fdo
->DeviceExtension
;
143 DeviceExtension
->Pdo
= PhysicalDeviceObject
;
144 DeviceExtension
->Common
.IsFDO
= TRUE
;
146 DeviceExtension
->Common
.Ldo
=
147 IoAttachDeviceToDeviceStack(Fdo
, PhysicalDeviceObject
);
149 DeviceExtension
->State
= dsStopped
;
151 Fdo
->Flags
&= ~DO_DEVICE_INITIALIZING
;
153 DPRINT("Done AddDevice\n");
155 return STATUS_SUCCESS
;
162 IN PDRIVER_OBJECT DriverObject
,
163 IN PUNICODE_STRING RegistryPath
)
165 DPRINT("Advanced Configuration and Power Interface Bus Driver\n");
167 DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
] = (PDRIVER_DISPATCH
) ACPIDispatchDeviceControl
;
168 DriverObject
->MajorFunction
[IRP_MJ_PNP
] = (PDRIVER_DISPATCH
) ACPIPnpControl
;
169 DriverObject
->MajorFunction
[IRP_MJ_POWER
] = (PDRIVER_DISPATCH
) ACPIPowerControl
;
170 DriverObject
->DriverExtension
->AddDevice
= ACPIAddDevice
;
172 return STATUS_SUCCESS
;