1 /* $OpenBSD: adw.h,v 1.11 2020/02/18 20:24:52 krw Exp $ */ 2 /* $NetBSD: adw.h,v 1.9 2000/05/26 15:13:43 dante Exp $ */ 3 4 /* 5 * Generic driver definitions and exported functions for the Advanced 6 * Systems Inc. SCSI controllers 7 * 8 * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. 9 * All rights reserved. 10 * 11 * Author: Baldassare Dante Profeta <dante@mclink.it> 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 * POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 #ifndef _ADVANSYS_WIDE_H_ 36 #define _ADVANSYS_WIDE_H_ 37 38 /******************************************************************************/ 39 40 typedef int (* ADW_ISR_CALLBACK) (ADW_SOFTC *, ADW_SCSI_REQ_Q *); 41 typedef void (* ADW_ASYNC_CALLBACK) (ADW_SOFTC *, u_int8_t); 42 43 44 /* 45 * per request scatter-gather element limit 46 * We could have up to 256 SG lists. 47 */ 48 #define ADW_MAX_SG_LIST 255 49 50 /* 51 * Scatter-Gather Definitions per request. 52 */ 53 54 #define NO_OF_SG_PER_BLOCK 15 55 56 /* Number of SG blocks needed. */ 57 #define ADW_NUM_SG_BLOCK \ 58 ((ADW_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK) 59 60 61 struct adw_ccb { 62 ADW_SCSI_REQ_Q scsiq; 63 ADW_SG_BLOCK sg_block[ADW_NUM_SG_BLOCK]; 64 65 struct scsi_sense_data scsi_sense; 66 67 TAILQ_ENTRY(adw_ccb) chain; 68 struct adw_ccb *nexthash; 69 u_int32_t hashkey; 70 71 struct scsi_xfer *xs; /* the scsi_xfer for this cmd */ 72 int flags; /* see below */ 73 74 int timeout; 75 76 /* 77 * This DMA map maps the buffer involved in the transfer. 78 */ 79 bus_dmamap_t dmamap_xfer; 80 }; 81 82 typedef struct adw_ccb ADW_CCB; 83 84 /* flags for ADW_CCB */ 85 #define CCB_ALLOC 0x01 86 #define CCB_ABORTING 0x02 87 #define CCB_ABORTED 0x04 88 89 90 #define ADW_MAX_CCB 63 /* Max. number commands per device (63) */ 91 92 struct adw_control { 93 ADW_CCB ccbs[ADW_MAX_CCB]; /* all our control blocks */ 94 ADW_CARRIER *carriers; /* all our carriers */ 95 }; 96 97 /* 98 * Offset of a CCB from the beginning of the control DMA mapping. 99 */ 100 #define ADW_CCB_OFF(c) (offsetof(struct adw_control, ccbs[0]) + \ 101 (((u_long)(c)) - ((u_long)&sc->sc_control->ccbs[0]))) 102 103 /******************************************************************************/ 104 105 int adw_init(ADW_SOFTC *sc); 106 void adw_attach(ADW_SOFTC *sc); 107 int adw_intr(void *arg); 108 ADW_CCB *adw_ccb_phys_kv(ADW_SOFTC *, u_int32_t); 109 110 /******************************************************************************/ 111 112 #endif /* _ADVANSYS_ADW_H_ */ 113