xref: /dflybsd-src/sys/platform/pc64/include/ioctl_fd.h (revision ee21086ce2d93da091939395287d3bbba1bcf221)
139923942SSimon Schubert /*
239923942SSimon Schubert  * Copyright (C) 1992-1994,2001 by Joerg Wunsch, Dresden
339923942SSimon Schubert  * All rights reserved.
439923942SSimon Schubert  *
539923942SSimon Schubert  * Redistribution and use in source and binary forms, with or without
639923942SSimon Schubert  * modification, are permitted provided that the following conditions
739923942SSimon Schubert  * are met:
839923942SSimon Schubert  * 1. Redistributions of source code must retain the above copyright
939923942SSimon Schubert  *    notice, this list of conditions and the following disclaimer.
1039923942SSimon Schubert  * 2. Redistributions in binary form must reproduce the above copyright
1139923942SSimon Schubert  *    notice, this list of conditions and the following disclaimer in the
1239923942SSimon Schubert  *    documentation and/or other materials provided with the distribution.
1339923942SSimon Schubert  *
1439923942SSimon Schubert  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY
1539923942SSimon Schubert  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1639923942SSimon Schubert  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1739923942SSimon Schubert  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE
1839923942SSimon Schubert  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1939923942SSimon Schubert  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
2039923942SSimon Schubert  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
2139923942SSimon Schubert  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
2239923942SSimon Schubert  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2339923942SSimon Schubert  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
2439923942SSimon Schubert  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
2539923942SSimon Schubert  * DAMAGE.
2639923942SSimon Schubert  *
2739923942SSimon Schubert  * $FreeBSD: src/sys/i386/include/ioctl_fd.h,v 1.13.2.1 2001/07/19 13:16:54 joerg Exp $
2839923942SSimon Schubert  */
2939923942SSimon Schubert 
3039923942SSimon Schubert #ifndef	_MACHINE_IOCTL_FD_H_
3139923942SSimon Schubert #define	_MACHINE_IOCTL_FD_H_
3239923942SSimon Schubert 
3339923942SSimon Schubert #ifndef _SYS_TYPES_H_
3439923942SSimon Schubert #include <sys/types.h>
3539923942SSimon Schubert #endif
3639923942SSimon Schubert #ifndef _SYS_IOCCOM_H_
3739923942SSimon Schubert #include <sys/ioccom.h>
3839923942SSimon Schubert #endif
3939923942SSimon Schubert 
4039923942SSimon Schubert #define FD_FORMAT_VERSION 110	/* used to validate before formatting */
4139923942SSimon Schubert #define FD_MAX_NSEC 36		/* highest known number of spt - allow for */
4239923942SSimon Schubert 				/* 2.88 MB drives */
4339923942SSimon Schubert 
4439923942SSimon Schubert struct fd_formb {
4539923942SSimon Schubert 	int format_version;	/* == FD_FORMAT_VERSION */
4639923942SSimon Schubert 	int cyl, head;
4739923942SSimon Schubert 	int transfer_rate;	/* fdreg.h: FDC_???KBPS */
4839923942SSimon Schubert 
4939923942SSimon Schubert 	union {
5039923942SSimon Schubert 		struct fd_form_data {
5139923942SSimon Schubert 			/*
5239923942SSimon Schubert 			 * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS
5339923942SSimon Schubert 			 * it is hardware-dependent since it exactly
5439923942SSimon Schubert 			 * matches the byte sequence to write to FDC
5539923942SSimon Schubert 			 * during its `format track' operation
5639923942SSimon Schubert 			 */
5739923942SSimon Schubert 			u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */
5839923942SSimon Schubert 			u_char nsecs;	/* must be <= FD_MAX_NSEC */
5939923942SSimon Schubert 			u_char gaplen;	/* GAP 3 length; usually 84 */
6039923942SSimon Schubert 			u_char fillbyte; /* usually 0xf6 */
6139923942SSimon Schubert 			struct fd_idfield_data {
6239923942SSimon Schubert 				/*
6339923942SSimon Schubert 				 * data to write into id fields;
6439923942SSimon Schubert 				 * for obscure formats, they mustn't match
6539923942SSimon Schubert 				 * the real values (but mostly do)
6639923942SSimon Schubert 				 */
6739923942SSimon Schubert 				u_char cylno;	/* 0 thru 79 (or 39) */
6839923942SSimon Schubert 				u_char headno;	/* 0, or 1 */
6939923942SSimon Schubert 				u_char secno;	/* starting at 1! */
7039923942SSimon Schubert 				u_char secsize;	/* usually 2 */
7139923942SSimon Schubert 			} idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */
7239923942SSimon Schubert 		} structured;
7339923942SSimon Schubert 		u_char raw[1];	/* to have continuous indexed access */
7439923942SSimon Schubert 	} format_info;
7539923942SSimon Schubert };
7639923942SSimon Schubert 
7739923942SSimon Schubert /* make life easier */
7839923942SSimon Schubert # define fd_formb_secshift   format_info.structured.secshift
7939923942SSimon Schubert # define fd_formb_nsecs      format_info.structured.nsecs
8039923942SSimon Schubert # define fd_formb_gaplen     format_info.structured.gaplen
8139923942SSimon Schubert # define fd_formb_fillbyte   format_info.structured.fillbyte
8239923942SSimon Schubert /* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */
8339923942SSimon Schubert # define fd_formb_cylno(i)   format_info.structured.idfields[i].cylno
8439923942SSimon Schubert # define fd_formb_headno(i)  format_info.structured.idfields[i].headno
8539923942SSimon Schubert # define fd_formb_secno(i)   format_info.structured.idfields[i].secno
8639923942SSimon Schubert # define fd_formb_secsize(i) format_info.structured.idfields[i].secsize
8739923942SSimon Schubert 
8839923942SSimon Schubert struct fd_type {
8939923942SSimon Schubert 	int	sectrac;		/* sectors per track         */
9039923942SSimon Schubert 	int	secsize;		/* size code for sectors     */
9139923942SSimon Schubert 	int	datalen;		/* data len when secsize = 0 */
9239923942SSimon Schubert 	int	gap;			/* gap len between sectors   */
9339923942SSimon Schubert 	int	tracks;			/* total num of tracks       */
9439923942SSimon Schubert 	int	size;			/* size of disk in sectors   */
9539923942SSimon Schubert 	int	steptrac;		/* steps per cylinder        */
9639923942SSimon Schubert 	int	trans;			/* transfer speed code       */
9739923942SSimon Schubert 	int	heads;			/* number of heads	     */
9839923942SSimon Schubert 	int     f_gap;                  /* format gap len            */
9939923942SSimon Schubert 	int     f_inter;                /* format interleave factor  */
10039923942SSimon Schubert };
10139923942SSimon Schubert 
10239923942SSimon Schubert struct fdc_status {
10339923942SSimon Schubert 	u_int	status[7];
10439923942SSimon Schubert };
10539923942SSimon Schubert 
10639923942SSimon Schubert #define FD_FORM   _IOW('F', 61, struct fd_formb) /* format a track */
10739923942SSimon Schubert #define FD_GTYPE  _IOR('F', 62, struct fd_type)  /* get drive type */
10839923942SSimon Schubert #define FD_STYPE  _IOW('F', 63, struct fd_type)  /* set drive type */
10939923942SSimon Schubert 
11039923942SSimon Schubert #define FD_GOPTS  _IOR('F', 64, int) /* drive options, see below */
11139923942SSimon Schubert #define FD_SOPTS  _IOW('F', 65, int)
11239923942SSimon Schubert 
11339923942SSimon Schubert /*
11439923942SSimon Schubert  * Obtain NE765 status registers.  Only successful if there is
11539923942SSimon Schubert  * a valid status stored in fdc->status[].
11639923942SSimon Schubert  */
11739923942SSimon Schubert #define FD_GSTAT  _IOR('F', 68, struct fdc_status)
11839923942SSimon Schubert 
11939923942SSimon Schubert /* Options for FD_GOPTS/FD_SOPTS, cleared on device close */
12039923942SSimon Schubert #define FDOPT_NORETRY 0x0001	/* no retries on failure */
12139923942SSimon Schubert #define FDOPT_NOERRLOG 0x002	/* no "hard error" kernel log messages */
12239923942SSimon Schubert 
12339923942SSimon Schubert /*
124*466d4f43Szrj  * The following definitions duplicate those in sys/dev/disk/fd/fdreg.h
12539923942SSimon Schubert  * They are here since their values are to be used in the above
12639923942SSimon Schubert  * structure when formatting a floppy. For very obvious reasons, both
12739923942SSimon Schubert  * definitions must match ;-)
12839923942SSimon Schubert  */
12939923942SSimon Schubert #ifndef FDC_500KBPS
13039923942SSimon Schubert #define	FDC_500KBPS	0x00	/* 500KBPS MFM drive transfer rate */
13139923942SSimon Schubert #define	FDC_300KBPS	0x01	/* 300KBPS MFM drive transfer rate */
13239923942SSimon Schubert #define	FDC_250KBPS	0x02	/* 250KBPS MFM drive transfer rate */
13339923942SSimon Schubert #define	FDC_125KBPS	0x03	/* 125KBPS FM drive transfer rate */
13439923942SSimon Schubert 				/* for some controllers 1MPBS instead */
13539923942SSimon Schubert #endif /* FDC_500KBPS */
13639923942SSimon Schubert 
13739923942SSimon Schubert #endif /* !_MACHINE_IOCTL_FD_H_ */
138