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