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