1*88ab3aa8Stsutsui /* $NetBSD: fdreg.h,v 1.6 2012/10/14 18:38:32 tsutsui Exp $ */ 2320e7320Soki 3320e7320Soki /*- 4320e7320Soki * Copyright (c) 1991 The Regents of the University of California. 5320e7320Soki * All rights reserved. 6320e7320Soki * 7320e7320Soki * Redistribution and use in source and binary forms, with or without 8320e7320Soki * modification, are permitted provided that the following conditions 9320e7320Soki * are met: 10320e7320Soki * 1. Redistributions of source code must retain the above copyright 11320e7320Soki * notice, this list of conditions and the following disclaimer. 12320e7320Soki * 2. Redistributions in binary form must reproduce the above copyright 13320e7320Soki * notice, this list of conditions and the following disclaimer in the 14320e7320Soki * documentation and/or other materials provided with the distribution. 15aad01611Sagc * 3. Neither the name of the University nor the names of its contributors 16320e7320Soki * may be used to endorse or promote products derived from this software 17320e7320Soki * without specific prior written permission. 18320e7320Soki * 19320e7320Soki * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20320e7320Soki * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21320e7320Soki * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22320e7320Soki * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23320e7320Soki * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24320e7320Soki * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25320e7320Soki * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26320e7320Soki * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27320e7320Soki * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28320e7320Soki * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29320e7320Soki * SUCH DAMAGE. 30320e7320Soki * 31320e7320Soki * @(#)fdreg.h 7.1 (Berkeley) 5/9/91 32320e7320Soki */ 33320e7320Soki 34320e7320Soki /* 35320e7320Soki * x680x0 floppy controller registers and bitfields 36320e7320Soki */ 37320e7320Soki 38320e7320Soki /* uses NEC72065 controller */ 39320e7320Soki #include <dev/ic/nec765reg.h> 40320e7320Soki 41320e7320Soki /* registers */ 42ba80d2c6Sminoura #define fdsts 0 /* NEC 765 Main Status Register (R) */ 43ba80d2c6Sminoura #define fddata 1 /* NEC 765 Data Register (R/W) */ 44320e7320Soki #define fdout 2 /* Digital Output Register (W) */ 45ba80d2c6Sminoura #define fdctl 3 /* Control Register (W) */ 46320e7320Soki #define FDC_500KBPS 0x00 /* 500KBPS MFM drive transfer rate */ 47320e7320Soki #define FDC_300KBPS 0x01 /* 300KBPS MFM drive transfer rate */ 48320e7320Soki #define FDC_250KBPS 0x02 /* 250KBPS MFM drive transfer rate */ 49320e7320Soki #define FDC_125KBPS 0x03 /* 125KBPS FM drive transfer rate */ 50320e7320Soki 51320e7320Soki #define FDC_BSIZE 512 52ba80d2c6Sminoura #define FDC_MAXIOSIZE MAXBSIZE 53ba80d2c6Sminoura 54ba80d2c6Sminoura /* Floppy disk controller command bytes. */ 55ba80d2c6Sminoura #define NE7CMD_RESET 0x36 /* reset command for fdc */ 56ba80d2c6Sminoura 57ba80d2c6Sminoura /* default attach args */ 58ba80d2c6Sminoura #define FDC_ADDR 0xe94000 /* builtin fdc is here */ 593bd688caStsutsui #define FDC_MAPSIZE 0x2000 /* builtin fdc I/O range */ 60ba80d2c6Sminoura #define FDC_INTR 96 /* interrupt vector */ 61ba80d2c6Sminoura #define FDC_DMA 0 /* DMA ch# */ 62ba80d2c6Sminoura #define FDC_DMAINTR 100 /* DMA interrupt vector */ 63*88ab3aa8Stsutsui 64*88ab3aa8Stsutsui /* 65*88ab3aa8Stsutsui * fdformat parameters 66*88ab3aa8Stsutsui */ 67*88ab3aa8Stsutsui 68*88ab3aa8Stsutsui #define FD_MAX_NSEC 18 /* highest known number of spt */ 69*88ab3aa8Stsutsui 70*88ab3aa8Stsutsui struct ne7_fd_formb { 71*88ab3aa8Stsutsui int cyl, head; 72*88ab3aa8Stsutsui int transfer_rate; /* fdreg.h: FDC_???KBPS */ 73*88ab3aa8Stsutsui 74*88ab3aa8Stsutsui union { 75*88ab3aa8Stsutsui struct fd_form_data { 76*88ab3aa8Stsutsui /* 77*88ab3aa8Stsutsui * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS 78*88ab3aa8Stsutsui * it is hardware-dependent since it exactly 79*88ab3aa8Stsutsui * matches the byte sequence to write to FDC 80*88ab3aa8Stsutsui * during its `format track' operation 81*88ab3aa8Stsutsui */ 82*88ab3aa8Stsutsui uint8_t secshift; /* 0 -> 128, ...; usually 2 -> 512 */ 83*88ab3aa8Stsutsui uint8_t nsecs; /* must be <= FD_MAX_NSEC */ 84*88ab3aa8Stsutsui uint8_t gaplen; /* GAP 3 length; usually 84 */ 85*88ab3aa8Stsutsui uint8_t fillbyte; /* usually 0xf6 */ 86*88ab3aa8Stsutsui struct fd_idfield_data { 87*88ab3aa8Stsutsui /* 88*88ab3aa8Stsutsui * data to write into id fields; 89*88ab3aa8Stsutsui * for obscure formats, they mustn't match 90*88ab3aa8Stsutsui * the real values (but mostly do) 91*88ab3aa8Stsutsui */ 92*88ab3aa8Stsutsui uint8_t cylno; /* 0 thru 79 (or 39) */ 93*88ab3aa8Stsutsui uint8_t headno; /* 0, or 1 */ 94*88ab3aa8Stsutsui uint8_t secno; /* starting at 1! */ 95*88ab3aa8Stsutsui uint8_t secsize; /* usually 2 */ 96*88ab3aa8Stsutsui } idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */ 97*88ab3aa8Stsutsui } structured; 98*88ab3aa8Stsutsui uint8_t raw[1]; /* to have continuous indexed access */ 99*88ab3aa8Stsutsui } format_info; 100*88ab3aa8Stsutsui }; 101*88ab3aa8Stsutsui 102*88ab3aa8Stsutsui /* make life easier */ 103*88ab3aa8Stsutsui # define fd_formb_secshift format_info.structured.secshift 104*88ab3aa8Stsutsui # define fd_formb_nsecs format_info.structured.nsecs 105*88ab3aa8Stsutsui # define fd_formb_gaplen format_info.structured.gaplen 106*88ab3aa8Stsutsui # define fd_formb_fillbyte format_info.structured.fillbyte 107*88ab3aa8Stsutsui /* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */ 108*88ab3aa8Stsutsui # define fd_formb_cylno(i) format_info.structured.idfields[i].cylno 109*88ab3aa8Stsutsui # define fd_formb_headno(i) format_info.structured.idfields[i].headno 110*88ab3aa8Stsutsui # define fd_formb_secno(i) format_info.structured.idfields[i].secno 111*88ab3aa8Stsutsui # define fd_formb_secsize(i) format_info.structured.idfields[i].secsize 112