1 #ifndef _LINUX_XD_H
2 #define _LINUX_XD_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #define XD_DATA (xd_iobase + 0x00)
18 #define XD_RESET (xd_iobase + 0x01)
19 #define XD_STATUS (xd_iobase + 0x01)
20 #define XD_SELECT (xd_iobase + 0x02)
21 #define XD_JUMPER (xd_iobase + 0x02)
22 #define XD_CONTROL (xd_iobase + 0x03)
23 #define XD_RESERVED (xd_iobase + 0x03)
24
25
26 #define CMD_TESTREADY 0x00
27 #define CMD_RECALIBRATE 0x01
28 #define CMD_SENSE 0x03
29 #define CMD_FORMATDRV 0x04
30 #define CMD_VERIFY 0x05
31 #define CMD_FORMATTRK 0x06
32 #define CMD_FORMATBAD 0x07
33 #define CMD_READ 0x08
34 #define CMD_WRITE 0x0A
35 #define CMD_SEEK 0x0B
36
37
38 #define CMD_DTCSETPARAM 0x0C
39 #define CMD_DTCGETECC 0x0D
40 #define CMD_DTCREADBUF 0x0E
41 #define CMD_DTCWRITEBUF 0x0F
42 #define CMD_DTCREMAPTRK 0x11
43 #define CMD_DTCGETPARAM 0xFB
44 #define CMD_DTCSETSTEP 0xFC
45 #define CMD_DTCSETGEOM 0xFE
46 #define CMD_DTCGETGEOM 0xFF
47 #define CMD_ST11GETGEOM 0xF8
48 #define CMD_WDSETPARAM 0x0C
49
50
51 #define CSB_ERROR 0x02
52 #define CSB_LUN 0x20
53
54
55 #define STAT_READY 0x01
56 #define STAT_INPUT 0x02
57 #define STAT_COMMAND 0x04
58 #define STAT_SELECT 0x08
59 #define STAT_REQUEST 0x10
60 #define STAT_INTERRUPT 0x20
61
62
63 #define PIO_MODE 0x00
64 #define DMA_MODE 0x03
65
66 #define XD_MAXDRIVES 2
67 #define XD_TIMEOUT 100
68 #define XD_RETRIES 4
69
70 #undef DEBUG
71 #undef XD_OVERRIDE
72
73 #ifdef DEBUG
74 #define DEBUG_STARTUP
75 #define DEBUG_OVERRIDE
76 #define DEBUG_READWRITE
77 #define DEBUG_OTHER
78 #define DEBUG_COMMAND
79 #endif DEBUG
80
81
82 typedef struct {
83 u_char heads;
84 u_short cylinders;
85 u_char sectors;
86 u_char control;
87 } XD_INFO;
88
89 #define HDIO_GETGEO 0x0301
90
91
92 typedef struct {
93 u_char heads;
94 u_char sectors;
95 u_short cylinders;
96 u_long start;
97 } XD_GEOMETRY;
98
99
100 typedef struct {
101 u_long offset;
102 u_char *string;
103 void (*init_controller)(u_char *address);
104 void (*init_drive)(u_char drive);
105 u_char *name;
106 } XD_SIGNATURE;
107
108 extern void resetup_one_dev (struct gendisk *dev,unsigned int drive);
109
110 u_long xd_init(u_long mem_start,u_long mem_end);
111 static u_char xd_detect (u_char *controller,u_char **address);
112 static u_char xd_initdrives (void (*init_drive)(u_char drive));
113 static void xd_geninit (void);
114
115 static int xd_open (struct inode *inode,struct file *file);
116 static void do_xd_request (void);
117 static int xd_ioctl (struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg);
118 static void xd_release (struct inode *inode,struct file *file);
119 static int xd_reread_partitions (int dev);
120 static int xd_readwrite (u_char operation,u_char drive,u_char *buffer,u_int block,u_int count);
121 static void xd_recalibrate (u_char drive);
122
123 static void xd_interrupt_handler (int unused);
124 static u_char xd_setup_dma (u_char opcode,u_char *buffer,u_int count);
125 static u_char *xd_build (u_char *cmdblk,u_char command,u_char drive,u_char head,u_short cylinder,u_char sector,u_char count,u_char control);
126 static inline u_char xd_waitport (u_short port,u_char flags,u_char mask,u_long timeout);
127 static u_int xd_command (u_char *command,u_char mode,u_char *indata,u_char *outdata,u_char *sense,u_long timeout);
128
129
130 #ifndef XD_OVERRIDE
131 static void xd_dtc5150x_init_controller (u_char *address);
132 static void xd_dtc5150x_init_drive (u_char drive);
133 static void xd_wd1004a27x_init_controller (u_char *address);
134 static void xd_wd1004a27x_init_drive (u_char drive);
135 static void xd_seagate11_init_controller (u_char *address);
136 static void xd_seagate11_init_drive (u_char drive);
137 static void xd_setparam (u_char command,u_char drive,u_char heads,u_short cylinders,u_short rwrite,u_short wprecomp,u_char ecc);
138 #endif XD_OVERRIDE
139
140 static void xd_override_init_controller (u_char *address);
141 static void xd_override_init_drive (u_char drive);
142
143 #endif _LINUX_XD_H