2 * PROJECT: ReactOS Floppy Disk Controller Driver
3 * LICENSE: GNU GPLv2 only as published by the Free Software Foundation
4 * FILE: drivers/storage/fdc/fdc/fdc.c
5 * PURPOSE: Main Driver Routines
6 * PROGRAMMERS: Eric Kohl
9 /* INCLUDES *******************************************************************/
16 /* GLOBALS ********************************************************************/
18 ULONG ControllerCount
= 0;
20 /* FUNCTIONS ******************************************************************/
26 IN PDRIVER_OBJECT DriverObject
,
27 IN PDEVICE_OBJECT Pdo
)
29 PFDO_DEVICE_EXTENSION DeviceExtension
= NULL
;
30 PDEVICE_OBJECT Fdo
= NULL
;
33 DPRINT("FdcAddDevice()\n");
38 /* Create functional device object */
39 Status
= IoCreateDevice(DriverObject
,
40 sizeof(FDO_DEVICE_EXTENSION
),
42 FILE_DEVICE_CONTROLLER
,
43 FILE_DEVICE_SECURE_OPEN
,
46 if (NT_SUCCESS(Status
))
48 DeviceExtension
= (PFDO_DEVICE_EXTENSION
)Fdo
->DeviceExtension
;
49 RtlZeroMemory(DeviceExtension
, sizeof(FDO_DEVICE_EXTENSION
));
51 DeviceExtension
->Common
.IsFDO
= TRUE
;
52 DeviceExtension
->Common
.DeviceObject
= Fdo
;
54 DeviceExtension
->Pdo
= Pdo
;
56 Status
= IoAttachDeviceToDeviceStackSafe(Fdo
, Pdo
, &DeviceExtension
->LowerDevice
);
57 if (!NT_SUCCESS(Status
))
59 DPRINT1("IoAttachDeviceToDeviceStackSafe() failed with status 0x%08lx\n", Status
);
65 Fdo
->Flags
|= DO_DIRECT_IO
;
66 Fdo
->Flags
|= DO_POWER_PAGABLE
;
68 Fdo
->Flags
&= ~DO_DEVICE_INITIALIZING
;
78 FdcDriverUnload(IN PDRIVER_OBJECT DriverObject
)
80 DPRINT("FdcDriverUnload()\n");
87 FdcCreate(IN PDEVICE_OBJECT DeviceObject
,
90 DPRINT("FdcCreate()\n");
92 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
93 Irp
->IoStatus
.Information
= FILE_OPENED
;
95 IoCompleteRequest( Irp
, IO_NO_INCREMENT
);
97 return STATUS_SUCCESS
;
104 FdcClose(IN PDEVICE_OBJECT DeviceObject
,
107 DPRINT("FdcClose()\n");
109 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
110 Irp
->IoStatus
.Information
= 0;
112 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
114 return STATUS_SUCCESS
;
121 FdcPnp(IN PDEVICE_OBJECT DeviceObject
,
124 PCOMMON_DEVICE_EXTENSION Common
= DeviceObject
->DeviceExtension
;
126 DPRINT("FdcPnP()\n");
129 return FdcFdoPnp(DeviceObject
,
134 return FdcPdoPnp(DeviceObject
,
143 FdcPower(IN PDEVICE_OBJECT DeviceObject
,
146 PIO_STACK_LOCATION IrpSp
;
147 NTSTATUS Status
= Irp
->IoStatus
.Status
;
148 PFDO_DEVICE_EXTENSION DeviceExtension
= DeviceObject
->DeviceExtension
;
150 DPRINT("FdcPower()\n");
152 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
154 if (DeviceExtension
->Common
.IsFDO
)
156 PoStartNextPowerIrp(Irp
);
157 IoSkipCurrentIrpStackLocation(Irp
);
158 return PoCallDriver(DeviceExtension
->LowerDevice
, Irp
);
162 switch (IrpSp
->MinorFunction
)
164 case IRP_MN_QUERY_POWER
:
165 case IRP_MN_SET_POWER
:
166 Status
= STATUS_SUCCESS
;
169 PoStartNextPowerIrp(Irp
);
170 Irp
->IoStatus
.Status
= Status
;
171 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
179 DriverEntry(IN PDRIVER_OBJECT DriverObject
,
180 IN PUNICODE_STRING RegistryPath
)
182 DPRINT("FDC: DriverEntry()\n");
184 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = FdcCreate
;
185 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = FdcClose
;
186 // DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = FdcDeviceControl;
187 DriverObject
->MajorFunction
[IRP_MJ_PNP
] = FdcPnp
;
188 DriverObject
->MajorFunction
[IRP_MJ_POWER
] = FdcPower
;
190 DriverObject
->DriverExtension
->AddDevice
= FdcAddDevice
;
191 DriverObject
->DriverUnload
= FdcDriverUnload
;
193 return STATUS_SUCCESS
;