fdcio.h revision 891
1877Sache/*
2877Sache * 386BSD:
3877Sache * format a floppy disk
4877Sache *
5877Sache * First, totally uncomfortable and unreliable version.
6877Sache * USE AT YOUR OWN RISK. NEITHER KIND OF WARRANTY OR LIABILITY.
7877Sache * No complaints about "lost data", "destroyed diskette", "blown
8877Sache * controllers" or so are accepted.
9877Sache *
10877Sache * Detailed bug reports, bug fixes, and suggestions are welcome.
11877Sache * Author & Copyright:
12877Sache *  (c) 1992, 1993 Joerg Wunsch, Dresden
13877Sache *  joerg_wunsch@uriah.sax.de
14877Sache */
15877Sache
16877Sache#ifndef _IOCTL_FD_H
17877Sache#define _IOCTL_FD_H
18877Sache
19877Sache#include <sys/types.h>
20877Sache#include <sys/ioctl.h>
21877Sache
22877Sache#define FD_FORMAT_VERSION 110	/* used to validate before formatting */
23877Sache#define FD_MAX_NSEC 36		/* highest known number of spt - allow for */
24877Sache				/* 2.88 MB drives */
25877Sache
26877Sachestruct fd_formb {
27877Sache	int format_version;	/* == FD_FORMAT_VERSION */
28877Sache	int cyl, head;
29877Sache	int transfer_rate;	/* fdreg.h: FDC_???KBPS */
30877Sache
31877Sache	union {
32877Sache		struct fd_form_data {
33877Sache			/*
34877Sache			 * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS
35877Sache			 * it is hardware-dependant since it exactly
36877Sache			 * matches the byte sequence to write to FDC
37877Sache			 * during its `format track' operation
38877Sache			 */
39877Sache			u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */
40877Sache			u_char nsecs;	/* must be <= FD_MAX_NSEC */
41877Sache			u_char gaplen;	/* GAP 3 length; usually 84 */
42877Sache			u_char fillbyte; /* usually 0xf6 */
43877Sache			struct fd_idfield_data {
44877Sache				/*
45877Sache				 * data to write into id fields;
46877Sache				 * for obscure formats, they mustn't match
47877Sache				 * the real values (but mostly do)
48877Sache				 */
49877Sache				u_char cylno;	/* 0 thru 79 (or 39) */
50877Sache				u_char headno;	/* 0, or 1 */
51877Sache				u_char secno;	/* starting at 1! */
52877Sache				u_char secsize;	/* usually 2 */
53877Sache			} idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */
54877Sache		} structured;
55877Sache		u_char raw[1];	/* to have continuous indexed access */
56877Sache	} format_info;
57877Sache};
58877Sache
59877Sache/* make life easier */
60877Sache# define fd_formb_secshift   format_info.structured.secshift
61877Sache# define fd_formb_nsecs      format_info.structured.nsecs
62877Sache# define fd_formb_gaplen     format_info.structured.gaplen
63877Sache# define fd_formb_fillbyte   format_info.structured.fillbyte
64877Sache/* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */
65877Sache# define fd_formb_cylno(i)   format_info.structured.idfields[i].cylno
66877Sache# define fd_formb_headno(i)  format_info.structured.idfields[i].headno
67877Sache# define fd_formb_secno(i)   format_info.structured.idfields[i].secno
68877Sache# define fd_formb_secsize(i) format_info.structured.idfields[i].secsize
69877Sache
70877Sachestruct fd_type {
71877Sache	int	sectrac;		/* sectors per track         */
72877Sache	int	secsize;		/* size code for sectors     */
73877Sache	int	datalen;		/* data len when secsize = 0 */
74877Sache	int	gap;			/* gap len between sectors   */
75877Sache	int	tracks;			/* total num of tracks       */
76877Sache	int	size;			/* size of disk in sectors   */
77877Sache	int	steptrac;		/* steps per cylinder        */
78877Sache	int	trans;			/* transfer speed code       */
79877Sache	int	heads;			/* number of heads	     */
80891Sache	int     f_gap;                  /* format gap len            */
81891Sache	int     f_inter;                /* format interleave factor  */
82877Sache};
83877Sache
84877Sache#define FD_FORM   _IOW('F', 61, struct fd_formb) /* format a track */
85877Sache#define FD_GTYPE  _IOR('F', 62, struct fd_type)  /* get drive type */
86877Sache
87877Sache#endif  /* !def _IOCTL_FD_H */
88