ReactOS 0.4.15-dev-7788-g1ad9096
floppy.h File Reference
#include <ntdddisk.h>
Include dependency graph for floppy.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DRIVE_INFO
 
struct  _CONTROLLER_INFO
 

Macros

#define MAX_DEVICE_NAME   255
 
#define MAX_ARC_PATH_LEN   255
 
#define MAX_DRIVES_PER_CONTROLLER   4
 
#define MAX_CONTROLLERS   4
 
#define GEOMETRY_144_MEDIATYPE   F3_1Pt44_512
 
#define GEOMETRY_144_CYLINDERS   80
 
#define GEOMETRY_144_TRACKSPERCYLINDER   2
 
#define GEOMETRY_144_SECTORSPERTRACK   18
 
#define GEOMETRY_144_BYTESPERSECTOR   512
 

Typedefs

typedef struct _DRIVE_INFO DRIVE_INFO
 
typedef struct _DRIVE_INFOPDRIVE_INFO
 
typedef struct _CONTROLLER_INFO CONTROLLER_INFO
 
typedef struct _CONTROLLER_INFOPCONTROLLER_INFO
 

Functions

int _cdecl swprintf (const WCHAR *,...)
 
NTSTATUS NTAPI DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
 
VOID NTAPI SignalMediaChanged (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI WaitForControllerInterrupt (PCONTROLLER_INFO ControllerInfo, PLARGE_INTEGER Timeout)
 
NTSTATUS NTAPI ResetChangeFlag (PDRIVE_INFO DriveInfo)
 
VOID NTAPI StartMotor (PDRIVE_INFO DriveInfo)
 
VOID NTAPI StopMotor (PCONTROLLER_INFO ControllerInfo)
 

Macro Definition Documentation

◆ GEOMETRY_144_BYTESPERSECTOR

#define GEOMETRY_144_BYTESPERSECTOR   512

Definition at line 127 of file floppy.h.

◆ GEOMETRY_144_CYLINDERS

#define GEOMETRY_144_CYLINDERS   80

Definition at line 124 of file floppy.h.

◆ GEOMETRY_144_MEDIATYPE

#define GEOMETRY_144_MEDIATYPE   F3_1Pt44_512

Definition at line 123 of file floppy.h.

◆ GEOMETRY_144_SECTORSPERTRACK

#define GEOMETRY_144_SECTORSPERTRACK   18

Definition at line 126 of file floppy.h.

◆ GEOMETRY_144_TRACKSPERCYLINDER

#define GEOMETRY_144_TRACKSPERCYLINDER   2

Definition at line 125 of file floppy.h.

◆ MAX_ARC_PATH_LEN

#define MAX_ARC_PATH_LEN   255

Definition at line 30 of file floppy.h.

◆ MAX_CONTROLLERS

#define MAX_CONTROLLERS   4

Definition at line 32 of file floppy.h.

◆ MAX_DEVICE_NAME

#define MAX_DEVICE_NAME   255

Definition at line 29 of file floppy.h.

◆ MAX_DRIVES_PER_CONTROLLER

#define MAX_DRIVES_PER_CONTROLLER   4

Definition at line 31 of file floppy.h.

Typedef Documentation

◆ CONTROLLER_INFO

◆ DRIVE_INFO

◆ PCONTROLLER_INFO

◆ PDRIVE_INFO

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( PDRIVER_OBJECT  DriverObject,
PUNICODE_STRING  RegistryPath 
)

Definition at line 16 of file battc.c.

18{
19 DPRINT("Battery class driver initialized\n");
20
21 return STATUS_SUCCESS;
22}
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71

◆ ResetChangeFlag()

NTSTATUS NTAPI ResetChangeFlag ( PDRIVE_INFO  DriveInfo)

Definition at line 291 of file floppy.c.

306{
307 BOOLEAN DiskChanged;
308
309 PAGED_CODE();
310 ASSERT(DriveInfo);
311
312 TRACE_(FLOPPY, "ResetChangeFlag called\n");
313
314 /* Try to recalibrate. We don't care if it works. */
315 Recalibrate(DriveInfo);
316
317 /* clear spurious interrupts in prep for seeks */
318 KeClearEvent(&DriveInfo->ControllerInfo->SynchEvent);
319
320 /* must re-start the drive because Recalibrate() stops it */
321 StartMotor(DriveInfo);
322
323 /* Seek to 1 */
324 if(HwSeek(DriveInfo, 1) != STATUS_SUCCESS)
325 {
326 WARN_(FLOPPY, "ResetChangeFlag(): HwSeek failed; returning STATUS_IO_DEVICE_ERROR\n");
327 StopMotor(DriveInfo->ControllerInfo);
329 }
330
332
334 {
335 WARN_(FLOPPY, "ResetChangeFlag(): HwSenseInterruptStatus failed; bailing out\n");
336 StopMotor(DriveInfo->ControllerInfo);
338 }
339
340 /* Seek back to 0 */
341 if(HwSeek(DriveInfo, 0) != STATUS_SUCCESS)
342 {
343 WARN_(FLOPPY, "ResetChangeFlag(): HwSeek failed; returning STATUS_IO_DEVICE_ERROR\n");
344 StopMotor(DriveInfo->ControllerInfo);
346 }
347
349
351 {
352 WARN_(FLOPPY, "ResetChangeFlag(): HwSenseInterruptStatus #2 failed; bailing\n");
353 StopMotor(DriveInfo->ControllerInfo);
355 }
356
357 /* Check the change bit */
358 if(HwDiskChanged(DriveInfo, &DiskChanged) != STATUS_SUCCESS)
359 {
360 WARN_(FLOPPY, "ResetChangeFlag(): HwDiskChanged failed; returning STATUS_IO_DEVICE_ERROR\n");
361 StopMotor(DriveInfo->ControllerInfo);
363 }
364
365 StopMotor(DriveInfo->ControllerInfo);
366
367 /* if the change flag is still set, there's probably no media in the drive. */
368 if(DiskChanged)
370
371 /* else we're done! */
372 return STATUS_SUCCESS;
373}
#define PAGED_CODE()
unsigned char BOOLEAN
#define NULL
Definition: types.h:112
#define TRACE_(x)
Definition: compat.h:76
NTSTATUS NTAPI HwSeek(PDRIVE_INFO DriveInfo, UCHAR Cylinder)
Definition: hardware.c:659
NTSTATUS NTAPI HwSenseInterruptStatus(PCONTROLLER_INFO ControllerInfo)
Definition: hardware.c:539
NTSTATUS NTAPI HwDiskChanged(PDRIVE_INFO DriveInfo, PBOOLEAN DiskChanged)
Definition: hardware.c:785
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
static NTSTATUS NTAPI Recalibrate(PDRIVE_INFO DriveInfo)
Definition: floppy.c:221
NTSTATUS NTAPI WaitForControllerInterrupt(PCONTROLLER_INFO ControllerInfo, PLARGE_INTEGER Timeout)
Definition: floppy.c:163
VOID NTAPI StartMotor(PDRIVE_INFO DriveInfo)
Definition: floppy.c:96
VOID NTAPI StopMotor(PCONTROLLER_INFO ControllerInfo)
Definition: floppy.c:135
#define ASSERT(a)
Definition: mode.c:44
#define WARN_(ch,...)
Definition: debug.h:157
struct _CONTROLLER_INFO * ControllerInfo
Definition: fdc.h:23
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
#define STATUS_NO_MEDIA_IN_DEVICE
Definition: udferr_usr.h:141

Referenced by DeviceIoctlPassive(), and ReadWritePassive().

◆ SignalMediaChanged()

VOID NTAPI SignalMediaChanged ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 1097 of file floppy.c.

1108{
1109 PDRIVE_INFO DriveInfo = DeviceObject->DeviceExtension;
1110
1111 TRACE_(FLOPPY, "SignalMediaChanged called\n");
1112
1113 DriveInfo->DiskChangeCount++;
1114
1115 /* If volume is not mounted, do NOT set verify and return STATUS_IO_DEVICE_ERROR */
1116 if(!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
1117 {
1118 Irp->IoStatus.Status = STATUS_IO_DEVICE_ERROR;
1119 Irp->IoStatus.Information = 0;
1120 return;
1121 }
1122
1123 /* Notify the filesystem that it will need to verify the volume */
1125 Irp->IoStatus.Status = STATUS_VERIFY_REQUIRED;
1126 Irp->IoStatus.Information = 0;
1127
1128 /*
1129 * If this is a user-based, threaded request, let the IO manager know to pop up a box asking
1130 * the user to supply the correct media, but only if the error (which we just picked out above)
1131 * is deemed by the IO manager to be "user induced". The reason we don't just unconditionally
1132 * call IoSetHardError... is because MS might change the definition of "user induced" some day,
1133 * and we don't want to have to remember to re-code this.
1134 */
1135 if(Irp->Tail.Overlay.Thread && IoIsErrorUserInduced(Irp->IoStatus.Status))
1137}
_In_ PIRP Irp
Definition: csq.h:116
#define DO_VERIFY_VOLUME
Definition: env_spec_w32.h:393
VOID NTAPI IoSetHardErrorOrVerifyDevice(IN PIRP Irp, IN PDEVICE_OBJECT DeviceObject)
Definition: util.c:316
ULONG DiskChangeCount
Definition: floppy.h:53
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define IoIsErrorUserInduced(Status)
Definition: iofuncs.h:2817
#define VPB_MOUNTED
Definition: iotypes.h:1807

Referenced by DeviceIoctlPassive(), and ReadWritePassive().

◆ StartMotor()

VOID NTAPI StartMotor ( PDRIVE_INFO  DriveInfo)

Definition at line 96 of file floppy.c.

111{
112 PAGED_CODE();
113 ASSERT(DriveInfo);
114
115 TRACE_(FLOPPY, "StartMotor called\n");
116
117 if(DriveInfo->ControllerInfo->StopDpcQueued && !KeCancelTimer(&DriveInfo->ControllerInfo->MotorTimer))
118 {
119 /* Motor turner-offer is already running; wait for it to finish */
120 INFO_(FLOPPY, "StartMotor: motor turner-offer is already running; waiting for it\n");
121 KeWaitForSingleObject(&DriveInfo->ControllerInfo->MotorStoppedEvent, Executive, KernelMode, FALSE, NULL);
122 INFO_(FLOPPY, "StartMotor: wait satisfied\n");
123 }
124
125 DriveInfo->ControllerInfo->StopDpcQueued = FALSE;
126
127 if(HwTurnOnMotor(DriveInfo) != STATUS_SUCCESS)
128 {
129 WARN_(FLOPPY, "StartMotor(): warning: HwTurnOnMotor failed\n");
130 }
131}
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI HwTurnOnMotor(PDRIVE_INFO DriveInfo)
Definition: hardware.c:245
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KernelMode
Definition: asm.h:34
#define INFO_(ch,...)
Definition: debug.h:159
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
@ Executive
Definition: ketypes.h:415

Referenced by AddControllers(), DeviceIoctlPassive(), ReadWritePassive(), Recalibrate(), and ResetChangeFlag().

◆ StopMotor()

VOID NTAPI StopMotor ( PCONTROLLER_INFO  ControllerInfo)

Definition at line 135 of file floppy.c.

145{
146 LARGE_INTEGER StopTime;
147
148 ASSERT(ControllerInfo);
149
150 TRACE_(FLOPPY, "StopMotor called\n");
151
152 /* one relative second, in 100-ns units */
153 StopTime.QuadPart = 10000000;
154 StopTime.QuadPart *= -1;
155
156 KeClearEvent(&ControllerInfo->MotorStoppedEvent);
157 KeSetTimer(&ControllerInfo->MotorTimer, StopTime, &ControllerInfo->MotorStopDpc);
158 ControllerInfo->StopDpcQueued = TRUE;
159}
#define TRUE
Definition: types.h:120
BOOLEAN StopDpcQueued
Definition: floppy.h:86
KTIMER MotorTimer
Definition: floppy.h:84
KEVENT MotorStoppedEvent
Definition: floppy.h:83
KDPC MotorStopDpc
Definition: floppy.h:85
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by AddControllers(), DeviceIoctlPassive(), ReadWritePassive(), Recalibrate(), and ResetChangeFlag().

◆ swprintf()

int _cdecl swprintf ( const WCHAR ,
  ... 
)

◆ WaitForControllerInterrupt()

NTSTATUS NTAPI WaitForControllerInterrupt ( PCONTROLLER_INFO  ControllerInfo,
PLARGE_INTEGER  Timeout 
)

Definition at line 163 of file floppy.c.

176{
178
179 PAGED_CODE();
180 ASSERT(ControllerInfo);
181
183 KeClearEvent(&ControllerInfo->SynchEvent);
184
185 return Status;
186}
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
static ULONG Timeout
Definition: ping.c:61
KEVENT SynchEvent
Definition: floppy.h:74

Referenced by InitController(), ReadWritePassive(), Recalibrate(), ResetChangeFlag(), RWDetermineMediaType(), and RWSeekToCylinder().