[USB-BRINGUP-TRUNK]
[reactos.git] / drivers / storage / 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 #define MAX_DEVICE_NAME 255
28 #define MAX_ARC_PATH_LEN 255
29 #define MAX_DRIVES_PER_CONTROLLER 4
30 #define MAX_CONTROLLERS 4
31
32 /* MS doesn't prototype this but the w2k kernel exports it */
33 int _cdecl swprintf(const WCHAR *, ...);
34
35 /* need ioctls in ddk build mode */
36 #include <ntdddisk.h>
37
38 struct _CONTROLLER_INFO;
39
40 typedef struct _DRIVE_INFO
41 {
42 struct _CONTROLLER_INFO *ControllerInfo;
43 UCHAR UnitNumber; /* 0,1,2,3 */
44 LARGE_INTEGER MotorStartTime;
45 PDEVICE_OBJECT DeviceObject;
46 CM_FLOPPY_DEVICE_DATA FloppyDeviceData;
47 DISK_GEOMETRY DiskGeometry;
48 UCHAR BytesPerSectorCode;
49 WCHAR SymLinkBuffer[MAX_DEVICE_NAME];
50 WCHAR ArcPathBuffer[MAX_ARC_PATH_LEN];
51 ULONG DiskChangeCount;
52 BOOLEAN Initialized;
53 } DRIVE_INFO, *PDRIVE_INFO;
54
55 typedef struct _CONTROLLER_INFO
56 {
57 BOOLEAN Populated;
58 BOOLEAN Initialized;
59 ULONG ControllerNumber;
60 INTERFACE_TYPE InterfaceType;
61 ULONG BusNumber;
62 ULONG Level;
63 KIRQL MappedLevel;
64 ULONG Vector;
65 ULONG MappedVector;
66 KINTERRUPT_MODE InterruptMode;
67 PUCHAR BaseAddress;
68 ULONG Dma;
69 ULONG MapRegisters;
70 PVOID MapRegisterBase;
71 BOOLEAN Master;
72 KEVENT SynchEvent;
73 KDPC Dpc;
74 PKINTERRUPT InterruptObject;
75 PADAPTER_OBJECT AdapterObject;
76 UCHAR NumberOfDrives;
77 BOOLEAN ImpliedSeeks;
78 DRIVE_INFO DriveInfo[MAX_DRIVES_PER_CONTROLLER];
79 PDRIVE_INFO CurrentDrive;
80 BOOLEAN Model30;
81 KEVENT MotorStoppedEvent;
82 KTIMER MotorTimer;
83 KDPC MotorStopDpc;
84 BOOLEAN StopDpcQueued;
85 } CONTROLLER_INFO, *PCONTROLLER_INFO;
86
87 NTSTATUS NTAPI
88 DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath);
89
90 VOID NTAPI
91 SignalMediaChanged(PDEVICE_OBJECT DeviceObject, PIRP Irp);
92
93 VOID NTAPI
94 WaitForControllerInterrupt(PCONTROLLER_INFO ControllerInfo);
95
96 NTSTATUS NTAPI
97 ResetChangeFlag(PDRIVE_INFO DriveInfo);
98
99 VOID NTAPI
100 StartMotor(PDRIVE_INFO DriveInfo);
101
102 VOID NTAPI
103 StopMotor(PCONTROLLER_INFO ControllerInfo);
104
105 /*
106 * MEDIA TYPES
107 *
108 * This table was found at http://www.nondot.org/sabre/os/files/Disk/FloppyMediaIDs.txt.
109 * Thanks to raster@indirect.com for this information.
110 *
111 * Format Size Cyls Heads Sec/Trk FATs Sec/FAT Sec/Root Media
112 * 160K 5 1/4 40 1 8 2 ? ? FE
113 * 180K 5 1/4 40 1 9 2 ? 4 FC
114 * 320K 5 1/4 40 2 8 2 ? ? FF
115 * 360K 5 1/4 40 2 9 2 4 7 FD
116 * 1.2M 5 1/4 80 2 15 2 14 14 F9
117 * 720K 3 1/2 80 2 9 2 6 7 F9
118 * 1.44M 3 1/2 80 2 18 2 18 14 F0
119 */
120
121 #define GEOMETRY_144_MEDIATYPE F3_1Pt44_512
122 #define GEOMETRY_144_CYLINDERS 80
123 #define GEOMETRY_144_TRACKSPERCYLINDER 2
124 #define GEOMETRY_144_SECTORSPERTRACK 18
125 #define GEOMETRY_144_BYTESPERSECTOR 512
126