1*4cbd24b2Swiz /* $NetBSD: fdvar.h,v 1.7 2011/06/30 20:09:37 wiz Exp $ */ 27c5210bcSpk 37c5210bcSpk /*- 47c5210bcSpk * Copyright (c) 1998 The NetBSD Foundation, Inc. 53c962bb5Sjeremy * All rights reserved. 63c962bb5Sjeremy * 77c5210bcSpk * This code is derived from software contributed to The NetBSD Foundation 87c5210bcSpk * by Paul Kranenburg. 97c5210bcSpk * 103c962bb5Sjeremy * Redistribution and use in source and binary forms, with or without 113c962bb5Sjeremy * modification, are permitted provided that the following conditions 123c962bb5Sjeremy * are met: 133c962bb5Sjeremy * 1. Redistributions of source code must retain the above copyright 143c962bb5Sjeremy * notice, this list of conditions and the following disclaimer. 153c962bb5Sjeremy * 2. Redistributions in binary form must reproduce the above copyright 163c962bb5Sjeremy * notice, this list of conditions and the following disclaimer in the 173c962bb5Sjeremy * documentation and/or other materials provided with the distribution. 183c962bb5Sjeremy * 197c5210bcSpk * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 207c5210bcSpk * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 217c5210bcSpk * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 227c5210bcSpk * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 237c5210bcSpk * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 247c5210bcSpk * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 257c5210bcSpk * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 267c5210bcSpk * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 277c5210bcSpk * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 287c5210bcSpk * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 297c5210bcSpk * POSSIBILITY OF SUCH DAMAGE. 303c962bb5Sjeremy */ 313c962bb5Sjeremy 323c962bb5Sjeremy #define FDC_BSIZE 512 333c962bb5Sjeremy #define FDC_MAXIOSIZE NBPG /* XXX should be MAXBSIZE */ 343c962bb5Sjeremy 353c962bb5Sjeremy #define FDC_NSTATUS 10 363c962bb5Sjeremy 373c962bb5Sjeremy #ifndef _LOCORE 383c962bb5Sjeremy struct fdcio { 393c962bb5Sjeremy /* 403c962bb5Sjeremy * 82072 (sun4c,sun3x) and 82077 (sun4m) controllers have different 413c962bb5Sjeremy * register layout; so we cache some here. 423c962bb5Sjeremy */ 4310b1a7beSchs volatile uint8_t *fdcio_reg_msr; 4410b1a7beSchs volatile uint8_t *fdcio_reg_fifo; 4510b1a7beSchs volatile uint8_t *fdcio_reg_dor; /* 82077 only */ 4610b1a7beSchs volatile uint8_t *fdcio_reg_fcr; /* sun3x floppy control reg */ 4710b1a7beSchs volatile uint8_t *fdcio_reg_fvr; /* sun3x floppy int. vector */ 483c962bb5Sjeremy 493c962bb5Sjeremy /* 503c962bb5Sjeremy * Interrupt state. 513c962bb5Sjeremy */ 523c962bb5Sjeremy int fdcio_istate; 533c962bb5Sjeremy 543c962bb5Sjeremy /* 553c962bb5Sjeremy * IO state. 563c962bb5Sjeremy */ 571ffa7b76Swiz char *fdcio_data; /* pseudo-DMA data */ 581ffa7b76Swiz int fdcio_tc; /* pseudo-DMA Terminal Count */ 593c962bb5Sjeremy u_char fdcio_status[FDC_NSTATUS]; /* copy of registers */ 603c962bb5Sjeremy int fdcio_nstat; /* # of valid status bytes */ 613c962bb5Sjeremy 623c962bb5Sjeremy /* 633c962bb5Sjeremy * Statictics. 643c962bb5Sjeremy */ 653c962bb5Sjeremy struct evcnt fdcio_intrcnt; 663c962bb5Sjeremy }; 673c962bb5Sjeremy #endif /* _LOCORE */ 683c962bb5Sjeremy 693c962bb5Sjeremy /* istate values */ 703c962bb5Sjeremy #define ISTATE_IDLE 0 /* No HW interrupt expected */ 713c962bb5Sjeremy #define ISTATE_SPURIOUS 1 /* Spurious HW interrupt detected */ 723c962bb5Sjeremy #define ISTATE_SENSEI 2 /* Do SENSEI on next HW interrupt */ 733c962bb5Sjeremy #define ISTATE_DMA 3 /* Pseudo-DMA in progress */ 743c962bb5Sjeremy #define ISTATE_DONE 4 /* Interrupt processing complete */ 753c962bb5Sjeremy 763c962bb5Sjeremy 773c962bb5Sjeremy #define FD_MAX_NSEC 36 /* highest known number of spt - allow for */ 783c962bb5Sjeremy /* 2.88 MB drives */ 793c962bb5Sjeremy 803c962bb5Sjeremy #ifndef _LOCORE 813c962bb5Sjeremy struct ne7_fd_formb { 823c962bb5Sjeremy int cyl, head; 833c962bb5Sjeremy int transfer_rate; /* fdreg.h: FDC_???KBPS */ 843c962bb5Sjeremy 853c962bb5Sjeremy union { 863c962bb5Sjeremy struct fd_form_data { 873c962bb5Sjeremy /* 883c962bb5Sjeremy * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS 89*4cbd24b2Swiz * it is hardware-dependent since it exactly 903c962bb5Sjeremy * matches the byte sequence to write to FDC 913c962bb5Sjeremy * during its `format track' operation 923c962bb5Sjeremy */ 933c962bb5Sjeremy u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */ 943c962bb5Sjeremy u_char nsecs; /* must be <= FD_MAX_NSEC */ 953c962bb5Sjeremy u_char gaplen; /* GAP 3 length; usually 84 */ 963c962bb5Sjeremy u_char fillbyte; /* usually 0xf6 */ 973c962bb5Sjeremy struct fd_idfield_data { 983c962bb5Sjeremy /* 993c962bb5Sjeremy * data to write into id fields; 1003c962bb5Sjeremy * for obscure formats, they mustn't match 1013c962bb5Sjeremy * the real values (but mostly do) 1023c962bb5Sjeremy */ 1033c962bb5Sjeremy u_char cylno; /* 0 thru 79 (or 39) */ 1043c962bb5Sjeremy u_char headno; /* 0, or 1 */ 1053c962bb5Sjeremy u_char secno; /* starting at 1! */ 1063c962bb5Sjeremy u_char secsize; /* usually 2 */ 1073c962bb5Sjeremy } idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */ 1083c962bb5Sjeremy } structured; 1093c962bb5Sjeremy u_char raw[1]; /* to have continuous indexed access */ 1103c962bb5Sjeremy } format_info; 1113c962bb5Sjeremy }; 1123c962bb5Sjeremy 1133c962bb5Sjeremy /* make life easier */ 1143c962bb5Sjeremy #define fd_formb_secshift format_info.structured.secshift 1153c962bb5Sjeremy #define fd_formb_nsecs format_info.structured.nsecs 1163c962bb5Sjeremy #define fd_formb_gaplen format_info.structured.gaplen 1173c962bb5Sjeremy #define fd_formb_fillbyte format_info.structured.fillbyte 1183c962bb5Sjeremy /* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */ 1193c962bb5Sjeremy #define fd_formb_cylno(i) format_info.structured.idfields[i].cylno 1203c962bb5Sjeremy #define fd_formb_headno(i) format_info.structured.idfields[i].headno 1213c962bb5Sjeremy #define fd_formb_secno(i) format_info.structured.idfields[i].secno 1223c962bb5Sjeremy #define fd_formb_secsize(i) format_info.structured.idfields[i].secsize 1233c962bb5Sjeremy #endif /* _LOCORE */ 124