1 /* $OpenBSD: twevar.h,v 1.14 2020/07/22 13:16:04 krw 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 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, 20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 25 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 * THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 struct twe_softc; 30 31 struct twe_ccb { 32 struct twe_softc *ccb_sc; 33 struct twe_cmd *ccb_cmd; 34 struct scsi_xfer *ccb_xs; 35 paddr_t ccb_cmdpa; 36 TAILQ_ENTRY(twe_ccb) ccb_link; 37 enum { 38 TWE_CCB_FREE, TWE_CCB_READY, TWE_CCB_QUEUED, TWE_CCB_PREQUEUED, 39 TWE_CCB_DONE 40 } ccb_state; 41 int ccb_length; 42 void *ccb_data; 43 void *ccb_realdata; 44 bus_dmamap_t ccb_dmamap; 45 bus_dma_segment_t ccb_2bseg[TWE_MAXOFFSETS]; 46 int ccb_2nseg; 47 }; 48 49 typedef TAILQ_HEAD(twe_queue_head, twe_ccb) twe_queue_head; 50 51 struct twe_softc { 52 struct device sc_dev; 53 void *sc_ih; 54 struct proc *sc_thread; 55 int sc_thread_on; 56 57 bus_space_tag_t iot; 58 bus_space_handle_t ioh; 59 bus_dma_tag_t dmat; 60 61 void *sc_cmds; 62 bus_dmamap_t sc_cmdmap; 63 bus_dma_segment_t sc_cmdseg[1]; 64 struct twe_ccb sc_ccbs[TWE_MAXCMDS]; 65 twe_queue_head sc_free_ccb; 66 twe_queue_head sc_ccbq; 67 twe_queue_head sc_ccb2q; 68 twe_queue_head sc_done_ccb; 69 struct mutex sc_ccb_mtx; 70 struct scsi_iopool sc_iopool; 71 72 struct timeout sc_enqueue_tmo; 73 74 struct scsi_iohandler sc_aen; 75 76 struct { 77 int hd_present; 78 int hd_devtype; 79 int hd_lock; 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(sc) splbio() 86 #define TWE_UNLOCK(sc, lock) splx(lock) 87 typedef int twe_lock_t; 88 89 int twe_attach(struct twe_softc *); 90 int twe_intr(void *); 91