fdcio.h revision 1019
1877Sache/*
21019Sache * Copyright (C) 1992-1993 by Joerg Wunsch, Dresden
31019Sache * All rights reserved.
4877Sache *
51019Sache * Redistribution and use in source and binary forms, with or without
61019Sache * modification, are permitted provided that the following conditions
71019Sache * are met:
81019Sache * 1. Redistributions of source code must retain the above copyright
91019Sache *    notice, this list of conditions and the following disclaimer.
101019Sache * 2. Redistributions in binary form must reproduce the above copyright
111019Sache *    notice, this list of conditions and the following disclaimer in the
121019Sache *    documentation and/or other materials provided with the distribution.
13877Sache *
141019Sache * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
151019Sache * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
161019Sache * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
171019Sache * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
181019Sache * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
191019Sache * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
201019Sache * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
211019Sache * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
221019Sache * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
231019Sache * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
241019Sache * SUCH DAMAGE.
25877Sache */
26877Sache
27877Sache#ifndef _IOCTL_FD_H
28877Sache#define _IOCTL_FD_H
29877Sache
30877Sache#include <sys/types.h>
31877Sache#include <sys/ioctl.h>
32877Sache
33877Sache#define FD_FORMAT_VERSION 110	/* used to validate before formatting */
34877Sache#define FD_MAX_NSEC 36		/* highest known number of spt - allow for */
35877Sache				/* 2.88 MB drives */
36877Sache
37877Sachestruct fd_formb {
38877Sache	int format_version;	/* == FD_FORMAT_VERSION */
39877Sache	int cyl, head;
40877Sache	int transfer_rate;	/* fdreg.h: FDC_???KBPS */
41877Sache
42877Sache	union {
43877Sache		struct fd_form_data {
44877Sache			/*
45877Sache			 * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS
46877Sache			 * it is hardware-dependant since it exactly
47877Sache			 * matches the byte sequence to write to FDC
48877Sache			 * during its `format track' operation
49877Sache			 */
50877Sache			u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */
51877Sache			u_char nsecs;	/* must be <= FD_MAX_NSEC */
52877Sache			u_char gaplen;	/* GAP 3 length; usually 84 */
53877Sache			u_char fillbyte; /* usually 0xf6 */
54877Sache			struct fd_idfield_data {
55877Sache				/*
56877Sache				 * data to write into id fields;
57877Sache				 * for obscure formats, they mustn't match
58877Sache				 * the real values (but mostly do)
59877Sache				 */
60877Sache				u_char cylno;	/* 0 thru 79 (or 39) */
61877Sache				u_char headno;	/* 0, or 1 */
62877Sache				u_char secno;	/* starting at 1! */
63877Sache				u_char secsize;	/* usually 2 */
64877Sache			} idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */
65877Sache		} structured;
66877Sache		u_char raw[1];	/* to have continuous indexed access */
67877Sache	} format_info;
68877Sache};
69877Sache
70877Sache/* make life easier */
71877Sache# define fd_formb_secshift   format_info.structured.secshift
72877Sache# define fd_formb_nsecs      format_info.structured.nsecs
73877Sache# define fd_formb_gaplen     format_info.structured.gaplen
74877Sache# define fd_formb_fillbyte   format_info.structured.fillbyte
75877Sache/* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */
76877Sache# define fd_formb_cylno(i)   format_info.structured.idfields[i].cylno
77877Sache# define fd_formb_headno(i)  format_info.structured.idfields[i].headno
78877Sache# define fd_formb_secno(i)   format_info.structured.idfields[i].secno
79877Sache# define fd_formb_secsize(i) format_info.structured.idfields[i].secsize
80877Sache
81877Sachestruct fd_type {
82877Sache	int	sectrac;		/* sectors per track         */
83877Sache	int	secsize;		/* size code for sectors     */
84877Sache	int	datalen;		/* data len when secsize = 0 */
85877Sache	int	gap;			/* gap len between sectors   */
86877Sache	int	tracks;			/* total num of tracks       */
87877Sache	int	size;			/* size of disk in sectors   */
88877Sache	int	steptrac;		/* steps per cylinder        */
89877Sache	int	trans;			/* transfer speed code       */
90877Sache	int	heads;			/* number of heads	     */
91891Sache	int     f_gap;                  /* format gap len            */
92891Sache	int     f_inter;                /* format interleave factor  */
93877Sache};
94877Sache
95877Sache#define FD_FORM   _IOW('F', 61, struct fd_formb) /* format a track */
96877Sache#define FD_GTYPE  _IOR('F', 62, struct fd_type)  /* get drive type */
97877Sache
98877Sache#endif  /* !def _IOCTL_FD_H */
99