11.5Swiz/* $NetBSD: fdreg.h,v 1.5 2011/06/30 20:09:17 wiz Exp $ */ 21.1Sreinoud 31.1Sreinoud/*- 41.1Sreinoud * Copyright (c) 1991 The Regents of the University of California. 51.1Sreinoud * All rights reserved. 61.1Sreinoud * 71.1Sreinoud * Redistribution and use in source and binary forms, with or without 81.1Sreinoud * modification, are permitted provided that the following conditions 91.1Sreinoud * are met: 101.1Sreinoud * 1. Redistributions of source code must retain the above copyright 111.1Sreinoud * notice, this list of conditions and the following disclaimer. 121.1Sreinoud * 2. Redistributions in binary form must reproduce the above copyright 131.1Sreinoud * notice, this list of conditions and the following disclaimer in the 141.1Sreinoud * documentation and/or other materials provided with the distribution. 151.3Sagc * 3. Neither the name of the University nor the names of its contributors 161.1Sreinoud * may be used to endorse or promote products derived from this software 171.1Sreinoud * without specific prior written permission. 181.1Sreinoud * 191.1Sreinoud * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 201.1Sreinoud * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 211.1Sreinoud * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 221.1Sreinoud * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 231.1Sreinoud * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 241.1Sreinoud * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 251.1Sreinoud * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 261.1Sreinoud * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 271.1Sreinoud * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 281.1Sreinoud * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 291.1Sreinoud * SUCH DAMAGE. 301.1Sreinoud * 311.1Sreinoud * @(#)fdreg.h 7.1 (Berkeley) 5/9/91 321.1Sreinoud * from: fdreg.h,v 1.9 1996/11/29 16:28:40 jtk 331.1Sreinoud */ 341.1Sreinoud 351.1Sreinoud/* 361.1Sreinoud * AT floppy controller registers and bitfields 371.1Sreinoud */ 381.1Sreinoud 391.1Sreinoud/* uses NEC765 controller */ 401.1Sreinoud#include <dev/ic/nec765reg.h> 411.1Sreinoud 421.1Sreinoud/* registers */ 431.1Sreinoud#define fdout 2 /* Digital Output Register (W) */ 441.1Sreinoud#define FDO_FDSEL 0x03 /* floppy device select */ 451.1Sreinoud#define FDO_FRST 0x04 /* floppy controller reset */ 461.1Sreinoud#define FDO_FDMAEN 0x08 /* enable floppy DMA and Interrupt */ 471.1Sreinoud#define FDO_MOEN(n) ((1 << n) * 0x10) /* motor enable */ 481.1Sreinoud 491.1Sreinoud#define fdsts 4 /* NEC 765 Main Status Register (R) */ 501.1Sreinoud#define fddata 5 /* NEC 765 Data Register (R/W) */ 511.1Sreinoud 521.1Sreinoud#define fdctl 7 /* Control Register (W) */ 531.1Sreinoud#define FDC_500KBPS 0x00 /* 500KBPS MFM drive transfer rate */ 541.1Sreinoud#define FDC_300KBPS 0x01 /* 300KBPS MFM drive transfer rate */ 551.1Sreinoud#define FDC_250KBPS 0x02 /* 250KBPS MFM drive transfer rate */ 561.1Sreinoud#define FDC_125KBPS 0x03 /* 125KBPS FM drive transfer rate */ 571.1Sreinoud 581.1Sreinoud#define fdin 7 /* Digital Input Register (R) */ 591.1Sreinoud#define FDI_DCHG 0x80 /* diskette has been changed */ 601.1Sreinoud 611.1Sreinoud#define FDC_BSIZE 512 621.1Sreinoud#define FDC_NPORT 8 631.2Sthorpej#define FDC_MAXIOSIZE PAGE_SIZE /* XXX should be MAXBSIZE */ 641.1Sreinoud 651.1Sreinoud/* 661.1Sreinoud * Copyright (C) 1992-1994 by Joerg Wunsch, Dresden 671.1Sreinoud * All rights reserved. 681.1Sreinoud * 691.1Sreinoud * Redistribution and use in source and binary forms, with or without 701.1Sreinoud * modification, are permitted provided that the following conditions 711.1Sreinoud * are met: 721.1Sreinoud * 1. Redistributions of source code must retain the above copyright 731.1Sreinoud * notice, this list of conditions and the following disclaimer. 741.1Sreinoud * 2. Redistributions in binary form must reproduce the above copyright 751.1Sreinoud * notice, this list of conditions and the following disclaimer in the 761.1Sreinoud * documentation and/or other materials provided with the distribution. 771.1Sreinoud * 781.1Sreinoud * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY 791.1Sreinoud * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 801.1Sreinoud * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 811.1Sreinoud * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE 821.1Sreinoud * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 831.1Sreinoud * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 841.1Sreinoud * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 851.1Sreinoud * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 861.1Sreinoud * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 871.1Sreinoud * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 881.1Sreinoud * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 891.1Sreinoud * DAMAGE. 901.1Sreinoud * 911.1Sreinoud * From: FreeBSD: Id: ioctl_fd.h,v 1.7 1994/10/30 19:17:39 joerg Exp 921.1Sreinoud */ 931.1Sreinoud 941.1Sreinoud#define FD_MAX_NSEC 36 /* highest known number of spt - allow for */ 951.1Sreinoud /* 2.88 MB drives */ 961.1Sreinoud 971.1Sreinoudstruct ne7_fd_formb { 981.1Sreinoud int cyl, head; 991.1Sreinoud int transfer_rate; /* fdreg.h: FDC_???KBPS */ 1001.1Sreinoud 1011.1Sreinoud union { 1021.1Sreinoud struct fd_form_data { 1031.1Sreinoud /* 1041.1Sreinoud * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS 1051.5Swiz * it is hardware-dependent since it exactly 1061.1Sreinoud * matches the byte sequence to write to FDC 1071.1Sreinoud * during its `format track' operation 1081.1Sreinoud */ 1091.1Sreinoud u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */ 1101.1Sreinoud u_char nsecs; /* must be <= FD_MAX_NSEC */ 1111.1Sreinoud u_char gaplen; /* GAP 3 length; usually 84 */ 1121.1Sreinoud u_char fillbyte; /* usually 0xf6 */ 1131.1Sreinoud struct fd_idfield_data { 1141.1Sreinoud /* 1151.1Sreinoud * data to write into id fields; 1161.1Sreinoud * for obscure formats, they mustn't match 1171.1Sreinoud * the real values (but mostly do) 1181.1Sreinoud */ 1191.1Sreinoud u_char cylno; /* 0 thru 79 (or 39) */ 1201.1Sreinoud u_char headno; /* 0, or 1 */ 1211.1Sreinoud u_char secno; /* starting at 1! */ 1221.1Sreinoud u_char secsize; /* usually 2 */ 1231.1Sreinoud } idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */ 1241.1Sreinoud } structured; 1251.1Sreinoud u_char raw[1]; /* to have continuous indexed access */ 1261.1Sreinoud } format_info; 1271.1Sreinoud}; 1281.1Sreinoud 1291.1Sreinoud/* make life easier */ 1301.1Sreinoud# define fd_formb_secshift format_info.structured.secshift 1311.1Sreinoud# define fd_formb_nsecs format_info.structured.nsecs 1321.1Sreinoud# define fd_formb_gaplen format_info.structured.gaplen 1331.1Sreinoud# define fd_formb_fillbyte format_info.structured.fillbyte 1341.1Sreinoud/* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */ 1351.1Sreinoud# define fd_formb_cylno(i) format_info.structured.idfields[i].cylno 1361.1Sreinoud# define fd_formb_headno(i) format_info.structured.idfields[i].headno 1371.1Sreinoud# define fd_formb_secno(i) format_info.structured.idfields[i].secno 1381.1Sreinoud# define fd_formb_secsize(i) format_info.structured.idfields[i].secsize 139