ReactOS 0.4.17-dev-470-gf9e3448
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

◆ _swprintf()

int _cdecl _swprintf ( const WCHAR ,
  ... 
)

◆ 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:73

◆ ResetChangeFlag()

NTSTATUS NTAPI ResetChangeFlag ( PDRIVE_INFO  DriveInfo)

Definition at line 354 of file floppy.c.

369{
370 BOOLEAN DiskChanged;
371
372 PAGED_CODE();
373 ASSERT(DriveInfo);
374
375 TRACE_(FLOPPY, "ResetChangeFlag called\n");
376
377 /* Try to recalibrate. We don't care if it works. */
378 Recalibrate(DriveInfo);
379
380 /* clear spurious interrupts in prep for seeks */
381 KeClearEvent(&DriveInfo->ControllerInfo->SynchEvent);
382
383 /* must re-start the drive because Recalibrate() stops it */
384 StartMotor(DriveInfo);
385
386 /* Seek to 1 */
387 if(HwSeek(DriveInfo, 1) != STATUS_SUCCESS)
388 {
389 WARN_(FLOPPY, "ResetChangeFlag(): HwSeek failed; returning STATUS_IO_DEVICE_ERROR\n");
390 StopMotor(DriveInfo->ControllerInfo);
392 }
393
395
397 {
398 WARN_(FLOPPY, "ResetChangeFlag(): HwSenseInterruptStatus failed; bailing out\n");
399 StopMotor(DriveInfo->ControllerInfo);
401 }
402
403 /* Seek back to 0 */
404 if(HwSeek(DriveInfo, 0) != STATUS_SUCCESS)
405 {
406 WARN_(FLOPPY, "ResetChangeFlag(): HwSeek failed; returning STATUS_IO_DEVICE_ERROR\n");
407 StopMotor(DriveInfo->ControllerInfo);
409 }
410
412
414 {
415 WARN_(FLOPPY, "ResetChangeFlag(): HwSenseInterruptStatus #2 failed; bailing\n");
416 StopMotor(DriveInfo->ControllerInfo);
418 }
419
420 /* Check the change bit */
421 if(HwDiskChanged(DriveInfo, &DiskChanged) != STATUS_SUCCESS)
422 {
423 WARN_(FLOPPY, "ResetChangeFlag(): HwDiskChanged failed; returning STATUS_IO_DEVICE_ERROR\n");
424 StopMotor(DriveInfo->ControllerInfo);
426 }
427
428 StopMotor(DriveInfo->ControllerInfo);
429
430 /* if the change flag is still set, there's probably no media in the drive. */
431 if(DiskChanged)
433
434 /* else we're done! */
435 return STATUS_SUCCESS;
436}
#define PAGED_CODE()
unsigned char BOOLEAN
Definition: actypes.h:127
#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:284
NTSTATUS NTAPI WaitForControllerInterrupt(PCONTROLLER_INFO ControllerInfo, PLARGE_INTEGER Timeout)
Definition: floppy.c:226
VOID NTAPI StartMotor(PDRIVE_INFO DriveInfo)
Definition: floppy.c:159
VOID NTAPI StopMotor(PCONTROLLER_INFO ControllerInfo)
Definition: floppy.c:198
#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 1128 of file floppy.c.

1139{
1140 PDRIVE_INFO DriveInfo = DeviceObject->DeviceExtension;
1141
1142 TRACE_(FLOPPY, "SignalMediaChanged called\n");
1143
1144 DriveInfo->DiskChangeCount++;
1145
1146 /* If volume is not mounted, do NOT set verify and return STATUS_IO_DEVICE_ERROR */
1147 if(!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
1148 {
1149 Irp->IoStatus.Status = STATUS_IO_DEVICE_ERROR;
1150 Irp->IoStatus.Information = 0;
1151 return;
1152 }
1153
1154 /* Notify the filesystem that it will need to verify the volume */
1156 Irp->IoStatus.Status = STATUS_VERIFY_REQUIRED;
1157 Irp->IoStatus.Information = 0;
1158
1159 /*
1160 * If this is a user-based, threaded request, let the IO manager know to pop up a box asking
1161 * the user to supply the correct media, but only if the error (which we just picked out above)
1162 * is deemed by the IO manager to be "user induced". The reason we don't just unconditionally
1163 * call IoSetHardError... is because MS might change the definition of "user induced" some day,
1164 * and we don't want to have to remember to re-code this.
1165 */
1166 if(Irp->Tail.Overlay.Thread && IoIsErrorUserInduced(Irp->IoStatus.Status))
1168}
_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:2061
#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 159 of file floppy.c.

174{
175 PAGED_CODE();
176 ASSERT(DriveInfo);
177
178 TRACE_(FLOPPY, "StartMotor called\n");
179
180 if(DriveInfo->ControllerInfo->StopDpcQueued && !KeCancelTimer(&DriveInfo->ControllerInfo->MotorTimer))
181 {
182 /* Motor turner-offer is already running; wait for it to finish */
183 INFO_(FLOPPY, "StartMotor: motor turner-offer is already running; waiting for it\n");
184 KeWaitForSingleObject(&DriveInfo->ControllerInfo->MotorStoppedEvent, Executive, KernelMode, FALSE, NULL);
185 INFO_(FLOPPY, "StartMotor: wait satisfied\n");
186 }
187
188 DriveInfo->ControllerInfo->StopDpcQueued = FALSE;
189
190 if(HwTurnOnMotor(DriveInfo) != STATUS_SUCCESS)
191 {
192 WARN_(FLOPPY, "StartMotor(): warning: HwTurnOnMotor failed\n");
193 }
194}
#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:38
#define INFO_(ch,...)
Definition: debug.h:159
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
@ Executive
Definition: ketypes.h:467

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

◆ StopMotor()

VOID NTAPI StopMotor ( PCONTROLLER_INFO  ControllerInfo)

Definition at line 198 of file floppy.c.

208{
209 LARGE_INTEGER StopTime;
210
211 ASSERT(ControllerInfo);
212
213 TRACE_(FLOPPY, "StopMotor called\n");
214
215 /* one relative second, in 100-ns units */
216 StopTime.QuadPart = 10000000;
217 StopTime.QuadPart *= -1;
218
219 KeClearEvent(&ControllerInfo->MotorStoppedEvent);
220 KeSetTimer(&ControllerInfo->MotorTimer, StopTime, &ControllerInfo->MotorStopDpc);
221 ControllerInfo->StopDpcQueued = TRUE;
222}
#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:282
LONGLONG QuadPart
Definition: typedefs.h:114

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

◆ WaitForControllerInterrupt()

NTSTATUS NTAPI WaitForControllerInterrupt ( PCONTROLLER_INFO  ControllerInfo,
PLARGE_INTEGER  Timeout 
)

Definition at line 226 of file floppy.c.

239{
241
242 PAGED_CODE();
243 ASSERT(ControllerInfo);
244
246 KeClearEvent(&ControllerInfo->SynchEvent);
247
248 return Status;
249}
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:24
static ULONG Timeout
Definition: ping.c:61
KEVENT SynchEvent
Definition: floppy.h:74

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