ncr5380var.h revision 1.1 1 /* $NetBSD: ncr5380var.h,v 1.1 1996/02/22 21:07:12 leo Exp $ */
2
3 /*
4 * Copyright (c) 1996 Leo Weppelman.
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 Leo Weppelman.
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 BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #ifndef _NCR5380VAR_H
34 #define _NCR5380VAR_H
35
36 struct ncr_softc {
37 struct device sc_dev;
38 struct scsi_link sc_link;
39
40 /*
41 * Some (pre-SCSI2) devices don't support select with ATN.
42 * If the device responds to select with ATN by going into
43 * command phase (ignoring ATN), then we flag it in the
44 * following bitmask.
45 * We also keep track of which devices have been selected
46 * before. This allows us to not even try raising ATN if
47 * the target doesn't respond to it the first time.
48 */
49 u_int8_t sc_noselatn;
50 u_int8_t sc_selected;
51 };
52
53 /*
54 * Max. number of dma-chains per request
55 */
56 #define MAXDMAIO (MAXPHYS/NBPG + 1)
57
58 /*
59 * Some requests are not contiguous in physical memory. We need to break them
60 * up into contiguous parts for DMA.
61 */
62 struct dma_chain {
63 u_int dm_count;
64 u_long dm_addr;
65 };
66
67 /*
68 * Define our issue, free and disconnect queue's.
69 */
70 typedef struct req_q {
71 struct req_q *next; /* next in free, issue or discon queue */
72 struct req_q *link; /* next linked command to execute */
73 struct scsi_xfer *xs; /* request from high-level driver */
74 u_short dr_flag; /* driver state */
75 u_char phase; /* current SCSI phase */
76 u_char msgout; /* message to send when requested */
77 u_char targ_id; /* target for command */
78 u_char targ_lun; /* lun for command */
79 u_char status; /* returned status byte */
80 u_char message; /* returned message byte */
81 u_char *bounceb; /* allocated bounce buffer */
82 u_char *bouncerp; /* bounce read-pointer */
83 struct dma_chain dm_chain[MAXDMAIO];
84 struct dma_chain *dm_cur; /* current dma-request */
85 struct dma_chain *dm_last; /* last dma-request */
86 long xdata_len; /* length of transfer */
87 u_char *xdata_ptr; /* virtual address of transfer */
88 struct scsi_generic xcmd; /* command to execute */
89 } SC_REQ;
90
91 /*
92 * Values for dr_flag:
93 */
94 #define DRIVER_IN_DMA 0x01 /* Non-polled DMA activated */
95 #define DRIVER_AUTOSEN 0x02 /* Doing automatic sense */
96 #define DRIVER_NOINT 0x04 /* We are booting: no interrupts */
97 #define DRIVER_DMAOK 0x08 /* DMA can be used on this request */
98 #define DRIVER_BOUNCING 0x10 /* Using the bounce buffer */
99 #define DRIVER_LINKCHK 0x20 /* Doing the linked command check */
100
101 static SC_REQ *issue_q = NULL; /* Commands waiting to be issued*/
102 static SC_REQ *discon_q = NULL; /* Commands disconnected */
103 static SC_REQ *connected = NULL; /* Command currently connected */
104
105 /*
106 * Various debug definitions
107 */
108 #ifdef DBG_NOSTATIC
109 # define static
110 #endif
111 #ifdef DBG_SEL
112 # define DBG_SELPRINT(a,b) printf(a,b)
113 #else
114 # define DBG_SELPRINT(a,b)
115 #endif
116 #ifdef DBG_PIO
117 # define DBG_PIOPRINT(a,b,c) printf(a,b,c)
118 #else
119 # define DBG_PIOPRINT(a,b,c)
120 #endif
121 #ifdef DBG_INF
122 # define DBG_INFPRINT(a,b,c) a(b,c)
123 #else
124 # define DBG_INFPRINT(a,b,c)
125 #endif
126 #ifdef DBG_PID
127 /* static char *last_hit = NULL, *olast_hit = NULL; */
128 static char *last_hit[DBG_PID];
129 # define PID(a) \
130 { int i; \
131 for (i=0; i< DBG_PID-1; i++) \
132 last_hit[i] = last_hit[i+1]; \
133 last_hit[DBG_PID-1] = a; } \
134 /* olast_hit = last_hit; last_hit = a; */
135 #else
136 # define PID(a)
137 #endif
138
139 #endif /* _NCR5380VAR_H */
140