ioctl_fd.h revision 1.1
1/*	$OpenBSD: ioctl_fd.h,v 1.1 1996/06/20 07:51:36 downsj Exp $	*/
2/*	$Id: ioctl_fd.h,v 1.1 1996/06/20 07:51:36 downsj Exp $	*/
3
4/*
5 * Copyright (C) 1992-1994 by Joerg Wunsch, Dresden
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
23 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
27 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
28 * DAMAGE.
29 *
30 * From: Id: ioctl_fd.h,v 1.7 1994/10/30 19:17:39 joerg Exp
31 */
32
33#ifndef _I386_IOCTL_FD_H_
34#define _I386_IOCTL_FD_H_
35
36#define FD_FORMAT_VERSION 110	/* used to validate before formatting */
37#define FD_MAX_NSEC 36		/* highest known number of spt - allow for */
38				/* 2.88 MB drives */
39
40struct fd_formb {
41	int format_version;	/* == FD_FORMAT_VERSION */
42	int cyl, head;
43	int transfer_rate;	/* fdreg.h: FDC_???KBPS */
44
45	union {
46		struct fd_form_data {
47			/*
48			 * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS
49			 * it is hardware-dependant since it exactly
50			 * matches the byte sequence to write to FDC
51			 * during its `format track' operation
52			 */
53			u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */
54			u_char nsecs;	/* must be <= FD_MAX_NSEC */
55			u_char gaplen;	/* GAP 3 length; usually 84 */
56			u_char fillbyte; /* usually 0xf6 */
57			struct fd_idfield_data {
58				/*
59				 * data to write into id fields;
60				 * for obscure formats, they mustn't match
61				 * the real values (but mostly do)
62				 */
63				u_char cylno;	/* 0 thru 79 (or 39) */
64				u_char headno;	/* 0, or 1 */
65				u_char secno;	/* starting at 1! */
66				u_char secsize;	/* usually 2 */
67			} idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */
68		} structured;
69		u_char raw[1];	/* to have continuous indexed access */
70	} format_info;
71};
72
73/* make life easier */
74# define fd_formb_secshift   format_info.structured.secshift
75# define fd_formb_nsecs      format_info.structured.nsecs
76# define fd_formb_gaplen     format_info.structured.gaplen
77# define fd_formb_fillbyte   format_info.structured.fillbyte
78/* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */
79# define fd_formb_cylno(i)   format_info.structured.idfields[i].cylno
80# define fd_formb_headno(i)  format_info.structured.idfields[i].headno
81# define fd_formb_secno(i)   format_info.structured.idfields[i].secno
82# define fd_formb_secsize(i) format_info.structured.idfields[i].secsize
83
84/*
85 * Floppies come in various flavors, e.g., 1.2MB vs 1.44MB; here is how
86 * we tell them apart.
87 */
88struct fd_type {
89	int	sectrac;	/* sectors per track */
90	int	heads;		/* number of heads */
91	int	seccyl;		/* sectors per cylinder */
92	int	secsize;	/* size code for sectors */
93	int	datalen;	/* data len when secsize = 0 */
94	int	steprate;	/* step rate and head unload time */
95	int	gap1;		/* gap len between sectors */
96	int	gap2;		/* formatting gap */
97	int	tracks;		/* total num of tracks */
98	int	size;		/* size of disk in sectors */
99	int	step;		/* steps per cylinder */
100	int	rate;		/* transfer speed code */
101	char	*name;
102};
103
104
105#define FD_FORM   _IOW('F', 61, struct fd_formb) /* format a track */
106#define FD_GTYPE  _IOR('F', 62, struct fd_type)  /* get drive type */
107#define FD_STYPE  _IOW('F', 63, struct fd_type)  /* set drive type */
108
109#define FD_GOPTS  _IOR('F', 64, int) /* drive options, see below */
110#define FD_SOPTS  _IOW('F', 65, int)
111
112#define FDOPT_NORETRY 0x0001	/* no retries on failure (cleared on close) */
113
114/*
115 * The following definitions duplicate those in sys/i386/isa/fdreg.h
116 * They are here since their values are to be used in the above
117 * structure when formatting a floppy. For very obvious reasons, both
118 * definitions must match ;-)
119 */
120#ifndef FDC_500KBPS
121#define	FDC_500KBPS	0x00	/* 500KBPS MFM drive transfer rate */
122#define	FDC_300KBPS	0x01	/* 300KBPS MFM drive transfer rate */
123#define	FDC_250KBPS	0x02	/* 250KBPS MFM drive transfer rate */
124#define	FDC_125KBPS	0x03	/* 125KBPS FM drive transfer rate */
125				/* for some controllers 1MPBS instead */
126#endif /* FDC_500KBPS */
127
128
129#endif /* !_I386_IOCTL_FD_H__ */
130