fdcio.h revision 50477
1877Sache/*
22838Sdg * Copyright (C) 1992-1994 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 *
142838Sdg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY
152838Sdg * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
162838Sdg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
172838Sdg * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE
182838Sdg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
192838Sdg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
202838Sdg * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
212838Sdg * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
222838Sdg * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
232838Sdg * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
242838Sdg * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
252838Sdg * DAMAGE.
261817Sdg *
2750477Speter * $FreeBSD: head/sys/sys/fdcio.h 50477 1999-08-28 01:08:13Z peter $
28877Sache */
29877Sache
3018444Sbde#ifndef	_MACHINE_IOCTL_FD_H_
3118444Sbde#define	_MACHINE_IOCTL_FD_H_
32877Sache
3318444Sbde#ifndef KERNEL
34877Sache#include <sys/types.h>
3518444Sbde#endif
3618444Sbde#include <sys/ioccom.h>
37877Sache
38877Sache#define FD_FORMAT_VERSION 110	/* used to validate before formatting */
39877Sache#define FD_MAX_NSEC 36		/* highest known number of spt - allow for */
40877Sache				/* 2.88 MB drives */
41877Sache
42877Sachestruct fd_formb {
43877Sache	int format_version;	/* == FD_FORMAT_VERSION */
44877Sache	int cyl, head;
45877Sache	int transfer_rate;	/* fdreg.h: FDC_???KBPS */
46877Sache
47877Sache	union {
48877Sache		struct fd_form_data {
49877Sache			/*
50877Sache			 * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS
5113765Smpp			 * it is hardware-dependent since it exactly
52877Sache			 * matches the byte sequence to write to FDC
53877Sache			 * during its `format track' operation
54877Sache			 */
55877Sache			u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */
56877Sache			u_char nsecs;	/* must be <= FD_MAX_NSEC */
57877Sache			u_char gaplen;	/* GAP 3 length; usually 84 */
58877Sache			u_char fillbyte; /* usually 0xf6 */
59877Sache			struct fd_idfield_data {
60877Sache				/*
61877Sache				 * data to write into id fields;
62877Sache				 * for obscure formats, they mustn't match
63877Sache				 * the real values (but mostly do)
64877Sache				 */
65877Sache				u_char cylno;	/* 0 thru 79 (or 39) */
66877Sache				u_char headno;	/* 0, or 1 */
67877Sache				u_char secno;	/* starting at 1! */
68877Sache				u_char secsize;	/* usually 2 */
69877Sache			} idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */
70877Sache		} structured;
71877Sache		u_char raw[1];	/* to have continuous indexed access */
72877Sache	} format_info;
73877Sache};
74877Sache
75877Sache/* make life easier */
76877Sache# define fd_formb_secshift   format_info.structured.secshift
77877Sache# define fd_formb_nsecs      format_info.structured.nsecs
78877Sache# define fd_formb_gaplen     format_info.structured.gaplen
79877Sache# define fd_formb_fillbyte   format_info.structured.fillbyte
80877Sache/* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */
81877Sache# define fd_formb_cylno(i)   format_info.structured.idfields[i].cylno
82877Sache# define fd_formb_headno(i)  format_info.structured.idfields[i].headno
83877Sache# define fd_formb_secno(i)   format_info.structured.idfields[i].secno
84877Sache# define fd_formb_secsize(i) format_info.structured.idfields[i].secsize
85877Sache
86877Sachestruct fd_type {
87877Sache	int	sectrac;		/* sectors per track         */
88877Sache	int	secsize;		/* size code for sectors     */
89877Sache	int	datalen;		/* data len when secsize = 0 */
90877Sache	int	gap;			/* gap len between sectors   */
91877Sache	int	tracks;			/* total num of tracks       */
92877Sache	int	size;			/* size of disk in sectors   */
93877Sache	int	steptrac;		/* steps per cylinder        */
94877Sache	int	trans;			/* transfer speed code       */
95877Sache	int	heads;			/* number of heads	     */
96891Sache	int     f_gap;                  /* format gap len            */
97891Sache	int     f_inter;                /* format interleave factor  */
98877Sache};
99877Sache
100877Sache#define FD_FORM   _IOW('F', 61, struct fd_formb) /* format a track */
101877Sache#define FD_GTYPE  _IOR('F', 62, struct fd_type)  /* get drive type */
1022838Sdg#define FD_STYPE  _IOW('F', 63, struct fd_type)  /* set drive type */
103877Sache
1042838Sdg#define FD_GOPTS  _IOR('F', 64, int) /* drive options, see below */
1052838Sdg#define FD_SOPTS  _IOW('F', 65, int)
1062838Sdg
1074009Sjoerg#define FD_DEBUG  _IOW('F', 66, int)
1084009Sjoerg
1092838Sdg#define FDOPT_NORETRY 0x0001	/* no retries on failure (cleared on close) */
1102838Sdg
1113095Sjoerg/*
1123095Sjoerg * The following definitions duplicate those in sys/i386/isa/fdreg.h
1133095Sjoerg * They are here since their values are to be used in the above
1143095Sjoerg * structure when formatting a floppy. For very obvious reasons, both
1153095Sjoerg * definitions must match ;-)
1163095Sjoerg */
1173095Sjoerg#ifndef FDC_500KBPS
1183095Sjoerg#define	FDC_500KBPS	0x00	/* 500KBPS MFM drive transfer rate */
1193095Sjoerg#define	FDC_300KBPS	0x01	/* 300KBPS MFM drive transfer rate */
1203095Sjoerg#define	FDC_250KBPS	0x02	/* 250KBPS MFM drive transfer rate */
1213095Sjoerg#define	FDC_125KBPS	0x03	/* 125KBPS FM drive transfer rate */
1223095Sjoerg				/* for some controllers 1MPBS instead */
1233095Sjoerg#endif /* FDC_500KBPS */
1243095Sjoerg
12518444Sbde#endif /* !_MACHINE_IOCTL_FD_H_ */
126