This source file includes following definitions.
- scsi_unregister
- scsi_register
- scsi_register_device
- scsi_init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 #include <linux/config.h>
17 #include "../block/blk.h"
18 #include <linux/kernel.h>
19 #include <linux/string.h>
20 #include "scsi.h"
21
22 #ifndef NULL
23 #define NULL 0L
24 #endif
25
26 #define HOSTS_C
27
28 #include "hosts.h"
29
30 #ifdef CONFIG_SCSI_AHA152X
31 #include "aha152x.h"
32 #endif
33
34 #ifdef CONFIG_SCSI_AHA1542
35 #include "aha1542.h"
36 #endif
37
38 #ifdef CONFIG_SCSI_AHA1740
39 #include "aha1740.h"
40 #endif
41
42 #ifdef CONFIG_SCSI_BUSLOGIC
43 #include "buslogic.h"
44 #endif
45
46 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
47 #include "fdomain.h"
48 #endif
49
50 #ifdef CONFIG_SCSI_GENERIC_NCR5380
51 #include "g_NCR5380.h"
52 #endif
53
54 #ifdef CONFIG_SCSI_IN2000
55 #include "in2000.h"
56 #endif
57
58 #ifdef CONFIG_SCSI_PAS16
59 #include "pas16.h"
60 #endif
61
62 #ifdef CONFIG_SCSI_SEAGATE
63 #include "seagate.h"
64 #endif
65
66 #ifdef CONFIG_SCSI_T128
67 #include "t128.h"
68 #endif
69
70 #ifdef CONFIG_SCSI_NCR53C7xx
71 #include "53c7,8xx.h"
72 #endif
73
74 #ifdef CONFIG_SCSI_ULTRASTOR
75 #include "ultrastor.h"
76 #endif
77
78 #ifdef CONFIG_SCSI_7000FASST
79 #include "wd7000.h"
80 #endif
81
82 #ifdef CONFIG_SCSI_DEBUG
83 #include "scsi_debug.h"
84 #endif
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105 #define NO_CONTROLLER {NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
106 NULL, NULL, 0, 0, 0, 0, 0, 0}
107
108
109
110
111
112
113
114
115 Scsi_Host_Template * scsi_hosts = NULL;
116
117 static Scsi_Host_Template builtin_scsi_hosts[] =
118 {
119 #ifdef CONFIG_SCSI_ULTRASTOR
120 ULTRASTOR_14F,
121 #endif
122 #ifdef CONFIG_SCSI_AHA152X
123 AHA152X,
124 #endif
125
126 #ifdef CONFIG_SCSI_BUSLOGIC
127 BUSLOGIC,
128 #endif
129 #ifdef CONFIG_SCSI_AHA1542
130 AHA1542,
131 #endif
132 #ifdef CONFIG_SCSI_AHA1740
133 AHA1740,
134 #endif
135 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
136 FDOMAIN_16X0,
137 #endif
138 #ifdef CONFIG_SCSI_IN2000
139 IN2000,
140 #endif
141 #ifdef CONFIG_SCSI_GENERIC_NCR5380
142 GENERIC_NCR5380,
143 #endif
144 #ifdef CONFIG_SCSI_PAS16
145 MV_PAS16,
146 #endif
147 #ifdef CONFIG_SCSI_SEAGATE
148 SEAGATE_ST0X,
149 #endif
150 #ifdef CONFIG_SCSI_T128
151 TRANTOR_T128,
152 #endif
153 #ifdef CONFIG_SCSI_NCR53C7xx
154 NCR53c7xx,
155 #endif
156 #ifdef CONFIG_SCSI_7000FASST
157 WD7000,
158 #endif
159 #ifdef CONFIG_SCSI_DEBUG
160 SCSI_DEBUG,
161 #endif
162 };
163
164 #define MAX_SCSI_HOSTS (sizeof(builtin_scsi_hosts) / sizeof(Scsi_Host_Template))
165
166
167
168
169
170 struct Scsi_Host * scsi_hostlist = NULL;
171 struct Scsi_Device_Template * scsi_devicelist;
172
173 int max_scsi_hosts = 0;
174 static int next_host = 0;
175
176 void
177 scsi_unregister(struct Scsi_Host * sh){
178 struct Scsi_Host * shpnt;
179 int j;
180
181 j = sh->extra_bytes;
182
183 if(scsi_hostlist == sh)
184 scsi_hostlist = NULL;
185 else {
186 shpnt = scsi_hostlist;
187 while(shpnt->next != sh) shpnt = shpnt->next;
188 shpnt->next = shpnt->next->next;
189 };
190 next_host--;
191 scsi_init_free((char *) sh, sizeof(struct Scsi_Host) + j);
192 }
193
194
195
196
197
198 struct Scsi_Host * scsi_register(Scsi_Host_Template * tpnt, int j){
199 struct Scsi_Host * retval, *shpnt;
200 retval = (struct Scsi_Host *)scsi_init_malloc(sizeof(struct Scsi_Host) + j);
201 retval->host_busy = 0;
202 if(j > 0xffff) panic("Too many extra bytes requested\n");
203 retval->extra_bytes = j;
204 retval->loaded_as_module = scsi_loadable_module_flag;
205 retval->host_no = next_host++;
206 retval->host_queue = NULL;
207 retval->host_wait = NULL;
208 retval->last_reset = 0;
209 retval->irq = 0;
210 retval->hostt = tpnt;
211 retval->next = NULL;
212 #ifdef DEBUG
213 printk("Register %x %x: %d\n", retval, retval->hostt, j);
214 #endif
215
216
217
218 retval->this_id = tpnt->this_id;
219 retval->sg_tablesize = tpnt->sg_tablesize;
220 retval->unchecked_isa_dma = tpnt->unchecked_isa_dma;
221
222 if(!scsi_hostlist)
223 scsi_hostlist = retval;
224 else
225 {
226 shpnt = scsi_hostlist;
227 while(shpnt->next) shpnt = shpnt->next;
228 shpnt->next = retval;
229 }
230
231 return retval;
232 }
233
234 int
235 scsi_register_device(struct Scsi_Device_Template * sdpnt)
236 {
237 if(sdpnt->next) panic("Device already registered");
238 sdpnt->next = scsi_devicelist;
239 scsi_devicelist = sdpnt;
240 return 0;
241 }
242
243 unsigned int scsi_init()
244 {
245 static int called = 0;
246 int i, j, count, pcount;
247 Scsi_Host_Template * tpnt;
248 count = 0;
249
250 if(called) return 0;
251
252 called = 1;
253 for (tpnt = &builtin_scsi_hosts[0], i = 0; i < MAX_SCSI_HOSTS; ++i, tpnt++)
254 {
255
256
257
258
259
260 pcount = next_host;
261 if ((tpnt->detect) &&
262 (tpnt->present =
263 tpnt->detect(tpnt)))
264 {
265
266
267 if(pcount == next_host) {
268 if(tpnt->present > 1)
269 panic("Failure to register low-level scsi driver");
270
271
272 scsi_register(tpnt,0);
273 };
274 tpnt->next = scsi_hosts;
275 scsi_hosts = tpnt;
276 for(j = 0; j < tpnt->present; j++)
277 printk ("scsi%d : %s\n",
278 count++, tpnt->name);
279 }
280 }
281 printk ("scsi : %d hosts.\n", count);
282
283
284 #ifdef CONFIG_BLK_DEV_SD
285 scsi_register_device(&sd_template);
286 #endif
287 #ifdef CONFIG_BLK_DEV_SR
288 scsi_register_device(&sr_template);
289 #endif
290 #ifdef CONFIG_CHR_DEV_ST
291 scsi_register_device(&st_template);
292 #endif
293 #ifdef CONFIG_CHR_DEV_SG
294 scsi_register_device(&sg_template);
295 #endif
296
297 max_scsi_hosts = count;
298 return 0;
299 }