This source file includes following definitions.
- blacklisted
- scan_scsis_done
- scan_scsis
- scsi_times_out
- request_queueable
- allocate_device
- internal_cmnd
- scsi_request_sense
- scsi_do_cmd
- reset
- check_sense
- scsi_done
- scsi_abort
- scsi_reset
- scsi_main_timeout
- update_timeout
- scsi_malloc
- scsi_free
- scsi_dev_init
- print_inquiry
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #include <asm/system.h>
19 #include <linux/sched.h>
20 #include <linux/timer.h>
21 #include <linux/string.h>
22
23 #include "../block/blk.h"
24 #include "scsi.h"
25 #include "hosts.h"
26 #include "constants.h"
27
28
29
30
31
32
33 const unsigned char scsi_command_size[8] = { 6, 10, 10, 12, 12, 12, 10, 10 };
34
35 #define INTERNAL_ERROR (panic ("Internal error in file %s, line %d.\n", __FILE__, __LINE__))
36
37 static void scsi_done (Scsi_Cmnd *SCpnt);
38 static int update_timeout (Scsi_Cmnd *, int);
39 static void print_inquiry(unsigned char *data);
40 static void scsi_times_out (Scsi_Cmnd * SCpnt);
41
42 static int time_start;
43 static int time_elapsed;
44
45 #define MAX_SCSI_DEVICE_CODE 10
46 const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE] =
47 {
48 "Direct-Access ",
49 "Sequential-Access",
50 "Printer ",
51 "Processor ",
52 "WORM ",
53 "CD-ROM ",
54 "Scanner ",
55 "Optical Device ",
56 "Medium Changer ",
57 "Communications "
58 };
59
60
61
62
63
64
65
66
67
68 int NR_SCSI_DEVICES=0;
69
70 Scsi_Device * scsi_devices = NULL;
71
72 static unsigned char generic_sense[6] = {REQUEST_SENSE, 0,0,0, 255, 0};
73
74
75 Scsi_Cmnd * last_cmnd = NULL;
76
77
78
79
80
81
82
83 #define WAS_RESET 0x01
84 #define WAS_TIMEDOUT 0x02
85 #define WAS_SENSE 0x04
86 #define IS_RESETTING 0x08
87 #define ASKED_FOR_SENSE 0x10
88
89
90
91
92
93
94
95
96
97
98
99
100 #ifdef DEBUG
101 #define SCSI_TIMEOUT 500
102 #else
103 #define SCSI_TIMEOUT 100
104 #endif
105
106 #ifdef DEBUG
107 #define SENSE_TIMEOUT SCSI_TIMEOUT
108 #define ABORT_TIMEOUT SCSI_TIMEOUT
109 #define RESET_TIMEOUT SCSI_TIMEOUT
110 #else
111 #define SENSE_TIMEOUT 50
112 #define RESET_TIMEOUT 50
113 #define ABORT_TIMEOUT 50
114 #define MIN_RESET_DELAY 100
115 #endif
116
117
118
119
120
121 struct blist{
122 char * vendor;
123 char * model;
124 char * revision;
125 };
126
127 static struct blist blacklist[] =
128 {
129 {"DENON","DRD-25X","V"},
130 {"MAXTOR","XT-4380S","B3C"},
131 {"MAXTOR","MXT-1240S","I1.2"},
132 {"MAXTOR","XT-4170S","B5A"},
133 {"NEC","CD-ROM DRIVE:841","1.0"},
134 {"SEAGATE", "ST157N", "\004|j"},
135
136 {"SEAGATE", "ST296","921"},
137 {"SONY","CD-ROM CDU-541","4.3d"},
138 {"TANDBERG","TDC 3600","U07"},
139 {"TEAC","CD-ROM","1.06"},
140
141 {"TEXEL","CD-ROM","1.06"},
142
143 {NULL, NULL, NULL}};
144
145 static int blacklisted(unsigned char * response_data){
146 int i = 0;
147 unsigned char * pnt;
148 for(i=0; 1; i++){
149 if(blacklist[i].vendor == NULL) return 0;
150 pnt = &response_data[8];
151 while(*pnt && *pnt == ' ') pnt++;
152 if(memcmp(blacklist[i].vendor, pnt,
153 strlen(blacklist[i].vendor))) continue;
154 pnt = &response_data[16];
155 while(*pnt && *pnt == ' ') pnt++;
156 if(memcmp(blacklist[i].model, pnt,
157 strlen(blacklist[i].model))) continue;
158 return 1;
159 };
160 };
161
162
163
164
165
166
167
168
169
170
171 static volatile int in_scan = 0;
172 static int the_result;
173 static void scan_scsis_done (Scsi_Cmnd * SCpnt)
174 {
175
176 #ifdef DEBUG
177 printk ("scan_scsis_done(%d, %06x)\n", SCpnt->host, SCpnt->result);
178 #endif
179 SCpnt->request.dev = 0xfffe;
180 }
181
182
183
184
185
186
187
188
189 static void scan_scsis (void)
190 {
191 int dev, lun, type;
192 unsigned char scsi_cmd [12];
193 unsigned char scsi_result [256];
194 struct Scsi_Host * shpnt;
195 Scsi_Cmnd SCmd;
196
197 ++in_scan;
198 lun = 0;
199
200 SCmd.next = NULL;
201 SCmd.prev = NULL;
202 for (shpnt = scsi_hostlist; shpnt; shpnt = shpnt->next)
203 {
204 shpnt->host_queue = &SCmd;
205
206 for (dev = 0; dev < 8; ++dev)
207 if (shpnt->this_id != dev)
208
209
210
211
212 #ifdef NO_MULTI_LUN
213 for (lun = 0; lun < 1; ++lun)
214 #else
215 for (lun = 0; lun < 8; ++lun)
216 #endif
217 {
218 scsi_devices[NR_SCSI_DEVICES].host = shpnt;
219 scsi_devices[NR_SCSI_DEVICES].id = dev;
220 scsi_devices[NR_SCSI_DEVICES].lun = lun;
221 scsi_devices[NR_SCSI_DEVICES].index = NR_SCSI_DEVICES;
222 scsi_devices[NR_SCSI_DEVICES].device_wait = NULL;
223
224
225
226
227 scsi_devices[NR_SCSI_DEVICES].borken = 1;
228
229 scsi_cmd[0] = TEST_UNIT_READY;
230 scsi_cmd[1] = lun << 5;
231 scsi_cmd[2] = scsi_cmd[3] = scsi_cmd[5] = 0;
232 scsi_cmd[4] = 0;
233
234 SCmd.host = shpnt;
235 SCmd.target = dev;
236 SCmd.lun = lun;
237
238 SCmd.request.dev = 0xffff;
239 SCmd.use_sg = 0;
240 SCmd.old_use_sg = 0;
241 SCmd.transfersize = 0;
242 SCmd.underflow = 0;
243 SCmd.index = NR_SCSI_DEVICES;
244
245 scsi_do_cmd (&SCmd,
246 (void *) scsi_cmd, (void *)
247 scsi_result, 256, scan_scsis_done,
248 SCSI_TIMEOUT + 400, 5);
249
250 while (SCmd.request.dev != 0xfffe);
251 #if defined(DEBUG) || defined(DEBUG_INIT)
252 printk("scsi: scan SCSIS id %d lun %d\n", dev, lun);
253 printk("scsi: return code %08x\n", SCmd.result);
254 #endif
255
256
257 if(SCmd.result) {
258 if ((driver_byte(SCmd.result) & DRIVER_SENSE) &&
259 ((SCmd.sense_buffer[0] & 0x70) >> 4) == 7) {
260 if (SCmd.sense_buffer[2] &0xe0)
261 continue;
262 if(((SCmd.sense_buffer[2] & 0xf) != NOT_READY) &&
263 ((SCmd.sense_buffer[2] & 0xf) != UNIT_ATTENTION))
264 continue;
265 }
266 else
267 break;
268 };
269
270 #if defined (DEBUG) || defined(DEBUG_INIT)
271 printk("scsi: performing INQUIRY\n");
272 #endif
273
274
275
276
277
278 scsi_cmd[0] = INQUIRY;
279 scsi_cmd[1] = (lun << 5) & 0xe0;
280 scsi_cmd[2] = 0;
281 scsi_cmd[3] = 0;
282 scsi_cmd[4] = 255;
283 scsi_cmd[5] = 0;
284
285 SCmd.request.dev = 0xffff;
286
287 scsi_do_cmd (&SCmd,
288 (void *) scsi_cmd, (void *)
289 scsi_result, 256, scan_scsis_done,
290 SCSI_TIMEOUT, 3);
291
292 while (SCmd.request.dev != 0xfffe);
293
294 the_result = SCmd.result;
295
296 #if defined(DEBUG) || defined(DEBUG_INIT)
297 if (!the_result)
298 printk("scsi: INQUIRY successful\n");
299 else
300 printk("scsi: INQUIRY failed with code %08x\n");
301 #endif
302
303 if(the_result) break;
304
305
306
307 if (!the_result)
308 {
309 scsi_devices[NR_SCSI_DEVICES].
310 removable = (0x80 &
311 scsi_result[1]) >> 7;
312 scsi_devices[NR_SCSI_DEVICES].lockable =
313 scsi_devices[NR_SCSI_DEVICES].removable;
314 scsi_devices[NR_SCSI_DEVICES].
315 changed = 0;
316 scsi_devices[NR_SCSI_DEVICES].
317 access_count = 0;
318 scsi_devices[NR_SCSI_DEVICES].
319 busy = 0;
320
321
322
323
324
325
326 switch (type = scsi_result[0])
327 {
328 case TYPE_TAPE :
329 case TYPE_DISK :
330 case TYPE_MOD :
331 scsi_devices[NR_SCSI_DEVICES].writeable = 1;
332 break;
333 case TYPE_WORM :
334 case TYPE_ROM :
335 scsi_devices[NR_SCSI_DEVICES].writeable = 0;
336 break;
337 default :
338 #if 0
339 #ifdef DEBUG
340 printk("scsi: unknown type %d\n", type);
341 print_inquiry(scsi_result);
342 #endif
343 #endif
344 type = -1;
345 }
346
347 scsi_devices[NR_SCSI_DEVICES].random =
348 (type == TYPE_TAPE) ? 0 : 1;
349 scsi_devices[NR_SCSI_DEVICES].type = type;
350
351 if (type != -1)
352 {
353 print_inquiry(scsi_result);
354 switch(type){
355 case TYPE_TAPE:
356 printk("Detected scsi tape st%d at scsi%d, id %d, lun %d\n", MAX_ST,
357 shpnt->host_no , dev, lun);
358 if(NR_ST != -1) ++MAX_ST;
359 break;
360 case TYPE_ROM:
361 printk("Detected scsi CD-ROM sr%d at scsi%d, id %d, lun %d\n", MAX_SR,
362 shpnt->host_no , dev, lun);
363 if(NR_SR != -1) ++MAX_SR;
364 break;
365 case TYPE_DISK:
366 case TYPE_MOD:
367 printk("Detected scsi disk sd%c at scsi%d, id %d, lun %d\n", 'a'+MAX_SD,
368 shpnt->host_no , dev, lun);
369 if(NR_SD != -1) ++MAX_SD;
370 break;
371 default:
372 break;
373 };
374
375 if(NR_SG != -1) ++MAX_SG;
376
377 scsi_devices[NR_SCSI_DEVICES].scsi_level =
378 scsi_result[2] & 0x07;
379 if (scsi_devices[NR_SCSI_DEVICES].scsi_level >= 2 ||
380 (scsi_devices[NR_SCSI_DEVICES].scsi_level == 1 &&
381 (scsi_result[3] & 0x0f) == 1))
382 scsi_devices[NR_SCSI_DEVICES].scsi_level++;
383
384
385
386
387
388 scsi_devices[NR_SCSI_DEVICES].tagged_queue = 0;
389
390 if ((scsi_devices[NR_SCSI_DEVICES].scsi_level == SCSI_2) &&
391 (scsi_result[7] & 2)) {
392 scsi_devices[NR_SCSI_DEVICES].tagged_supported = 1;
393 scsi_devices[NR_SCSI_DEVICES].current_tag = 0;
394 }
395
396
397
398
399
400
401 scsi_devices[NR_SCSI_DEVICES].disconnect = 0;
402
403
404
405
406
407
408
409
410
411 if(strncmp("TEXEL", (char *) &scsi_result[8], 5) != 0 ||
412 strncmp("CD-ROM", (char *) &scsi_result[16], 6) != 0
413
414
415
416
417
418
419 #ifdef notyet
420 || (strncmp("1.06", (char *) &scsi_result[[, 4) != 0)
421 #endif
422 )
423 scsi_devices[NR_SCSI_DEVICES].borken = 0;
424
425
426
427
428 if(memcmp("INSITE", &scsi_result[8], 6) == 0 &&
429 (memcmp("Floptical F*8I", &scsi_result[16], 16) == 0
430 || memcmp("I325VM", &scsi_result[16], 6) == 0)) {
431 printk("Unlocked floptical drive.\n");
432 scsi_devices[NR_SCSI_DEVICES].lockable = 0;
433 scsi_cmd[0] = MODE_SENSE;
434 scsi_cmd[1] = (lun << 5) & 0xe0;
435 scsi_cmd[2] = 0x2e;
436 scsi_cmd[3] = 0;
437 scsi_cmd[4] = 0x2a;
438 scsi_cmd[5] = 0;
439
440 SCmd.request.dev = 0xffff;
441
442 scsi_do_cmd (&SCmd,
443 (void *) scsi_cmd, (void *)
444 scsi_result, 0x2a, scan_scsis_done,
445 SCSI_TIMEOUT, 3);
446
447 while (SCmd.request.dev != 0xfffe);
448 };
449
450 ++NR_SCSI_DEVICES;
451
452
453 if(blacklisted(scsi_result)) break;
454
455
456 if((scsi_result[2] & 0x07) == 1 &&
457 (scsi_result[3] & 0x0f) == 0) break;
458 }
459 }
460 }
461 shpnt->host_queue = NULL;
462 }
463
464 printk("scsi : detected ");
465 if(NR_SD != -1)
466 printk("%d SCSI disk%s ", MAX_SD, (MAX_SD != 1) ? "s" : "");
467
468 if(NR_ST != -1)
469 printk("%d tape%s ", MAX_ST, (MAX_ST != 1) ? "s" : "");
470
471 if(NR_SR != -1)
472 printk("%d CD-ROM drive%s ", MAX_SR, (MAX_SR != 1) ? "s" : "");
473
474 printk("total.\n");
475 in_scan = 0;
476 }
477
478
479
480
481
482 #define NORMAL_TIMEOUT 0
483 #define IN_ABORT 1
484 #define IN_RESET 2
485
486
487
488
489
490
491 static void scsi_times_out (Scsi_Cmnd * SCpnt)
492 {
493
494 switch (SCpnt->internal_timeout & (IN_ABORT | IN_RESET))
495 {
496 case NORMAL_TIMEOUT:
497 if (!in_scan)
498 printk("SCSI host %d timed out - aborting command\n",
499 SCpnt->host->host_no);
500
501 if (!scsi_abort (SCpnt, DID_TIME_OUT))
502 return;
503 case IN_ABORT:
504 printk("SCSI host %d abort() timed out - reseting\n",
505 SCpnt->host->host_no);
506 if (!scsi_reset (SCpnt))
507 return;
508 case IN_RESET:
509 case (IN_ABORT | IN_RESET):
510 panic("Unable to reset scsi host %d\n",SCpnt->host->host_no);
511 default:
512 INTERNAL_ERROR;
513 }
514
515 }
516
517
518
519
520
521
522
523
524 Scsi_Cmnd * request_queueable (struct request * req, int index)
525 {
526 Scsi_Cmnd * SCpnt = NULL;
527 int tablesize;
528 struct buffer_head * bh;
529
530 if ((index < 0) || (index > NR_SCSI_DEVICES))
531 panic ("Index number in allocate_device() is out of range.\n");
532
533 if (req && req->dev <= 0)
534 panic("Invalid device in allocate_device");
535
536 SCpnt = scsi_devices[index].host->host_queue;
537 while(SCpnt){
538 if(SCpnt->target == scsi_devices[index].id &&
539 SCpnt->lun == scsi_devices[index].lun)
540 if(SCpnt->request.dev < 0) break;
541 SCpnt = SCpnt->next;
542 };
543
544 if (!SCpnt) return NULL;
545
546 if (scsi_devices[index].host->hostt->can_queue
547 && scsi_devices[index].host->host_busy >= scsi_devices[index].host->hostt->can_queue) return NULL;
548
549 if (req) {
550 memcpy(&SCpnt->request, req, sizeof(struct request));
551 tablesize = scsi_devices[index].host->sg_tablesize;
552 bh = req->bh;
553 if(!tablesize) bh = NULL;
554
555
556 while(req->nr_sectors && bh){
557 tablesize--;
558 req->nr_sectors -= bh->b_size >> 9;
559 req->sector += bh->b_size >> 9;
560 if(!tablesize) break;
561 bh = bh->b_reqnext;
562 };
563 if(req->nr_sectors && bh && bh->b_reqnext){
564 SCpnt->request.bhtail = bh;
565 req->bh = bh->b_reqnext;
566 bh->b_reqnext = NULL;
567 bh = req->bh;
568
569
570 SCpnt->request.nr_sectors -= req->nr_sectors;
571 req->current_nr_sectors = bh->b_size >> 9;
572 req->buffer = bh->b_data;
573 SCpnt->request.waiting = NULL;
574 } else
575 req->dev = -1;
576
577 } else {
578 SCpnt->request.dev = 0xffff;
579 SCpnt->request.waiting = NULL;
580 };
581
582 SCpnt->use_sg = 0;
583 SCpnt->old_use_sg = 0;
584 SCpnt->transfersize = 0;
585 SCpnt->underflow = 0;
586 return SCpnt;
587 }
588
589
590
591
592
593
594
595
596
597
598 Scsi_Cmnd * allocate_device (struct request ** reqp, int index, int wait)
599 {
600 int dev = -1;
601 struct request * req = NULL;
602 int tablesize;
603 struct buffer_head * bh;
604 struct Scsi_Host * host;
605 Scsi_Cmnd * SCpnt = NULL;
606 Scsi_Cmnd * SCwait = NULL;
607
608 if ((index < 0) || (index > NR_SCSI_DEVICES))
609 panic ("Index number in allocate_device() is out of range.\n");
610
611 if (reqp) req = *reqp;
612
613
614 if (req && (dev = req->dev) <= 0) return NULL;
615
616 host = scsi_devices[index].host;
617
618 while (1==1){
619 SCpnt = host->host_queue;
620 while(SCpnt){
621 if(SCpnt->target == scsi_devices[index].id &&
622 SCpnt->lun == scsi_devices[index].lun) {
623 SCwait = SCpnt;
624 if(SCpnt->request.dev < 0) break;
625 };
626 SCpnt = SCpnt->next;
627 };
628 cli();
629
630 if (req && ((req->dev < 0) || (req->dev != dev))) {
631 sti();
632 return NULL;
633 };
634 if (!SCpnt || SCpnt->request.dev >= 0)
635 {
636 sti();
637 if(!wait) return NULL;
638 if (!SCwait) {
639 printk("Attempt to allocate device index %d, target %d, lun %d\n",
640 index, scsi_devices[index].id ,scsi_devices[index].lun);
641 panic("No device found in allocate_device\n");
642 };
643 SCSI_SLEEP(&scsi_devices[SCwait->index].device_wait,
644 (SCwait->request.dev > 0));
645 } else {
646 if (req) {
647 memcpy(&SCpnt->request, req, sizeof(struct request));
648 tablesize = scsi_devices[index].host->sg_tablesize;
649 bh = req->bh;
650 if(!tablesize) bh = NULL;
651
652
653 while(req->nr_sectors && bh){
654 tablesize--;
655 req->nr_sectors -= bh->b_size >> 9;
656 req->sector += bh->b_size >> 9;
657 if(!tablesize) break;
658 bh = bh->b_reqnext;
659 };
660 if(req->nr_sectors && bh && bh->b_reqnext){
661 SCpnt->request.bhtail = bh;
662 req->bh = bh->b_reqnext;
663 bh->b_reqnext = NULL;
664 bh = req->bh;
665
666 SCpnt->request.nr_sectors -= req->nr_sectors;
667 req->current_nr_sectors = bh->b_size >> 9;
668 req->buffer = bh->b_data;
669 SCpnt->request.waiting = NULL;
670 }
671 else
672 {
673 req->dev = -1;
674 *reqp = req->next;
675 };
676 } else {
677 SCpnt->request.dev = 0xffff;
678 SCpnt->request.waiting = NULL;
679 };
680 sti();
681 break;
682 };
683 };
684
685 SCpnt->use_sg = 0;
686 SCpnt->old_use_sg = 0;
687 SCpnt->transfersize = 0;
688 SCpnt->underflow = 0;
689 return SCpnt;
690 }
691
692
693
694
695
696 inline void internal_cmnd (Scsi_Cmnd * SCpnt)
697 {
698 int temp;
699 struct Scsi_Host * host;
700 #ifdef DEBUG_DELAY
701 int clock;
702 #endif
703
704 if ((unsigned long) &SCpnt < current->kernel_stack_page)
705 panic("Kernel stack overflow.");
706
707 host = SCpnt->host;
708
709
710
711
712
713 temp = host->last_reset;
714 while (jiffies < temp);
715
716 update_timeout(SCpnt, SCpnt->timeout_per_command);
717
718
719
720
721
722 #ifdef DEBUG
723 printk("internal_cmnd (host = %d, target = %d, command = %08x, buffer = %08x, \n"
724 "bufflen = %d, done = %08x)\n", SCpnt->host->host_no, SCpnt->target, SCpnt->cmnd, SCpnt->buffer, SCpnt->bufflen, SCpnt->done);
725 #endif
726
727 if (host->hostt->can_queue)
728 {
729 #ifdef DEBUG
730 printk("queuecommand : routine at %08x\n",
731 host->hostt->queuecommand);
732 #endif
733 host->hostt->queuecommand (SCpnt, scsi_done);
734 }
735 else
736 {
737
738 #ifdef DEBUG
739 printk("command() : routine at %08x\n", host->hostt->command);
740 #endif
741 temp=host->hostt->command (SCpnt);
742 SCpnt->result = temp;
743 #ifdef DEBUG_DELAY
744 clock = jiffies + 400;
745 while (jiffies < clock);
746 printk("done(host = %d, result = %04x) : routine at %08x\n", host->host_no, temp, done);
747 #endif
748 scsi_done(SCpnt);
749 }
750 #ifdef DEBUG
751 printk("leaving internal_cmnd()\n");
752 #endif
753 }
754
755 static void scsi_request_sense (Scsi_Cmnd * SCpnt)
756 {
757 cli();
758 SCpnt->flags |= WAS_SENSE | ASKED_FOR_SENSE;
759 update_timeout(SCpnt, SENSE_TIMEOUT);
760 sti();
761
762
763 memcpy ((void *) SCpnt->cmnd , (void *) generic_sense,
764 sizeof(generic_sense));
765
766 SCpnt->cmnd[1] = SCpnt->lun << 5;
767 SCpnt->cmnd[4] = sizeof(SCpnt->sense_buffer);
768
769 SCpnt->request_buffer = &SCpnt->sense_buffer;
770 SCpnt->request_bufflen = sizeof(SCpnt->sense_buffer);
771 SCpnt->use_sg = 0;
772 internal_cmnd (SCpnt);
773 SCpnt->use_sg = SCpnt->old_use_sg;
774 }
775
776
777
778
779
780
781
782
783
784
785 void scsi_do_cmd (Scsi_Cmnd * SCpnt, const void *cmnd ,
786 void *buffer, unsigned bufflen, void (*done)(Scsi_Cmnd *),
787 int timeout, int retries
788 )
789 {
790 struct Scsi_Host * host = SCpnt->host;
791
792 #ifdef DEBUG
793 {
794 int i;
795 int target = SCpnt->target;
796 printk ("scsi_do_cmd (host = %d, target = %d, buffer =%08x, "
797 "bufflen = %d, done = %08x, timeout = %d, retries = %d)\n"
798 "command : " , host->host_no, target, buffer, bufflen, done, timeout, retries);
799 for (i = 0; i < 10; ++i)
800 printk ("%02x ", ((unsigned char *) cmnd)[i]);
801 printk("\n");
802 };
803 #endif
804
805 if (!host)
806 {
807 panic ("Invalid or not present host. %d\n", host->host_no);
808 }
809
810
811
812
813
814
815
816
817
818
819 while (1==1){
820 cli();
821 if (host->hostt->can_queue
822 && host->host_busy >= host->hostt->can_queue)
823 {
824 sti();
825 SCSI_SLEEP(&host->host_wait,
826 (host->host_busy >= host->hostt->can_queue));
827 } else {
828 host->host_busy++;
829 sti();
830 break;
831 };
832 };
833
834
835
836
837
838
839
840
841 memcpy ((void *) SCpnt->data_cmnd , (void *) cmnd, 12);
842 #if 0
843 SCpnt->host = host;
844 SCpnt->target = target;
845 SCpnt->lun = (SCpnt->data_cmnd[1] >> 5);
846 #endif
847 SCpnt->bufflen = bufflen;
848 SCpnt->buffer = buffer;
849 SCpnt->flags=0;
850 SCpnt->retries=0;
851 SCpnt->allowed=retries;
852 SCpnt->done = done;
853 SCpnt->timeout_per_command = timeout;
854
855 memcpy ((void *) SCpnt->cmnd , (void *) cmnd, 12);
856
857
858 memset ((void *) SCpnt->sense_buffer, 0, sizeof SCpnt->sense_buffer);
859 SCpnt->request_buffer = buffer;
860 SCpnt->request_bufflen = bufflen;
861 SCpnt->old_use_sg = SCpnt->use_sg;
862
863
864
865 SCpnt->internal_timeout = 0;
866 internal_cmnd (SCpnt);
867
868 #ifdef DEBUG
869 printk ("Leaving scsi_do_cmd()\n");
870 #endif
871 }
872
873
874
875
876
877
878
879
880
881 static void reset (Scsi_Cmnd * SCpnt)
882 {
883 #ifdef DEBUG
884 printk("scsi: reset(%d)\n", SCpnt->host->host_no);
885 #endif
886
887 SCpnt->flags |= (WAS_RESET | IS_RESETTING);
888 scsi_reset(SCpnt);
889
890 #ifdef DEBUG
891 printk("performing request sense\n");
892 #endif
893
894 if(SCpnt->flags & NEEDS_JUMPSTART) {
895 SCpnt->flags &= ~NEEDS_JUMPSTART;
896 scsi_request_sense (SCpnt);
897 };
898 }
899
900
901
902 static int check_sense (Scsi_Cmnd * SCpnt)
903 {
904
905
906
907 if (((SCpnt->sense_buffer[0] & 0x70) >> 4) != 7) {
908 if(!(SCpnt->flags & ASKED_FOR_SENSE))
909 return SUGGEST_SENSE;
910 else
911 return SUGGEST_RETRY;
912 }
913
914 SCpnt->flags &= ~ASKED_FOR_SENSE;
915
916 #ifdef DEBUG_INIT
917 printk("scsi%d : ", SCpnt->host->host_no);
918 print_sense("", SCpnt);
919 printk("\n");
920 #endif
921 if (SCpnt->sense_buffer[2] &0xe0)
922 return SUGGEST_ABORT;
923
924 switch (SCpnt->sense_buffer[2] & 0xf)
925 {
926 case NO_SENSE:
927 return 0;
928 case RECOVERED_ERROR:
929 if (scsi_devices[SCpnt->index].type == TYPE_TAPE)
930 return SUGGEST_IS_OK;
931 else
932 return 0;
933
934 case ABORTED_COMMAND:
935 return SUGGEST_RETRY;
936 case NOT_READY:
937 case UNIT_ATTENTION:
938 return SUGGEST_ABORT;
939
940
941 case COPY_ABORTED:
942 case VOLUME_OVERFLOW:
943 case MISCOMPARE:
944
945 case MEDIUM_ERROR:
946 return SUGGEST_REMAP;
947 case BLANK_CHECK:
948 case DATA_PROTECT:
949 case HARDWARE_ERROR:
950 case ILLEGAL_REQUEST:
951 default:
952 return SUGGEST_ABORT;
953 }
954 }
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977 static void scsi_done (Scsi_Cmnd * SCpnt)
978 {
979 int status=0;
980 int exit=0;
981 int checked;
982 int oldto;
983 struct Scsi_Host * host = SCpnt->host;
984 int result = SCpnt->result;
985 oldto = update_timeout(SCpnt, 0);
986
987 #define FINISHED 0
988 #define MAYREDO 1
989 #define REDO 3
990 #define PENDING 4
991
992 #ifdef DEBUG
993 printk("In scsi_done(host = %d, result = %06x)\n", host->host_no, result);
994 #endif
995 switch (host_byte(result))
996 {
997 case DID_OK:
998 if (SCpnt->flags & IS_RESETTING)
999 {
1000 SCpnt->flags &= ~IS_RESETTING;
1001 status = REDO;
1002 break;
1003 }
1004
1005 if (status_byte(result) && (SCpnt->flags & WAS_SENSE))
1006
1007 {
1008 SCpnt->flags &= ~WAS_SENSE;
1009 SCpnt->internal_timeout &= ~SENSE_TIMEOUT;
1010
1011 if (!(SCpnt->flags & WAS_RESET))
1012 {
1013 printk("scsi%d : target %d lun %d request sense failed, performing reset.\n",
1014 SCpnt->host->host_no, SCpnt->target, SCpnt->lun);
1015 reset(SCpnt);
1016 return;
1017 }
1018 else
1019 {
1020 exit = (DRIVER_HARD | SUGGEST_ABORT);
1021 status = FINISHED;
1022 }
1023 }
1024 else switch(msg_byte(result))
1025 {
1026 case COMMAND_COMPLETE:
1027 switch (status_byte(result))
1028 {
1029 case GOOD:
1030 if (SCpnt->flags & WAS_SENSE)
1031 {
1032 #ifdef DEBUG
1033 printk ("In scsi_done, GOOD status, COMMAND COMPLETE, parsing sense information.\n");
1034 #endif
1035
1036 SCpnt->flags &= ~WAS_SENSE;
1037 SCpnt->internal_timeout &= ~SENSE_TIMEOUT;
1038
1039 switch (checked = check_sense(SCpnt))
1040 {
1041 case SUGGEST_SENSE:
1042 case 0:
1043 #ifdef DEBUG
1044 printk("NO SENSE. status = REDO\n");
1045 #endif
1046
1047 update_timeout(SCpnt, oldto);
1048 status = REDO;
1049 break;
1050 case SUGGEST_IS_OK:
1051 break;
1052 case SUGGEST_REMAP:
1053 case SUGGEST_RETRY:
1054 #ifdef DEBUG
1055 printk("SENSE SUGGEST REMAP or SUGGEST RETRY - status = MAYREDO\n");
1056 #endif
1057
1058 status = MAYREDO;
1059 exit = DRIVER_SENSE | SUGGEST_RETRY;
1060 break;
1061 case SUGGEST_ABORT:
1062 #ifdef DEBUG
1063 printk("SENSE SUGGEST ABORT - status = FINISHED");
1064 #endif
1065
1066 status = FINISHED;
1067 exit = DRIVER_SENSE | SUGGEST_ABORT;
1068 break;
1069 default:
1070 printk ("Internal error %s %d \n", __FILE__,
1071 __LINE__);
1072 }
1073 }
1074 else
1075 {
1076 #ifdef DEBUG
1077 printk("COMMAND COMPLETE message returned, status = FINISHED. \n");
1078 #endif
1079
1080 exit = DRIVER_OK;
1081 status = FINISHED;
1082 }
1083 break;
1084
1085 case CHECK_CONDITION:
1086 switch (check_sense(SCpnt))
1087 {
1088 case 0:
1089 update_timeout(SCpnt, oldto);
1090 status = REDO;
1091 break;
1092 case SUGGEST_REMAP:
1093 case SUGGEST_RETRY:
1094 status = MAYREDO;
1095 exit = DRIVER_SENSE | SUGGEST_RETRY;
1096 break;
1097 case SUGGEST_ABORT:
1098 status = FINISHED;
1099 exit = DRIVER_SENSE | SUGGEST_ABORT;
1100 break;
1101 case SUGGEST_SENSE:
1102 scsi_request_sense (SCpnt);
1103 status = PENDING;
1104 break;
1105 }
1106 break;
1107
1108 case CONDITION_GOOD:
1109 case INTERMEDIATE_GOOD:
1110 case INTERMEDIATE_C_GOOD:
1111 break;
1112
1113 case BUSY:
1114 update_timeout(SCpnt, oldto);
1115 status = REDO;
1116 break;
1117
1118 case RESERVATION_CONFLICT:
1119 printk("scsi%d : RESERVATION CONFLICT performing reset.\n",
1120 SCpnt->host->host_no);
1121 reset(SCpnt);
1122 return;
1123 #if 0
1124 exit = DRIVER_SOFT | SUGGEST_ABORT;
1125 status = MAYREDO;
1126 break;
1127 #endif
1128 default:
1129 printk ("Internal error %s %d \n"
1130 "status byte = %d \n", __FILE__,
1131 __LINE__, status_byte(result));
1132
1133 }
1134 break;
1135 default:
1136 panic("scsi: unsupported message byte %d recieved\n", msg_byte(result));
1137 }
1138 break;
1139 case DID_TIME_OUT:
1140 #ifdef DEBUG
1141 printk("Host returned DID_TIME_OUT - ");
1142 #endif
1143
1144 if (SCpnt->flags & WAS_TIMEDOUT)
1145 {
1146 #ifdef DEBUG
1147 printk("Aborting\n");
1148 #endif
1149 exit = (DRIVER_TIMEOUT | SUGGEST_ABORT);
1150 }
1151 else
1152 {
1153 #ifdef DEBUG
1154 printk ("Retrying.\n");
1155 #endif
1156 SCpnt->flags |= WAS_TIMEDOUT;
1157 status = REDO;
1158 }
1159 break;
1160 case DID_BUS_BUSY:
1161 case DID_PARITY:
1162 status = REDO;
1163 break;
1164 case DID_NO_CONNECT:
1165 #ifdef DEBUG
1166 printk("Couldn't connect.\n");
1167 #endif
1168 exit = (DRIVER_HARD | SUGGEST_ABORT);
1169 break;
1170 case DID_ERROR:
1171 status = MAYREDO;
1172 exit = (DRIVER_HARD | SUGGEST_ABORT);
1173 break;
1174 case DID_BAD_TARGET:
1175 case DID_ABORT:
1176 exit = (DRIVER_INVALID | SUGGEST_ABORT);
1177 break;
1178 case DID_RESET:
1179 if(msg_byte(result) == GOOD &&
1180 status_byte(result) == CHECK_CONDITION) {
1181 switch (check_sense(SCpnt)) {
1182 case 0:
1183 update_timeout(SCpnt, oldto);
1184 status = REDO;
1185 break;
1186 case SUGGEST_REMAP:
1187 case SUGGEST_RETRY:
1188 status = MAYREDO;
1189 exit = DRIVER_SENSE | SUGGEST_RETRY;
1190 break;
1191 case SUGGEST_ABORT:
1192 status = FINISHED;
1193 exit = DRIVER_SENSE | SUGGEST_ABORT;
1194 break;
1195 case SUGGEST_SENSE:
1196 scsi_request_sense (SCpnt);
1197 status = PENDING;
1198 break;
1199 }
1200 } else {
1201 status=REDO;
1202 exit = SUGGEST_RETRY;
1203 }
1204 break;
1205 default :
1206 exit = (DRIVER_ERROR | SUGGEST_DIE);
1207 }
1208
1209 switch (status)
1210 {
1211 case FINISHED:
1212 case PENDING:
1213 break;
1214 case MAYREDO:
1215
1216 #ifdef DEBUG
1217 printk("In MAYREDO, allowing %d retries, have %d\n",
1218 SCpnt->allowed, SCpnt->retries);
1219 #endif
1220
1221 if ((++SCpnt->retries) < SCpnt->allowed)
1222 {
1223 if ((SCpnt->retries >= (SCpnt->allowed >> 1))
1224 && !(SCpnt->flags & WAS_RESET))
1225 {
1226 printk("scsi%d : reseting for second half of retries.\n",
1227 SCpnt->host->host_no);
1228 reset(SCpnt);
1229 break;
1230 }
1231
1232 }
1233 else
1234 {
1235 status = FINISHED;
1236 break;
1237 }
1238
1239
1240 case REDO:
1241 if (SCpnt->flags & WAS_SENSE)
1242 scsi_request_sense(SCpnt);
1243 else
1244 {
1245 memcpy ((void *) SCpnt->cmnd,
1246 (void*) SCpnt->data_cmnd,
1247 sizeof(SCpnt->data_cmnd));
1248 SCpnt->request_buffer = SCpnt->buffer;
1249 SCpnt->request_bufflen = SCpnt->bufflen;
1250 SCpnt->use_sg = SCpnt->old_use_sg;
1251 internal_cmnd (SCpnt);
1252 };
1253 break;
1254 default:
1255 INTERNAL_ERROR;
1256 }
1257
1258 if (status == FINISHED)
1259 {
1260 #ifdef DEBUG
1261 printk("Calling done function - at address %08x\n", SCpnt->done);
1262 #endif
1263 host->host_busy--;
1264 wake_up(&host->host_wait);
1265 SCpnt->result = result | ((exit & 0xff) << 24);
1266 SCpnt->use_sg = SCpnt->old_use_sg;
1267 SCpnt->done (SCpnt);
1268 }
1269
1270
1271 #undef FINISHED
1272 #undef REDO
1273 #undef MAYREDO
1274 #undef PENDING
1275 }
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293 int scsi_abort (Scsi_Cmnd * SCpnt, int why)
1294 {
1295 int temp, oldto;
1296 struct Scsi_Host * host = SCpnt->host;
1297
1298 while(1)
1299 {
1300 cli();
1301 if (SCpnt->internal_timeout & IN_ABORT)
1302 {
1303 sti();
1304 while (SCpnt->internal_timeout & IN_ABORT);
1305 }
1306 else
1307 {
1308 SCpnt->internal_timeout |= IN_ABORT;
1309 oldto = update_timeout(SCpnt, ABORT_TIMEOUT);
1310
1311
1312 sti();
1313 if (!host->host_busy || !host->hostt->abort(SCpnt, why))
1314 temp = 0;
1315 else
1316 temp = 1;
1317
1318 cli();
1319 SCpnt->internal_timeout &= ~IN_ABORT;
1320 update_timeout(SCpnt, oldto);
1321 sti();
1322 return temp;
1323 }
1324 }
1325 }
1326
1327 int scsi_reset (Scsi_Cmnd * SCpnt)
1328 {
1329 int temp, oldto;
1330 Scsi_Cmnd * SCpnt1;
1331 struct Scsi_Host * host = SCpnt->host;
1332
1333 #ifdef DEBUG
1334 printk("Danger Will Robinson! - SCSI bus for host %d is being reset.\n",host->host_no);
1335 #endif
1336 while (1) {
1337 cli();
1338 if (SCpnt->internal_timeout & IN_RESET)
1339 {
1340 sti();
1341 while (SCpnt->internal_timeout & IN_RESET);
1342 }
1343 else
1344 {
1345 SCpnt->internal_timeout |= IN_RESET;
1346 oldto = update_timeout(SCpnt, RESET_TIMEOUT);
1347
1348 if (host->host_busy)
1349 {
1350 sti();
1351 SCpnt1 = host->host_queue;
1352 while(SCpnt1) {
1353 if ((SCpnt1->request.dev > 0) &&
1354 !(SCpnt1->flags & IS_RESETTING) &&
1355 !(SCpnt1->internal_timeout & IN_ABORT))
1356 scsi_abort(SCpnt1, DID_RESET);
1357 SCpnt1 = SCpnt1->next;
1358 };
1359
1360 temp = host->hostt->reset(SCpnt);
1361 }
1362 else
1363 {
1364 host->host_busy++;
1365
1366 sti();
1367 temp = host->hostt->reset(SCpnt);
1368 host->last_reset = jiffies;
1369 host->host_busy--;
1370 }
1371
1372 cli();
1373 SCpnt->internal_timeout &= ~IN_RESET;
1374 update_timeout(SCpnt, oldto);
1375 sti();
1376 return temp;
1377 }
1378 }
1379 }
1380
1381
1382 static void scsi_main_timeout(void)
1383 {
1384
1385
1386
1387
1388 int timed_out;
1389 struct Scsi_Host * host;
1390 Scsi_Cmnd * SCpnt = NULL;
1391
1392 do {
1393 cli();
1394
1395
1396
1397
1398
1399
1400 timed_out = 0;
1401 for(host = scsi_hostlist; host; host = host->next) {
1402 SCpnt = host->host_queue;
1403 while (SCpnt){
1404 if (SCpnt->timeout > 0 && SCpnt->timeout <= time_elapsed)
1405 {
1406 sti();
1407 SCpnt->timeout = 0;
1408 scsi_times_out(SCpnt);
1409 ++timed_out;
1410 cli();
1411 }
1412 SCpnt = SCpnt->next;
1413 };
1414 };
1415 update_timeout(NULL, 0);
1416 } while (timed_out);
1417 sti();
1418 }
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428 static int update_timeout(Scsi_Cmnd * SCset, int timeout)
1429 {
1430 unsigned int least, used;
1431 unsigned int oldto;
1432 struct Scsi_Host * host;
1433 Scsi_Cmnd * SCpnt = NULL;
1434
1435 cli();
1436
1437
1438
1439
1440
1441 used = (time_start) ? (jiffies - time_start) : 0;
1442
1443
1444
1445
1446
1447
1448
1449 oldto = 0;
1450
1451 if(SCset){
1452 oldto = SCset->timeout - used;
1453 SCset->timeout = timeout + used;
1454 };
1455
1456 least = 0xffffffff;
1457
1458 for(host = scsi_hostlist; host; host = host->next) {
1459 SCpnt = host->host_queue;
1460 while (SCpnt){
1461 if (SCpnt->timeout > 0 && (SCpnt->timeout -= used) < least)
1462 least = SCpnt->timeout;
1463 SCpnt = SCpnt->next;
1464 };
1465 };
1466
1467
1468
1469
1470
1471
1472 if (least != 0xffffffff)
1473 {
1474 time_start = jiffies;
1475 timer_table[SCSI_TIMER].expires = (time_elapsed = least) + jiffies;
1476 timer_active |= 1 << SCSI_TIMER;
1477 }
1478 else
1479 {
1480 timer_table[SCSI_TIMER].expires = time_start = time_elapsed = 0;
1481 timer_active &= ~(1 << SCSI_TIMER);
1482 }
1483 sti();
1484 return oldto;
1485 }
1486
1487
1488 static unsigned short * dma_malloc_freelist = NULL;
1489 static unsigned int dma_sectors = 0;
1490 unsigned int dma_free_sectors = 0;
1491 unsigned int need_isa_buffer = 0;
1492 static unsigned char * dma_malloc_buffer = NULL;
1493
1494 void *scsi_malloc(unsigned int len)
1495 {
1496 unsigned int nbits, mask;
1497 int i, j;
1498 if((len & 0x1ff) || len > 4096)
1499 panic("Inappropriate buffer size requested");
1500
1501 cli();
1502 nbits = len >> 9;
1503 mask = (1 << nbits) - 1;
1504
1505 for(i=0;i < (dma_sectors >> 4); i++)
1506 for(j=0; j<17-nbits; j++){
1507 if ((dma_malloc_freelist[i] & (mask << j)) == 0){
1508 dma_malloc_freelist[i] |= (mask << j);
1509 sti();
1510 dma_free_sectors -= nbits;
1511 #ifdef DEBUG
1512 printk("SMalloc: %d %x ",len, dma_malloc_buffer + (i << 13) + (j << 9));
1513 #endif
1514 return (void *) ((unsigned long) dma_malloc_buffer + (i << 13) + (j << 9));
1515 };
1516 };
1517 sti();
1518 return NULL;
1519 }
1520
1521 int scsi_free(void *obj, unsigned int len)
1522 {
1523 int offset;
1524 int page, sector, nbits, mask;
1525
1526 #ifdef DEBUG
1527 printk("Sfree %x %d\n",obj, len);
1528 #endif
1529
1530 offset = ((int) obj) - ((int) dma_malloc_buffer);
1531
1532 if (offset < 0) panic("Bad offset");
1533 page = offset >> 13;
1534 sector = offset >> 9;
1535 if(sector >= dma_sectors) panic ("Bad page");
1536
1537 sector = (offset >> 9) & 15;
1538 nbits = len >> 9;
1539 mask = (1 << nbits) - 1;
1540
1541 if ((mask << sector) > 0xffff) panic ("Bad memory alignment");
1542
1543 cli();
1544 if(dma_malloc_freelist[page] & (mask << sector) != (mask<<sector))
1545 panic("Trying to free unused memory");
1546
1547 dma_free_sectors += nbits;
1548 dma_malloc_freelist[page] &= ~(mask << sector);
1549 sti();
1550 return 0;
1551 }
1552
1553
1554
1555
1556
1557
1558
1559 unsigned long scsi_dev_init (unsigned long memory_start,unsigned long memory_end)
1560 {
1561 int i;
1562 struct Scsi_Host * host;
1563 Scsi_Cmnd * SCpnt;
1564 #ifdef FOO_ON_YOU
1565 return;
1566 #endif
1567 timer_table[SCSI_TIMER].fn = scsi_main_timeout;
1568 timer_table[SCSI_TIMER].expires = 0;
1569
1570
1571 memory_start = scsi_init(memory_start, memory_end);
1572
1573 scsi_devices = (Scsi_Device *) memory_start;
1574 scan_scsis();
1575 memory_start += NR_SCSI_DEVICES * sizeof(Scsi_Device);
1576
1577 memory_start = sd_init1(memory_start, memory_end);
1578 memory_start = st_init1(memory_start, memory_end);
1579 memory_start = sr_init1(memory_start, memory_end);
1580 memory_start = sg_init1(memory_start, memory_end);
1581
1582 last_cmnd = (Scsi_Cmnd *) memory_start;
1583
1584 SCpnt = last_cmnd;
1585
1586 for (i=0; i< NR_SCSI_DEVICES; i++) {
1587 int j;
1588 switch (scsi_devices[i].type)
1589 {
1590 case TYPE_TAPE :
1591 st_attach(&scsi_devices[i]);
1592 break;
1593 case TYPE_ROM:
1594 sr_attach(&scsi_devices[i]);
1595 break;
1596 case TYPE_DISK:
1597 case TYPE_MOD:
1598 sd_attach(&scsi_devices[i]);
1599 default:
1600 break;
1601 };
1602 sg_attach(&scsi_devices[i]);
1603 if(scsi_devices[i].type != -1){
1604 for(j=0;j<scsi_devices[i].host->hostt->cmd_per_lun;j++){
1605 SCpnt->host = scsi_devices[i].host;
1606 SCpnt->target = scsi_devices[i].id;
1607 SCpnt->lun = scsi_devices[i].lun;
1608 SCpnt->index = i;
1609 SCpnt->request.dev = -1;
1610 SCpnt->use_sg = 0;
1611 SCpnt->old_use_sg = 0;
1612 SCpnt->underflow = 0;
1613 SCpnt->transfersize = 0;
1614 SCpnt->host_scribble = NULL;
1615 host = scsi_devices[i].host;
1616 if(host->host_queue)
1617 host->host_queue->prev = SCpnt;
1618 SCpnt->next = host->host_queue;
1619 SCpnt->prev = NULL;
1620 host->host_queue = SCpnt;
1621 SCpnt++;
1622 };
1623 };
1624 };
1625
1626 memory_start = (int) SCpnt;
1627
1628 if (NR_SD > 0 || NR_SR > 0 || NR_ST > 0)
1629 dma_sectors = 16;
1630
1631 for (i = 0; i < NR_SCSI_DEVICES; ++i) {
1632 struct Scsi_Host * host;
1633 host = scsi_devices[i].host;
1634
1635 if(scsi_devices[i].type != TYPE_TAPE)
1636 dma_sectors += ((host->sg_tablesize *
1637 sizeof(struct scatterlist) + 511) >> 9) *
1638 host->hostt->cmd_per_lun;
1639
1640 if(host->unchecked_isa_dma &&
1641 memory_end > ISA_DMA_THRESHOLD &&
1642 scsi_devices[i].type != TYPE_TAPE) {
1643 dma_sectors += (PAGE_SIZE >> 9) * host->sg_tablesize *
1644 host->hostt->cmd_per_lun;
1645 need_isa_buffer++;
1646 };
1647 };
1648
1649 dma_sectors = (dma_sectors + 15) & 0xfff0;
1650 dma_free_sectors = dma_sectors;
1651
1652 memory_start = (memory_start + 3) & 0xfffffffc;
1653 dma_malloc_freelist = (unsigned short *) memory_start;
1654 memory_start += dma_sectors >> 3;
1655 memset(dma_malloc_freelist, 0, dma_sectors >> 3);
1656
1657 if(memory_start & 1) memory_start++;
1658
1659 dma_malloc_buffer = (unsigned char *) memory_start;
1660 memory_start += dma_sectors << 9;
1661
1662 memory_start = sd_init(memory_start, memory_end);
1663 memory_start = st_init(memory_start, memory_end);
1664 memory_start = sr_init(memory_start, memory_end);
1665 memory_start = sg_init(memory_start, memory_end);
1666
1667 return memory_start;
1668 }
1669
1670 static void print_inquiry(unsigned char *data)
1671 {
1672 int i;
1673
1674 printk(" Vendor: ");
1675 for (i = 8; i < 16; i++)
1676 {
1677 if (data[i] >= 0x20 && i < data[4] + 5)
1678 printk("%c", data[i]);
1679 else
1680 printk(" ");
1681 }
1682
1683 printk(" Model: ");
1684 for (i = 16; i < 32; i++)
1685 {
1686 if (data[i] >= 0x20 && i < data[4] + 5)
1687 printk("%c", data[i]);
1688 else
1689 printk(" ");
1690 }
1691
1692 printk(" Rev: ");
1693 for (i = 32; i < 36; i++)
1694 {
1695 if (data[i] >= 0x20 && i < data[4] + 5)
1696 printk("%c", data[i]);
1697 else
1698 printk(" ");
1699 }
1700
1701 printk("\n");
1702
1703 i = data[0] & 0x1f;
1704
1705 printk(" Type: %s ",
1706 i < MAX_SCSI_DEVICE_CODE ? scsi_device_types[i] : "Unknown " );
1707 printk(" ANSI SCSI revision: %02x", data[2] & 0x07);
1708 if ((data[2] & 0x07) == 1 && (data[3] & 0x0f) == 1)
1709 printk(" CCS\n");
1710 else
1711 printk("\n");
1712 }