This source file includes following definitions.
- do_pause
- append_SC
- remove_first_SC
- remove_SC
- make_acklow
- getphase
- aha152x_setup
- aha152x_porttest
- aha152x_checksetup
- aha152x_detect
- aha152x_queue
- aha152x_command
- aha152x_abort
- aha152x_reset_ports
- aha152x_reset
- aha152x_biosparam
- aha152x_done
- aha152x_intr
- aha152x_panic
- disp_ports
- disp_enintr
- enter_driver
- leave_driver
- show_command
- show_queues
- aha152x_set_info
- get_command
- aha152x_proc_info
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230 #ifdef PCMCIA
231 #define MODULE
232 #endif
233
234 #include <linux/module.h>
235
236 #ifdef PCMCIA
237 #undef MODULE
238 #endif
239
240 #include <linux/sched.h>
241 #include <asm/io.h>
242 #include <linux/blk.h>
243 #include "scsi.h"
244 #include "sd.h"
245 #include "hosts.h"
246 #include "constants.h"
247 #include <asm/system.h>
248 #include <linux/errno.h>
249 #include <linux/string.h>
250 #include <linux/wait.h>
251 #include <linux/ioport.h>
252 #include <linux/proc_fs.h>
253
254 #include "aha152x.h"
255 #include <linux/stat.h>
256
257 struct proc_dir_entry proc_scsi_aha152x = {
258 PROC_SCSI_AHA152X, 7, "aha152x",
259 S_IFDIR | S_IRUGO | S_IXUGO, 2
260 };
261
262
263
264
265 #if defined(PCMCIA) || defined(MODULE)
266 #if !defined(AUTOCONF)
267 #define AUTOCONF
268 #endif
269 #endif
270
271 #if !defined(AUTOCONF) && !defined(SETUP0)
272 #error define AUTOCONF or SETUP0
273 #endif
274
275 #if defined(DEBUG_AHA152X)
276
277 #undef SKIP_PORTS
278
279 #undef DEBUG_QUEUE
280 #undef DEBUG_RESET
281 #undef DEBUG_INTR
282 #undef DEBUG_SELECTION
283 #undef DEBUG_MSGO
284 #undef DEBUG_MSGI
285 #undef DEBUG_STATUS
286 #undef DEBUG_CMD
287 #undef DEBUG_DATAI
288 #undef DEBUG_DATAO
289 #undef DEBUG_ABORT
290 #undef DEBUG_DONE
291 #undef DEBUG_BIOSPARAM
292
293 #undef DEBUG_RACE
294 #undef DEBUG_PHASES
295 #undef DEBUG_QUEUES
296
297
298 #if 0
299 #endif
300
301 #define DEBUG_SELECTION
302 #define DEBUG_PHASES
303 #define DEBUG_RESET
304 #define DEBUG_ABORT
305
306 #define DEBUG_DEFAULT (debug_reset|debug_abort)
307
308 #endif
309
310
311
312 extern long loops_per_sec;
313
314 #define DELAY_DEFAULT 100
315
316
317 #define P_BUSFREE 1
318 #define P_PARITY 2
319
320
321 #define IRQ_MIN 9
322 #define IRQ_MAX 12
323 #define IRQS IRQ_MAX-IRQ_MIN+1
324
325 enum {
326 not_issued = 0x0001,
327 in_selection = 0x0002,
328 disconnected = 0x0004,
329 aborted = 0x0008,
330 sent_ident = 0x0010,
331 in_other = 0x0020,
332 in_sync = 0x0040,
333 sync_ok = 0x0080,
334 };
335
336
337 static int setup_count=0;
338 static struct aha152x_setup {
339 int io_port;
340 int irq;
341 int scsiid;
342 int reconnect;
343 int parity;
344 int synchronous;
345 int delay;
346 #ifdef DEBUG_AHA152X
347 int debug;
348 #endif
349 char *conf;
350 } setup[2];
351
352 static struct Scsi_Host *aha152x_host[IRQS];
353
354 #define HOSTDATA(shpnt) ((struct aha152x_hostdata *) &shpnt->hostdata)
355 #define CURRENT_SC (HOSTDATA(shpnt)->current_SC)
356 #define ISSUE_SC (HOSTDATA(shpnt)->issue_SC)
357 #define DISCONNECTED_SC (HOSTDATA(shpnt)->disconnected_SC)
358 #define DELAY (HOSTDATA(shpnt)->delay)
359 #define SYNCRATE (HOSTDATA(shpnt)->syncrate[CURRENT_SC->target])
360 #define MSG(i) (HOSTDATA(shpnt)->message[i])
361 #define MSGLEN (HOSTDATA(shpnt)->message_len)
362 #define ADDMSG(x) (MSG(MSGLEN++)=x)
363
364 struct aha152x_hostdata {
365 Scsi_Cmnd *issue_SC;
366 Scsi_Cmnd *current_SC;
367 Scsi_Cmnd *disconnected_SC;
368 int aborting;
369 int abortion_complete;
370 int abort_result;
371 int commands;
372
373 int reconnect;
374 int parity;
375 int synchronous;
376 int delay;
377
378 unsigned char syncrate[8];
379
380 unsigned char message[256];
381 int message_len;
382
383 #ifdef DEBUG_AHA152X
384 int debug;
385 #endif
386 };
387
388 void aha152x_intr(int irq, void *dev_id, struct pt_regs *);
389 void aha152x_done(struct Scsi_Host *shpnt, int error);
390 void aha152x_setup(char *str, int *ints);
391 int aha152x_checksetup(struct aha152x_setup *setup);
392
393 static void aha152x_reset_ports(struct Scsi_Host *shpnt);
394 static void aha152x_panic(struct Scsi_Host *shpnt, char *msg);
395
396 static void disp_ports(struct Scsi_Host *shpnt);
397 static void show_command(Scsi_Cmnd *ptr);
398 static void show_queues(struct Scsi_Host *shpnt);
399 static void disp_enintr(struct Scsi_Host *shpnt);
400
401 #if defined(DEBUG_RACE)
402 static void enter_driver(const char *);
403 static void leave_driver(const char *);
404 #endif
405
406
407 static unsigned short ports[] =
408 {
409 0x340,
410 0x140
411 };
412 #define PORT_COUNT (sizeof(ports) / sizeof(unsigned short))
413
414 #if !defined(SKIP_BIOSTEST)
415
416 static void *addresses[] =
417 {
418 (void *) 0xdc000,
419 (void *) 0xc8000,
420 (void *) 0xcc000,
421 (void *) 0xd0000,
422 (void *) 0xd4000,
423 (void *) 0xd8000,
424 (void *) 0xe0000,
425 (void *) 0xeb800,
426 (void *) 0xf0000,
427 };
428 #define ADDRESS_COUNT (sizeof(addresses) / sizeof(void *))
429
430
431
432
433
434
435
436
437 static struct signature {
438 char *signature;
439 int sig_offset;
440 int sig_length;
441 } signatures[] =
442 {
443 { "Adaptec AHA-1520 BIOS", 0x102e, 21 },
444 { "Adaptec ASW-B626 BIOS", 0x1029, 21 },
445 { "Adaptec BIOS: ASW-B626", 0x0f, 22 },
446 { "Adaptec ASW-B626 S2", 0x2e6c, 19 },
447 { "Adaptec BIOS:AIC-6360", 0xc, 21 },
448 { "ScsiPro SP-360 BIOS", 0x2873, 19 },
449 { "GA-400 LOCAL BUS SCSI BIOS", 0x102e, 26 },
450 { "Adaptec BIOS:AVA-282X", 0xc, 21 },
451 { "Adaptec IBM Dock II SCSI", 0x2edd, 24 },
452 { "Adaptec BIOS:AHA-1532P", 0x1c, 22 },
453 };
454 #define SIGNATURE_COUNT (sizeof(signatures) / sizeof(struct signature))
455 #endif
456
457
458 static void do_pause(unsigned amount)
459 {
460 unsigned long the_time = jiffies + amount;
461
462 while (jiffies < the_time)
463 barrier();
464 }
465
466
467
468
469 static inline void append_SC(Scsi_Cmnd **SC, Scsi_Cmnd *new_SC)
470 {
471 Scsi_Cmnd *end;
472
473 new_SC->host_scribble = (unsigned char *) NULL;
474 if(!*SC)
475 *SC=new_SC;
476 else
477 {
478 for(end=*SC; end->host_scribble; end = (Scsi_Cmnd *) end->host_scribble)
479 ;
480 end->host_scribble = (unsigned char *) new_SC;
481 }
482 }
483
484 static inline Scsi_Cmnd *remove_first_SC(Scsi_Cmnd **SC)
485 {
486 Scsi_Cmnd *ptr;
487
488 ptr=*SC;
489 if(ptr)
490 *SC= (Scsi_Cmnd *) (*SC)->host_scribble;
491 return ptr;
492 }
493
494 static inline Scsi_Cmnd *remove_SC(Scsi_Cmnd **SC, int target, int lun)
495 {
496 Scsi_Cmnd *ptr, *prev;
497
498 for(ptr=*SC, prev=NULL;
499 ptr && ((ptr->target!=target) || (ptr->lun!=lun));
500 prev = ptr, ptr = (Scsi_Cmnd *) ptr->host_scribble)
501 ;
502
503 if(ptr)
504 if(prev)
505 prev->host_scribble = ptr->host_scribble;
506 else
507 *SC= (Scsi_Cmnd *) ptr->host_scribble;
508 return ptr;
509 }
510
511
512
513
514 static void make_acklow(struct Scsi_Host *shpnt)
515 {
516 SETPORT(SXFRCTL0, CH1|SPIOEN);
517 GETPORT(SCSIDAT);
518 SETPORT(SXFRCTL0, CH1);
519
520 while(TESTHI(SCSISIG, ACKI))
521 barrier();
522 }
523
524
525
526
527
528
529
530
531
532
533
534 static int getphase(struct Scsi_Host *shpnt)
535 {
536 int phase, sstat1;
537
538 while(1)
539 {
540 do
541 {
542 while(!((sstat1 = GETPORT(SSTAT1)) & (BUSFREE|SCSIRSTI|REQINIT)))
543 barrier();
544 if(sstat1 & BUSFREE)
545 return P_BUSFREE;
546 if(sstat1 & SCSIRSTI)
547 {
548 printk("aha152x: RESET IN\n");
549 SETPORT(SSTAT1, SCSIRSTI);
550 }
551 }
552 while(TESTHI(SCSISIG, ACKI) || TESTLO(SSTAT1, REQINIT));
553
554 SETPORT(SSTAT1, CLRSCSIPERR);
555
556 phase = GETPORT(SCSISIG) & P_MASK ;
557
558 if(TESTHI(SSTAT1, SCSIPERR))
559 {
560 if((phase & (CDO|MSGO))==0)
561 return P_PARITY;
562
563 make_acklow(shpnt);
564 }
565 else
566 return phase;
567 }
568 }
569
570
571 void aha152x_setup(char *str, int *ints)
572 {
573 if(setup_count>2)
574 panic("aha152x: you can only configure up to two controllers\n");
575
576 setup[setup_count].conf = str;
577 setup[setup_count].io_port = ints[0] >= 1 ? ints[1] : 0x340;
578 setup[setup_count].irq = ints[0] >= 2 ? ints[2] : 11;
579 setup[setup_count].scsiid = ints[0] >= 3 ? ints[3] : 7;
580 setup[setup_count].reconnect = ints[0] >= 4 ? ints[4] : 1;
581 setup[setup_count].parity = ints[0] >= 5 ? ints[5] : 1;
582 setup[setup_count].synchronous = ints[0] >= 6 ? ints[6] : 0 ;
583 setup[setup_count].delay = ints[0] >= 7 ? ints[7] : DELAY_DEFAULT;
584 #ifdef DEBUG_AHA152X
585 setup[setup_count].debug = ints[0] >= 8 ? ints[8] : DEBUG_DEFAULT;
586 if(ints[0]>8)
587 {
588 printk("aha152x: usage: aha152x=<IOBASE>[,<IRQ>[,<SCSI ID>"
589 "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>[,<DEBUG>]]]]]]]\n");
590 #else
591 if(ints[0]>7)
592 {
593 printk("aha152x: usage: aha152x=<IOBASE>[,<IRQ>[,<SCSI ID>"
594 "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>]]]]]]\n");
595 #endif
596 }
597 else
598 setup_count++;
599 }
600
601
602
603
604 static int aha152x_porttest(int io_port)
605 {
606 int i;
607
608 if(check_region(io_port, IO_RANGE))
609 return 0;
610
611 SETPORT(io_port+O_DMACNTRL1, 0);
612 for(i=0; i<16; i++)
613 SETPORT(io_port+O_STACK, i);
614
615 SETPORT(io_port+O_DMACNTRL1, 0);
616 for(i=0; i<16 && GETPORT(io_port+O_STACK)==i; i++)
617 ;
618
619 return(i==16);
620 }
621
622 int aha152x_checksetup(struct aha152x_setup *setup)
623 {
624 int i;
625
626 #ifndef PCMCIA
627 for(i=0; i<PORT_COUNT && (setup->io_port != ports[i]); i++)
628 ;
629
630 if(i==PORT_COUNT)
631 return 0;
632 #endif
633
634 if(!aha152x_porttest(setup->io_port))
635 return 0;
636
637 if((setup->irq < IRQ_MIN) && (setup->irq > IRQ_MAX))
638 return 0;
639
640 if((setup->scsiid < 0) || (setup->scsiid > 7))
641 return 0;
642
643 if((setup->reconnect < 0) || (setup->reconnect > 1))
644 return 0;
645
646 if((setup->parity < 0) || (setup->parity > 1))
647 return 0;
648
649 if((setup->synchronous < 0) || (setup->synchronous > 1))
650 return 0;
651
652 return 1;
653 }
654
655
656 int aha152x_detect(Scsi_Host_Template * tpnt)
657 {
658 int i, j, ok;
659 #if defined(AUTOCONF)
660 aha152x_config conf;
661 #endif
662
663 tpnt->proc_dir = &proc_scsi_aha152x;
664
665 for(i=0; i<IRQS; i++)
666 aha152x_host[i] = (struct Scsi_Host *) NULL;
667
668 if(setup_count)
669 {
670 printk("aha152x: processing commandline: ");
671
672 for(i=0; i<setup_count; i++)
673 if(!aha152x_checksetup(&setup[i]))
674 {
675 printk("\naha152x: %s\n", setup[i].conf);
676 printk("aha152x: invalid line (controller=%d)\n", i+1);
677 }
678
679 printk("ok\n");
680 }
681
682 #ifdef SETUP0
683 if(setup_count<2)
684 {
685 struct aha152x_setup override = SETUP0;
686
687 if(setup_count==0 || (override.io_port != setup[0].io_port))
688 if(!aha152x_checksetup(&override))
689 {
690 printk("\naha152x: SETUP0 (0x%x, %d, %d, %d, %d, %d, %d) invalid\n",
691 override.io_port,
692 override.irq,
693 override.scsiid,
694 override.reconnect,
695 override.parity,
696 override.synchronous,
697 override.delay);
698 }
699 else
700 setup[setup_count++] = override;
701 }
702 #endif
703
704 #ifdef SETUP1
705 if(setup_count<2)
706 {
707 struct aha152x_setup override = SETUP1;
708
709 if(setup_count==0 || (override.io_port != setup[0].io_port))
710 if(!aha152x_checksetup(&override))
711 {
712 printk("\naha152x: SETUP1 (0x%x, %d, %d, %d, %d, %d, %d) invalid\n",
713 override.io_port,
714 override.irq,
715 override.scsiid,
716 override.reconnect,
717 override.parity,
718 override.synchronous,
719 override.delay);
720 }
721 else
722 setup[setup_count++] = override;
723 }
724 #endif
725
726 #if defined(AUTOCONF)
727 if(setup_count<2)
728 {
729 #if !defined(SKIP_BIOSTEST)
730 ok=0;
731 for(i=0; i < ADDRESS_COUNT && !ok; i++)
732 for(j=0; (j < SIGNATURE_COUNT) && !ok; j++)
733 ok=!memcmp((void *) addresses[i]+signatures[j].sig_offset,
734 (void *) signatures[j].signature,
735 (int) signatures[j].sig_length);
736
737 if(!ok && setup_count==0)
738 return 0;
739
740 printk("aha152x: BIOS test: passed, ");
741 #else
742 printk("aha152x: ");
743 #endif
744
745 for(i=0; i<PORT_COUNT && setup_count<2; i++)
746 {
747 if((setup_count==1) && (setup[0].io_port == ports[i]))
748 continue;
749
750 if(aha152x_porttest(ports[i]))
751 {
752 setup[setup_count].io_port = ports[i];
753
754 conf.cf_port =
755 (GETPORT(ports[i]+O_PORTA)<<8) + GETPORT(ports[i]+O_PORTB);
756
757 setup[setup_count].irq = IRQ_MIN + conf.cf_irq;
758 setup[setup_count].scsiid = conf.cf_id;
759 setup[setup_count].reconnect = conf.cf_tardisc;
760 setup[setup_count].parity = !conf.cf_parity;
761 setup[setup_count].synchronous = 0 ;
762 setup[setup_count].delay = DELAY_DEFAULT;
763 #ifdef DEBUG_AHA152X
764 setup[setup_count].debug = DEBUG_DEFAULT;
765 #endif
766 setup_count++;
767 }
768 }
769
770 printk("auto configuration: ok, ");
771 }
772 #endif
773
774 printk("detection complete\n");
775
776 for(i=0; i<setup_count; i++)
777 {
778 struct Scsi_Host *shpnt;
779
780 shpnt = aha152x_host[setup[i].irq-IRQ_MIN] =
781 scsi_register(tpnt, sizeof(struct aha152x_hostdata));
782
783 shpnt->io_port = setup[i].io_port;
784 shpnt->n_io_port = IO_RANGE;
785 shpnt->irq = setup[i].irq;
786
787 ISSUE_SC = (Scsi_Cmnd *) NULL;
788 CURRENT_SC = (Scsi_Cmnd *) NULL;
789 DISCONNECTED_SC = (Scsi_Cmnd *) NULL;
790
791 HOSTDATA(shpnt)->reconnect = setup[i].reconnect;
792 HOSTDATA(shpnt)->parity = setup[i].parity;
793 HOSTDATA(shpnt)->synchronous = setup[i].synchronous;
794 HOSTDATA(shpnt)->delay = setup[i].delay;
795 #ifdef DEBUG_AHA152X
796 HOSTDATA(shpnt)->debug = setup[i].debug;
797 #endif
798
799 HOSTDATA(shpnt)->aborting = 0;
800 HOSTDATA(shpnt)->abortion_complete = 0;
801 HOSTDATA(shpnt)->abort_result = 0;
802 HOSTDATA(shpnt)->commands = 0;
803
804 HOSTDATA(shpnt)->message_len = 0;
805
806 for(j=0; j<8; j++)
807 HOSTDATA(shpnt)->syncrate[j] = 0;
808
809 SETPORT(SCSIID, setup[i].scsiid << 4);
810 shpnt->this_id=setup[i].scsiid;
811
812 if(setup[i].reconnect)
813 shpnt->hostt->can_queue=AHA152X_MAXQUEUE;
814
815
816 SETBITS(SCSISEQ, SCSIRSTO);
817 do_pause(30);
818 CLRBITS(SCSISEQ, SCSIRSTO);
819 do_pause(setup[i].delay);
820
821 aha152x_reset_ports(shpnt);
822
823 printk("aha152x%d: vital data: PORTBASE=0x%03x, IRQ=%d, SCSI ID=%d,"
824 " reconnect=%s, parity=%s, synchronous=%s, delay=%d\n",
825 i,
826 shpnt->io_port,
827 shpnt->irq,
828 shpnt->this_id,
829 HOSTDATA(shpnt)->reconnect ? "enabled" : "disabled",
830 HOSTDATA(shpnt)->parity ? "enabled" : "disabled",
831 HOSTDATA(shpnt)->synchronous ? "enabled" : "disabled",
832 HOSTDATA(shpnt)->delay);
833
834 request_region(shpnt->io_port, IO_RANGE, "aha152x");
835
836
837 SETPORT(SIMODE0, 0);
838 SETPORT(SIMODE1, 0);
839
840 SETBITS(DMACNTRL0, INTEN);
841
842 ok = request_irq(setup[i].irq, aha152x_intr, SA_INTERRUPT, "aha152x", NULL);
843
844 if(ok<0)
845 {
846 if(ok == -EINVAL)
847 {
848 printk("aha152x%d: bad IRQ %d.\n", i, setup[i].irq);
849 printk(" Contact author.\n");
850 }
851 else
852 if(ok == -EBUSY)
853 printk("aha152x%d: IRQ %d already in use. Configure another.\n",
854 i, setup[i].irq);
855 else
856 {
857 printk("\naha152x%d: Unexpected error code on"
858 " requesting IRQ %d.\n", i, setup[i].irq);
859 printk(" Contact author.\n");
860 }
861 printk("aha152x: driver needs an IRQ.\n");
862 continue;
863 }
864 }
865
866 return (setup_count>0);
867 }
868
869
870
871
872 int aha152x_queue(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *))
873 {
874 struct Scsi_Host *shpnt = SCpnt->host;
875 unsigned long flags;
876
877 #if defined(DEBUG_RACE)
878 enter_driver("queue");
879 #else
880 #if defined(DEBUG_QUEUE)
881 if(HOSTDATA(shpnt)->debug & debug_queue)
882 printk("aha152x: queue(), ");
883 #endif
884 #endif
885
886 #if defined(DEBUG_QUEUE)
887 if(HOSTDATA(shpnt)->debug & debug_queue)
888 {
889 printk("SCpnt (target = %d lun = %d cmnd = ",
890 SCpnt->target, SCpnt->lun);
891 print_command(SCpnt->cmnd);
892 printk(", cmd_len=%d, pieces = %d size = %u), ",
893 SCpnt->cmd_len, SCpnt->use_sg, SCpnt->request_bufflen);
894 disp_ports(shpnt);
895 }
896 #endif
897
898 SCpnt->scsi_done = done;
899
900
901
902
903
904
905
906 SCpnt->SCp.phase = not_issued;
907 if (SCpnt->use_sg)
908 {
909 SCpnt->SCp.buffer =
910 (struct scatterlist *) SCpnt->request_buffer;
911 SCpnt->SCp.ptr = SCpnt->SCp.buffer->address;
912 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
913 SCpnt->SCp.buffers_residual = SCpnt->use_sg - 1;
914 }
915 else
916 {
917 SCpnt->SCp.ptr = (char *)SCpnt->request_buffer;
918 SCpnt->SCp.this_residual = SCpnt->request_bufflen;
919 SCpnt->SCp.buffer = NULL;
920 SCpnt->SCp.buffers_residual = 0;
921 }
922
923 SCpnt->SCp.Status = CHECK_CONDITION;
924 SCpnt->SCp.Message = 0;
925 SCpnt->SCp.have_data_in = 0;
926 SCpnt->SCp.sent_command = 0;
927
928
929 save_flags(flags);
930 cli();
931 HOSTDATA(shpnt)->commands++;
932 if(HOSTDATA(shpnt)->commands==1)
933 SETPORT(PORTA, 1);
934
935 #if defined(DEBUG_QUEUES)
936 if(HOSTDATA(shpnt)->debug & debug_queues)
937 printk("i+ (%d), ", HOSTDATA(shpnt)->commands);
938 #endif
939 append_SC(&ISSUE_SC, SCpnt);
940
941
942 if(!CURRENT_SC)
943 {
944 SETPORT(SIMODE0, DISCONNECTED_SC ? ENSELDI : 0);
945 SETPORT(SIMODE1, ISSUE_SC ? ENBUSFREE : 0);
946 }
947 restore_flags(flags);
948
949 #if defined(DEBUG_RACE)
950 leave_driver("queue");
951 #endif
952
953 return 0;
954 }
955
956
957
958
959 int aha152x_command(Scsi_Cmnd *SCpnt)
960 {
961 printk("aha152x: interrupt driven driver; use aha152x_queue()\n");
962 return -1;
963 }
964
965
966
967
968
969 int aha152x_abort(Scsi_Cmnd *SCpnt)
970 {
971 struct Scsi_Host *shpnt = SCpnt->host;
972 unsigned long flags;
973 Scsi_Cmnd *ptr, *prev;
974
975 save_flags(flags);
976 cli();
977
978 #if defined(DEBUG_ABORT)
979 if(HOSTDATA(shpnt)->debug & debug_abort)
980 {
981 printk("aha152x: abort(), SCpnt=0x%08x, ", (unsigned int) SCpnt);
982 show_queues(shpnt);
983 }
984 #endif
985
986
987 for(ptr=ISSUE_SC, prev=NULL;
988 ptr && ptr!=SCpnt;
989 prev=ptr, ptr=(Scsi_Cmnd *) ptr->host_scribble)
990 ;
991
992 if(ptr)
993 {
994
995 if(prev)
996 prev->host_scribble = ptr->host_scribble;
997 else
998 ISSUE_SC = (Scsi_Cmnd *) ptr->host_scribble;
999 restore_flags(flags);
1000
1001 ptr->host_scribble = NULL;
1002 ptr->result = DID_ABORT << 16;
1003 ptr->scsi_done(ptr);
1004 return SCSI_ABORT_SUCCESS;
1005 }
1006
1007
1008
1009 if (TESTLO(SSTAT1, BUSFREE) || (CURRENT_SC && CURRENT_SC!=SCpnt))
1010 {
1011
1012
1013 if(!CURRENT_SC)
1014 printk("bus busy w/o current command, ");
1015
1016 restore_flags(flags);
1017 return SCSI_ABORT_BUSY;
1018 }
1019
1020
1021
1022 if(CURRENT_SC)
1023 {
1024
1025 restore_flags(flags);
1026 CURRENT_SC->result = DID_ERROR << 16;
1027 CURRENT_SC->scsi_done(CURRENT_SC);
1028 CURRENT_SC = (Scsi_Cmnd *) NULL;
1029 return SCSI_ABORT_SUCCESS;
1030 }
1031
1032
1033 for(ptr=DISCONNECTED_SC, prev=NULL;
1034 ptr && ptr!=SCpnt;
1035 prev=ptr, ptr=(Scsi_Cmnd *) ptr->host_scribble)
1036 ;
1037
1038 if(ptr)
1039 if(!HOSTDATA(shpnt)->aborting)
1040 {
1041
1042 if(prev)
1043 prev->host_scribble = ptr->host_scribble;
1044 else
1045 DISCONNECTED_SC = (Scsi_Cmnd *) ptr->host_scribble;
1046
1047
1048
1049 CURRENT_SC = ptr;
1050 ptr->SCp.phase = in_selection|aborted;
1051 SETPORT(SCSIID, (shpnt->this_id << OID_) | CURRENT_SC->target);
1052
1053 ADDMSG(ABORT);
1054
1055
1056 SETPORT(SIMODE0, ENSELDO | (DISCONNECTED_SC ? ENSELDI : 0));
1057 SETPORT(SIMODE1, ENSELTIMO);
1058
1059
1060 SETBITS(SCSISEQ, ENSELO | ENAUTOATNO);
1061
1062 SETBITS(DMACNTRL0, INTEN);
1063 HOSTDATA(shpnt)->abort_result=SCSI_ABORT_SUCCESS;
1064 HOSTDATA(shpnt)->aborting++;
1065 HOSTDATA(shpnt)->abortion_complete=0;
1066
1067 sti();
1068
1069
1070 while(!HOSTDATA(shpnt)->abortion_complete)
1071 barrier();
1072 HOSTDATA(shpnt)->aborting=0;
1073 return HOSTDATA(shpnt)->abort_result;
1074 }
1075 else
1076 {
1077
1078 restore_flags(flags);
1079 return SCSI_ABORT_BUSY;
1080 }
1081
1082
1083 printk("command not found\n");
1084 restore_flags(flags);
1085 return SCSI_ABORT_NOT_RUNNING;
1086 }
1087
1088
1089
1090
1091 static void aha152x_reset_ports(struct Scsi_Host *shpnt)
1092 {
1093
1094 SETPORT(DMACNTRL0, RSTFIFO);
1095
1096 SETPORT(SCSISEQ, 0);
1097
1098 SETPORT(SXFRCTL1, 0);
1099 SETPORT(SCSISIG, 0);
1100 SETPORT(SCSIRATE, 0);
1101
1102
1103 SETPORT(SSTAT0, 0x7f);
1104 SETPORT(SSTAT1, 0xef);
1105
1106 SETPORT(SSTAT4, SYNCERR|FWERR|FRERR);
1107
1108 SETPORT(DMACNTRL0, 0);
1109 SETPORT(DMACNTRL1, 0);
1110
1111 SETPORT(BRSTCNTRL, 0xf1);
1112
1113
1114 SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT);
1115 SETPORT(SXFRCTL0, CH1);
1116
1117
1118 SETPORT(SIMODE0, DISCONNECTED_SC ? ENSELDI : 0);
1119 SETPORT(SIMODE1, ISSUE_SC ? ENBUSFREE : 0);
1120 }
1121
1122
1123
1124
1125
1126 int aha152x_reset(Scsi_Cmnd *SCpnt)
1127 {
1128 struct Scsi_Host *shpnt = SCpnt->host;
1129 unsigned long flags;
1130 Scsi_Cmnd *ptr, *prev, *next;
1131
1132 aha152x_reset_ports(shpnt);
1133
1134
1135 if(TESTLO(SSTAT1, BUSFREE))
1136 {
1137 CLRBITS(DMACNTRL0, INTEN);
1138
1139 #if defined(DEBUG_RESET)
1140 if(HOSTDATA(shpnt)->debug & debug_reset)
1141 {
1142 printk("aha152x: reset(), bus not free: SCSI RESET OUT\n");
1143 show_queues(shpnt);
1144 }
1145 #endif
1146
1147 ptr=CURRENT_SC;
1148 if(ptr && !ptr->device->soft_reset)
1149 {
1150 ptr->host_scribble = NULL;
1151 ptr->result = DID_RESET << 16;
1152 ptr->scsi_done(CURRENT_SC);
1153 CURRENT_SC=NULL;
1154 }
1155
1156 save_flags(flags);
1157 cli();
1158 prev=NULL; ptr=DISCONNECTED_SC;
1159 while(ptr)
1160 {
1161 if(!ptr->device->soft_reset)
1162 {
1163 if(prev)
1164 prev->host_scribble = ptr->host_scribble;
1165 else
1166 DISCONNECTED_SC = (Scsi_Cmnd *) ptr->host_scribble;
1167
1168 next = (Scsi_Cmnd *) ptr->host_scribble;
1169
1170 ptr->host_scribble = NULL;
1171 ptr->result = DID_RESET << 16;
1172 ptr->scsi_done(ptr);
1173
1174 ptr = next;
1175 }
1176 else
1177 {
1178 prev=ptr;
1179 ptr = (Scsi_Cmnd *) ptr->host_scribble;
1180 }
1181 }
1182 restore_flags(flags);
1183
1184 #if defined(DEBUG_RESET)
1185 if(HOSTDATA(shpnt)->debug & debug_reset)
1186 {
1187 printk("commands on targets w/ soft-resets:\n");
1188 show_queues(shpnt);
1189 }
1190 #endif
1191
1192
1193 SETPORT(SCSISEQ, SCSIRSTO);
1194 do_pause(30);
1195 SETPORT(SCSISEQ, 0);
1196 do_pause(DELAY);
1197
1198 SETPORT(SIMODE0, DISCONNECTED_SC ? ENSELDI : 0);
1199 SETPORT(SIMODE1, ISSUE_SC ? ENBUSFREE : 0);
1200
1201 SETPORT(DMACNTRL0, INTEN);
1202 }
1203
1204 return SCSI_RESET_SUCCESS;
1205 }
1206
1207
1208
1209
1210 int aha152x_biosparam(Scsi_Disk * disk, kdev_t dev, int *info_array)
1211 {
1212 #if defined(DEBUG_BIOSPARAM)
1213 if(HOSTDATA(shpnt)->debug & debug_biosparam)
1214 printk("aha152x_biosparam: dev=%s, size=%d, ",
1215 kdevname(dev), disk->capacity);
1216 #endif
1217
1218 if(disk->capacity<=1024*64*32) {
1219 info_array[0]=64;
1220 info_array[1]=32;
1221 info_array[2]=disk->capacity / (64 * 32);
1222 } else {
1223 info_array[0] = 256;
1224 info_array[1] = 63;
1225 info_array[2] = disk->capacity / (256 * 63);
1226 if(info_array[2] > 1023)
1227 info_array[2]=1023;
1228 }
1229
1230 #if defined(DEBUG_BIOSPARAM)
1231 if(HOSTDATA(shpnt)->debug & debug_biosparam)
1232 {
1233 printk("bios geometry: head=%d, sec=%d, cyl=%d\n",
1234 info_array[0], info_array[1], info_array[2]);
1235 printk("WARNING: check, if the bios geometry is correct.\n");
1236 }
1237 #endif
1238
1239 return 0;
1240 }
1241
1242
1243
1244
1245 void aha152x_done(struct Scsi_Host *shpnt, int error)
1246 {
1247 unsigned long flags;
1248 Scsi_Cmnd *done_SC;
1249
1250 #if defined(DEBUG_DONE)
1251 if(HOSTDATA(shpnt)->debug & debug_done)
1252 {
1253 printk("\naha152x: done(), ");
1254 disp_ports(shpnt);
1255 }
1256 #endif
1257
1258 if (CURRENT_SC)
1259 {
1260 #if defined(DEBUG_DONE)
1261 if(HOSTDATA(shpnt)->debug & debug_done)
1262 printk("done(%x), ", error);
1263 #endif
1264
1265 save_flags(flags);
1266 cli();
1267
1268 done_SC = CURRENT_SC;
1269 CURRENT_SC = NULL;
1270
1271
1272 HOSTDATA(shpnt)->commands--;
1273 if(!HOSTDATA(shpnt)->commands)
1274 SETPORT(PORTA, 0);
1275
1276 #if defined(DEBUG_QUEUES)
1277 if(HOSTDATA(shpnt)->debug & debug_queues)
1278 printk("ok (%d), ", HOSTDATA(shpnt)->commands);
1279 #endif
1280 restore_flags(flags);
1281
1282 SETPORT(SIMODE0, DISCONNECTED_SC ? ENSELDI : 0);
1283 SETPORT(SIMODE1, ISSUE_SC ? ENBUSFREE : 0);
1284
1285 #if defined(DEBUG_PHASES)
1286 if(HOSTDATA(shpnt)->debug & debug_phases)
1287 printk("BUS FREE loop, ");
1288 #endif
1289 while(TESTLO(SSTAT1, BUSFREE))
1290 barrier();
1291 #if defined(DEBUG_PHASES)
1292 if(HOSTDATA(shpnt)->debug & debug_phases)
1293 printk("BUS FREE\n");
1294 #endif
1295
1296 done_SC->result = error;
1297 if(done_SC->scsi_done)
1298 {
1299 #if defined(DEBUG_DONE)
1300 if(HOSTDATA(shpnt)->debug & debug_done)
1301 printk("calling scsi_done, ");
1302 #endif
1303 done_SC->scsi_done(done_SC);
1304 #if defined(DEBUG_DONE)
1305 if(HOSTDATA(shpnt)->debug & debug_done)
1306 printk("done returned, ");
1307 #endif
1308 }
1309 else
1310 panic("aha152x: current_SC->scsi_done() == NULL");
1311 }
1312 else
1313 aha152x_panic(shpnt, "done() called outside of command");
1314 }
1315
1316
1317
1318
1319 void aha152x_intr(int irqno, void *dev_id, struct pt_regs * regs)
1320 {
1321 struct Scsi_Host *shpnt = aha152x_host[irqno-IRQ_MIN];
1322 unsigned int flags;
1323 int done=0, phase;
1324
1325 #if defined(DEBUG_RACE)
1326 enter_driver("intr");
1327 #else
1328 #if defined(DEBUG_INTR)
1329 if(HOSTDATA(shpnt)->debug & debug_intr)
1330 printk("\naha152x: intr(), ");
1331 #endif
1332 #endif
1333
1334
1335
1336
1337
1338 CLRBITS(DMACNTRL0, INTEN);
1339 sti();
1340
1341
1342
1343
1344
1345 if(TESTHI(SSTAT0, SELDI) &&
1346 DISCONNECTED_SC &&
1347 (!CURRENT_SC || (CURRENT_SC->SCp.phase & in_selection)) )
1348 {
1349 int identify_msg, target, i;
1350
1351
1352
1353 if(CURRENT_SC)
1354 {
1355 #if defined(DEBUG_QUEUES)
1356 if(HOSTDATA(shpnt)->debug & debug_queues)
1357 printk("i+, ");
1358 #endif
1359 save_flags(flags);
1360 cli();
1361 append_SC(&ISSUE_SC, CURRENT_SC);
1362 CURRENT_SC=NULL;
1363 restore_flags(flags);
1364 }
1365
1366
1367 SETPORT(SCSISEQ, 0);
1368 SETPORT(SSTAT0, CLRSELDI);
1369 SETPORT(SSTAT1, CLRBUSFREE);
1370
1371 #if defined(DEBUG_QUEUES) || defined(DEBUG_PHASES)
1372 if(HOSTDATA(shpnt)->debug & (debug_queues|debug_phases))
1373 printk("reselected, ");
1374 #endif
1375
1376 i = GETPORT(SELID) & ~(1 << shpnt->this_id);
1377 target=0;
1378 if(i)
1379 for(; (i & 1)==0; target++, i>>=1)
1380 ;
1381 else
1382 aha152x_panic(shpnt, "reconnecting target unknown");
1383
1384 #if defined(DEBUG_QUEUES)
1385 if(HOSTDATA(shpnt)->debug & debug_queues)
1386 printk("SELID=%02x, target=%d, ", GETPORT(SELID), target);
1387 #endif
1388 SETPORT(SCSIID, (shpnt->this_id << OID_) | target);
1389 SETPORT(SCSISEQ, ENRESELI);
1390
1391 if(TESTLO(SSTAT0, SELDI))
1392 aha152x_panic(shpnt, "RESELI failed");
1393
1394 SETPORT(SCSIRATE, HOSTDATA(shpnt)->syncrate[target]&0x7f);
1395
1396 SETPORT(SCSISIG, P_MSGI);
1397
1398
1399 if((i=getphase(shpnt))!=P_MSGI)
1400 {
1401 printk("target doesn't enter MSGI to identify (phase=%02x)\n", i);
1402 aha152x_panic(shpnt, "unknown lun");
1403 }
1404 SETPORT(SCSISEQ, 0);
1405
1406 SETPORT(SXFRCTL0, CH1);
1407
1408 identify_msg = GETPORT(SCSIBUS);
1409
1410 if(!(identify_msg & IDENTIFY_BASE))
1411 {
1412 printk("target=%d, inbound message (%02x) != IDENTIFY\n",
1413 target, identify_msg);
1414 aha152x_panic(shpnt, "unknown lun");
1415 }
1416
1417
1418 #if defined(DEBUG_QUEUES)
1419 if(HOSTDATA(shpnt)->debug & debug_queues)
1420 printk("identify=%02x, lun=%d, ", identify_msg, identify_msg & 0x3f);
1421 #endif
1422
1423 save_flags(flags);
1424 cli();
1425
1426 #if defined(DEBUG_QUEUES)
1427 if(HOSTDATA(shpnt)->debug & debug_queues)
1428 printk("d-, ");
1429 #endif
1430 CURRENT_SC = remove_SC(&DISCONNECTED_SC,
1431 target,
1432 identify_msg & 0x3f);
1433
1434 if(!CURRENT_SC)
1435 {
1436 printk("lun=%d, ", identify_msg & 0x3f);
1437 aha152x_panic(shpnt, "no disconnected command for that lun");
1438 }
1439
1440 CURRENT_SC->SCp.phase &= ~disconnected;
1441 restore_flags(flags);
1442
1443 make_acklow(shpnt);
1444 if(getphase(shpnt)!=P_MSGI) {
1445 SETPORT(SIMODE0, 0);
1446 SETPORT(SIMODE1, ENPHASEMIS|ENBUSFREE);
1447 #if defined(DEBUG_RACE)
1448 leave_driver("(reselected) intr");
1449 #endif
1450 SETBITS(DMACNTRL0, INTEN);
1451 return;
1452 }
1453 }
1454
1455
1456 if(!CURRENT_SC)
1457 {
1458
1459 if(TESTHI(SSTAT1, BUSFREE) && ISSUE_SC)
1460 {
1461 save_flags(flags);
1462 cli();
1463 #if defined(DEBUG_QUEUES)
1464 if(HOSTDATA(shpnt)->debug & debug_queues)
1465 printk("i-, ");
1466 #endif
1467 CURRENT_SC = remove_first_SC(&ISSUE_SC);
1468 restore_flags(flags);
1469
1470 #if defined(DEBUG_INTR) || defined(DEBUG_SELECTION) || defined(DEBUG_PHASES)
1471 if(HOSTDATA(shpnt)->debug & (debug_intr|debug_selection|debug_phases))
1472 printk("issuing command, ");
1473 #endif
1474 CURRENT_SC->SCp.phase = in_selection;
1475
1476 #if defined(DEBUG_INTR) || defined(DEBUG_SELECTION) || defined(DEBUG_PHASES)
1477 if(HOSTDATA(shpnt)->debug & (debug_intr|debug_selection|debug_phases))
1478 printk("selecting %d, ", CURRENT_SC->target);
1479 #endif
1480 SETPORT(SCSIID, (shpnt->this_id << OID_) | CURRENT_SC->target);
1481
1482
1483 SETPORT(SXFRCTL1, HOSTDATA(shpnt)->parity ? (ENSPCHK|ENSTIMER) : ENSTIMER);
1484
1485
1486 SETPORT(SIMODE0, ENSELDO | (DISCONNECTED_SC ? ENSELDI : 0));
1487 SETPORT(SIMODE1, ENSELTIMO);
1488
1489
1490 SETBITS(SCSISEQ, ENSELO | ENAUTOATNO);
1491
1492 }
1493 else
1494 {
1495
1496 printk("aha152x: ignoring spurious interrupt, nothing to do\n");
1497 if(TESTHI(DMACNTRL0, SWINT)) {
1498 printk("aha152x: SWINT is set! Why?\n");
1499 CLRBITS(DMACNTRL0, SWINT);
1500 }
1501 show_queues(shpnt);
1502 }
1503
1504 #if defined(DEBUG_RACE)
1505 leave_driver("(selecting) intr");
1506 #endif
1507 SETBITS(DMACNTRL0, INTEN);
1508 return;
1509 }
1510
1511
1512
1513 #if defined(DEBUG_INTR)
1514 if(HOSTDATA(shpnt)->debug & debug_intr)
1515 disp_ports(shpnt);
1516 #endif
1517
1518
1519 if(CURRENT_SC->SCp.phase & in_selection)
1520 {
1521 if(TESTLO(SSTAT1, SELTO))
1522
1523 if(TESTHI(SSTAT0, SELDO))
1524 {
1525
1526 SETPORT(SSTAT1, CLRBUSFREE);
1527
1528
1529 CLRBITS(SCSISEQ, ENSELO|ENAUTOATNO);
1530
1531
1532 CLRBITS(SIMODE0, ENSELDO);
1533 CLRBITS(SIMODE1, ENSELTIMO);
1534
1535 if(TESTLO(SSTAT0, SELDO))
1536 {
1537 printk("aha152x: passing bus free condition\n");
1538
1539 #if defined(DEBUG_RACE)
1540 leave_driver("(passing bus free) intr");
1541 #endif
1542 SETBITS(DMACNTRL0, INTEN);
1543
1544 if(CURRENT_SC->SCp.phase & aborted)
1545 {
1546 HOSTDATA(shpnt)->abort_result=SCSI_ABORT_ERROR;
1547 HOSTDATA(shpnt)->abortion_complete++;
1548 }
1549
1550 aha152x_done(shpnt, DID_NO_CONNECT << 16);
1551 return;
1552 }
1553 #if defined(DEBUG_SELECTION) || defined(DEBUG_PHASES)
1554 if(HOSTDATA(shpnt)->debug & (debug_selection|debug_phases))
1555 printk("SELDO (SELID=%x), ", GETPORT(SELID));
1556 #endif
1557
1558
1559 SETPORT(SSTAT0, CLRSELDO);
1560
1561 #if defined(DEBUG_ABORT)
1562 if((HOSTDATA(shpnt)->debug & debug_abort) && (CURRENT_SC->SCp.phase & aborted))
1563 printk("(ABORT) target selected, ");
1564 #endif
1565
1566 CURRENT_SC->SCp.phase &= ~in_selection;
1567 CURRENT_SC->SCp.phase |= in_other;
1568
1569 ADDMSG(IDENTIFY(HOSTDATA(shpnt)->reconnect,CURRENT_SC->lun));
1570
1571 if(!(SYNCRATE&0x80) && HOSTDATA(shpnt)->synchronous)
1572 {
1573 ADDMSG(EXTENDED_MESSAGE);
1574 ADDMSG(3);
1575 ADDMSG(EXTENDED_SDTR);
1576 ADDMSG(50);
1577 ADDMSG(8);
1578
1579 printk("outbound SDTR: ");
1580 print_msg(&MSG(MSGLEN-5));
1581
1582 SYNCRATE=0x80;
1583 CURRENT_SC->SCp.phase |= in_sync;
1584 }
1585
1586 #if defined(DEBUG_RACE)
1587 leave_driver("(SELDO) intr");
1588 #endif
1589 SETPORT(SCSIRATE, SYNCRATE&0x7f);
1590
1591 SETPORT(SCSISIG, P_MSGO);
1592
1593 SETPORT(SIMODE0, 0);
1594 SETPORT(SIMODE1, ENREQINIT|ENBUSFREE);
1595 SETBITS(DMACNTRL0, INTEN);
1596 return;
1597 }
1598 else
1599 aha152x_panic(shpnt, "neither timeout nor selection\007");
1600 else
1601 {
1602 #if defined(DEBUG_SELECTION) || defined(DEBUG_PHASES)
1603 if(HOSTDATA(shpnt)->debug & (debug_selection|debug_phases))
1604 printk("SELTO, ");
1605 #endif
1606
1607 CLRBITS(SCSISEQ, ENSELO|ENAUTOATNO);
1608
1609
1610 SETPORT(SSTAT1, CLRSELTIMO);
1611
1612 SETPORT(SIMODE0, DISCONNECTED_SC ? ENSELDI : 0);
1613 SETPORT(SIMODE1, ISSUE_SC ? ENBUSFREE : 0);
1614 SETBITS(DMACNTRL0, INTEN);
1615 #if defined(DEBUG_RACE)
1616 leave_driver("(SELTO) intr");
1617 #endif
1618
1619 if(CURRENT_SC->SCp.phase & aborted)
1620 {
1621 #if defined(DEBUG_ABORT)
1622 if(HOSTDATA(shpnt)->debug & debug_abort)
1623 printk("(ABORT) selection timeout, ");
1624 #endif
1625 HOSTDATA(shpnt)->abort_result=SCSI_ABORT_ERROR;
1626 HOSTDATA(shpnt)->abortion_complete++;
1627 }
1628
1629 if(TESTLO(SSTAT0, SELINGO))
1630
1631 aha152x_done(shpnt, DID_BUS_BUSY << 16);
1632 else
1633
1634 aha152x_done(shpnt, DID_NO_CONNECT << 16);
1635
1636 return;
1637 }
1638 }
1639
1640
1641 phase = getphase(shpnt);
1642 if(!(phase & ~P_MASK))
1643 SETPORT(SCSISIG, phase);
1644 SETPORT(SSTAT1, CLRPHASECHG);
1645 CURRENT_SC->SCp.phase =
1646 (CURRENT_SC->SCp.phase & ~((P_MASK|1)<<16)) | (phase << 16);
1647
1648
1649 switch(phase)
1650 {
1651 case P_MSGO:
1652 {
1653 int i, identify=0, abort=0;
1654
1655 #if defined(DEBUG_INTR) || defined(DEBUG_MSGO) || defined(DEBUG_PHASES)
1656 if(HOSTDATA(shpnt)->debug & (debug_intr|debug_msgo|debug_phases))
1657 printk("MESSAGE OUT, ");
1658 #endif
1659 if(MSGLEN==0)
1660 {
1661 ADDMSG(MESSAGE_REJECT);
1662 #if defined(DEBUG_MSGO)
1663 if(HOSTDATA(shpnt)->debug & debug_msgo)
1664 printk("unexpected MSGO; rejecting, ");
1665 #endif
1666 }
1667
1668
1669 CLRBITS(SXFRCTL0, ENDMA);
1670
1671 SETPORT(SIMODE0, 0);
1672 SETPORT(SIMODE1, ENPHASEMIS|ENREQINIT|ENBUSFREE);
1673
1674
1675 while(TESTLO(DMASTAT, INTSTAT))
1676 barrier();
1677
1678 #if defined(DEBUG_MSGO)
1679 if(HOSTDATA(shpnt)->debug & debug_msgo)
1680 {
1681 int i;
1682
1683 printk("messages (");
1684 for(i=0; i<MSGLEN; i+=print_msg(&MSG(i)), printk(" "))
1685 ;
1686 printk("), ");
1687 }
1688 #endif
1689
1690 for(i=0; i<MSGLEN && TESTLO(SSTAT1, PHASEMIS); i++)
1691 {
1692 #if defined(DEBUG_MSGO)
1693 if(HOSTDATA(shpnt)->debug & debug_msgo)
1694 printk("%x ", MSG(i));
1695 #endif
1696 if(i==MSGLEN-1)
1697 {
1698
1699 SETPORT(SSTAT1, CLRATNO);
1700 }
1701
1702 SETPORT(SCSIDAT, MSG(i));
1703
1704 make_acklow(shpnt);
1705 getphase(shpnt);
1706
1707 if(MSG(i)==IDENTIFY(HOSTDATA(shpnt)->reconnect,CURRENT_SC->lun))
1708 identify++;
1709
1710 if(MSG(i)==ABORT)
1711 abort++;
1712
1713 }
1714
1715 MSGLEN=0;
1716
1717 if(identify)
1718 CURRENT_SC->SCp.phase |= sent_ident;
1719
1720 if(abort)
1721 {
1722
1723 HOSTDATA(shpnt)->abort_result=SCSI_ABORT_SUCCESS;
1724 HOSTDATA(shpnt)->abortion_complete++;
1725
1726 CURRENT_SC->SCp.phase &= ~(P_MASK<<16);
1727
1728
1729 SETBITS(DMACNTRL0, INTEN);
1730 #if defined(DEBUG_RACE)
1731 leave_driver("(ABORT) intr");
1732 #endif
1733 aha152x_done(shpnt, DID_ABORT<<16);
1734 return;
1735 }
1736 }
1737 break;
1738
1739 case P_CMD:
1740 #if defined(DEBUG_INTR) || defined(DEBUG_CMD) || defined(DEBUG_PHASES)
1741 if(HOSTDATA(shpnt)->debug & (debug_intr|debug_cmd|debug_phases))
1742 printk("COMMAND, ");
1743 #endif
1744 if(!(CURRENT_SC->SCp.sent_command))
1745 {
1746 int i;
1747
1748 CLRBITS(SXFRCTL0, ENDMA);
1749
1750 SETPORT(SIMODE0, 0);
1751 SETPORT(SIMODE1, ENPHASEMIS|ENREQINIT|ENBUSFREE);
1752
1753
1754 while(TESTLO(DMASTAT, INTSTAT))
1755 barrier();
1756
1757 for(i=0; i<CURRENT_SC->cmd_len && TESTLO(SSTAT1, PHASEMIS); i++)
1758 {
1759 SETPORT(SCSIDAT, CURRENT_SC->cmnd[i]);
1760
1761 make_acklow(shpnt);
1762 getphase(shpnt);
1763 }
1764
1765 if(i<CURRENT_SC->cmd_len && TESTHI(SSTAT1, PHASEMIS))
1766 aha152x_panic(shpnt, "target left COMMAND");
1767
1768 CURRENT_SC->SCp.sent_command++;
1769 }
1770 else
1771 aha152x_panic(shpnt, "Nothing to send while in COMMAND");
1772 break;
1773
1774 case P_MSGI:
1775 {
1776 int start_sync=0;
1777
1778 #if defined(DEBUG_INTR) || defined(DEBUG_MSGI) || defined(DEBUG_PHASES)
1779 if(HOSTDATA(shpnt)->debug & (debug_intr|debug_msgi|debug_phases))
1780 printk("MESSAGE IN, ");
1781 #endif
1782 SETPORT(SXFRCTL0, CH1);
1783
1784 SETPORT(SIMODE0, 0);
1785 SETPORT(SIMODE1, ENBUSFREE);
1786
1787 while(phase == P_MSGI)
1788 {
1789 CURRENT_SC->SCp.Message = GETPORT(SCSIDAT);
1790 switch(CURRENT_SC->SCp.Message)
1791 {
1792 case DISCONNECT:
1793 #if defined(DEBUG_MSGI) || defined(DEBUG_PHASES)
1794 if(HOSTDATA(shpnt)->debug & (debug_msgi|debug_phases))
1795 printk("target disconnected, ");
1796 #endif
1797 CURRENT_SC->SCp.Message = 0;
1798 CURRENT_SC->SCp.phase |= disconnected;
1799 if(!HOSTDATA(shpnt)->reconnect)
1800 aha152x_panic(shpnt, "target was not allowed to disconnect");
1801 break;
1802
1803 case COMMAND_COMPLETE:
1804 #if defined(DEBUG_MSGI) || defined(DEBUG_PHASES)
1805 if(HOSTDATA(shpnt)->debug & (debug_msgi|debug_phases))
1806 printk("inbound message (COMMAND COMPLETE), ");
1807 #endif
1808 done++;
1809 break;
1810
1811 case MESSAGE_REJECT:
1812 if(CURRENT_SC->SCp.phase & in_sync)
1813 {
1814 CURRENT_SC->SCp.phase &= ~in_sync;
1815 SYNCRATE=0x80;
1816 printk("synchronous rejected, ");
1817 }
1818 else
1819 printk("inbound message (MESSAGE REJECT), ");
1820 #if defined(DEBUG_MSGI)
1821 if(HOSTDATA(shpnt)->debug & debug_msgi)
1822 printk("inbound message (MESSAGE REJECT), ");
1823 #endif
1824 break;
1825
1826 case SAVE_POINTERS:
1827 #if defined(DEBUG_MSGI)
1828 if(HOSTDATA(shpnt)->debug & debug_msgi)
1829 printk("inbound message (SAVE DATA POINTERS), ");
1830 #endif
1831 break;
1832
1833 case EXTENDED_MESSAGE:
1834 {
1835 char buffer[16];
1836 int i;
1837
1838 #if defined(DEBUG_MSGI)
1839 if(HOSTDATA(shpnt)->debug & debug_msgi)
1840 printk("inbound message (EXTENDED MESSAGE), ");
1841 #endif
1842 make_acklow(shpnt);
1843 if(getphase(shpnt)!=P_MSGI)
1844 break;
1845
1846 buffer[0]=EXTENDED_MESSAGE;
1847 buffer[1]=GETPORT(SCSIDAT);
1848
1849 for(i=0; i<buffer[1] &&
1850 (make_acklow(shpnt), getphase(shpnt)==P_MSGI); i++)
1851 buffer[2+i]=GETPORT(SCSIDAT);
1852
1853 #if defined(DEBUG_MSGI)
1854 if(HOSTDATA(shpnt)->debug & debug_msgi)
1855 print_msg(buffer);
1856 #endif
1857
1858 switch(buffer [2])
1859 {
1860 case EXTENDED_SDTR:
1861 {
1862 long ticks;
1863
1864 if(buffer[1]!=3)
1865 aha152x_panic(shpnt, "SDTR message length != 3");
1866
1867 if(!HOSTDATA(shpnt)->synchronous)
1868 break;
1869
1870 printk("inbound SDTR: "); print_msg(buffer);
1871
1872 ticks=(buffer[3]*4+49)/50;
1873
1874 if(CURRENT_SC->SCp.phase & in_sync)
1875 {
1876
1877 if(ticks>9 || buffer[4]<1 || buffer[4]>8)
1878 aha152x_panic(shpnt, "received SDTR invalid");
1879
1880 SYNCRATE |= ((ticks-2)<<4) + buffer[4];
1881 }
1882 else if(ticks<=9 && buffer[4]>=1)
1883 {
1884 if(buffer[4]>8)
1885 buffer[4]=8;
1886
1887 ADDMSG(EXTENDED_MESSAGE);
1888 ADDMSG(3);
1889 ADDMSG(EXTENDED_SDTR);
1890 if(ticks<4)
1891 {
1892 ticks=4;
1893 ADDMSG(50);
1894 }
1895 else
1896 ADDMSG(buffer[3]);
1897
1898 ADDMSG(buffer[4]);
1899
1900 printk("outbound SDTR: ");
1901 print_msg(&MSG(MSGLEN-5));
1902
1903 CURRENT_SC->SCp.phase |= in_sync;
1904
1905 SYNCRATE |= ((ticks-2)<<4) + buffer[4];
1906
1907 start_sync++;
1908 }
1909 else
1910 {
1911
1912 ADDMSG(MESSAGE_REJECT);
1913 SYNCRATE = 0;
1914 }
1915
1916 SETPORT(SCSIRATE, SYNCRATE&0x7f);
1917 }
1918 break;
1919
1920 case EXTENDED_MODIFY_DATA_POINTER:
1921 case EXTENDED_EXTENDED_IDENTIFY:
1922 case EXTENDED_WDTR:
1923 default:
1924 ADDMSG(MESSAGE_REJECT);
1925 break;
1926 }
1927 }
1928 break;
1929
1930 default:
1931 printk("unsupported inbound message %x, ",
1932 CURRENT_SC->SCp.Message);
1933 break;
1934
1935 }
1936
1937 make_acklow(shpnt);
1938 phase=getphase(shpnt);
1939 }
1940
1941 if(start_sync)
1942 CURRENT_SC->SCp.phase |= in_sync;
1943 else
1944 CURRENT_SC->SCp.phase &= ~in_sync;
1945
1946 if(MSGLEN>0)
1947 SETPORT(SCSISIG, P_MSGI|ATNO);
1948
1949
1950 if(phase==P_BUSFREE)
1951 SETPORT(SXFRCTL0, CH1|CLRCH1);
1952
1953 if(CURRENT_SC->SCp.phase & disconnected)
1954 {
1955 save_flags(flags);
1956 cli();
1957 #if defined(DEBUG_QUEUES)
1958 if(HOSTDATA(shpnt)->debug & debug_queues)
1959 printk("d+, ");
1960 #endif
1961 append_SC(&DISCONNECTED_SC, CURRENT_SC);
1962 CURRENT_SC->SCp.phase |= 1<<16;
1963 CURRENT_SC = NULL;
1964 restore_flags(flags);
1965
1966 SETBITS(SCSISEQ, ENRESELI);
1967
1968 SETPORT(SIMODE0, DISCONNECTED_SC ? ENSELDI : 0);
1969 SETPORT(SIMODE1, ISSUE_SC ? ENBUSFREE : 0);
1970
1971 SETBITS(DMACNTRL0, INTEN);
1972 return;
1973 }
1974 }
1975 break;
1976
1977 case P_STATUS:
1978 #if defined(DEBUG_STATUS) || defined(DEBUG_INTR) || defined(DEBUG_PHASES)
1979 if(HOSTDATA(shpnt)->debug & (debug_status|debug_intr|debug_phases))
1980 printk("STATUS, ");
1981 #endif
1982 SETPORT(SXFRCTL0, CH1);
1983
1984 SETPORT(SIMODE0, 0);
1985 SETPORT(SIMODE1, ENREQINIT|ENBUSFREE);
1986
1987 if(TESTHI(SSTAT1, PHASEMIS))
1988 printk("aha152x: passing STATUS phase");
1989
1990 CURRENT_SC->SCp.Status = GETPORT(SCSIBUS);
1991 make_acklow(shpnt);
1992 getphase(shpnt);
1993
1994 #if defined(DEBUG_STATUS)
1995 if(HOSTDATA(shpnt)->debug & debug_status)
1996 {
1997 printk("inbound status ");
1998 print_status(CURRENT_SC->SCp.Status);
1999 printk(", ");
2000 }
2001 #endif
2002 break;
2003
2004 case P_DATAI:
2005 {
2006 int fifodata, data_count, done;
2007
2008 #if defined(DEBUG_DATAI) || defined(DEBUG_INTR) || defined(DEBUG_PHASES)
2009 if(HOSTDATA(shpnt)->debug & (debug_datai|debug_intr|debug_phases))
2010 printk("DATA IN, ");
2011 #endif
2012
2013 #if 0
2014 if(GETPORT(FIFOSTAT) || GETPORT(SSTAT2) & (SFULL|SFCNT))
2015 printk("aha152x: P_DATAI: %d(%d) bytes left in FIFO, resetting\n",
2016 GETPORT(FIFOSTAT), GETPORT(SSTAT2) & (SFULL|SFCNT));
2017 #endif
2018
2019
2020 SETPORT(DMACNTRL0, RSTFIFO);
2021 SETPORT(DMACNTRL0, RSTFIFO|ENDMA);
2022
2023 SETPORT(SXFRCTL0, CH1|SCSIEN|DMAEN);
2024
2025 SETPORT(SIMODE0, 0);
2026 SETPORT(SIMODE1, ENPHASEMIS|ENBUSFREE);
2027
2028
2029 done=0;
2030
2031
2032 while (!done)
2033 {
2034 #if defined(DEBUG_DATAI)
2035 if(HOSTDATA(shpnt)->debug & debug_datai)
2036 printk("expecting data, ");
2037 #endif
2038
2039 while(TESTLO (DMASTAT, DFIFOFULL|INTSTAT))
2040 barrier();
2041
2042 #if defined(DEBUG_DATAI)
2043 if(HOSTDATA(shpnt)->debug & debug_datai)
2044 printk("ok, ");
2045 #endif
2046
2047 if(TESTHI(DMASTAT, DFIFOFULL))
2048 fifodata=GETPORT(FIFOSTAT);
2049 else
2050 {
2051
2052 while(TESTLO(SSTAT2, SEMPTY))
2053 barrier();
2054
2055
2056 fifodata=GETPORT(FIFOSTAT);
2057 #if defined(DEBUG_DATAI)
2058 if(HOSTDATA(shpnt)->debug & debug_datai)
2059 printk("last transfer, ");
2060 #endif
2061 done=1;
2062 }
2063
2064 #if defined(DEBUG_DATAI)
2065 if(HOSTDATA(shpnt)->debug & debug_datai)
2066 printk("fifodata=%d, ", fifodata);
2067 #endif
2068
2069 while(fifodata && CURRENT_SC->SCp.this_residual)
2070 {
2071 data_count=fifodata;
2072
2073
2074 if (data_count > CURRENT_SC->SCp.this_residual)
2075 data_count = CURRENT_SC->SCp.this_residual;
2076
2077 fifodata -= data_count;
2078
2079 #if defined(DEBUG_DATAI)
2080 if(HOSTDATA(shpnt)->debug & debug_datai)
2081 printk("data_count=%d, ", data_count);
2082 #endif
2083
2084 if(data_count&1)
2085 {
2086
2087 SETBITS(DMACNTRL0, _8BIT);
2088 *CURRENT_SC->SCp.ptr++ = GETPORT(DATAPORT);
2089 CURRENT_SC->SCp.this_residual--;
2090 }
2091 if(data_count>1)
2092 {
2093 CLRBITS(DMACNTRL0, _8BIT);
2094 data_count >>= 1;
2095 insw(DATAPORT, CURRENT_SC->SCp.ptr, data_count);
2096 #if defined(DEBUG_DATAI)
2097 if(HOSTDATA(shpnt)->debug & debug_datai)
2098
2099 if(done)
2100 {
2101 #ifdef 0
2102 int i;
2103 unsigned char *data;
2104 #endif
2105
2106 printk("data on last transfer (%d bytes) ",
2107 2*data_count);
2108 #ifdef 0
2109 printk("data on last transfer (%d bytes: ",
2110 2*data_count);
2111 data = (unsigned char *) CURRENT_SC->SCp.ptr;
2112 for(i=0; i<2*data_count; i++)
2113 printk("%2x ", *data++);
2114 printk("), ");
2115 #endif
2116 }
2117 #endif
2118 CURRENT_SC->SCp.ptr += 2 * data_count;
2119 CURRENT_SC->SCp.this_residual -= 2 * data_count;
2120 }
2121
2122
2123 if (!CURRENT_SC->SCp.this_residual &&
2124 CURRENT_SC->SCp.buffers_residual)
2125 {
2126
2127 CURRENT_SC->SCp.buffers_residual--;
2128 CURRENT_SC->SCp.buffer++;
2129 CURRENT_SC->SCp.ptr =
2130 CURRENT_SC->SCp.buffer->address;
2131 CURRENT_SC->SCp.this_residual =
2132 CURRENT_SC->SCp.buffer->length;
2133 }
2134 }
2135
2136
2137
2138
2139 if(fifodata>0)
2140 {
2141 printk("aha152x: more data than expected (%d bytes)\n",
2142 GETPORT(FIFOSTAT));
2143 SETBITS(DMACNTRL0, _8BIT);
2144 printk("aha152x: data (");
2145 while(fifodata--)
2146 printk("%2x ", GETPORT(DATAPORT));
2147 printk(")\n");
2148 }
2149
2150 #if defined(DEBUG_DATAI)
2151 if(HOSTDATA(shpnt)->debug & debug_datai)
2152 if(!fifodata)
2153 printk("fifo empty, ");
2154 else
2155 printk("something left in fifo, ");
2156 #endif
2157 }
2158
2159 #if defined(DEBUG_DATAI)
2160 if((HOSTDATA(shpnt)->debug & debug_datai) &&
2161 (CURRENT_SC->SCp.buffers_residual ||
2162 CURRENT_SC->SCp.this_residual))
2163 printk("left buffers (buffers=%d, bytes=%d), ",
2164 CURRENT_SC->SCp.buffers_residual,
2165 CURRENT_SC->SCp.this_residual);
2166 #endif
2167
2168 CLRBITS(SXFRCTL0, SCSIEN|DMAEN);
2169 while(TESTHI(SXFRCTL0, SCSIEN))
2170 barrier();
2171 CLRBITS(DMACNTRL0, ENDMA);
2172
2173 #if defined(DEBUG_DATAI) || defined(DEBUG_INTR)
2174 if(HOSTDATA(shpnt)->debug & (debug_datai|debug_intr))
2175 printk("got %d bytes, ", GETSTCNT());
2176 #endif
2177
2178 CURRENT_SC->SCp.have_data_in++;
2179 }
2180 break;
2181
2182 case P_DATAO:
2183 {
2184 int data_count;
2185
2186 #if defined(DEBUG_DATAO) || defined(DEBUG_INTR) || defined(DEBUG_PHASES)
2187 if(HOSTDATA(shpnt)->debug & (debug_datao|debug_intr|debug_phases))
2188 printk("DATA OUT, ");
2189 #endif
2190 #if defined(DEBUG_DATAO)
2191 if(HOSTDATA(shpnt)->debug & debug_datao)
2192 printk("got data to send (bytes=%d, buffers=%d), ",
2193 CURRENT_SC->SCp.this_residual,
2194 CURRENT_SC->SCp.buffers_residual);
2195 #endif
2196
2197 if(GETPORT(FIFOSTAT) || GETPORT(SSTAT2) & (SFULL|SFCNT))
2198 {
2199 printk("%d(%d) left in FIFO, ",
2200 GETPORT(FIFOSTAT), GETPORT(SSTAT2) & (SFULL|SFCNT));
2201 aha152x_panic(shpnt, "FIFO should be empty");
2202 }
2203
2204 SETPORT(SXFRCTL0, CH1|CLRSTCNT|CLRCH1);
2205 SETPORT(SXFRCTL0, SCSIEN|DMAEN|CH1);
2206
2207 SETPORT(DMACNTRL0, WRITE_READ|RSTFIFO);
2208 SETPORT(DMACNTRL0, ENDMA|WRITE_READ);
2209
2210 SETPORT(SIMODE0, 0);
2211 SETPORT(SIMODE1, ENPHASEMIS|ENBUSFREE);
2212
2213
2214
2215 while(TESTLO(SSTAT1, PHASEMIS) &&
2216 (CURRENT_SC->SCp.this_residual ||
2217 CURRENT_SC->SCp.buffers_residual))
2218 {
2219 #if defined(DEBUG_DATAO)
2220 if(HOSTDATA(shpnt)->debug & debug_datao)
2221 printk("sending data (left: bytes=%d, buffers=%d), waiting, ",
2222 CURRENT_SC->SCp.this_residual,
2223 CURRENT_SC->SCp.buffers_residual);
2224 #endif
2225
2226 data_count =
2227 CURRENT_SC->SCp.this_residual > 128 ?
2228 128 : CURRENT_SC->SCp.this_residual ;
2229
2230 #if defined(DEBUG_DATAO)
2231 if(HOSTDATA(shpnt)->debug & debug_datao)
2232 printk("data_count=%d, ", data_count);
2233 #endif
2234
2235 if(data_count&1)
2236 {
2237
2238 SETBITS(DMACNTRL0, _8BIT);
2239 SETPORT(DATAPORT, *CURRENT_SC->SCp.ptr++);
2240 CURRENT_SC->SCp.this_residual--;
2241 }
2242 if(data_count>1)
2243 {
2244 CLRBITS(DMACNTRL0, _8BIT);
2245 data_count >>= 1;
2246 outsw(DATAPORT, CURRENT_SC->SCp.ptr, data_count);
2247 CURRENT_SC->SCp.ptr += 2 * data_count;
2248 CURRENT_SC->SCp.this_residual -= 2 * data_count;
2249 }
2250
2251
2252 while(TESTLO(DMASTAT, DFIFOEMP|INTSTAT))
2253 barrier();
2254
2255 #if defined(DEBUG_DATAO)
2256 if(HOSTDATA(shpnt)->debug & debug_datao)
2257 printk("fifo (%d bytes), transfered (%d bytes), ",
2258 GETPORT(FIFOSTAT), GETSTCNT());
2259 #endif
2260
2261
2262 if (TESTLO(SSTAT1, PHASEMIS) &&
2263 !CURRENT_SC->SCp.this_residual &&
2264 CURRENT_SC->SCp.buffers_residual)
2265 {
2266
2267 CURRENT_SC->SCp.buffers_residual--;
2268 CURRENT_SC->SCp.buffer++;
2269 CURRENT_SC->SCp.ptr =
2270 CURRENT_SC->SCp.buffer->address;
2271 CURRENT_SC->SCp.this_residual =
2272 CURRENT_SC->SCp.buffer->length;
2273 }
2274 }
2275
2276 if (CURRENT_SC->SCp.this_residual || CURRENT_SC->SCp.buffers_residual)
2277 {
2278
2279
2280
2281
2282 data_count = GETPORT(SSTAT2) & (SFULL|SFCNT);
2283
2284 data_count += GETPORT(FIFOSTAT) ;
2285 CURRENT_SC->SCp.ptr -= data_count;
2286 CURRENT_SC->SCp.this_residual += data_count;
2287 #if defined(DEBUG_DATAO)
2288 if(HOSTDATA(shpnt)->debug & debug_datao)
2289 printk("left data (bytes=%d, buffers=%d), fifos (bytes=%d), "
2290 "transfer incomplete, resetting fifo, ",
2291 CURRENT_SC->SCp.this_residual,
2292 CURRENT_SC->SCp.buffers_residual,
2293 data_count);
2294 #endif
2295 SETPORT(DMACNTRL0, WRITE_READ|RSTFIFO);
2296 CLRBITS(SXFRCTL0, SCSIEN|DMAEN);
2297 CLRBITS(DMACNTRL0, ENDMA);
2298 }
2299 else
2300 {
2301 #if defined(DEBUG_DATAO)
2302 if(HOSTDATA(shpnt)->debug & debug_datao)
2303 printk("waiting for SCSI fifo to get empty, ");
2304 #endif
2305
2306 while(TESTLO(SSTAT2, SEMPTY))
2307 barrier();
2308 #if defined(DEBUG_DATAO)
2309 if(HOSTDATA(shpnt)->debug & debug_datao)
2310 printk("ok, left data (bytes=%d, buffers=%d) ",
2311 CURRENT_SC->SCp.this_residual,
2312 CURRENT_SC->SCp.buffers_residual);
2313 #endif
2314 CLRBITS(SXFRCTL0, SCSIEN|DMAEN);
2315
2316
2317 while(TESTHI(SXFRCTL0, SCSIEN))
2318 barrier();
2319
2320 CLRBITS(DMACNTRL0, ENDMA);
2321 }
2322
2323 #if defined(DEBUG_DATAO) || defined(DEBUG_INTR)
2324 if(HOSTDATA(shpnt)->debug & (debug_datao|debug_intr))
2325 printk("sent %d data bytes, ", GETSTCNT());
2326 #endif
2327 }
2328 break;
2329
2330 case P_BUSFREE:
2331 #if defined(DEBUG_RACE)
2332 leave_driver("(BUSFREE) intr");
2333 #endif
2334 #if defined(DEBUG_PHASES)
2335 if(HOSTDATA(shpnt)->debug & debug_phases)
2336 printk("unexpected BUS FREE, ");
2337 #endif
2338 CURRENT_SC->SCp.phase &= ~(P_MASK<<16);
2339
2340 aha152x_done(shpnt, DID_ERROR << 16);
2341 return;
2342 break;
2343
2344 case P_PARITY:
2345 #if defined(DEBUG_RACE)
2346 leave_driver("(DID_PARITY) intr");
2347 #endif
2348 printk("PARITY error in DATA phase, ");
2349
2350 CURRENT_SC->SCp.phase &= ~(P_MASK<<16);
2351
2352 SETBITS(DMACNTRL0, INTEN);
2353 aha152x_done(shpnt, DID_PARITY << 16);
2354 return;
2355 break;
2356
2357 default:
2358 printk("aha152x: unexpected phase\n");
2359 break;
2360 }
2361
2362 if(done)
2363 {
2364 #if defined(DEBUG_INTR)
2365 if(HOSTDATA(shpnt)->debug & debug_intr)
2366 printk("command done.\n");
2367 #endif
2368 #if defined(DEBUG_RACE)
2369 leave_driver("(done) intr");
2370 #endif
2371
2372 SETPORT(SIMODE0, DISCONNECTED_SC ? ENSELDI : 0);
2373 SETPORT(SIMODE1, ISSUE_SC ? ENBUSFREE : 0);
2374 SETPORT(SCSISEQ, DISCONNECTED_SC ? ENRESELI : 0);
2375
2376 SETBITS(DMACNTRL0, INTEN);
2377
2378 aha152x_done(shpnt,
2379 (CURRENT_SC->SCp.Status & 0xff)
2380 | ((CURRENT_SC->SCp.Message & 0xff) << 8)
2381 | (DID_OK << 16));
2382
2383 #if defined(DEBUG_RACE)
2384 printk("done returned (DID_OK: Status=%x; Message=%x).\n",
2385 CURRENT_SC->SCp.Status, CURRENT_SC->SCp.Message);
2386 #endif
2387 return;
2388 }
2389
2390 if(CURRENT_SC)
2391 CURRENT_SC->SCp.phase |= 1<<16 ;
2392
2393 SETPORT(SIMODE0, 0);
2394 SETPORT(SIMODE1, ENPHASEMIS|ENBUSFREE);
2395 #if defined(DEBUG_INTR)
2396 if(HOSTDATA(shpnt)->debug & debug_intr)
2397 disp_enintr(shpnt);
2398 #endif
2399 #if defined(DEBUG_RACE)
2400 leave_driver("(PHASEEND) intr");
2401 #endif
2402
2403 SETBITS(DMACNTRL0, INTEN);
2404 return;
2405 }
2406
2407
2408
2409
2410 static void aha152x_panic(struct Scsi_Host *shpnt, char *msg)
2411 {
2412 printk("\naha152x: %s\n", msg);
2413 show_queues(shpnt);
2414 panic("aha152x panic");
2415 }
2416
2417
2418
2419
2420 static void disp_ports(struct Scsi_Host *shpnt)
2421 {
2422 #ifdef DEBUG_AHA152X
2423 int s;
2424
2425 #ifdef SKIP_PORTS
2426 if(HOSTDATA(shpnt)->debug & debug_skipports)
2427 return;
2428 #endif
2429
2430 printk("\n%s: ", CURRENT_SC ? "on bus" : "waiting");
2431
2432 s=GETPORT(SCSISEQ);
2433 printk("SCSISEQ (");
2434 if(s & TEMODEO) printk("TARGET MODE ");
2435 if(s & ENSELO) printk("SELO ");
2436 if(s & ENSELI) printk("SELI ");
2437 if(s & ENRESELI) printk("RESELI ");
2438 if(s & ENAUTOATNO) printk("AUTOATNO ");
2439 if(s & ENAUTOATNI) printk("AUTOATNI ");
2440 if(s & ENAUTOATNP) printk("AUTOATNP ");
2441 if(s & SCSIRSTO) printk("SCSIRSTO ");
2442 printk(");");
2443
2444 printk(" SCSISIG (");
2445 s=GETPORT(SCSISIG);
2446 switch(s & P_MASK)
2447 {
2448 case P_DATAO:
2449 printk("DATA OUT");
2450 break;
2451 case P_DATAI:
2452 printk("DATA IN");
2453 break;
2454 case P_CMD:
2455 printk("COMMAND");
2456 break;
2457 case P_STATUS:
2458 printk("STATUS");
2459 break;
2460 case P_MSGO:
2461 printk("MESSAGE OUT");
2462 break;
2463 case P_MSGI:
2464 printk("MESSAGE IN");
2465 break;
2466 default:
2467 printk("*illegal*");
2468 break;
2469 }
2470
2471 printk("); ");
2472
2473 printk("INTSTAT (%s); ", TESTHI(DMASTAT, INTSTAT) ? "hi" : "lo");
2474
2475 printk("SSTAT (");
2476 s=GETPORT(SSTAT0);
2477 if(s & TARGET) printk("TARGET ");
2478 if(s & SELDO) printk("SELDO ");
2479 if(s & SELDI) printk("SELDI ");
2480 if(s & SELINGO) printk("SELINGO ");
2481 if(s & SWRAP) printk("SWRAP ");
2482 if(s & SDONE) printk("SDONE ");
2483 if(s & SPIORDY) printk("SPIORDY ");
2484 if(s & DMADONE) printk("DMADONE ");
2485
2486 s=GETPORT(SSTAT1);
2487 if(s & SELTO) printk("SELTO ");
2488 if(s & ATNTARG) printk("ATNTARG ");
2489 if(s & SCSIRSTI) printk("SCSIRSTI ");
2490 if(s & PHASEMIS) printk("PHASEMIS ");
2491 if(s & BUSFREE) printk("BUSFREE ");
2492 if(s & SCSIPERR) printk("SCSIPERR ");
2493 if(s & PHASECHG) printk("PHASECHG ");
2494 if(s & REQINIT) printk("REQINIT ");
2495 printk("); ");
2496
2497
2498 printk("SSTAT (");
2499
2500 s=GETPORT(SSTAT0) & GETPORT(SIMODE0);
2501
2502 if(s & TARGET) printk("TARGET ");
2503 if(s & SELDO) printk("SELDO ");
2504 if(s & SELDI) printk("SELDI ");
2505 if(s & SELINGO) printk("SELINGO ");
2506 if(s & SWRAP) printk("SWRAP ");
2507 if(s & SDONE) printk("SDONE ");
2508 if(s & SPIORDY) printk("SPIORDY ");
2509 if(s & DMADONE) printk("DMADONE ");
2510
2511 s=GETPORT(SSTAT1) & GETPORT(SIMODE1);
2512
2513 if(s & SELTO) printk("SELTO ");
2514 if(s & ATNTARG) printk("ATNTARG ");
2515 if(s & SCSIRSTI) printk("SCSIRSTI ");
2516 if(s & PHASEMIS) printk("PHASEMIS ");
2517 if(s & BUSFREE) printk("BUSFREE ");
2518 if(s & SCSIPERR) printk("SCSIPERR ");
2519 if(s & PHASECHG) printk("PHASECHG ");
2520 if(s & REQINIT) printk("REQINIT ");
2521 printk("); ");
2522
2523 printk("SXFRCTL0 (");
2524
2525 s=GETPORT(SXFRCTL0);
2526 if(s & SCSIEN) printk("SCSIEN ");
2527 if(s & DMAEN) printk("DMAEN ");
2528 if(s & CH1) printk("CH1 ");
2529 if(s & CLRSTCNT) printk("CLRSTCNT ");
2530 if(s & SPIOEN) printk("SPIOEN ");
2531 if(s & CLRCH1) printk("CLRCH1 ");
2532 printk("); ");
2533
2534 printk("SIGNAL (");
2535
2536 s=GETPORT(SCSISIG);
2537 if(s & ATNI) printk("ATNI ");
2538 if(s & SELI) printk("SELI ");
2539 if(s & BSYI) printk("BSYI ");
2540 if(s & REQI) printk("REQI ");
2541 if(s & ACKI) printk("ACKI ");
2542 printk("); ");
2543
2544 printk("SELID (%02x), ", GETPORT(SELID));
2545
2546 printk("SSTAT2 (");
2547
2548 s=GETPORT(SSTAT2);
2549 if(s & SOFFSET) printk("SOFFSET ");
2550 if(s & SEMPTY) printk("SEMPTY ");
2551 if(s & SFULL) printk("SFULL ");
2552 printk("); SFCNT (%d); ", s & (SFULL|SFCNT));
2553
2554 s=GETPORT(SSTAT3);
2555 printk("SCSICNT (%d), OFFCNT(%d), ", (s&0xf0)>>4, s&0x0f);
2556
2557 printk("SSTAT4 (");
2558 s=GETPORT(SSTAT4);
2559 if(s & SYNCERR) printk("SYNCERR ");
2560 if(s & FWERR) printk("FWERR ");
2561 if(s & FRERR) printk("FRERR ");
2562 printk("); ");
2563
2564 printk("DMACNTRL0 (");
2565 s=GETPORT(DMACNTRL0);
2566 printk("%s ", s & _8BIT ? "8BIT" : "16BIT");
2567 printk("%s ", s & DMA ? "DMA" : "PIO" );
2568 printk("%s ", s & WRITE_READ ? "WRITE" : "READ" );
2569 if(s & ENDMA) printk("ENDMA ");
2570 if(s & INTEN) printk("INTEN ");
2571 if(s & RSTFIFO) printk("RSTFIFO ");
2572 if(s & SWINT) printk("SWINT ");
2573 printk("); ");
2574
2575
2576 #if 0
2577 printk("DMACNTRL1 (");
2578
2579 s=GETPORT(DMACNTRL1);
2580 if(s & PWRDWN) printk("PWRDN ");
2581 printk("); ");
2582
2583
2584 printk("STK (%d); ", s & 0xf);
2585
2586 #endif
2587
2588 printk("DMASTAT (");
2589 s=GETPORT(DMASTAT);
2590 if(s & ATDONE) printk("ATDONE ");
2591 if(s & WORDRDY) printk("WORDRDY ");
2592 if(s & DFIFOFULL) printk("DFIFOFULL ");
2593 if(s & DFIFOEMP) printk("DFIFOEMP ");
2594 printk(")");
2595
2596 printk("\n");
2597 #endif
2598 }
2599
2600
2601
2602
2603 static void disp_enintr(struct Scsi_Host *shpnt)
2604 {
2605 int s;
2606
2607 printk("enabled interrupts (");
2608
2609 s=GETPORT(SIMODE0);
2610 if(s & ENSELDO) printk("ENSELDO ");
2611 if(s & ENSELDI) printk("ENSELDI ");
2612 if(s & ENSELINGO) printk("ENSELINGO ");
2613 if(s & ENSWRAP) printk("ENSWRAP ");
2614 if(s & ENSDONE) printk("ENSDONE ");
2615 if(s & ENSPIORDY) printk("ENSPIORDY ");
2616 if(s & ENDMADONE) printk("ENDMADONE ");
2617
2618 s=GETPORT(SIMODE1);
2619 if(s & ENSELTIMO) printk("ENSELTIMO ");
2620 if(s & ENATNTARG) printk("ENATNTARG ");
2621 if(s & ENPHASEMIS) printk("ENPHASEMIS ");
2622 if(s & ENBUSFREE) printk("ENBUSFREE ");
2623 if(s & ENSCSIPERR) printk("ENSCSIPERR ");
2624 if(s & ENPHASECHG) printk("ENPHASECHG ");
2625 if(s & ENREQINIT) printk("ENREQINIT ");
2626 printk(")\n");
2627 }
2628
2629 #if defined(DEBUG_RACE)
2630
2631 static const char *should_leave;
2632 static int in_driver=0;
2633
2634
2635
2636
2637 static void enter_driver(const char *func)
2638 {
2639 unsigned long flags;
2640
2641 save_flags(flags);
2642 cli();
2643 printk("aha152x: entering %s() (%x)\n", func, jiffies);
2644 if(in_driver)
2645 {
2646 printk("%s should leave first.\n", should_leave);
2647 panic("aha152x: already in driver\n");
2648 }
2649
2650 in_driver++;
2651 should_leave=func;
2652 restore_flags(flags);
2653 }
2654
2655 static void leave_driver(const char *func)
2656 {
2657 unsigned long flags;
2658
2659 save_flags(flags);
2660 cli();
2661 printk("\naha152x: leaving %s() (%x)\n", func, jiffies);
2662 if(!in_driver)
2663 {
2664 printk("aha152x: %s already left.\n", should_leave);
2665 panic("aha152x: %s already left driver.\n");
2666 }
2667
2668 in_driver--;
2669 should_leave=func;
2670 restore_flags(flags);
2671 }
2672 #endif
2673
2674
2675
2676
2677 static void show_command(Scsi_Cmnd *ptr)
2678 {
2679 printk("0x%08x: target=%d; lun=%d; cmnd=(",
2680 (unsigned int) ptr, ptr->target, ptr->lun);
2681
2682 print_command(ptr->cmnd);
2683
2684 printk("); residual=%d; buffers=%d; phase |",
2685 ptr->SCp.this_residual, ptr->SCp.buffers_residual);
2686
2687 if(ptr->SCp.phase & not_issued ) printk("not issued|");
2688 if(ptr->SCp.phase & in_selection) printk("in selection|");
2689 if(ptr->SCp.phase & disconnected) printk("disconnected|");
2690 if(ptr->SCp.phase & aborted ) printk("aborted|");
2691 if(ptr->SCp.phase & sent_ident ) printk("send_ident|");
2692 if(ptr->SCp.phase & in_other)
2693 {
2694 printk("; in other(");
2695 switch((ptr->SCp.phase >> 16) & P_MASK)
2696 {
2697 case P_DATAO:
2698 printk("DATA OUT");
2699 break;
2700 case P_DATAI:
2701 printk("DATA IN");
2702 break;
2703 case P_CMD:
2704 printk("COMMAND");
2705 break;
2706 case P_STATUS:
2707 printk("STATUS");
2708 break;
2709 case P_MSGO:
2710 printk("MESSAGE OUT");
2711 break;
2712 case P_MSGI:
2713 printk("MESSAGE IN");
2714 break;
2715 default:
2716 printk("*illegal*");
2717 break;
2718 }
2719 printk(")");
2720 if(ptr->SCp.phase & (1<<16))
2721 printk("; phaseend");
2722 }
2723 printk("; next=0x%08x\n", (unsigned int) ptr->host_scribble);
2724 }
2725
2726
2727
2728
2729 static void show_queues(struct Scsi_Host *shpnt)
2730 {
2731 unsigned long flags;
2732 Scsi_Cmnd *ptr;
2733
2734 save_flags(flags);
2735 cli();
2736 printk("QUEUE STATUS:\nissue_SC:\n");
2737 for(ptr=ISSUE_SC; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
2738 show_command(ptr);
2739
2740 printk("current_SC:\n");
2741 if(CURRENT_SC)
2742 show_command(CURRENT_SC);
2743 else
2744 printk("none\n");
2745
2746 printk("disconnected_SC:\n");
2747 for(ptr=DISCONNECTED_SC; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
2748 show_command(ptr);
2749
2750 disp_ports(shpnt);
2751 disp_enintr(shpnt);
2752 restore_flags(flags);
2753 }
2754
2755 int aha152x_set_info(char *buffer, int length, struct Scsi_Host *shpnt)
2756 {
2757 return(-ENOSYS);
2758 }
2759
2760 #undef SPRINTF
2761 #define SPRINTF(args...) pos += sprintf(pos, ## args)
2762
2763 static int get_command(char *pos, Scsi_Cmnd *ptr)
2764 {
2765 char *start = pos;
2766 int i;
2767
2768 SPRINTF("0x%08x: target=%d; lun=%d; cmnd=(",
2769 (unsigned int) ptr, ptr->target, ptr->lun);
2770
2771 for(i=0; i<COMMAND_SIZE(ptr->cmnd[0]); i++)
2772 SPRINTF("0x%02x", ptr->cmnd[i]);
2773
2774 SPRINTF("); residual=%d; buffers=%d; phase |",
2775 ptr->SCp.this_residual, ptr->SCp.buffers_residual);
2776
2777 if(ptr->SCp.phase & not_issued ) SPRINTF("not issued|");
2778 if(ptr->SCp.phase & in_selection) SPRINTF("in selection|");
2779 if(ptr->SCp.phase & disconnected) SPRINTF("disconnected|");
2780 if(ptr->SCp.phase & aborted ) SPRINTF("aborted|");
2781 if(ptr->SCp.phase & sent_ident ) SPRINTF("send_ident|");
2782 if(ptr->SCp.phase & in_other)
2783 {
2784 SPRINTF("; in other(");
2785 switch((ptr->SCp.phase >> 16) & P_MASK)
2786 {
2787 case P_DATAO:
2788 SPRINTF("DATA OUT");
2789 break;
2790 case P_DATAI:
2791 SPRINTF("DATA IN");
2792 break;
2793 case P_CMD:
2794 SPRINTF("COMMAND");
2795 break;
2796 case P_STATUS:
2797 SPRINTF("STATUS");
2798 break;
2799 case P_MSGO:
2800 SPRINTF("MESSAGE OUT");
2801 break;
2802 case P_MSGI:
2803 SPRINTF("MESSAGE IN");
2804 break;
2805 default:
2806 SPRINTF("*illegal*");
2807 break;
2808 }
2809 SPRINTF(")");
2810 if(ptr->SCp.phase & (1<<16))
2811 SPRINTF("; phaseend");
2812 }
2813 SPRINTF("; next=0x%08x\n", (unsigned int) ptr->host_scribble);
2814
2815 return(pos-start);
2816 }
2817
2818 #undef SPRINTF
2819 #define SPRINTF(args...) do { if(pos < buffer + length) pos += sprintf(pos, ## args); } while(0)
2820
2821 int aha152x_proc_info(
2822 char *buffer,
2823 char **start,
2824 off_t offset,
2825 int length,
2826 int hostno,
2827 int inout
2828 )
2829 {
2830 int i;
2831 char *pos = buffer;
2832 Scsi_Device *scd;
2833 struct Scsi_Host *shpnt;
2834 unsigned long flags;
2835 Scsi_Cmnd *ptr;
2836
2837 for(i=0, shpnt= (struct Scsi_Host *) NULL; i<IRQS; i++)
2838 if(aha152x_host[i] && aha152x_host[i]->host_no == hostno)
2839 shpnt=aha152x_host[i];
2840
2841 if(!shpnt)
2842 return(-ESRCH);
2843
2844 if(inout)
2845 return(aha152x_set_info(buffer, length, shpnt));
2846
2847 SPRINTF(AHA152X_REVID "\n");
2848
2849 save_flags(flags);
2850 cli();
2851
2852 SPRINTF("vital data:\nioports 0x%04x to 0x%04x\n",
2853 shpnt->io_port, shpnt->io_port+shpnt->n_io_port-1);
2854 SPRINTF("interrupt 0x%02x\n", shpnt->irq);
2855 SPRINTF("disconnection/reconnection %s\n",
2856 HOSTDATA(shpnt)->reconnect ? "enabled" : "disabled");
2857 SPRINTF("parity checking %s\n",
2858 HOSTDATA(shpnt)->parity ? "enabled" : "disabled");
2859 SPRINTF("synchronous transfers %s\n",
2860 HOSTDATA(shpnt)->synchronous ? "enabled" : "disabled");
2861 SPRINTF("current queued %d commands\n",
2862 HOSTDATA(shpnt)->commands);
2863
2864 #if 0
2865 SPRINTF("synchronously operating targets (tick=%ld ns):\n",
2866 250000000/loops_per_sec);
2867 for(i=0; i<8; i++)
2868 if(HOSTDATA(shpnt)->syncrate[i]&0x7f)
2869 SPRINTF("target %d: period %dT/%ldns; req/ack offset %d\n",
2870 i,
2871 (((HOSTDATA(shpnt)->syncrate[i]&0x70)>>4)+2),
2872 (((HOSTDATA(shpnt)->syncrate[i]&0x70)>>4)+2)*
2873 250000000/loops_per_sec,
2874 HOSTDATA(shpnt)->syncrate[i]&0x0f);
2875 #else
2876 SPRINTF("synchronously operating targets (tick=50 ns):\n");
2877 for(i=0; i<8; i++)
2878 if(HOSTDATA(shpnt)->syncrate[i]&0x7f)
2879 SPRINTF("target %d: period %dT/%dns; req/ack offset %d\n",
2880 i,
2881 (((HOSTDATA(shpnt)->syncrate[i]&0x70)>>4)+2),
2882 (((HOSTDATA(shpnt)->syncrate[i]&0x70)>>4)+2)*50,
2883 HOSTDATA(shpnt)->syncrate[i]&0x0f);
2884 #endif
2885
2886 #ifdef DEBUG_AHA152X
2887 #define PDEBUG(flags,txt) if(HOSTDATA(shpnt)->debug & flags) SPRINTF("(%s) ", txt);
2888
2889 SPRINTF("enabled debugging options:\n");
2890
2891 PDEBUG(debug_skipports, "skip ports");
2892 PDEBUG(debug_queue, "queue");
2893 PDEBUG(debug_intr, "interrupt");
2894 PDEBUG(debug_selection, "selection");
2895 PDEBUG(debug_msgo, "message out");
2896 PDEBUG(debug_msgi, "message in");
2897 PDEBUG(debug_status, "status");
2898 PDEBUG(debug_cmd, "command");
2899 PDEBUG(debug_datai, "data in");
2900 PDEBUG(debug_datao, "data out");
2901 PDEBUG(debug_abort, "abort");
2902 PDEBUG(debug_done, "done");
2903 PDEBUG(debug_biosparam, "bios parameters");
2904 PDEBUG(debug_phases, "phases");
2905 PDEBUG(debug_queues, "queues");
2906 PDEBUG(debug_reset, "reset");
2907
2908 SPRINTF("\n");
2909 #endif
2910
2911 SPRINTF("queue status:\nnot yet issued commands:\n");
2912 for(ptr=ISSUE_SC; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
2913 pos += get_command(pos, ptr);
2914
2915 if(CURRENT_SC)
2916 {
2917 SPRINTF("current command:\n");
2918 pos += get_command(pos, CURRENT_SC);
2919 }
2920
2921 SPRINTF("disconnected commands:\n");
2922 for(ptr=DISCONNECTED_SC; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
2923 pos += get_command(pos, ptr);
2924
2925 restore_flags(flags);
2926
2927 scd = scsi_devices;
2928
2929 SPRINTF("Attached devices: %s\n", (scd)?"":"none");
2930
2931 while (scd) {
2932 if (scd->host == shpnt) {
2933
2934 SPRINTF("Channel: %02d Id: %02d Lun: %02d\n Vendor: ",
2935 scd->channel, scd->id, scd->lun);
2936 for (i=0; i<8; i++) {
2937 if (scd->vendor[i] >= 0x20)
2938 SPRINTF("%c", scd->vendor[i]);
2939 else
2940 SPRINTF(" ");
2941 }
2942 SPRINTF(" Model: ");
2943 for (i = 0; i < 16; i++) {
2944 if (scd->model[i] >= 0x20)
2945 SPRINTF("%c", scd->model[i]);
2946 else
2947 SPRINTF(" ");
2948 }
2949 SPRINTF(" Rev: ");
2950 for (i = 0; i < 4; i++) {
2951 if (scd->rev[i] >= 0x20)
2952 SPRINTF("%c", scd->rev[i]);
2953 else
2954 SPRINTF(" ");
2955 }
2956 SPRINTF("\n");
2957
2958 SPRINTF(" Type: %d ", scd->type);
2959 SPRINTF(" ANSI SCSI revision: %02x",
2960 (scd->scsi_level < 3)?1:2);
2961
2962 if (scd->scsi_level == 2)
2963 SPRINTF(" CCS\n");
2964 else
2965 SPRINTF("\n");
2966 }
2967 scd = scd->next;
2968 }
2969
2970 *start=buffer+offset;
2971 if (pos - buffer < offset)
2972 return 0;
2973 else if (pos - buffer - offset < length)
2974 return pos - buffer - offset;
2975 else
2976 return length;
2977 }
2978
2979 #ifdef MODULE
2980
2981 Scsi_Host_Template driver_template = AHA152X;
2982
2983 #include "scsi_module.c"
2984 #endif