xref: /openbsd-src/sys/dev/ic/adv.h (revision fabcfecb28af5579f8c0c1cb806278199e88da42)
1 /*	$OpenBSD: adv.h,v 1.8 2024/10/22 21:50:02 jsg 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 	ASC_SG_HEAD	sghead;
44 	ASC_SCSI_Q	scsiq;
45 
46 	struct scsi_sense_data scsi_sense;
47 
48 	TAILQ_ENTRY(adv_ccb) chain;
49 	struct scsi_xfer	*xs;	/* the scsi_xfer for this cmd */
50 	int			flags;	/* see below */
51 
52 	int			timeout;
53 	/*
54 	 * This DMA map maps the buffer involved in the transfer.
55 	 */
56 	bus_dmamap_t		dmamap_xfer;
57 };
58 
59 typedef struct adv_ccb ADV_CCB;
60 
61 /* flags for ADV_CCB */
62 #define CCB_ALLOC       0x01
63 #define CCB_ABORT       0x02
64 #define	CCB_WATCHDOG	0x10
65 
66 
67 #define ADV_MAX_CCB	32
68 
69 struct adv_control {
70 	ADV_CCB	ccbs[ADV_MAX_CCB];	/* all our control blocks */
71 };
72 
73 /*
74  * Offset of a CCB from the beginning of the control DMA mapping.
75  */
76 #define	ADV_CCB_OFF(c)	(offsetof(struct adv_control, ccbs[0]) +	\
77 		    (((u_long)(c)) - ((u_long)&sc->sc_control->ccbs[0])))
78 
79 /******************************************************************************/
80 
81 int adv_init(ASC_SOFTC *sc);
82 void adv_attach(ASC_SOFTC *sc);
83 int adv_intr(void *arg);
84 
85 /******************************************************************************/
86 
87 #endif /* _ADVANSYS_NARROW_H_ */
88