ReactOS  0.4.13-dev-645-g69454b4
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 }
void DPRINT(...)
Definition: polytest.cpp:61
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by DriverEntry(), and IopInitializeDriverModule().

◆ 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);
328  return STATUS_IO_DEVICE_ERROR;
329  }
330 
332 
334  {
335  WARN_(FLOPPY, "ResetChangeFlag(): HwSenseInterruptStatus failed; bailing out\n");
336  StopMotor(DriveInfo->ControllerInfo);
337  return STATUS_IO_DEVICE_ERROR;
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);
345  return STATUS_IO_DEVICE_ERROR;
346  }
347 
349 
351  {
352  WARN_(FLOPPY, "ResetChangeFlag(): HwSenseInterruptStatus #2 failed; bailing\n");
353  StopMotor(DriveInfo->ControllerInfo);
354  return STATUS_IO_DEVICE_ERROR;
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);
362  return STATUS_IO_DEVICE_ERROR;
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 STATUS_NO_MEDIA_IN_DEVICE
Definition: udferr_usr.h:141
NTSTATUS NTAPI WaitForControllerInterrupt(PCONTROLLER_INFO ControllerInfo, PLARGE_INTEGER Timeout)
Definition: floppy.c:163
NTSTATUS NTAPI HwDiskChanged(PDRIVE_INFO DriveInfo, PBOOLEAN DiskChanged)
Definition: hardware.c:785
VOID NTAPI StopMotor(PCONTROLLER_INFO ControllerInfo)
Definition: floppy.c:135
static NTSTATUS NTAPI Recalibrate(PDRIVE_INFO DriveInfo)
Definition: floppy.c:221
struct _CONTROLLER_INFO * ControllerInfo
Definition: fdc.h:23
#define PAGED_CODE()
Definition: video.h:57
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI HwSenseInterruptStatus(PCONTROLLER_INFO ControllerInfo)
Definition: hardware.c:539
#define TRACE_(x)
Definition: compat.h:66
NTSTATUS NTAPI HwSeek(PDRIVE_INFO DriveInfo, UCHAR Cylinder)
Definition: hardware.c:659
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define WARN_(ch,...)
Definition: debug.h:157
VOID NTAPI StartMotor(PDRIVE_INFO DriveInfo)
Definition: floppy.c:96

Referenced by DeviceIoctlPassive(), and ReadWritePassive().

◆ SignalMediaChanged()

VOID NTAPI SignalMediaChanged ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 1010 of file floppy.c.

1021 {
1023 
1024  TRACE_(FLOPPY, "SignalMediaChanged called\n");
1025 
1026  DriveInfo->DiskChangeCount++;
1027 
1028  /* If volume is not mounted, do NOT set verify and return STATUS_IO_DEVICE_ERROR */
1029  if(!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
1030  {
1031  Irp->IoStatus.Status = STATUS_IO_DEVICE_ERROR;
1032  Irp->IoStatus.Information = 0;
1033  return;
1034  }
1035 
1036  /* Notify the filesystem that it will need to verify the volume */
1038  Irp->IoStatus.Status = STATUS_VERIFY_REQUIRED;
1039  Irp->IoStatus.Information = 0;
1040 
1041  /*
1042  * If this is a user-based, threaded request, let the IO manager know to pop up a box asking
1043  * the user to supply the correct media, but only if the error (which we just picked out above)
1044  * is deemed by the IO manager to be "user induced". The reason we don't just unconditionally
1045  * call IoSetHardError... is because MS might change the definition of "user induced" some day,
1046  * and we don't want to have to remember to re-code this.
1047  */
1048  if(Irp->Tail.Overlay.Thread && IoIsErrorUserInduced(Irp->IoStatus.Status))
1050 }
ULONG DiskChangeCount
Definition: floppy.h:53
_In_ PIRP Irp
Definition: csq.h:116
#define IoIsErrorUserInduced(Status)
Definition: iofuncs.h:2769
#define DO_VERIFY_VOLUME
Definition: env_spec_w32.h:393
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define TRACE_(x)
Definition: compat.h:66
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI IoSetHardErrorOrVerifyDevice(IN PIRP Irp, IN PDEVICE_OBJECT DeviceObject)
Definition: util.c:316
#define VPB_MOUNTED
Definition: iotypes.h:1763

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 INFO_(ch,...)
Definition: debug.h:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
struct _CONTROLLER_INFO * ControllerInfo
Definition: fdc.h:23
#define PAGED_CODE()
Definition: video.h:57
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI HwTurnOnMotor(PDRIVE_INFO DriveInfo)
Definition: hardware.c:245
#define TRACE_(x)
Definition: compat.h:66
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define WARN_(ch,...)
Definition: debug.h:157

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 NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
#define TRACE_(x)
Definition: compat.h:66
KDPC MotorStopDpc
Definition: floppy.h:85
KEVENT MotorStoppedEvent
Definition: floppy.h:83
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOLEAN StopDpcQueued
Definition: floppy.h:86
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
LONGLONG QuadPart
Definition: typedefs.h:112
KTIMER MotorTimer
Definition: floppy.h:84

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
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define PAGED_CODE()
Definition: video.h:57
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
static ULONG Timeout
Definition: ping.c:61
KEVENT SynchEvent
Definition: floppy.h:74
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22

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