1 /* $NetBSD: uhavar.h,v 1.12 2001/04/25 17:53:35 bouyer 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 and by Jason R. Thorpe of the Numerical Aerospace 9 * Simulation Facility, 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 #include <sys/queue.h> 41 42 #define UHA_MSCP_MAX 32 /* store up to 32 MSCPs at one time */ 43 #define MSCP_HASH_SIZE 32 /* hash table size for phystokv */ 44 #define MSCP_HASH_SHIFT 9 45 #define MSCP_HASH(x) ((((long)(x))>>MSCP_HASH_SHIFT) & (MSCP_HASH_SIZE - 1)) 46 47 struct uha_softc { 48 struct device sc_dev; 49 50 bus_space_tag_t sc_iot; 51 bus_space_handle_t sc_ioh; 52 bus_dma_tag_t sc_dmat; 53 void *sc_ih; 54 55 int sc_dmaflags; /* bus-specific DMA map creation flags */ 56 57 void (*start_mbox) __P((struct uha_softc *, struct uha_mscp *)); 58 int (*poll) __P((struct uha_softc *, struct scsipi_xfer *, int)); 59 void (*init) __P((struct uha_softc *)); 60 61 bus_dmamap_t sc_dmamap_mscp; /* maps the mscps */ 62 struct uha_mscp *sc_mscps; /* all our mscps */ 63 64 struct uha_mscp *sc_mscphash[MSCP_HASH_SIZE]; 65 TAILQ_HEAD(, uha_mscp) sc_free_mscp; 66 int sc_nummscps; 67 68 struct scsipi_adapter sc_adapter; 69 struct scsipi_channel sc_channel; 70 }; 71 72 /* 73 * Offset of an MSCP from the beginning of the MSCP DMA mapping. 74 */ 75 #define UHA_MSCP_OFF(m) (((u_long)(m)) - ((u_long)&sc->sc_mscps[0])) 76 77 struct uha_probe_data { 78 int sc_irq, sc_drq; 79 int sc_scsi_dev; 80 }; 81 82 void uha_attach __P((struct uha_softc *, struct uha_probe_data *)); 83 void uha_timeout __P((void *arg)); 84 struct uha_mscp *uha_mscp_phys_kv __P((struct uha_softc *, u_long)); 85 void uha_done __P((struct uha_softc *, struct uha_mscp *)); 86