Home | History | Annotate | Line # | Download | only in dev
fdvar.h revision 1.1
      1  1.1  jeremy /*
      2  1.1  jeremy  *	$NetBSD: fdvar.h,v 1.1 1997/04/09 04:49:11 jeremy Exp $
      3  1.1  jeremy  *
      4  1.1  jeremy  * Copyright (c) 1995 Paul Kranenburg
      5  1.1  jeremy  * All rights reserved.
      6  1.1  jeremy  *
      7  1.1  jeremy  * Redistribution and use in source and binary forms, with or without
      8  1.1  jeremy  * modification, are permitted provided that the following conditions
      9  1.1  jeremy  * are met:
     10  1.1  jeremy  * 1. Redistributions of source code must retain the above copyright
     11  1.1  jeremy  *    notice, this list of conditions and the following disclaimer.
     12  1.1  jeremy  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  jeremy  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  jeremy  *    documentation and/or other materials provided with the distribution.
     15  1.1  jeremy  * 3. All advertising materials mentioning features or use of this software
     16  1.1  jeremy  *    must display the following acknowledgement:
     17  1.1  jeremy  *      This product includes software developed by Paul Kranenburg.
     18  1.1  jeremy  * 4. The name of the author may not be used to endorse or promote products
     19  1.1  jeremy  *    derived from this software without specific prior written permission
     20  1.1  jeremy  *
     21  1.1  jeremy  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.1  jeremy  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.1  jeremy  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.1  jeremy  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.1  jeremy  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.1  jeremy  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.1  jeremy  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.1  jeremy  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.1  jeremy  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.1  jeremy  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.1  jeremy  *
     32  1.1  jeremy  */
     33  1.1  jeremy 
     34  1.1  jeremy #define	FDC_BSIZE	512
     35  1.1  jeremy #define	FDC_MAXIOSIZE	NBPG	/* XXX should be MAXBSIZE */
     36  1.1  jeremy 
     37  1.1  jeremy #define FDC_NSTATUS	10
     38  1.1  jeremy 
     39  1.1  jeremy #ifndef _LOCORE
     40  1.1  jeremy struct fdcio {
     41  1.1  jeremy 	/*
     42  1.1  jeremy 	 * 82072 (sun4c,sun3x) and 82077 (sun4m) controllers have different
     43  1.1  jeremy 	 * register layout; so we cache some here.
     44  1.1  jeremy 	 */
     45  1.1  jeremy 	volatile u_int8_t	*fdcio_reg_msr;
     46  1.1  jeremy 	volatile u_int8_t	*fdcio_reg_fifo;
     47  1.1  jeremy 	volatile u_int8_t	*fdcio_reg_dor;	/* 82077 only */
     48  1.1  jeremy 	volatile u_int8_t	*fdcio_reg_fcr; /* sun3x floppy control reg */
     49  1.1  jeremy 	volatile u_int8_t	*fdcio_reg_fvr; /* sun3x floppy int. vector */
     50  1.1  jeremy 
     51  1.1  jeremy 	/*
     52  1.1  jeremy 	 * Interrupt state.
     53  1.1  jeremy 	 */
     54  1.1  jeremy 	int	fdcio_istate;
     55  1.1  jeremy 
     56  1.1  jeremy 	/*
     57  1.1  jeremy 	 * IO state.
     58  1.1  jeremy 	 */
     59  1.1  jeremy 	char	*fdcio_data;		/* pseudo-dma data */
     60  1.1  jeremy 	int	fdcio_tc;		/* pseudo-dma Terminal Count */
     61  1.1  jeremy 	u_char	fdcio_status[FDC_NSTATUS];	/* copy of registers */
     62  1.1  jeremy 	int	fdcio_nstat;		/* # of valid status bytes */
     63  1.1  jeremy 
     64  1.1  jeremy 	/*
     65  1.1  jeremy 	 * Statictics.
     66  1.1  jeremy 	 */
     67  1.1  jeremy 	struct	evcnt	fdcio_intrcnt;
     68  1.1  jeremy };
     69  1.1  jeremy #endif /* _LOCORE */
     70  1.1  jeremy 
     71  1.1  jeremy /* istate values */
     72  1.1  jeremy #define ISTATE_IDLE		0	/* No HW interrupt expected */
     73  1.1  jeremy #define ISTATE_SPURIOUS		1	/* Spurious HW interrupt detected */
     74  1.1  jeremy #define ISTATE_SENSEI		2	/* Do SENSEI on next HW interrupt */
     75  1.1  jeremy #define ISTATE_DMA		3	/* Pseudo-DMA in progress */
     76  1.1  jeremy #define ISTATE_DONE		4	/* Interrupt processing complete */
     77  1.1  jeremy 
     78  1.1  jeremy 
     79  1.1  jeremy #define FD_MAX_NSEC 36		/* highest known number of spt - allow for */
     80  1.1  jeremy 				/* 2.88 MB drives */
     81  1.1  jeremy 
     82  1.1  jeremy #ifndef _LOCORE
     83  1.1  jeremy struct ne7_fd_formb {
     84  1.1  jeremy 	int cyl, head;
     85  1.1  jeremy 	int transfer_rate;	/* fdreg.h: FDC_???KBPS */
     86  1.1  jeremy 
     87  1.1  jeremy 	union {
     88  1.1  jeremy 		struct fd_form_data {
     89  1.1  jeremy 			/*
     90  1.1  jeremy 			 * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS
     91  1.1  jeremy 			 * it is hardware-dependant since it exactly
     92  1.1  jeremy 			 * matches the byte sequence to write to FDC
     93  1.1  jeremy 			 * during its `format track' operation
     94  1.1  jeremy 			 */
     95  1.1  jeremy 			u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */
     96  1.1  jeremy 			u_char nsecs;	/* must be <= FD_MAX_NSEC */
     97  1.1  jeremy 			u_char gaplen;	/* GAP 3 length; usually 84 */
     98  1.1  jeremy 			u_char fillbyte; /* usually 0xf6 */
     99  1.1  jeremy 			struct fd_idfield_data {
    100  1.1  jeremy 				/*
    101  1.1  jeremy 				 * data to write into id fields;
    102  1.1  jeremy 				 * for obscure formats, they mustn't match
    103  1.1  jeremy 				 * the real values (but mostly do)
    104  1.1  jeremy 				 */
    105  1.1  jeremy 				u_char cylno;	/* 0 thru 79 (or 39) */
    106  1.1  jeremy 				u_char headno;	/* 0, or 1 */
    107  1.1  jeremy 				u_char secno;	/* starting at 1! */
    108  1.1  jeremy 				u_char secsize;	/* usually 2 */
    109  1.1  jeremy 			} idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */
    110  1.1  jeremy 		} structured;
    111  1.1  jeremy 		u_char raw[1];	/* to have continuous indexed access */
    112  1.1  jeremy 	} format_info;
    113  1.1  jeremy };
    114  1.1  jeremy 
    115  1.1  jeremy /* make life easier */
    116  1.1  jeremy #define fd_formb_secshift   format_info.structured.secshift
    117  1.1  jeremy #define fd_formb_nsecs      format_info.structured.nsecs
    118  1.1  jeremy #define fd_formb_gaplen     format_info.structured.gaplen
    119  1.1  jeremy #define fd_formb_fillbyte   format_info.structured.fillbyte
    120  1.1  jeremy /* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */
    121  1.1  jeremy #define fd_formb_cylno(i)   format_info.structured.idfields[i].cylno
    122  1.1  jeremy #define fd_formb_headno(i)  format_info.structured.idfields[i].headno
    123  1.1  jeremy #define fd_formb_secno(i)   format_info.structured.idfields[i].secno
    124  1.1  jeremy #define fd_formb_secsize(i) format_info.structured.idfields[i].secsize
    125  1.1  jeremy #endif /* _LOCORE */
    126