xref: /openbsd-src/sys/dev/isa/fdlink.h (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1 /*	$OpenBSD: fdlink.h,v 1.5 2001/03/06 13:55:02 ho Exp $	*/
2 
3 /*-
4  * Copyright (c) 1993, 1994, 1995 Charles Hannum.
5  * Copyright (c) 1990 The Regents of the University of California.
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to Berkeley by
9  * Don Ahn.
10  *
11  * Portions Copyright (c) 1993, 1994 by
12  *  jc@irbs.UUCP (John Capo)
13  *  vak@zebub.msk.su (Serge Vakulenko)
14  *  ache@astral.msk.su (Andrew A. Chernov)
15  *  joerg_wunsch@uriah.sax.de (Joerg Wunsch)
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions
19  * are met:
20  * 1. Redistributions of source code must retain the above copyright
21  *    notice, this list of conditions and the following disclaimer.
22  * 2. Redistributions in binary form must reproduce the above copyright
23  *    notice, this list of conditions and the following disclaimer in the
24  *    documentation and/or other materials provided with the distribution.
25  * 3. All advertising materials mentioning features or use of this software
26  *    must display the following acknowledgement:
27  *	This product includes software developed by the University of
28  *	California, Berkeley and its contributors.
29  * 4. Neither the name of the University nor the names of its contributors
30  *    may be used to endorse or promote products derived from this software
31  *    without specific prior written permission.
32  *
33  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
34  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
35  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
36  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
37  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
41  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
42  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43  * SUCH DAMAGE.
44  *
45  */
46 
47 /*
48  * The goo that binds the floppy controller to it's devices.
49  */
50 
51 enum fdc_state {
52 	DEVIDLE = 0,
53 	MOTORWAIT,
54 	DOSEEK,
55 	SEEKWAIT,
56 	SEEKTIMEDOUT,
57 	SEEKCOMPLETE,
58 	DOIO,
59 	IOCOMPLETE,
60 	IOTIMEDOUT,
61 	DORESET,
62 	RESETCOMPLETE,
63 	RESETTIMEDOUT,
64 	DORECAL,
65 	RECALWAIT,
66 	RECALTIMEDOUT,
67 	RECALCOMPLETE,
68 };
69 
70 enum fdc_type {
71 	FDC_TYPE_TAPE,
72 	FDC_TYPE_DISK
73 };
74 
75 
76 /* software state, per controller */
77 struct fd_softc;
78 struct fdc_fdlink {
79 	struct fd_softc *sc_fd[4];	/* pointers to children */
80 	TAILQ_HEAD(drivehead, fd_softc) sc_drives;
81 };
82 
83 struct ft_softc;
84 struct fdc_ftlink {
85 	struct ft_softc *sc_ft[4];	/* pointers to children */
86 };
87 
88 struct fdc_softc {
89 	struct device sc_dev;		/* boilerplate */
90 	struct isadev sc_id;
91 	void *sc_ih;
92 
93 	bus_space_tag_t sc_iot;		/* ISA chipset identifier */
94 	bus_space_handle_t sc_ioh;	/* ISA io handle */
95 	bus_space_handle_t sc_ioh_ctl;	/* ISA io handle */
96 
97 	int sc_drq;
98 
99 	enum fdc_type sc_type[4];	/* type of device */
100 	union {
101 		struct fdc_fdlink fdlink;
102 		struct fdc_ftlink ftlink;
103 	} sc_link;
104 	enum fdc_state sc_state;
105 	int sc_errors;			/* number of retries so far */
106 	struct timeout fdcpseudointr_to;
107 	u_char sc_status[7];		/* copy of registers */
108 };
109 
110 /*
111  * Arguments passed between fdcattach and f[dt]probe.
112  */
113 struct fdc_attach_args {
114 	int fa_drive;
115 	int fa_flags;
116 	int fa_type;			/* tape drive type */
117 	struct fd_type *fa_deftype;
118 };
119 
120 /* Functions from fdc.c. */
121 int fdcresult __P((struct fdc_softc *));
122 int out_fdc __P((bus_space_tag_t, bus_space_handle_t, u_char));
123 void fdcstart __P((struct fdc_softc *));
124 void fdcstatus __P((struct device *, int, char *));
125 void fdcpseudointr __P((void *));
126 
127 /* Functions from fd.c. */
128 struct fd_type *fd_nvtotype __P((char *, int, int));
129