xref: /openbsd/sys/dev/isa/fdlink.h (revision 0f1683a6)
1 /*	$OpenBSD: fdlink.h,v 1.9 2007/04/10 17:47:55 miod 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. Neither the name of the University nor the names of its contributors
26  *    may be used to endorse or promote products derived from this software
27  *    without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39  * SUCH DAMAGE.
40  *
41  */
42 
43 /*
44  * The goo that binds the floppy controller to its devices.
45  */
46 
47 enum fdc_state {
48 	DEVIDLE = 0,
49 	MOTORWAIT,
50 	DOSEEK,
51 	SEEKWAIT,
52 	SEEKTIMEDOUT,
53 	SEEKCOMPLETE,
54 	DOIO,
55 	IOCOMPLETE,
56 	IOTIMEDOUT,
57 	DORESET,
58 	RESETCOMPLETE,
59 	RESETTIMEDOUT,
60 	DORECAL,
61 	RECALWAIT,
62 	RECALTIMEDOUT,
63 	RECALCOMPLETE
64 };
65 
66 enum fdc_type {
67 	FDC_TYPE_TAPE,
68 	FDC_TYPE_DISK
69 };
70 
71 
72 /* software state, per controller */
73 struct fd_softc;
74 struct fdc_fdlink {
75 	struct fd_softc *sc_fd[4];	/* pointers to children */
76 	TAILQ_HEAD(drivehead, fd_softc) sc_drives;
77 };
78 
79 struct ft_softc;
80 struct fdc_ftlink {
81 	struct ft_softc *sc_ft[4];	/* pointers to children */
82 };
83 
84 struct fdc_softc {
85 	struct device sc_dev;		/* boilerplate */
86 	struct isadev sc_id;
87 	void *sc_ih;
88 
89 	bus_space_tag_t sc_iot;		/* ISA chipset identifier */
90 	bus_space_handle_t sc_ioh;	/* ISA io handle */
91 	bus_space_handle_t sc_ioh_ctl;	/* ISA io handle */
92 
93 	int sc_drq;
94 
95 	enum fdc_type sc_type[4];	/* type of device */
96 	union {
97 		struct fdc_fdlink fdlink;
98 		struct fdc_ftlink ftlink;
99 	} sc_link;
100 	enum fdc_state sc_state;
101 	int sc_errors;			/* number of retries so far */
102 	struct timeout fdcpseudointr_to;
103 	u_char sc_status[7];		/* copy of registers */
104 };
105 
106 /*
107  * Arguments passed between fdcattach and f[dt]probe.
108  */
109 struct fdc_attach_args {
110 	int fa_drive;
111 	int fa_flags;
112 	int fa_type;			/* tape drive type */
113 	struct fd_type *fa_deftype;
114 };
115 
116 /* Functions from fdc.c. */
117 int fdcresult(struct fdc_softc *);
118 int out_fdc(bus_space_tag_t, bus_space_handle_t, u_char);
119 void fdcstart(struct fdc_softc *);
120 void fdcstatus(struct device *, int, char *);
121 void fdcpseudointr(void *);
122 
123 /* Functions from fd.c. */
124 struct fd_type *fd_nvtotype(char *, int, int);
125