1 /* $OpenBSD: twevar.h,v 1.3 2001/05/10 20:07:35 mickey Exp $ */ 2 3 /* 4 * Copyright (c) 2000 Michael Shalayeff 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Michael Shalayeff. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, 25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31 * THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 struct twe_softc; 35 36 struct twe_ccb { 37 struct twe_softc *ccb_sc; 38 struct twe_cmd *ccb_cmd; 39 struct scsi_xfer *ccb_xs; 40 paddr_t ccb_cmdpa; 41 TAILQ_ENTRY(twe_ccb) ccb_link; 42 enum { 43 TWE_CCB_FREE, TWE_CCB_READY, TWE_CCB_QUEUED, TWE_CCB_PREQUEUED 44 } ccb_state; 45 int ccb_length; 46 void *ccb_data; 47 void *ccb_realdata; 48 bus_dmamap_t ccb_dmamap; 49 bus_dma_segment_t ccb_2bseg[TWE_MAXOFFSETS]; 50 int ccb_2nseg; 51 }; 52 53 typedef TAILQ_HEAD(twe_queue_head, twe_ccb) twe_queue_head; 54 55 struct twe_softc { 56 struct device sc_dev; 57 void *sc_ih; 58 struct scsi_link sc_link; 59 60 bus_space_tag_t iot; 61 bus_space_handle_t ioh; 62 bus_dma_tag_t dmat; 63 64 void *sc_cmds; 65 bus_dmamap_t sc_cmdmap; 66 bus_dma_segment_t sc_cmdseg[1]; 67 struct twe_ccb sc_ccbs[TWE_MAXCMDS]; 68 twe_queue_head sc_free_ccb; 69 twe_queue_head sc_ccbq; 70 twe_queue_head sc_ccb2q; 71 72 struct timeout sc_enqueue_tmo; 73 74 struct { 75 int hd_present; 76 int hd_devtype; 77 int hd_lock; 78 int hd_secs; 79 int hd_heads; 80 int hd_size; 81 } sc_hdr[TWE_MAX_UNITS]; 82 }; 83 84 /* XXX These have to become spinlocks in case of SMP */ 85 #define TWE_LOCK_TWE(sc) splbio() 86 #define TWE_UNLOCK_TWE(sc, lock) splx(lock) 87 typedef int twe_lock_t; 88 89 void tweminphys __P((struct buf *bp)); 90 int twe_attach __P((struct twe_softc *)); 91 int twe_intr __P((void *)); 92