uhavar.h revision 1.16 1 1.16 chs /* $NetBSD: uhavar.h,v 1.16 2012/10/27 17:18:23 chs Exp $ */
2 1.8 thorpej
3 1.8 thorpej /*-
4 1.8 thorpej * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 1.8 thorpej * All rights reserved.
6 1.8 thorpej *
7 1.8 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.9 mycroft * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
9 1.9 mycroft * Simulation Facility, NASA Ames Research Center.
10 1.8 thorpej *
11 1.8 thorpej * Redistribution and use in source and binary forms, with or without
12 1.8 thorpej * modification, are permitted provided that the following conditions
13 1.8 thorpej * are met:
14 1.8 thorpej * 1. Redistributions of source code must retain the above copyright
15 1.8 thorpej * notice, this list of conditions and the following disclaimer.
16 1.8 thorpej * 2. Redistributions in binary form must reproduce the above copyright
17 1.8 thorpej * notice, this list of conditions and the following disclaimer in the
18 1.8 thorpej * documentation and/or other materials provided with the distribution.
19 1.8 thorpej *
20 1.8 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 1.8 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 1.8 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 1.8 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 1.8 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 1.8 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 1.8 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 1.8 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 1.8 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 1.8 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 1.8 thorpej * POSSIBILITY OF SUCH DAMAGE.
31 1.2 mycroft */
32 1.2 mycroft
33 1.7 thorpej #include <sys/queue.h>
34 1.7 thorpej
35 1.1 mycroft #define UHA_MSCP_MAX 32 /* store up to 32 MSCPs at one time */
36 1.1 mycroft #define MSCP_HASH_SIZE 32 /* hash table size for phystokv */
37 1.1 mycroft #define MSCP_HASH_SHIFT 9
38 1.1 mycroft #define MSCP_HASH(x) ((((long)(x))>>MSCP_HASH_SHIFT) & (MSCP_HASH_SIZE - 1))
39 1.1 mycroft
40 1.1 mycroft struct uha_softc {
41 1.16 chs device_t sc_dev;
42 1.1 mycroft
43 1.3 thorpej bus_space_tag_t sc_iot;
44 1.3 thorpej bus_space_handle_t sc_ioh;
45 1.5 thorpej bus_dma_tag_t sc_dmat;
46 1.1 mycroft void *sc_ih;
47 1.5 thorpej
48 1.5 thorpej int sc_dmaflags; /* bus-specific DMA map creation flags */
49 1.1 mycroft
50 1.13 perry void (*start_mbox)(struct uha_softc *, struct uha_mscp *);
51 1.13 perry int (*poll)(struct uha_softc *, struct scsipi_xfer *, int);
52 1.13 perry void (*init)(struct uha_softc *);
53 1.1 mycroft
54 1.8 thorpej bus_dmamap_t sc_dmamap_mscp; /* maps the mscps */
55 1.8 thorpej struct uha_mscp *sc_mscps; /* all our mscps */
56 1.8 thorpej
57 1.1 mycroft struct uha_mscp *sc_mscphash[MSCP_HASH_SIZE];
58 1.1 mycroft TAILQ_HEAD(, uha_mscp) sc_free_mscp;
59 1.1 mycroft int sc_nummscps;
60 1.12 bouyer
61 1.10 thorpej struct scsipi_adapter sc_adapter;
62 1.12 bouyer struct scsipi_channel sc_channel;
63 1.1 mycroft };
64 1.8 thorpej
65 1.8 thorpej /*
66 1.8 thorpej * Offset of an MSCP from the beginning of the MSCP DMA mapping.
67 1.8 thorpej */
68 1.8 thorpej #define UHA_MSCP_OFF(m) (((u_long)(m)) - ((u_long)&sc->sc_mscps[0]))
69 1.1 mycroft
70 1.4 mycroft struct uha_probe_data {
71 1.4 mycroft int sc_irq, sc_drq;
72 1.4 mycroft int sc_scsi_dev;
73 1.4 mycroft };
74 1.4 mycroft
75 1.13 perry void uha_attach(struct uha_softc *, struct uha_probe_data *);
76 1.13 perry void uha_timeout(void *arg);
77 1.13 perry struct uha_mscp *uha_mscp_phys_kv(struct uha_softc *, u_long);
78 1.13 perry void uha_done(struct uha_softc *, struct uha_mscp *);
79