1 /*
2 * hosts.h Copyright (C) 1992 Drew Eckhardt
3 * mid to low-level SCSI driver interface header by
4 * Drew Eckhardt
5 *
6 * <drew@colorado.edu>
7 *
8 * Modified by Eric Youngdale eric@tantalus.nrl.navy.mil to
9 * add scatter-gather, multiple outstanding request, and other
10 * enhancements.
11 *
12 * Further modified by Eric Youngdale to support multiple host adapters
13 * of the same type.
14 */
15
16 #ifndef _HOSTS_H
17 #define _HOSTS_H
18
19 /*
20 $Header: /usr/src/linux/kernel/blk_drv/scsi/RCS/hosts.h,v 1.3 1993/09/24 12:21:00 drew Exp drew $
21 */
22
23
24 /* A jumpstart is often required when the reset() function is called -
25 many host adapters cannot do this cleanly, so they do nothing at all.
26 To get the command going again, these routines set this bit in the flags
27 so that a scsi_request_sense() is executed, and the command starts running
28 again */
29
30 #define NEEDS_JUMPSTART 0x20
31
32 #define SG_NONE 0
33 #define SG_ALL 0xff
34
35 /* The various choices mean:
36 NONE: Self evident. Host adapter is not capable of scatter-gather.
37 ALL: Means that the host adapter module can do scatter-gather,
38 and that there is no limit to the size of the table to which
39 we scatter/gather data.
40 Anything else: Indicates the maximum number of chains that can be
41 used in one scatter-gather request.
42 */
43
44 /*
45 The Scsi_Host_Template type has all that is needed to interface with a SCSI
46 host in a device independant matter. There is one entry for each different
47 type of host adapter that is supported on the system.
48 */
49
50 typedef struct
51 {
52 /*
53 The name pointer is a pointer to the name of the SCSI
54 device detected.
55 */
56
57 char *name;
58
59 /*
60 The detect function shall return non zero on detection,
61 indicating the number of host adapters of this particular
62 type were found. It should also
63 initialize all data necessary for this particular
64 SCSI driver. It is passed the host number, so this host
65 knows where the first entry is in the scsi_hosts[] array.
66
67 Note that the detect routine MUST not call any of the mid level
68 functions to queue commands because things are not guaranteed
69 to be set up yet. The detect routine can send commands to
70 the host adapter as long as the program control will not be
71 passed to scsi.c in the processesing of the command. Note
72 especially that scsi_malloc/scsi_free must not be called.
73 */
74
75 int (* detect)(int);
76
77 /*
78 The info function will return whatever useful
79 information the developer sees fit.
80 */
81
82 const char *(* info)(void);
83
84 /*
85 The command function takes a target, a command (this is a SCSI
86 command formatted as per the SCSI spec, nothing strange), a
87 data buffer pointer, and data buffer length pointer. The return
88 is a status int, bit fielded as follows :
89 Byte What
90 0 SCSI status code
91 1 SCSI 1 byte message
92 2 host error return.
93 3 mid level error return
94 */
95
96 int (* command)(Scsi_Cmnd *);
97
98 /*
99 The QueueCommand function works in a similar manner
100 to the command function. It takes an additional parameter,
101 void (* done)(int host, int code) which is passed the host
102 # and exit result when the command is complete.
103 Host number is the POSITION IN THE hosts array of THIS
104 host adapter.
105 */
106
107 int (* queuecommand)(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
108
109 /*
110 Since the mid level driver handles time outs, etc, we want to
111 be able to abort the current command. Abort returns 0 if the
112 abortion was successful. If non-zero, the code passed to it
113 will be used as the return code, otherwise
114 DID_ABORT should be returned.
115
116 Note that the scsi driver should "clean up" after itself,
117 resetting the bus, etc. if necessary.
118 */
119
120 int (* abort)(Scsi_Cmnd *, int);
121
122 /*
123 The reset function will reset the SCSI bus. Any executing
124 commands should fail with a DID_RESET in the host byte.
125 The Scsi_Cmnd is passed so that the reset routine can figure
126 out which host adapter should be reset, and also which command
127 within the command block was responsible for the reset in
128 the first place. Some hosts do not implement a reset function,
129 and these hosts must call scsi_request_sense(SCpnt) to keep
130 the command alive.
131 */
132
133 int (* reset)(Scsi_Cmnd *);
134 /*
135 This function is used to select synchronous communications,
136 which will result in a higher data throughput. Not implemented
137 yet.
138 */
139
140 int (* slave_attach)(int, int);
141 /*
142 This function determines the bios parameters for a given
143 harddisk. These tend to be numbers that are made up by
144 the host adapter. Parameters:
145 size, device number, list (heads, sectors, cylinders)
146 */
147
148 int (* bios_param)(int, int, int []);
149
150 /*
151 This determines if we will use a non-interrupt driven
152 or an interrupt driven scheme, It is set to the maximum number
153 of simulataneous commands a given host adapter will accept.
154 */
155 int can_queue;
156
157 /*
158 In many instances, especially where disconnect / reconnect are
159 supported, our host also has an ID on the SCSI bus. If this is
160 the case, then it must be reserved. Please set this_id to -1 if
161 your settup is in single initiator mode, and the host lacks an
162 ID.
163 */
164
165 int this_id;
166
167 /*
168 This determines the degree to which the host adapter is capable
169 of scatter-gather.
170 */
171
172 short unsigned int sg_tablesize;
173
174 /*
175 True if this host adapter can make good use of linked commands.
176 This will allow more than one command to be queued to a given
177 unit on a given host. Set this to the maximum number of command
178 blocks to be provided for each device. Set this to 1 for one
179 command block per lun, 2 for two, etc. Do not set this to 0.
180 You should make sure that the host adapter will do the right thing
181 before you try setting this above 1.
182 */
183
184 short cmd_per_lun;
185 /*
186 present contains counter indicating how many boards of this
187 type were found when we did the scan.
188 */
189
190 unsigned char present;
191 /*
192 true if this host adapter uses unchecked DMA onto an ISA bus.
193 */
194 unsigned unchecked_isa_dma:1;
195 } Scsi_Host_Template;
196
197 /*
198 The scsi_hosts array is the array containing the data for all
199 possible <supported> scsi hosts. This is similar to the
200 Scsi_Host_Template, except that we have one entry for each
201 actual physical host adapter on the system, stored as a linked
202 list. Note that if there are 2 aha1542 boards, then there will
203 be two Scsi_Host entries, but only 1 Scsi_Host_Template entries.
204 */
205
206 struct Scsi_Host
207 {
208 struct Scsi_Host * next;
209 volatile unsigned char host_busy;
210 char host_no; /* Used for IOCTL_GET_IDLUN */
211 int last_reset;
212 struct wait_queue *host_wait;
213 Scsi_Cmnd *host_queue;
214 Scsi_Host_Template * hostt;
215
216 /* These parameters should be set by the detect routine */
217 unsigned char *base;
218 short unsigned int io_port;
219 unsigned char irq;
220 unsigned char dma_channel;
221 /*
222 The rest can be copied from the template, or specifically
223 initialized, as required.
224 */
225
226 int this_id;
227 short unsigned int sg_tablesize;
228 unsigned unchecked_isa_dma:1;
229 int hostdata[0]; /* Used for storage of host specific stuff */
230 };
231
232 extern struct Scsi_Host * scsi_hostlist;
233
234 extern Scsi_Host_Template scsi_hosts[];
235
236 /*
237 scsi_init initializes the scsi hosts.
238 */
239
240
241 unsigned int scsi_init(unsigned long memory_start,unsigned long memory_end);
242 extern struct Scsi_Host * scsi_register(int i, int j);
243 extern void scsi_unregister(struct Scsi_Host * i, int j);
244
245 #define BLANK_HOST {"", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
246 #endif