fdcio.h revision 87992
1214152Sed/* 2214152Sed * Copyright (C) 1992-1994,2001 by Joerg Wunsch, Dresden 3214152Sed * All rights reserved. 4214152Sed * 5222656Sed * Redistribution and use in source and binary forms, with or without 6222656Sed * modification, are permitted provided that the following conditions 7214152Sed * are met: 8214152Sed * 1. Redistributions of source code must retain the above copyright 9214152Sed * notice, this list of conditions and the following disclaimer. 10214152Sed * 2. Redistributions in binary form must reproduce the above copyright 11214152Sed * notice, this list of conditions and the following disclaimer in the 12214152Sed * documentation and/or other materials provided with the distribution. 13214152Sed * 14214152Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY 15214152Sed * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16214152Sed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17214152Sed * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE 18214152Sed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19214152Sed * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 20214152Sed * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 21214152Sed * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 22263560Sdim * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23222656Sed * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 24214152Sed * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 25214152Sed * DAMAGE. 26214152Sed * 27214152Sed * $FreeBSD: head/sys/sys/fdcio.h 87992 2001-12-15 19:09:04Z joerg $ 28214152Sed */ 29214152Sed 30214152Sed#ifndef _MACHINE_IOCTL_FD_H_ 31214152Sed#define _MACHINE_IOCTL_FD_H_ 32214152Sed 33214152Sed#ifndef _KERNEL 34214152Sed#include <sys/types.h> 35214152Sed#endif 36214152Sed#include <sys/ioccom.h> 37214152Sed 38214152Sed#define FD_FORMAT_VERSION 110 /* used to validate before formatting */ 39214152Sed#define FD_MAX_NSEC 36 /* highest known number of spt - allow for */ 40214152Sed /* 2.88 MB drives */ 41214152Sed 42214152Sedstruct fd_formb { 43214152Sed int format_version; /* == FD_FORMAT_VERSION */ 44214152Sed int cyl, head; 45214152Sed int transfer_rate; /* FDC_???KBPS */ 46214152Sed 47214152Sed union { 48214152Sed struct fd_form_data { 49214152Sed /* 50214152Sed * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS 51214152Sed * it is hardware-dependent since it exactly 52214152Sed * matches the byte sequence to write to FDC 53214152Sed * during its `format track' operation 54214152Sed */ 55214152Sed u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */ 56214152Sed u_char nsecs; /* must be <= FD_MAX_NSEC */ 57214152Sed u_char gaplen; /* GAP 3 length; usually 84 */ 58214152Sed u_char fillbyte; /* usually 0xf6 */ 59214152Sed struct fd_idfield_data { 60214152Sed /* 61214152Sed * data to write into id fields; 62214152Sed * for obscure formats, they mustn't match 63214152Sed * the real values (but mostly do) 64214152Sed */ 65214152Sed u_char cylno; /* 0 thru 79 (or 39) */ 66214152Sed u_char headno; /* 0, or 1 */ 67214152Sed u_char secno; /* starting at 1! */ 68214152Sed u_char secsize; /* usually 2 */ 69214152Sed } idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */ 70214152Sed } structured; 71214152Sed u_char raw[1]; /* to have continuous indexed access */ 72214152Sed } format_info; 73214152Sed}; 74214152Sed 75214152Sed/* make life easier */ 76214152Sed# define fd_formb_secshift format_info.structured.secshift 77214152Sed# define fd_formb_nsecs format_info.structured.nsecs 78214152Sed# define fd_formb_gaplen format_info.structured.gaplen 79214152Sed# define fd_formb_fillbyte format_info.structured.fillbyte 80214152Sed/* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */ 81214152Sed# define fd_formb_cylno(i) format_info.structured.idfields[i].cylno 82214152Sed# define fd_formb_headno(i) format_info.structured.idfields[i].headno 83214152Sed# define fd_formb_secno(i) format_info.structured.idfields[i].secno 84214152Sed# define fd_formb_secsize(i) format_info.structured.idfields[i].secsize 85214152Sed 86214152Sedstruct fd_type { 87214152Sed int sectrac; /* sectors per track */ 88214152Sed int secsize; /* size code for sectors */ 89214152Sed int datalen; /* data len when secsize = 0 */ 90214152Sed int gap; /* gap len between sectors */ 91214152Sed int tracks; /* total number of cylinders */ 92214152Sed int size; /* size of disk in sectors */ 93214152Sed int trans; /* transfer speed code */ 94214152Sed int heads; /* number of heads */ 95214152Sed int f_gap; /* format gap len */ 96214152Sed int f_inter; /* format interleave factor */ 97214152Sed int offset_side2; /* offset of sectors on side2 */ 98214152Sed int flags; /* misc. features */ 99214152Sed#define FL_MFM 0x0001 /* MFM recording */ 100214152Sed#define FL_2STEP 0x0002 /* 2 steps between cylinders */ 101214152Sed#define FL_PERPND 0x0004 /* perpendicular recording */ 102214152Sed}; 103214152Sed 104214152Sedstruct fdc_status { 105214152Sed u_int status[7]; 106214152Sed}; 107214152Sed 108214152Sed/* 109214152Sed * cyl and head are being passed into ioctl(FD_READID) 110214152Sed * all four fields are being returned 111214152Sed */ 112214152Sedstruct fdc_readid { 113214152Sed u_char cyl; /* C - 0...79 */ 114214152Sed u_char head; /* H - 0...1 */ 115214152Sed u_char sec; /* R - 1...n */ 116214152Sed u_char secshift; /* N - log2(secsize / 128) */ 117214152Sed}; 118214152Sed 119214152Sed/* 120214152Sed * Diskette drive type, basically the same as stored in RTC on ISA 121214152Sed * machines (see /sys/isa/rtc.h), but right-shifted by four bits. 122214152Sed */ 123214152Sedenum fd_drivetype { 124214152Sed FDT_NONE, FDT_360K, FDT_12M, FDT_720K, FDT_144M, FDT_288M_1, 125214152Sed FDT_288M 126214152Sed}; 127214152Sed 128214152Sed 129214152Sed#define FD_FORM _IOW('F', 61, struct fd_formb) /* format a track */ 130214152Sed#define FD_GTYPE _IOR('F', 62, struct fd_type) /* get drive type */ 131214152Sed#define FD_STYPE _IOW('F', 63, struct fd_type) /* set drive type */ 132214152Sed 133214152Sed#define FD_GOPTS _IOR('F', 64, int) /* drive options, see below */ 134214152Sed#define FD_SOPTS _IOW('F', 65, int) 135214152Sed 136214152Sed#define FD_DEBUG _IOW('F', 66, int) 137214152Sed 138214152Sed#define FD_CLRERR _IO('F', 67) /* clear error counter */ 139214152Sed 140214152Sed#define FD_READID _IOWR('F', 68, struct fdc_readid) /* read ID field */ 141214152Sed 142214152Sed/* 143214152Sed * Obtain NE765 status registers. Only successful if there is 144214152Sed * a valid status stored in fdc->status[]. 145214152Sed */ 146214152Sed#define FD_GSTAT _IOR('F', 69, struct fdc_status) 147214152Sed 148214152Sed#define FD_GDTYPE _IOR('F', 70, enum fd_drivetype) /* obtain drive type */ 149214152Sed 150214152Sed/* Options for FD_GOPTS/FD_SOPTS, cleared on device close */ 151214152Sed#define FDOPT_NORETRY 0x0001 /* no retries on failure */ 152214152Sed#define FDOPT_NOERRLOG 0x002 /* no "hard error" kernel log messages */ 153214152Sed#define FDOPT_NOERROR 0x0004 /* do not indicate errors, caller will use 154214152Sed FD_GSTAT in order to obtain status */ 155214152Sed#define FDOPT_AUTOSEL 0x8000 /* read/only option: device performs media 156214152Sed * autoselection */ 157214152Sed 158214152Sed/* 159214152Sed * Transfer rate definitions. Used in the structures above. They 160214152Sed * represent the hardware encoding of bits 0 and 1 of the FDC control 161214152Sed * register when writing to the register. 162214152Sed * Transfer rates for FM encoding are half the values listed here 163214152Sed * (but we currently don't support FM encoding). 164214152Sed */ 165214152Sed#define FDC_500KBPS 0x00 /* 500KBPS MFM drive transfer rate */ 166214152Sed#define FDC_300KBPS 0x01 /* 300KBPS MFM drive transfer rate */ 167214152Sed#define FDC_250KBPS 0x02 /* 250KBPS MFM drive transfer rate */ 168214152Sed#define FDC_1MBPS 0x03 /* 1MPBS MFM drive transfer rate */ 169 170#endif /* !_MACHINE_IOCTL_FD_H_ */ 171