| 1 | /* $NetBSD: fdcvar.h,v 1.10 2008/04/28 20:23:52 martin Exp $ */ |
| 2 | |
| 3 | /*- |
| 4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * This code is derived from software contributed to The NetBSD Foundation |
| 8 | * by Charles M. Hannum. |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions |
| 12 | * are met: |
| 13 | * 1. Redistributions of source code must retain the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer. |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in the |
| 17 | * documentation and/or other materials provided with the distribution. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
| 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
| 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 | * POSSIBILITY OF SUCH DAMAGE. |
| 30 | */ |
| 31 | |
| 32 | /*- |
| 33 | * Copyright (c) 1990 The Regents of the University of California. |
| 34 | * All rights reserved. |
| 35 | * |
| 36 | * This code is derived from software contributed to Berkeley by |
| 37 | * Don Ahn. |
| 38 | * |
| 39 | * Redistribution and use in source and binary forms, with or without |
| 40 | * modification, are permitted provided that the following conditions |
| 41 | * are met: |
| 42 | * 1. Redistributions of source code must retain the above copyright |
| 43 | * notice, this list of conditions and the following disclaimer. |
| 44 | * 2. Redistributions in binary form must reproduce the above copyright |
| 45 | * notice, this list of conditions and the following disclaimer in the |
| 46 | * documentation and/or other materials provided with the distribution. |
| 47 | * 3. Neither the name of the University nor the names of its contributors |
| 48 | * may be used to endorse or promote products derived from this software |
| 49 | * without specific prior written permission. |
| 50 | * |
| 51 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 52 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 53 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 54 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 55 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 56 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 57 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 58 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 59 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 60 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 61 | * SUCH DAMAGE. |
| 62 | * |
| 63 | * @(#)fd.c 7.4 (Berkeley) 5/25/91 |
| 64 | */ |
| 65 | |
| 66 | #include <sys/mutex.h> |
| 67 | #include <sys/condvar.h> |
| 68 | |
| 69 | /* |
| 70 | * Floppy formatting facilities merged from FreeBSD fd.c driver: |
| 71 | * Id: fd.c,v 1.53 1995/03/12 22:40:56 joerg Exp |
| 72 | * which carries the same copyright/redistribution notice as shown above with |
| 73 | * the addition of the following statement before the "Redistribution and |
| 74 | * use ..." clause: |
| 75 | * |
| 76 | * Copyright (c) 1993, 1994 by |
| 77 | * jc@irbs.UUCP (John Capo) |
| 78 | * vak@zebub.msk.su (Serge Vakulenko) |
| 79 | * ache@astral.msk.su (Andrew A. Chernov) |
| 80 | * |
| 81 | * Copyright (c) 1993, 1994, 1995 by |
| 82 | * joerg_wunsch@uriah.sax.de (Joerg Wunsch) |
| 83 | * dufault@hda.com (Peter Dufault) |
| 84 | */ |
| 85 | |
| 86 | enum fdc_state { |
| 87 | PROBING = -1, |
| 88 | DEVIDLE = 0, |
| 89 | MOTORWAIT, |
| 90 | DOSEEK, |
| 91 | SEEKWAIT, |
| 92 | SEEKTIMEDOUT, |
| 93 | SEEKCOMPLETE, |
| 94 | DOIO, |
| 95 | IOCOMPLETE, |
| 96 | IOTIMEDOUT, |
| 97 | DORESET, |
| 98 | RESETCOMPLETE, |
| 99 | RESETTIMEDOUT, |
| 100 | DORECAL, |
| 101 | RECALWAIT, |
| 102 | RECALTIMEDOUT, |
| 103 | RECALCOMPLETE, |
| 104 | }; |
| 105 | |
| 106 | /* software state, per controller */ |
| 107 | struct fdc_softc { |
| 108 | device_t sc_dev; /* boilerplate */ |
| 109 | void *sc_ih; |
| 110 | |
| 111 | bus_space_tag_t sc_iot; /* ISA i/o space identifier */ |
| 112 | bus_space_handle_t sc_ioh; /* ISA io handle */ |
| 113 | isa_chipset_tag_t sc_ic; /* ISA chipset info */ |
| 114 | |
| 115 | struct callout sc_timo_ch; /* timeout callout */ |
| 116 | struct callout sc_intr_ch; /* pseudo-intr callout */ |
| 117 | |
| 118 | /* |
| 119 | * XXX We have port overlap with the first IDE controller. |
| 120 | * Until we have a reasonable solution for handling overlap |
| 121 | * like this, we kludge access to our control register at |
| 122 | * offset 7. |
| 123 | */ |
| 124 | bus_space_handle_t sc_fdctlioh; |
| 125 | #define sc_fdinioh sc_fdctlioh |
| 126 | |
| 127 | int sc_drq; |
| 128 | bus_size_t sc_maxiosize; |
| 129 | |
| 130 | struct fd_softc *sc_fd[4]; /* pointers to children */ |
| 131 | TAILQ_HEAD(drivehead, fd_softc) sc_drives; |
| 132 | enum fdc_state sc_state; |
| 133 | int sc_errors; /* number of retries so far */ |
| 134 | u_char sc_status[7]; /* copy of registers */ |
| 135 | |
| 136 | int sc_known; /* direct configuration if non-zero */ |
| 137 | int sc_present; /* bitmap of available fds */ |
| 138 | const struct fd_type *sc_knownfds[4]; /* drive info known fds */ |
| 139 | kmutex_t sc_mtx; |
| 140 | kcondvar_t sc_cv; |
| 141 | int sc_probe; |
| 142 | }; |
| 143 | |
| 144 | int out_fdc(bus_space_tag_t iot, bus_space_handle_t ioh, u_char x); |
| 145 | |
| 146 | void fdcattach(struct fdc_softc *); |
| 147 | void fdc_childdet(device_t, device_t); |
| 148 | int fdcdetach(device_t self, int flags); |
| 149 | int fdcintr(void *); |
| 150 | |