uhavar.h revision 1.8 1 /* $NetBSD: uhavar.h,v 1.8 1998/02/17 03:02:56 thorpej 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 Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40 /*
41 * Copyright (c) 1994, 1996, 1997 Charles M. Hannum. All rights reserved.
42 *
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
45 * are met:
46 * 1. Redistributions of source code must retain the above copyright
47 * notice, this list of conditions and the following disclaimer.
48 * 2. Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in the
50 * documentation and/or other materials provided with the distribution.
51 * 3. All advertising materials mentioning features or use of this software
52 * must display the following acknowledgement:
53 * This product includes software developed by Charles M. Hannum.
54 * 4. The name of the author may not be used to endorse or promote products
55 * derived from this software without specific prior written permission.
56 *
57 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
58 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
59 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
60 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
61 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
63 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
64 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
65 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
66 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67 */
68
69 #include <sys/queue.h>
70
71 #define UHA_MSCP_MAX 32 /* store up to 32 MSCPs at one time */
72 #define MSCP_HASH_SIZE 32 /* hash table size for phystokv */
73 #define MSCP_HASH_SHIFT 9
74 #define MSCP_HASH(x) ((((long)(x))>>MSCP_HASH_SHIFT) & (MSCP_HASH_SIZE - 1))
75
76 struct uha_softc {
77 struct device sc_dev;
78
79 bus_space_tag_t sc_iot;
80 bus_space_handle_t sc_ioh;
81 bus_dma_tag_t sc_dmat;
82 void *sc_ih;
83
84 int sc_dmaflags; /* bus-specific DMA map creation flags */
85
86 void (*start_mbox) __P((struct uha_softc *, struct uha_mscp *));
87 int (*poll) __P((struct uha_softc *, struct scsipi_xfer *, int));
88 void (*init) __P((struct uha_softc *));
89
90 bus_dmamap_t sc_dmamap_mscp; /* maps the mscps */
91 struct uha_mscp *sc_mscps; /* all our mscps */
92
93 struct uha_mscp *sc_mscphash[MSCP_HASH_SIZE];
94 TAILQ_HEAD(, uha_mscp) sc_free_mscp;
95 int sc_nummscps;
96 struct scsipi_link sc_link;
97
98 LIST_HEAD(, scsipi_xfer) sc_queue;
99 struct scsipi_xfer *sc_queuelast;
100 };
101
102 /*
103 * Offset of an MSCP from the beginning of the MSCP DMA mapping.
104 */
105 #define UHA_MSCP_OFF(m) (((u_long)(m)) - ((u_long)&sc->sc_mscps[0]))
106
107 struct uha_probe_data {
108 int sc_irq, sc_drq;
109 int sc_scsi_dev;
110 };
111
112 void uha_attach __P((struct uha_softc *, struct uha_probe_data *));
113 void uha_timeout __P((void *arg));
114 struct uha_mscp *uha_mscp_phys_kv __P((struct uha_softc *, u_long));
115 void uha_done __P((struct uha_softc *, struct uha_mscp *));
116