[STORAGE] Storage driver cleanup part 3
[reactos.git] / drivers / storage / floppy / floppy / floppy.h
1 /*
2 * ReactOS Floppy Driver
3 * Copyright (C) 2004, Vizzini (vizzini@plasmic.com)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * PROJECT: ReactOS Floppy Driver
20 * FILE: floppy.h
21 * PURPOSE: Header for Main floppy driver routines
22 * PROGRAMMER: Vizzini (vizzini@plasmic.com)
23 * REVISIONS:
24 * 15-Feb-2004 vizzini - Created
25 */
26
27 #pragma once
28
29 #define MAX_DEVICE_NAME 255
30 #define MAX_ARC_PATH_LEN 255
31 #define MAX_DRIVES_PER_CONTROLLER 4
32 #define MAX_CONTROLLERS 4
33
34 /* MS doesn't prototype this but the w2k kernel exports it */
35 int _cdecl swprintf(const WCHAR *, ...);
36
37 /* need ioctls in ddk build mode */
38 #include <ntdddisk.h>
39
40 struct _CONTROLLER_INFO;
41
42 typedef struct _DRIVE_INFO
43 {
44 struct _CONTROLLER_INFO *ControllerInfo;
45 UCHAR UnitNumber; /* 0,1,2,3 */
46 LARGE_INTEGER MotorStartTime;
47 PDEVICE_OBJECT DeviceObject;
48 CM_FLOPPY_DEVICE_DATA FloppyDeviceData;
49 DISK_GEOMETRY DiskGeometry;
50 UCHAR BytesPerSectorCode;
51 WCHAR ArcPathBuffer[MAX_ARC_PATH_LEN];
52 WCHAR DeviceNameBuffer[MAX_DEVICE_NAME];
53 ULONG DiskChangeCount;
54 BOOLEAN Initialized;
55 } DRIVE_INFO, *PDRIVE_INFO;
56
57 typedef struct _CONTROLLER_INFO
58 {
59 BOOLEAN Populated;
60 BOOLEAN Initialized;
61 ULONG ControllerNumber;
62 INTERFACE_TYPE InterfaceType;
63 ULONG BusNumber;
64 ULONG Level;
65 KIRQL MappedLevel;
66 ULONG Vector;
67 ULONG MappedVector;
68 KINTERRUPT_MODE InterruptMode;
69 PUCHAR BaseAddress;
70 ULONG Dma;
71 ULONG MapRegisters;
72 PVOID MapRegisterBase;
73 BOOLEAN Master;
74 KEVENT SynchEvent;
75 KDPC Dpc;
76 PKINTERRUPT InterruptObject;
77 PADAPTER_OBJECT AdapterObject;
78 UCHAR NumberOfDrives;
79 BOOLEAN ImpliedSeeks;
80 DRIVE_INFO DriveInfo[MAX_DRIVES_PER_CONTROLLER];
81 PDRIVE_INFO CurrentDrive;
82 BOOLEAN Model30;
83 KEVENT MotorStoppedEvent;
84 KTIMER MotorTimer;
85 KDPC MotorStopDpc;
86 BOOLEAN StopDpcQueued;
87 } CONTROLLER_INFO, *PCONTROLLER_INFO;
88
89 NTSTATUS NTAPI
90 DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath);
91
92 VOID NTAPI
93 SignalMediaChanged(PDEVICE_OBJECT DeviceObject, PIRP Irp);
94
95 NTSTATUS NTAPI
96 WaitForControllerInterrupt(PCONTROLLER_INFO ControllerInfo, PLARGE_INTEGER Timeout);
97
98 NTSTATUS NTAPI
99 ResetChangeFlag(PDRIVE_INFO DriveInfo);
100
101 VOID NTAPI
102 StartMotor(PDRIVE_INFO DriveInfo);
103
104 VOID NTAPI
105 StopMotor(PCONTROLLER_INFO ControllerInfo);
106
107 /*
108 * MEDIA TYPES
109 *
110 * This table was found at http://www.nondot.org/sabre/os/files/Disk/FloppyMediaIDs.txt.
111 * Thanks to raster@indirect.com for this information.
112 *
113 * Format Size Cyls Heads Sec/Trk FATs Sec/FAT Sec/Root Media
114 * 160K 5 1/4 40 1 8 2 ? ? FE
115 * 180K 5 1/4 40 1 9 2 ? 4 FC
116 * 320K 5 1/4 40 2 8 2 ? ? FF
117 * 360K 5 1/4 40 2 9 2 4 7 FD
118 * 1.2M 5 1/4 80 2 15 2 14 14 F9
119 * 720K 3 1/2 80 2 9 2 6 7 F9
120 * 1.44M 3 1/2 80 2 18 2 18 14 F0
121 */
122
123 #define GEOMETRY_144_MEDIATYPE F3_1Pt44_512
124 #define GEOMETRY_144_CYLINDERS 80
125 #define GEOMETRY_144_TRACKSPERCYLINDER 2
126 #define GEOMETRY_144_SECTORSPERTRACK 18
127 #define GEOMETRY_144_BYTESPERSECTOR 512