1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _sun_dkio_h
#define _sun_dkio_h
#pragma ident "%Z%%M% %I% %E% SMI"
/* #include <sys/ioctl.h> not needed? */
#include <sun/dklabel.h>
/*
* Structures and definitions for disk io control commands
*/
/*
* Structures used as data by ioctl calls.
*/
/*
* Used for controller info
*/
struct dk_info {
int dki_ctlr; /* controller address */
short dki_unit; /* unit (slave) address */
short dki_ctype; /* controller type */
short dki_flags; /* flags */
};
#define DK_DEVLEN 16 /* device name max length, including */
/* unit # & NULL (ie - "xyc1") */
/*
* Used for configuration info
*/
struct dk_conf {
char dkc_cname[DK_DEVLEN]; /* controller name (no unit #) */
u_short dkc_ctype; /* controller type */
u_short dkc_flags; /* flags */
short dkc_cnum; /* controller number */
int dkc_addr; /* controller address */
u_int dkc_space; /* controller bus type */
int dkc_prio; /* interrupt priority */
int dkc_vec; /* interrupt vector */
char dkc_dname[DK_DEVLEN]; /* drive name (no unit #) */
short dkc_unit; /* unit number */
short dkc_slave; /* slave number */
};
/*
* Controller types
*/
#define DKC_UNKNOWN 0
/* 1 used to be Interphase 2180 */
#define DKC_WDC2880 2
/* 3 used to be Interphase 2181 */
/* 4 used to be Xylogics 440 */
#define DKC_DSD5215 5
#define DKC_XY450 6
#define DKC_ACB4000 7
#define DKC_MD21 8
/* 9 used to be Xylogics 751 */
#define DKC_NCRFLOPPY 10
/* #define DKC_XB1401 10 does not match dkinfo.c*/
#define DKC_XD7053 11
#define DKC_SMSFLOPPY 12
#define DKC_SCSI_CCS 13
#define DKC_INTEL82072 14 /* floppy ctlr on campus and hydra */
#define DKC_PANTHER 15
#define DKC_SUN_IPI1 DKC_PANTHER /* Sun Panther VME/IPI controller */
#define DKC_MD 16 /* meta-disk (virtual-disk) driver */
#define DKC_CDC_9057 17 /* CDC 9057-321 (CM-3) IPI String Controller */
#define DKC_FJ_M1060 18 /* Fujitsu/Intellistor M1060 IPI-3 SC */
/*
* Flags
*/
#define DKI_BAD144 0x01 /* use DEC std 144 bad sector fwding */
#define DKI_MAPTRK 0x02 /* controller does track mapping */
#define DKI_FMTTRK 0x04 /* formats only full track at a time */
#define DKI_FMTVOL 0x08 /* formats only full volume at a time */
#define DKI_FMTCYL 0x10 /* formats only full cylinders at a time */
#define DKI_HEXUNIT 0x20 /* unit number is printed as 3 hex digits */
/*
* Used for drive info
*/
struct dk_type {
u_short dkt_hsect; /* hard sector count (read only) */
u_short dkt_promrev; /* prom revision (read only) */
u_char dkt_drtype; /* drive type (ctlr specific) */
u_char dkt_drstat; /* drive status (ctlr specific, ro) */
};
/*
* Used for all partitions
*/
struct dk_allmap {
struct dk_map dka_map[NDKMAP];
};
/*
* Used for bad sector map
*/
struct dk_badmap {
caddr_t dkb_bufaddr; /* address of user's map buffer */
};
/*
* Definition of a disk's geometry
*/
struct dk_geom {
unsigned short dkg_ncyl; /* # of data cylinders */
unsigned short dkg_acyl; /* # of alternate cylinders */
unsigned short dkg_bcyl; /* cyl offset (for fixed head area) */
unsigned short dkg_nhead; /* # of heads */
unsigned short dkg_obs1; /* obsolete */
unsigned short dkg_nsect; /* # of data sectors per track */
unsigned short dkg_intrlv; /* interleave factor */
unsigned short dkg_obs2; /* obsolete */
unsigned short dkg_obs3; /* obsolete */
unsigned short dkg_apc; /* alternates per cyl (SCSI only) */
unsigned short dkg_rpm; /* revolutions per minute */
unsigned short dkg_pcyl; /* # of physical cylinders */
unsigned short dkg_extra[7]; /* for compatible expansion */
};
/*
* These defines are for historic compatibility with old drivers.
*/
#define dkg_bhead dkg_obs1 /* used to be head offset */
#define dkg_gap1 dkg_obs2 /* used to be gap1 */
#define dkg_gap2 dkg_obs3 /* used to be gap2 */
/*
* Used for generic commands
*/
struct dk_cmd {
u_short dkc_cmd; /* command to be executed */
int dkc_flags; /* execution flags */
daddr_t dkc_blkno; /* disk address for command */
int dkc_secnt; /* sector count for command */
caddr_t dkc_bufaddr; /* user's buffer address */
u_int dkc_buflen; /* size of user's buffer */
};
/*
* Execution flags.
*/
#define DK_SILENT 0x01 /* no error messages */
#define DK_DIAGNOSE 0x02 /* fail if any error occurs */
#define DK_ISOLATE 0x04 /* isolate from normal commands */
#define DK_READ 0x08 /* read from device */
#define DK_WRITE 0x10 /* write to device */
/*
* Used for disk diagnostics
*/
struct dk_diag {
u_short dkd_errcmd; /* most recent command in error */
daddr_t dkd_errsect; /* most recent sector in error */
u_char dkd_errno; /* most recent error number */
u_char dkd_severe; /* severity of most recent error */
};
/*
* Used for getting disk error log.
*/
struct dk_loghdr {
long dkl_entries; /* number of dk_log entries */
long dkl_max_size; /* max. size of dk_log table */
caddr_t dkl_logbfr; /* pointer to dk_log table */
};
/*
* Disk error log table entry.
*/
struct dk_log {
daddr_t block; /* location of block in error */
u_long count; /* number of failures */
short type; /* type of error (e.g. soft error) */
short err1; /* primary error code (e.g sense key) */
short err2; /* secondary error code */
};
/*
* Dk_log type flags.
*
* FIXME: Really should specify dkd_errno error codes.
* For some reason they're specified in the drivers
* instead of here?? Should also use those here for
* dk_log.type too.
*/
#define DKL_SOFT 0x01 /* recoverable erro */
#define DKL_HARD 0x02 /* unrecoverable error */
/*
* Used for floppies
*/
struct fdk_char{
u_char medium; /* medium type. Unused, why have it? history! */
int transfer_rate; /* transfer rate */
int ncyl; /* number of cylinders */
int nhead; /* number of heads */
int sec_size; /* sector size */
int secptrack; /* sectors per track */
int steps; /* number of steps per */
};
struct fdk_state {
int fkc_bsec; /* bytes per sector */
int fkc_strack; /* sectors per track */
int fkc_step; /* step rate */
int fkc_rate; /* data rate */
int fkc_error; /* error returned by controller */
};
struct fdk_cmd { /* used by generic command */
struct dk_cmd dcmd; /* disk command info */
struct fdk_state fstate; /* floppy state info */
};
/*
* Floppy commands
*/
#define FKWRITE 1
#define FKREAD 2
#define FKSEEK 3
#define FKREZERO 4
#define FKFORMAT_UNIT 5
#define FKFORMAT_TRACK 6
/*
* Used by FDKGETCHANGE, return state of the sense disk change bit.
*/
#define FDKGC_HISTORY 0x01 /* disk has changed since last call */
#define FDKGC_CURRENT 0x02 /* current state of disk change */
/*
* Used by FDK{G, S}ETDRIVECHAR
*/
struct fdk_drive {
int fdd_ejectable; /* does the drive support eject? */
int fdd_maxsearch; /* size of per-unit search table */
int fdd_writeprecomp; /* cyl to start write prcompensation */
int fdd_writereduce; /* cyl to start recucing write current */
int fdd_stepwidth; /* width of step pulse in 1 us units */
int fdd_steprate; /* step rate in 100 us units */
int fdd_headsettle; /* delay, in 100 us units */
int fdd_headload; /* delay, in 100 us units */
int fdd_headunload; /* delay, in 100 us units */
int fdd_motoron; /* delay, in 100 ms units */
int fdd_motoroff; /* delay, in 100 ms units */
int fdd_precomplevel; /* bit shift, in nano-secs */
int fdd_pins; /* defines meaning of pin 1, 2, 4, and 34 */
int fdd_flags; /* TRUE READY, Starting Sector #, & Motor On */
};
/*
* Used by FDK{G, S}ETSEARCH
*/
struct fdk_search {
int fdk_numentries; /* number of elements in the table */
struct fdk_char *fdk_search;
};
/*
* Used by F_RAW
*/
struct fdraw {
char fr_cmd[10]; /* user-supplied command bytes */
short fr_cnum; /* number of command bytes */
char fr_result[10]; /* controller-supplied result bytes */
short fr_nbytes; /* number to transfer if read/write command */
char *fr_addr; /* where to transfer if read/write command */
};
/*
* Floppy raw commands
*/
#define FRAW_SPECIFY 0x03
#define FRAW_READID 0x0a
#define FRAW_SENSE_DRV 0x04
#define FRAW_REZERO 0x07
#define FRAW_SEEK 0x0f
#define FRAW_SENSE_INT 0x08
#define FRAW_FORMAT 0x0d
#define FRAW_READTRACK 0x02
#define FRAW_WRCMD 0x05
#define FRAW_RDCMD 0x06
#define FRAW_WRITEDEL 0x09
#define FRAW_READDEL 0x0c
/*
* Severity values
*/
#define DK_NOERROR 0
#define DK_CORRECTED 1
#define DK_RECOVERED 2
#define DK_FATAL 3
/*
* Error types
*/
#define DK_NONMEDIA 0 /* not caused by a media defect */
#define DK_ISMEDIA 1 /* caused by a media defect */
/*
* Disk io control commands
*/
#define DKIOCGGEOM _IOR('d', 2, struct dk_geom) /* Get geometry */
#define DKIOCSGEOM _IOW('d', 3, struct dk_geom) /* Set geometry */
#define DKIOCGPART _IOR('d', 4, struct dk_map) /* Get partition info */
#define DKIOCSPART _IOW('d', 5, struct dk_map) /* Set partition info */
#define DKIOCINFO _IOR('d', 8, struct dk_info) /* Get info */
#define DKIOCGCONF _IOR('d', 126, struct dk_conf) /* Get conf info */
#define DKIOCSTYPE _IOW('d', 125, struct dk_type) /* Set drive info */
#define DKIOCGTYPE _IOR('d', 124, struct dk_type) /* Get drive info */
#define DKIOCSAPART _IOW('d', 123, struct dk_allmap) /* Set all partitions */
#define DKIOCGAPART _IOR('d', 122, struct dk_allmap) /* Get all partitions */
#define DKIOCSBAD _IOW('d', 121, struct dk_badmap) /* Set bad sector map */
#define DKIOCGBAD _IOW('d', 120, struct dk_badmap) /* Get bad sector map */
#define DKIOCSCMD _IOW('d', 119, struct dk_cmd) /* Set generic cmd */
#define DKIOCGLOG _IOR('d', 118, struct dk_loghdr) /* Get error log */
#define DKIOCGDIAG _IOR('d', 116, struct dk_diag) /* Get diagnostics */
#define DKIOCWCHK _IOWR('d', 115, int) /* Toggle write check */
#define FDKIOGCHAR _IOR('d', 114, struct fdk_char) /* GetCharacteristics */
#define FDKIOSCHAR _IOW('d', 113, struct fdk_char) /* SetCharacteristics */
#define FDKEJECT _IO('d', 112) /* Eject floppy disk */
#define FDKGETCHANGE _IOR('d', 111, int) /* Get diskchng stat */
#define FDKGETDRIVECHAR _IOR('d', 110, struct fdk_drive) /* Get drivechar */
#define FDKSETDRIVECHAR _IOW('d', 109, struct fdk_drive) /* Set drivechar */
#define FDKGETSEARCH _IOR('d', 108, struct fdk_search) /* Get search tbl */
#define FDKSETSEARCH _IOW('d', 107, struct fdk_search) /* Set search tbl */
#define FDKIOCSCMD _IOWR('d', 106, struct fdk_cmd) /* Floppy command */
#define F_RAW _IOWR('d', 105, struct fdraw) /* ECDstyle genericcmd*/
#endif /* !_sun_dkio_h */
|