xref: /openbsd/sys/dev/ic/adv.h (revision f6aab3d8)
1 /*	$OpenBSD: adv.h,v 1.7 2020/02/18 20:24:52 krw Exp $	*/
2 /*      $NetBSD: adv.h,v 1.3 1998/09/26 16:02:56 dante Exp $        */
3 
4 /*
5  * Generic driver definitions and exported functions for the Advanced
6  * Systems Inc. Narrow SCSI controllers
7  *
8  * Copyright (c) 1998 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_NARROW_H_
36 #define _ADVANSYS_NARROW_H_
37 
38 #include <dev/ic/advlib.h>
39 
40 /******************************************************************************/
41 
42 struct adv_ccb
43 {
44 	ASC_SG_HEAD	sghead;
45 	ASC_SCSI_Q	scsiq;
46 
47 	struct scsi_sense_data scsi_sense;
48 
49 	TAILQ_ENTRY(adv_ccb) chain;
50 	struct scsi_xfer	*xs;	/* the scsi_xfer for this cmd */
51 	int			flags;	/* see below */
52 
53 	int			timeout;
54 	/*
55 	 * This DMA map maps the buffer involved in the transfer.
56 	 */
57 	bus_dmamap_t		dmamap_xfer;
58 };
59 
60 typedef struct adv_ccb ADV_CCB;
61 
62 /* flags for ADV_CCB */
63 #define CCB_ALLOC       0x01
64 #define CCB_ABORT       0x02
65 #define	CCB_WATCHDOG	0x10
66 
67 
68 #define ADV_MAX_CCB	32
69 
70 struct adv_control
71 {
72 	ADV_CCB	ccbs[ADV_MAX_CCB];	/* all our control blocks */
73 };
74 
75 /*
76  * Offset of a CCB from the beginning of the control DMA mapping.
77  */
78 #define	ADV_CCB_OFF(c)	(offsetof(struct adv_control, ccbs[0]) +	\
79 		    (((u_long)(c)) - ((u_long)&sc->sc_control->ccbs[0])))
80 
81 /******************************************************************************/
82 
83 int adv_init(ASC_SOFTC *sc);
84 void adv_attach(ASC_SOFTC *sc);
85 int adv_intr(void *arg);
86 
87 /******************************************************************************/
88 
89 #endif /* _ADVANSYS_NARROW_H_ */
90