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