xref: /netbsd-src/sys/arch/sparc/dev/fdvar.h (revision 4cbd24b23f7b9efac0cd70749df49d28974c7799)
1*4cbd24b2Swiz /*	$NetBSD: fdvar.h,v 1.15 2011/06/30 20:09:36 wiz Exp $	*/
22c9a80baSpk 
32c9a80baSpk /*-
42c9a80baSpk  * Copyright (c) 1998 The NetBSD Foundation, Inc.
503b9b4a4Spk  * All rights reserved.
603b9b4a4Spk  *
72c9a80baSpk  * This code is derived from software contributed to The NetBSD Foundation
8b39d7e33Spk  * by Paul Kranenburg.
92c9a80baSpk  *
1003b9b4a4Spk  * Redistribution and use in source and binary forms, with or without
1103b9b4a4Spk  * modification, are permitted provided that the following conditions
1203b9b4a4Spk  * are met:
1303b9b4a4Spk  * 1. Redistributions of source code must retain the above copyright
1403b9b4a4Spk  *    notice, this list of conditions and the following disclaimer.
1503b9b4a4Spk  * 2. Redistributions in binary form must reproduce the above copyright
1603b9b4a4Spk  *    notice, this list of conditions and the following disclaimer in the
1703b9b4a4Spk  *    documentation and/or other materials provided with the distribution.
1803b9b4a4Spk  *
192c9a80baSpk  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
202c9a80baSpk  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
212c9a80baSpk  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
222c9a80baSpk  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
232c9a80baSpk  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
242c9a80baSpk  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
252c9a80baSpk  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
262c9a80baSpk  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
272c9a80baSpk  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
282c9a80baSpk  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
292c9a80baSpk  * POSSIBILITY OF SUCH DAMAGE.
3003b9b4a4Spk  */
3103b9b4a4Spk 
32a0d6bae7Spk #define	FD_BSIZE(fd)	(128 * (1 << fd->sc_type->secsize))
33e6e777cfSpk #define	FDC_MAXIOSIZE	NBPG	/* XXX should be MAXBSIZE */
34e6e777cfSpk 
35e6e777cfSpk #define FDC_NSTATUS	10
36e6e777cfSpk 
3788e512b6Smycroft #ifndef _LOCORE
38e6e777cfSpk struct fdcio {
39725c6438Spk 	bus_space_handle_t	fdcio_handle;
40e6e777cfSpk 	/*
41e6e777cfSpk 	 * 82072 (sun4c) and 82077 (sun4m) controllers have different
42725c6438Spk 	 * register layout; so we cache offsets to the registers here.
43e6e777cfSpk 	 */
44725c6438Spk 	u_int	fdcio_reg_msr;
45725c6438Spk 	u_int	fdcio_reg_fifo;
46725c6438Spk 	u_int	fdcio_reg_dor;		/* 82077 only */
47c7a9b61eSpk 	u_int	fdcio_reg_dir;		/* 82077 only */
48e6e777cfSpk 
49e6e777cfSpk 	/*
50e6e777cfSpk 	 * Interrupt state.
51e6e777cfSpk 	 */
52f8ac5484Spk 	int	fdcio_itask;
53f8ac5484Spk 	int	fdcio_istatus;
54e6e777cfSpk 
55e6e777cfSpk 	/*
56e6e777cfSpk 	 * IO state.
57e6e777cfSpk 	 */
581ffa7b76Swiz 	char	*fdcio_data;		/* pseudo-DMA data */
591ffa7b76Swiz 	int	fdcio_tc;		/* pseudo-DMA Terminal Count */
60e6e777cfSpk 	u_char	fdcio_status[FDC_NSTATUS];	/* copy of registers */
61e6e777cfSpk 	int	fdcio_nstat;		/* # of valid status bytes */
6281619075Spk 
6381619075Spk 	/*
6481619075Spk 	 * Statictics.
6581619075Spk 	 */
6681619075Spk 	struct	evcnt	fdcio_intrcnt;
67e6e777cfSpk };
6888e512b6Smycroft #endif /* _LOCORE */
69e6e777cfSpk 
70f8ac5484Spk /* itask values */
71f8ac5484Spk #define FDC_ITASK_NONE		0	/* No HW interrupt expected */
72f8ac5484Spk #define FDC_ITASK_SENSEI	1	/* Do SENSEI on next HW interrupt */
73f8ac5484Spk #define FDC_ITASK_DMA		2	/* Do Pseudo-DMA */
74f8ac5484Spk #define FDC_ITASK_RESULT	3	/* Pick up command results */
75f8ac5484Spk 
76f8ac5484Spk /* istatus values */
77f8ac5484Spk #define FDC_ISTATUS_NONE	0	/* No status available */
78f8ac5484Spk #define FDC_ISTATUS_SPURIOUS	1	/* Spurious HW interrupt detected */
79f8ac5484Spk #define FDC_ISTATUS_ERROR	2	/* Operation completed abnormally */
80f8ac5484Spk #define FDC_ISTATUS_DONE	3	/* Operation completed normally */
81e6e777cfSpk 
82e6e777cfSpk 
83837dd8e3Spk #define FD_MAX_NSEC 36		/* highest known number of spt - allow for */
84837dd8e3Spk 				/* 2.88 MB drives */
85837dd8e3Spk 
86837dd8e3Spk #ifndef _LOCORE
87837dd8e3Spk struct ne7_fd_formb {
88837dd8e3Spk 	int cyl, head;
89837dd8e3Spk 	int transfer_rate;	/* fdreg.h: FDC_???KBPS */
90837dd8e3Spk 
91837dd8e3Spk 	union {
92837dd8e3Spk 		struct fd_form_data {
93837dd8e3Spk 			/*
94837dd8e3Spk 			 * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS
95*4cbd24b2Swiz 			 * it is hardware-dependent since it exactly
96837dd8e3Spk 			 * matches the byte sequence to write to FDC
97837dd8e3Spk 			 * during its `format track' operation
98837dd8e3Spk 			 */
99837dd8e3Spk 			u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */
100837dd8e3Spk 			u_char nsecs;	/* must be <= FD_MAX_NSEC */
101837dd8e3Spk 			u_char gaplen;	/* GAP 3 length; usually 84 */
102837dd8e3Spk 			u_char fillbyte; /* usually 0xf6 */
103837dd8e3Spk 			struct fd_idfield_data {
104837dd8e3Spk 				/*
105837dd8e3Spk 				 * data to write into id fields;
106837dd8e3Spk 				 * for obscure formats, they mustn't match
107837dd8e3Spk 				 * the real values (but mostly do)
108837dd8e3Spk 				 */
109837dd8e3Spk 				u_char cylno;	/* 0 thru 79 (or 39) */
110837dd8e3Spk 				u_char headno;	/* 0, or 1 */
111837dd8e3Spk 				u_char secno;	/* starting at 1! */
112837dd8e3Spk 				u_char secsize;	/* usually 2 */
113837dd8e3Spk 			} idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */
114837dd8e3Spk 		} structured;
115837dd8e3Spk 		u_char raw[1];	/* to have continuous indexed access */
116837dd8e3Spk 	} format_info;
117837dd8e3Spk };
118837dd8e3Spk 
119837dd8e3Spk /* make life easier */
120837dd8e3Spk #define fd_formb_secshift   format_info.structured.secshift
121837dd8e3Spk #define fd_formb_nsecs      format_info.structured.nsecs
122837dd8e3Spk #define fd_formb_gaplen     format_info.structured.gaplen
123837dd8e3Spk #define fd_formb_fillbyte   format_info.structured.fillbyte
124837dd8e3Spk /* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */
125837dd8e3Spk #define fd_formb_cylno(i)   format_info.structured.idfields[i].cylno
126837dd8e3Spk #define fd_formb_headno(i)  format_info.structured.idfields[i].headno
127837dd8e3Spk #define fd_formb_secno(i)   format_info.structured.idfields[i].secno
128837dd8e3Spk #define fd_formb_secsize(i) format_info.structured.idfields[i].secsize
129837dd8e3Spk #endif /* _LOCORE */
130