1*2fa72412Spirofti /* $OpenBSD: ioctl_fd.h,v 1.2 2011/03/23 16:54:37 pirofti Exp $ */ 2323e9233Smiod /* from: ioctl_fd.h,v 1.4 1995/06/29 03:49:32 jtk Exp */ 3323e9233Smiod 4323e9233Smiod /* 5323e9233Smiod * Copyright (C) 1992-1994 by Joerg Wunsch, Dresden 6323e9233Smiod * All rights reserved. 7323e9233Smiod * 8323e9233Smiod * Redistribution and use in source and binary forms, with or without 9323e9233Smiod * modification, are permitted provided that the following conditions 10323e9233Smiod * are met: 11323e9233Smiod * 1. Redistributions of source code must retain the above copyright 12323e9233Smiod * notice, this list of conditions and the following disclaimer. 13323e9233Smiod * 2. Redistributions in binary form must reproduce the above copyright 14323e9233Smiod * notice, this list of conditions and the following disclaimer in the 15323e9233Smiod * documentation and/or other materials provided with the distribution. 16323e9233Smiod * 17323e9233Smiod * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY 18323e9233Smiod * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19323e9233Smiod * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20323e9233Smiod * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE 21323e9233Smiod * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22323e9233Smiod * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23323e9233Smiod * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24323e9233Smiod * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25323e9233Smiod * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26323e9233Smiod * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 27323e9233Smiod * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 28323e9233Smiod * DAMAGE. 29323e9233Smiod * 30323e9233Smiod * From: Id: ioctl_fd.h,v 1.7 1994/10/30 19:17:39 joerg Exp 31323e9233Smiod */ 32323e9233Smiod 33*2fa72412Spirofti #ifndef _MACHINE_IOCTL_FD_H_ 34*2fa72412Spirofti #define _MACHINE_IOCTL_FD_H_ 35323e9233Smiod 36323e9233Smiod #define FD_FORMAT_VERSION 110 /* used to validate before formatting */ 37323e9233Smiod #define FD_MAX_NSEC 36 /* highest known number of spt - allow for */ 38323e9233Smiod /* 2.88 MB drives */ 39323e9233Smiod 40323e9233Smiod struct fd_formb { 41323e9233Smiod int format_version; /* == FD_FORMAT_VERSION */ 42323e9233Smiod int cyl, head; 43323e9233Smiod int transfer_rate; /* fdreg.h: FDC_???KBPS */ 44323e9233Smiod 45323e9233Smiod union { 46323e9233Smiod struct fd_form_data { 47323e9233Smiod /* 48323e9233Smiod * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS 49323e9233Smiod * it is hardware-dependant since it exactly 50323e9233Smiod * matches the byte sequence to write to FDC 51323e9233Smiod * during its `format track' operation 52323e9233Smiod */ 53323e9233Smiod u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */ 54323e9233Smiod u_char nsecs; /* must be <= FD_MAX_NSEC */ 55323e9233Smiod u_char gaplen; /* GAP 3 length; usually 84 */ 56323e9233Smiod u_char fillbyte; /* usually 0xf6 */ 57323e9233Smiod struct fd_idfield_data { 58323e9233Smiod /* 59323e9233Smiod * data to write into id fields; 60323e9233Smiod * for obscure formats, they mustn't match 61323e9233Smiod * the real values (but mostly do) 62323e9233Smiod */ 63323e9233Smiod u_char cylno; /* 0 thru 79 (or 39) */ 64323e9233Smiod u_char headno; /* 0, or 1 */ 65323e9233Smiod u_char secno; /* starting at 1! */ 66323e9233Smiod u_char secsize; /* usually 2 */ 67323e9233Smiod } idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */ 68323e9233Smiod } structured; 69323e9233Smiod u_char raw[1]; /* to have continuous indexed access */ 70323e9233Smiod } format_info; 71323e9233Smiod }; 72323e9233Smiod 73323e9233Smiod /* make life easier */ 74323e9233Smiod # define fd_formb_secshift format_info.structured.secshift 75323e9233Smiod # define fd_formb_nsecs format_info.structured.nsecs 76323e9233Smiod # define fd_formb_gaplen format_info.structured.gaplen 77323e9233Smiod # define fd_formb_fillbyte format_info.structured.fillbyte 78323e9233Smiod /* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */ 79323e9233Smiod # define fd_formb_cylno(i) format_info.structured.idfields[i].cylno 80323e9233Smiod # define fd_formb_headno(i) format_info.structured.idfields[i].headno 81323e9233Smiod # define fd_formb_secno(i) format_info.structured.idfields[i].secno 82323e9233Smiod # define fd_formb_secsize(i) format_info.structured.idfields[i].secsize 83323e9233Smiod 84323e9233Smiod /* 85323e9233Smiod * Floppies come in various flavors, e.g., 1.2MB vs 1.44MB; here is how 86323e9233Smiod * we tell them apart. 87323e9233Smiod */ 88323e9233Smiod struct fd_type { 89323e9233Smiod int sectrac; /* sectors per track */ 90323e9233Smiod int heads; /* number of heads */ 91323e9233Smiod int seccyl; /* sectors per cylinder */ 92323e9233Smiod int secsize; /* size code for sectors */ 93323e9233Smiod int datalen; /* data len when secsize = 0 */ 94323e9233Smiod int steprate; /* step rate and head unload time */ 95323e9233Smiod int gap1; /* gap len between sectors */ 96323e9233Smiod int gap2; /* formatting gap */ 97323e9233Smiod int tracks; /* total num of tracks */ 98323e9233Smiod int size; /* size of disk in sectors */ 99323e9233Smiod int step; /* steps per cylinder */ 100323e9233Smiod int rate; /* transfer speed code */ 101323e9233Smiod char *name; 102323e9233Smiod }; 103323e9233Smiod 104323e9233Smiod 105323e9233Smiod #define FD_FORM _IOW('F', 61, struct fd_formb) /* format a track */ 106323e9233Smiod #define FD_GTYPE _IOR('F', 62, struct fd_type) /* get drive type */ 107323e9233Smiod #define FD_STYPE _IOW('F', 63, struct fd_type) /* set drive type */ 108323e9233Smiod 109323e9233Smiod #define FD_GOPTS _IOR('F', 64, int) /* drive options, see below */ 110323e9233Smiod #define FD_SOPTS _IOW('F', 65, int) 111323e9233Smiod 112323e9233Smiod #define FDOPT_NORETRY 0x0001 /* no retries on failure (cleared on close) */ 113323e9233Smiod #define FDOPT_SILENT 0x0002 114323e9233Smiod 115323e9233Smiod /* 116323e9233Smiod * The following definitions duplicate those in sys/i386/isa/fdreg.h 117323e9233Smiod * They are here since their values are to be used in the above 118323e9233Smiod * structure when formatting a floppy. For very obvious reasons, both 119323e9233Smiod * definitions must match ;-) 120323e9233Smiod */ 121323e9233Smiod #ifndef FDC_500KBPS 122323e9233Smiod #define FDC_500KBPS 0x00 /* 500KBPS MFM drive transfer rate */ 123323e9233Smiod #define FDC_300KBPS 0x01 /* 300KBPS MFM drive transfer rate */ 124323e9233Smiod #define FDC_250KBPS 0x02 /* 250KBPS MFM drive transfer rate */ 125323e9233Smiod #define FDC_125KBPS 0x03 /* 125KBPS FM drive transfer rate */ 126323e9233Smiod /* for some controllers 1MPBS instead */ 127323e9233Smiod #endif /* FDC_500KBPS */ 128323e9233Smiod 129323e9233Smiod 130*2fa72412Spirofti #endif /* !_MACHINE_IOCTL_FD_H__ */ 131