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 #ifndef NCR53c7x0_H
40 #define NCR53c7x0_H
41
42
43
44
45
46
47
48
49 #if defined(HOSTS_C) || defined(MODULE)
50 #include <linux/scsicam.h>
51 extern int NCR53c7xx_abort(Scsi_Cmnd *);
52 extern int NCR53c7xx_detect(Scsi_Host_Template *tpnt);
53 extern int NCR53c7xx_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
54 extern int NCR53c7xx_reset(Scsi_Cmnd *);
55 #ifdef MODULE
56 extern int NCR53c7xx_release(struct Scsi_Host *);
57 #else
58 #define NCR53c7xx_release NULL
59 #endif
60
61 #define NCR53c7xx {NULL, NULL, "NCR53c{7,8}xx (rel 4)", NCR53c7xx_detect, \
62 NULL, NULL, NULL, \
63 NCR53c7xx_queue_command, NCR53c7xx_abort, NCR53c7xx_reset, \
64 NULL , scsicam_bios_param, 1, \
65 7, 127 , 1 , \
66 0, 0, DISABLE_CLUSTERING}
67 #endif
68
69 #ifndef HOSTS_C
70
71
72
73
74 #define SCNTL0_REG 0x00
75 #define SCNTL0_ARB1 0x80
76 #define SCNTL0_ARB2 0x40
77 #define SCNTL0_STRT 0x20
78 #define SCNTL0_WATN 0x10
79 #define SCNTL0_EPC 0x08
80
81 #define SCNTL0_EPG_700 0x04
82 #define SCNTL0_AAP 0x02
83 #define SCNTL0_TRG 0x01
84
85
86
87 #define SCNTL1_REG 0x01
88 #define SCNTL1_EXC 0x80
89 #define SCNTL1_ADB 0x40
90 #define SCNTL1_ESR_700 0x20
91
92 #define SCNTL1_DHP_800 0x20
93
94 #define SCNTL1_CON 0x10
95 #define SCNTL1_RST 0x08
96 #define SCNTL1_AESP 0x04
97 #define SCNTL1_SND_700 0x02
98 #define SCNTL1_IARB_800 0x02
99
100
101 #define SCNTL1_RCV_700 0x01
102 #define SCNTL1_SST_800 0x01
103
104
105
106 #define SCNTL2_REG_800 0x02
107 #define SCNTL2_800_SDU 0x80
108
109
110
111 #define SCNTL3_REG_800 0x03
112 #define SCNTL3_800_SCF_SHIFT 4
113 #define SCNTL3_800_SCF_MASK 0x70
114 #define SCNTL3_800_SCF2 0x40
115 #define SCNTL3_800_SCF1 0x20
116 #define SCNTL3_800_SCF0 0x10
117
118
119
120
121 #define SCNTL3_800_CCF_SHIFT 0
122 #define SCNTL3_800_CCF_MASK 0x07
123 #define SCNTL3_800_CCF2 0x04
124 #define SCNTL3_800_CCF1 0x02
125 #define SCNTL3_800_CCF0 0x01
126
127
128
129
130
131
132
133
134 #define SDID_REG_700 0x02
135 #define SDID_REG_800 0x06
136
137 #define GP_REG_800 0x07
138 #define GP_800_IO1 0x02
139 #define GP_800_IO2 0x01
140
141
142
143 #define SIEN_REG_700 0x03
144 #define SIEN0_REG_800 0x40
145 #define SIEN_MA 0x80
146 #define SIEN_FC 0x40
147 #define SIEN_700_STO 0x20
148 #define SIEN_800_SEL 0x20
149 #define SIEN_700_SEL 0x10
150 #define SIEN_800_RESEL 0x10
151 #define SIEN_SGE 0x08
152 #define SIEN_UDC 0x04
153 #define SIEN_RST 0x02
154 #define SIEN_PAR 0x01
155
156
157
158
159
160
161
162
163
164
165 #define SCID_REG 0x04
166
167 #define SCID_800_RRE 0x40
168 #define SCID_800_SRE 0x20
169
170 #define SCID_800_ENC_MASK 0x07
171
172
173 #define SXFER_REG 0x05
174 #define SXFER_DHP 0x80
175
176 #define SXFER_TP2 0x40
177 #define SXFER_TP1 0x20
178 #define SXFER_TP0 0x10
179 #define SXFER_TP_MASK 0x70
180 #define SXFER_TP_SHIFT 4
181 #define SXFER_TP_4 0x00
182 #define SXFER_TP_5 0x10
183 #define SXFER_TP_6 0x20
184 #define SXFER_TP_7 0x30
185 #define SXFER_TP_8 0x40
186 #define SXFER_TP_9 0x50
187 #define SXFER_TP_10 0x60
188 #define SXFER_TP_11 0x70
189
190 #define SXFER_MO3 0x08
191 #define SXFER_MO2 0x04
192 #define SXFER_MO1 0x02
193 #define SXFER_MO0 0x01
194 #define SXFER_MO_MASK 0x0f
195 #define SXFER_MO_SHIFT 0
196
197
198
199
200
201
202
203 #define SODL_REG_700 0x06
204 #define SODL_REG_800 0x54
205
206
207
208
209
210
211
212
213
214
215 #define SBCL_REG 0x0b
216 #define SBCL_REQ 0x80
217 #define SBCL_ACK 0x40
218 #define SBCL_BSY 0x20
219 #define SBCL_SEL 0x10
220 #define SBCL_ATN 0x08
221 #define SBCL_MSG 0x04
222 #define SBCL_CD 0x02
223 #define SBCL_IO 0x01
224 #define SBCL_PHASE_CMDOUT SBCL_CD
225 #define SBCL_PHASE_DATAIN SBCL_IO
226 #define SBCL_PHASE_DATAOUT 0
227 #define SBCL_PHASE_MSGIN (SBCL_CD|SBCL_IO|SBCL_MSG)
228 #define SBCL_PHASE_MSGOUT (SBCL_CD|SBCL_MSG)
229 #define SBCL_PHASE_STATIN (SBCL_CD|SBCL_IO)
230 #define SBCL_PHASE_MASK (SBCL_CD|SBCL_IO|SBCL_MSG)
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248 #define SFBR_REG 0x08
249
250
251
252
253
254
255
256 #define SIDL_REG_700 0x09
257 #define SIDL_REG_800 0x50
258
259
260
261
262
263
264
265 #define SBDL_REG_700 0x0a
266 #define SBDL_REG_800 0x58
267
268 #define SSID_REG_800 0x0a
269 #define SSID_800_VAL 0x80
270 #define SSID_800_ENCID_MASK 0x07
271
272
273
274
275
276
277 #define SOCL_REG 0x0b
278 #define SOCL_REQ 0x80
279 #define SOCL_ACK 0x40
280 #define SOCL_BSY 0x20
281 #define SOCL_SEL 0x10
282 #define SOCL_ATN 0x08
283 #define SOCL_MSG 0x04
284 #define SOCL_CD 0x02
285 #define SOCL_IO 0x01
286
287
288
289
290
291
292
293 #define SBCL_SSCF1 0x02
294 #define SBCL_SSCF0 0x01
295 #define SBCL_SSCF_MASK 0x03
296
297
298
299
300
301
302 #define DSTAT_REG 0x0c
303 #define DSTAT_DFE 0x80
304 #define DSTAT_800_MDPE 0x40
305 #define DSTAT_800_BF 0x20
306 #define DSTAT_ABRT 0x10
307 #define DSTAT_SSI 0x08
308 #define DSTAT_SIR 0x04
309
310
311 #define DSTAT_WTD 0x02
312 #define DSTAT_OPC 0x01
313 #define DSTAT_800_IID 0x01
314
315
316 #define SSTAT0_REG 0x0d
317 #define SIST0_REG_800 0x42
318 #define SSTAT0_MA 0x80
319
320
321 #define SSTAT0_CMP 0x40
322 #define SSTAT0_700_STO 0x20
323 #define SIST0_800_SEL 0x20
324 #define SSTAT0_700_SEL 0x10
325 #define SIST0_800_RSL 0x10
326 #define SSTAT0_SGE 0x08
327 #define SSTAT0_UDC 0x04
328 #define SSTAT0_RST 0x02
329 #define SSTAT0_PAR 0x01
330
331 #define SSTAT1_REG 0x0e
332 #define SSTAT1_ILF 0x80
333 #define SSTAT1_ORF 0x40
334 #define SSTAT1_OLF 0x20
335 #define SSTAT1_AIP 0x10
336 #define SSTAT1_LOA 0x08
337 #define SSTAT1_WOA 0x04
338 #define SSTAT1_RST 0x02
339 #define SSTAT1_SDP 0x01
340
341 #define SSTAT2_REG 0x0f
342 #define SSTAT2_FF3 0x80
343 #define SSTAT2_FF2 0x40
344 #define SSTAT2_FF1 0x20
345 #define SSTAT2_FF0 0x10
346 #define SSTAT2_FF_MASK 0xf0
347
348
349
350
351
352 #define SSTAT2_SDP 0x08
353 #define SSTAT2_MSG 0x04
354 #define SSTAT2_CD 0x02
355 #define SSTAT2_IO 0x01
356
357
358
359 #define SCRATCHA_REG_00 0x10
360
361 #define DSA_REG 0x10
362
363 #define CTEST0_REG_700 0x14
364 #define CTEST0_REG_800 0x18
365
366 #define CTEST0_700_RTRG 0x02
367 #define CTEST0_700_DDIR 0x01
368
369
370
371
372 #define CTEST1_REG_700 0x15
373 #define CTEST1_REG_800 0x19
374 #define CTEST1_FMT3 0x80
375 #define CTEST1_FMT2 0x40
376 #define CTEST1_FMT1 0x20
377 #define CTEST1_FMT0 0x10
378
379 #define CTEST1_FFL3 0x08
380 #define CTEST1_FFL2 0x04
381 #define CTEST1_FFL1 0x02
382 #define CTEST1_FFL0 0x01
383
384 #define CTEST2_REG_700 0x16
385 #define CTEST2_REG_800 0x1a
386
387 #define CTEST2_800_DDIR 0x80
388 #define CTEST2_800_SIGP 0x40
389
390 #define CTEST2_800_CIO 0x20 .
391 #define CTEST2_800_CM 0x10
392
393
394 #define CTEST2_700_SOFF 0x20
395
396
397
398
399
400
401
402 #define CTEST2_700_SFP 0x10
403
404
405
406 #define CTEST2_700_DFP 0x08
407
408
409
410 #define CTEST2_TEOP 0x04
411
412
413
414 #define CTEST2_DREQ 0x02
415
416 #define CTEST2_800_DACK 0x01
417
418
419
420
421
422
423
424
425 #define CTEST3_REG_700 0x17
426
427 #define CTEST3_REG_800 0x1b
428 #define CTEST3_800_V3 0x80
429 #define CTEST3_800_V2 0x40
430 #define CTEST3_800_V1 0x20
431 #define CTEST3_800_V0 0x10
432 #define CTEST3_800_FLF 0x08
433 #define CTEST3_800_CLF 0x04
434 #define CTEST3_800_FM 0x02
435
436
437 #define CTEST4_REG_700 0x18
438 #define CTEST4_REG_800 0x21
439
440 #define CTEST4_800_BDIS 0x80
441 #define CTEST4_ZMOD 0x40
442 #define CTEST4_SZM 0x20
443 #define CTEST4_700_SLBE 0x10
444 #define CTEST4_800_SRTM 0x10
445 #define CTEST4_700_SFWR 0x08
446
447
448
449 #define CTEST4_800_MPEE 0x08
450
451
452
453
454
455
456
457
458 #define CTEST4_FBL2 0x04
459 #define CTEST4_FBL1 0x02
460 #define CTEST4_FBL0 0x01
461 #define CTEST4_FBL_MASK 0x07
462 #define CTEST4_FBL_0 0x04
463 #define CTEST4_FBL_1 0x05
464 #define CTEST4_FBL_2 0x06
465 #define CTEST4_FBL_3 0x07
466 #define CTEST4_800_SAVE (CTEST4_800_BDIS)
467
468
469 #define CTEST5_REG_700 0x19
470 #define CTEST5_REG_800 0x22
471
472
473
474
475
476 #define CTEST5_ADCK 0x80
477
478
479
480
481 #define CTEST5_BBCK 0x40
482
483
484
485
486
487
488
489
490
491 #define CTEST5_700_ROFF 0x20
492
493
494
495
496
497 #define CTEST5_MASR 0x10
498 #define CTEST5_DDIR 0x08
499
500
501
502 #define CTEST5_700_EOP 0x04
503 #define CTEST5_700_DREQ 0x02
504 #define CTEST5_700_DACK 0x01
505
506
507
508
509
510
511 #define CTEST6_REG_700 0x1a
512 #define CTEST6_REG_800 0x23
513
514 #define CTEST7_REG 0x1b
515
516 #define CTEST7_10_CDIS 0x80
517 #define CTEST7_10_SC1 0x40
518 #define CTEST7_10_SC0 0x20
519 #define CTEST7_10_SC_MASK 0x60
520
521 #define CTEST7_0060_FM 0x20
522 #define CTEST7_STD 0x10
523 #define CTEST7_DFP 0x08
524 #define CTEST7_EVP 0x04
525 #define CTEST7_10_TT1 0x02
526 #define CTEST7_00_DC 0x02
527
528 #define CTEST7_DIFF 0x01
529
530 #define CTEST7_SAVE ( CTEST7_EVP | CTEST7_DIFF )
531
532
533 #define TEMP_REG 0x1c
534
535 #define DFIFO_REG 0x20
536
537
538
539
540 #define DFIFO_00_FLF 0x80
541 #define DFIFO_00_CLF 0x40
542 #define DFIFO_BO6 0x40
543 #define DFIFO_BO5 0x20
544 #define DFIFO_BO4 0x10
545 #define DFIFO_BO3 0x08
546 #define DFIFO_BO2 0x04
547 #define DFIFO_BO1 0x02
548 #define DFIFO_BO0 0x01
549 #define DFIFO_10_BO_MASK 0x7f
550 #define DFIFO_00_BO_MASK 0x3f
551
552
553
554
555
556
557 #define ISTAT_REG_700 0x21
558 #define ISTAT_REG_800 0x14
559 #define ISTAT_ABRT 0x80
560
561
562 #define ISTAT_10_SRST 0x40
563 #define ISTAT_10_SIGP 0x20
564
565 #define ISTAT_800_SEM 0x10
566 #define ISTAT_CON 0x08
567 #define ISTAT_800_INTF 0x04
568 #define ISTAT_700_PRE 0x04
569
570
571
572
573 #define ISTAT_SIP 0x02
574
575
576
577 #define ISTAT_DIP 0x01
578
579
580
581
582 #define CTEST8_REG 0x22
583 #define CTEST8_0066_EAS 0x80
584
585
586 #define CTEST8_0066_EFM 0x40
587 #define CTEST8_0066_GRP 0x20
588
589
590
591
592 #define CTEST8_0066_TE 0x10
593
594
595
596
597 #define CTEST8_0066_HSC 0x08
598 #define CTEST8_0066_SRA 0x04
599
600
601
602 #define CTEST8_0066_DAS 0x02
603
604
605 #define CTEST8_0066_LDE 0x01
606
607
608
609
610
611
612
613
614
615 #define CTEST8_10_V3 0x80
616 #define CTEST8_10_V2 0x40
617 #define CTEST8_10_V1 0x20
618 #define CTEST8_10_V0 0x10
619 #define CTEST8_10_V_MASK 0xf0
620 #define CTEST8_10_FLF 0x08
621 #define CTEST8_10_CLF 0x04
622 #define CTEST8_10_FM 0x02
623 #define CTEST8_10_SM 0x01
624
625
626
627
628
629
630
631
632
633
634
635
636 #define CTEST9_REG_00 0x23
637 #define LCRC_REG_10 0x23
638
639
640
641
642
643
644
645
646
647
648 #define DBC_REG 0x24
649
650
651
652
653
654
655 #define DBC_TCI_TRUE (1 << 19)
656 #define DBC_TCI_COMPARE_DATA (1 << 18)
657 #define DBC_TCI_COMPARE_PHASE (1 << 17)
658 #define DBC_TCI_WAIT_FOR_VALID (1 << 16)
659
660 #define DBC_TCI_MASK_MASK 0xff00
661 #define DBC_TCI_MASK_SHIFT 8
662 #define DBC_TCI_DATA_MASK 0xff
663 #define DBC_TCI_DATA_SHIFT 0
664
665 #define DBC_RWRI_IMMEDIATE_MASK 0xff00
666 #define DBC_RWRI_IMMEDIATE_SHIFT 8
667 #define DBC_RWRI_ADDRESS_MASK 0x3f0000
668 #define DBC_RWRI_ADDRESS_SHIFT 16
669
670
671
672
673
674 #define DCMD_REG 0x27
675 #define DCMD_TYPE_MASK 0xc0
676 #define DCMD_TYPE_BMI 0x00
677 #define DCMD_BMI_IO 0x01
678 #define DCMD_BMI_CD 0x02
679 #define DCMD_BMI_MSG 0x04
680
681 #define DCMD_BMI_OP_MASK 0x18
682 #define DCMD_BMI_OP_MOVE_T 0x00
683 #define DCMD_BMI_OP_MOVE_I 0x08
684
685 #define DCMD_BMI_INDIRECT 0x20
686
687 #define DCMD_TYPE_TCI 0x80
688
689 #define DCMD_TCI_IO 0x01
690 #define DCMD_TCI_CD 0x02
691 #define DCMD_TCI_MSG 0x04
692 #define DCMD_TCI_OP_MASK 0x38
693 #define DCMD_TCI_OP_JUMP 0x00
694 #define DCMD_TCI_OP_CALL 0x08
695 #define DCMD_TCI_OP_RETURN 0x10
696 #define DCMD_TCI_OP_INT 0x18
697
698 #define DCMD_TYPE_RWRI 0x40
699
700 #define DCMD_RWRI_OPC_MASK 0x38
701 #define DCMD_RWRI_OPC_WRITE 0x28
702 #define DCMD_RWRI_OPC_READ 0x30
703 #define DCMD_RWRI_OPC_MODIFY 0x38
704
705 #define DCMD_RWRI_OP_MASK 0x07
706 #define DCMD_RWRI_OP_MOVE 0x00
707 #define DCMD_RWRI_OP_SHL 0x01
708 #define DCMD_RWRI_OP_OR 0x02
709 #define DCMD_RWRI_OP_XOR 0x03
710 #define DCMD_RWRI_OP_AND 0x04
711 #define DCMD_RWRI_OP_SHR 0x05
712 #define DCMD_RWRI_OP_ADD 0x06
713 #define DCMD_RWRI_OP_ADDC 0x07
714
715 #define DCMD_TYPE_MMI 0xc0
716
717
718
719 #define DNAD_REG 0x28
720
721 #define DSP_REG 0x2c
722 #define DSPS_REG 0x30
723
724 #define DMODE_REG_00 0x34
725 #define DMODE_00_BL1 0x80
726 #define DMODE_00_BL0 0x40
727 #define DMODE_BL_MASK 0xc0
728
729 #define DMODE_BL_2 0x00
730 #define DMODE_BL_4 0x40
731 #define DMODE_BL_8 0x80
732 #define DMODE_BL_16 0xc0
733
734 #define DMODE_700_BW16 0x20
735 #define DMODE_700_286 0x10
736 #define DMODE_700_IOM 0x08
737 #define DMODE_700_FAM 0x04
738 #define DMODE_700_PIPE 0x02
739
740
741 #define DMODE_MAN 0x01
742
743
744
745
746
747 #define DMODE_700_SAVE ( DMODE_00_BL_MASK | DMODE_00_BW16 | DMODE_00_286 )
748
749
750 #define SCRATCHA_REG_800 0x34
751
752 #define SCRATCB_REG_10 0x34
753
754 #define DMODE_REG_10 0x38
755 #define DMODE_800_SIOM 0x20
756 #define DMODE_800_DIOM 0x10
757 #define DMODE_800_ERL 0x08
758
759
760 #define DIEN_REG 0x39
761
762 #define DIEN_800_MDPE 0x40
763 #define DIEN_800_BF 0x20
764 #define DIEN_ABRT 0x10
765 #define DIEN_SSI 0x08
766 #define DIEN_SIR 0x04
767
768
769
770 #define DIEN_700_WTD 0x02
771 #define DIEN_700_OPC 0x01
772
773
774 #define DIEN_800_IID 0x01
775
776
777
778
779
780 #define DWT_REG 0x3a
781
782
783 #define DCNTL_REG 0x3b
784 #define DCNTL_700_CF1 0x80
785 #define DCNTL_700_CF0 0x40
786 #define DCNTL_700_CF_MASK 0xc0
787
788 #define DCNTL_700_CF_2 0x00
789 #define DCNTL_700_CF_1_5 0x40
790 #define DCNTL_700_CF_1 0x80
791 #define DCNTL_700_CF_3 0xc0
792
793 #define DCNTL_700_S16 0x20
794 #define DCNTL_SSM 0x10
795 #define DCNTL_700_LLM 0x08
796
797 #define DCNTL_800_IRQM 0x08
798 #define DCNTL_STD 0x04
799
800 #define DCNTL_00_RST 0x01
801
802
803
804 #define DCNTL_10_COM 0x01
805
806 #define DCNTL_700_SAVE ( DCNTL_CF_MASK | DCNTL_S16)
807
808
809
810 #define SCRATCHB_REG_00 0x3c
811 #define SCRATCHB_REG_800 0x5c
812
813 #define ADDER_REG_10 0x3c
814
815 #define SIEN1_REG_800 0x41
816 #define SIEN1_800_STO 0x04
817 #define SIEN1_800_GEN 0x02
818 #define SIEN1_800_HTH 0x01
819
820 #define SIST1_REG_800 0x43
821 #define SIST1_800_STO 0x04
822 #define SIST1_800_GEN 0x02
823 #define SIST1_800_HTH 0x01
824
825 #define SLPAR_REG_800 0x44
826
827 #define MACNTL_REG_800 0x46
828 #define MACNTL_800_TYP3 0x80
829 #define MACNTL_800_TYP2 0x40
830 #define MACNTL_800_TYP1 0x20
831 #define MACNTL_800_TYP0 0x10
832 #define MACNTL_800_DWR 0x08
833 #define MACNTL_800_DRD 0x04
834 #define MACNTL_800_PSCPT 0x02
835 #define MACNTL_800_SCPTS 0x01
836
837 #define GPCNTL_REG_800 0x47
838
839
840 #define STIME0_REG_800 0x48
841 #define STIME0_800_HTH_MASK 0xf0
842 #define STIME0_800_HTH_SHIFT 4
843 #define STIME0_800_SEL_MASK 0x0f
844 #define STIME0_800_SEL_SHIFT 0
845
846 #define STIME1_REG_800 0x49
847 #define STIME1_800_GEN_MASK 0x0f
848
849 #define RESPID_REG_800 0x4a
850
851 #define STEST0_REG_800 0x4c
852 #define STEST0_800_SLT 0x08
853 #define STEST0_800_ART 0x04
854 #define STEST0_800_SOZ 0x02
855 #define STEST0_800_SOM 0x01
856
857 #define STEST1_REG_800 0x4d
858 #define STEST1_800_SCLK 0x80
859
860 #define STEST2_REG_800 0x4e
861 #define STEST2_800_SCE 0x80
862 #define STEST2_800_ROF 0x40
863 #define STEST2_800_SLB 0x10
864 #define STEST2_800_SZM 0x08
865 #define STEST2_800_EXT 0x02
866 #define STEST2_800_LOW 0x01
867
868 #define STEST3_REG_800 0x4f
869 #define STEST3_800_TE 0x80
870 #define STEST3_800_STR 0x40
871 #define STEST3_800_HSC 0x20
872 #define STEST3_800_DSI 0x10
873 #define STEST3_800_TTM 0x04
874 #define STEST3_800_CSF 0x02
875 #define STEST3_800_STW 0x01
876
877
878
879
880
881 #define OPTION_PARITY 0x1
882 #define OPTION_TAGGED_QUEUE 0x2
883 #define OPTION_700 0x8
884 #define OPTION_INTFLY 0x10
885 #define OPTION_DEBUG_INTR 0x20
886 #define OPTION_DEBUG_INIT_ONLY 0x40
887
888
889
890 #define OPTION_DEBUG_READ_ONLY 0x80
891
892 #define OPTION_DEBUG_TRACE 0x100
893
894
895 #define OPTION_DEBUG_SINGLE 0x200
896
897 #define OPTION_SYNCHRONOUS 0x400
898 #define OPTION_MEMORY_MAPPED 0x800
899
900 #define OPTION_IO_MAPPED 0x1000
901
902 #define OPTION_DEBUG_PROBE_ONLY 0x2000
903 #define OPTION_DEBUG_TESTS_ONLY 0x4000
904
905 #define OPTION_DEBUG_TEST0 0x08000
906 #define OPTION_DEBUG_TEST1 0x10000
907 #define OPTION_DEBUG_TEST2 0x20000
908
909 #define OPTION_DEBUG_DUMP 0x40000
910 #define OPTION_DEBUG_TARGET_LIMIT 0x80000
911 #define OPTION_DEBUG_NCOMMANDS_LIMIT 0x100000
912 #define OPTION_DEBUG_SCRIPT 0x200000
913 #define OPTION_DEBUG_FIXUP 0x400000
914 #define OPTION_DEBUG_DSA 0x800000
915 #define OPTION_DEBUG_CORRUPTION 0x1000000
916
917 #if !defined(PERM_OPTIONS)
918 #define PERM_OPTIONS 0
919 #endif
920
921 struct NCR53c7x0_synchronous {
922 unsigned long select_indirect;
923 unsigned long script[6];
924
925 unsigned renegotiate:1;
926
927 };
928
929 #define CMD_FLAG_SDTR 1
930
931 #define CMD_FLAG_WDTR 2
932
933 #define CMD_FLAG_DID_SDTR 4
934
935 struct NCR53c7x0_table_indirect {
936 unsigned long count;
937 void *address;
938 };
939
940 struct NCR53c7x0_cmd {
941 void *real;
942 void (* free)(void *);
943
944
945 Scsi_Cmnd *cmd;
946
947
948
949
950 int size;
951
952
953 int flags;
954
955 unsigned char select[11];
956
957
958
959
960
961
962 volatile struct NCR53c7x0_cmd *next, *prev;
963
964
965
966
967
968
969 unsigned long *data_transfer_start;
970 unsigned long *data_transfer_end;
971
972
973 unsigned long residual[8];
974
975
976
977
978
979
980
981 unsigned long dsa[0];
982
983
984 };
985
986 struct NCR53c7x0_break {
987 unsigned long *address, old_instruction[2];
988 struct NCR53c7x0_break *next;
989 unsigned char old_size;
990 };
991
992
993 #define STATE_HALTED 0
994
995
996
997
998
999 #define STATE_WAITING 1
1000
1001 #define STATE_RUNNING 2
1002
1003
1004
1005 #define STATE_ABORTING 3
1006
1007
1008 #define STATE_ABORTED 4
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018 #define SPECIFIC_INT_NOTHING 0
1019 #define SPECIFIC_INT_RESTART 1
1020 #define SPECIFIC_INT_ABORT 2
1021 #define SPECIFIC_INT_PANIC 3
1022 #define SPECIFIC_INT_DONE 4
1023 #define SPECIFIC_INT_BREAK 5
1024
1025 struct NCR53c7x0_hostdata {
1026 int size;
1027
1028 struct Scsi_Host *next;
1029 int board;
1030
1031
1032
1033
1034
1035 int chip;
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050 unsigned char pci_bus, pci_device_fn;
1051 unsigned pci_valid:1;
1052
1053 unsigned long *dsp;
1054
1055
1056
1057 unsigned dsp_changed:1;
1058
1059
1060 unsigned char dstat;
1061 unsigned dstat_valid:1;
1062
1063 unsigned expecting_iid:1;
1064 unsigned expecting_sto:1;
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077 void (* init_fixup)(struct Scsi_Host *host);
1078 void (* init_save_regs)(struct Scsi_Host *host);
1079 void (* dsa_fixup)(struct NCR53c7x0_cmd *cmd);
1080 void (* soft_reset)(struct Scsi_Host *host);
1081 int (* run_tests)(struct Scsi_Host *host);
1082
1083
1084
1085
1086
1087
1088
1089 int (* dstat_sir_intr)(struct Scsi_Host *host, struct NCR53c7x0_cmd *cmd);
1090
1091 long dsa_size;
1092
1093
1094
1095
1096
1097
1098 long dsa_start;
1099 long dsa_end;
1100 long dsa_next;
1101 long dsa_prev;
1102 long dsa_cmnd;
1103 long dsa_select;
1104 long dsa_msgout;
1105 long dsa_cmdout;
1106 long dsa_dataout;
1107 long dsa_datain;
1108 long dsa_msgin;
1109 long dsa_msgout_other;
1110 long dsa_write_sync;
1111 long dsa_write_resume;
1112 long dsa_jump_resume;
1113 long dsa_check_reselect;
1114 long dsa_status;
1115
1116
1117
1118
1119
1120
1121 long E_accept_message;
1122 long E_dsa_code_template;
1123 long E_dsa_code_template_end;
1124 long E_command_complete;
1125 long E_msg_in;
1126 long E_initiator_abort;
1127 long E_other_transfer;
1128 long E_target_abort;
1129 long E_schedule;
1130 long E_debug_break;
1131 long E_reject_message;
1132 long E_respond_message;
1133 long E_select;
1134 long E_select_msgout;
1135 long E_test_0;
1136 long E_test_1;
1137 long E_test_2;
1138 long E_test_3;
1139 long E_dsa_zero;
1140 long E_dsa_jump_resume;
1141
1142 int options;
1143 long test_completed;
1144 int test_running;
1145 int test_source;
1146 volatile int test_dest;
1147
1148 volatile int state;
1149
1150
1151 unsigned char dmode;
1152
1153
1154
1155 unsigned char istat;
1156
1157
1158
1159
1160 int scsi_clock;
1161
1162
1163
1164
1165
1166 volatile int intrs;
1167 unsigned char saved_dmode;
1168 unsigned char saved_ctest4;
1169 unsigned char saved_ctest7;
1170 unsigned char saved_dcntl;
1171 unsigned char saved_scntl3;
1172
1173 unsigned char this_id_mask;
1174
1175
1176 struct NCR53c7x0_break *breakpoints,
1177 *breakpoint_current;
1178
1179
1180 #ifdef NCR_DEBUG
1181 int debug_size;
1182 volatile int debug_count;
1183 volatile char *debug_buf;
1184 volatile char *debug_write;
1185 volatile char *debug_read;
1186 #endif
1187
1188
1189 int debug_print_limit;
1190
1191
1192
1193
1194 unsigned char debug_lun_limit[8];
1195
1196
1197
1198 int debug_count_limit;
1199
1200
1201
1202
1203 volatile unsigned idle:1;
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213 volatile struct NCR53c7x0_synchronous sync[8];
1214
1215 volatile struct NCR53c7x0_cmd *issue_queue;
1216
1217
1218 volatile struct NCR53c7x0_cmd *running_list;
1219
1220
1221 volatile struct NCR53c7x0_cmd *current;
1222
1223
1224
1225
1226 volatile struct NCR53c7x0_cmd *spare;
1227
1228
1229
1230 volatile struct NCR53c7x0_cmd *free;
1231 int max_cmd_size;
1232
1233
1234
1235 volatile int num_cmds;
1236
1237 volatile unsigned char cmd_allocated[8];
1238
1239
1240 volatile unsigned char busy[8][8];
1241
1242
1243
1244
1245
1246
1247
1248
1249 volatile struct NCR53c7x0_cmd *finished_queue;
1250
1251
1252
1253 volatile unsigned char *issue_dsa_head;
1254
1255
1256
1257
1258
1259 volatile unsigned char *issue_dsa_tail;
1260 volatile unsigned char msg_buf[16];
1261
1262
1263 volatile unsigned char *reconnect_dsa_head;
1264
1265
1266
1267 volatile unsigned char reselected_identify;
1268 volatile unsigned char reselected_tag;
1269
1270
1271
1272 long NCR53c7xx_zero;
1273 long NCR53c7xx_sink;
1274 char NCR53c7xx_msg_reject;
1275 char NCR53c7xx_msg_abort;
1276 char NCR53c7xx_msg_nop;
1277
1278 int script_count;
1279 unsigned long script[0];
1280
1281 };
1282
1283 #define IRQ_NONE 255
1284 #define DMA_NONE 255
1285 #define IRQ_AUTO 254
1286 #define DMA_AUTO 254
1287
1288 #define BOARD_GENERIC 0
1289
1290 #define NCR53c7x0_insn_size(insn) \
1291 (((insn) & DCMD_TYPE_MASK) == DCMD_TYPE_MMI ? 3 : 2)
1292
1293
1294 #define NCR53c7x0_local_declare() \
1295 volatile unsigned char *NCR53c7x0_address_memory; \
1296 unsigned short NCR53c7x0_address_io; \
1297 int NCR53c7x0_memory_mapped
1298
1299 #define NCR53c7x0_local_setup(host) \
1300 NCR53c7x0_address_memory = (void *) (host)->base; \
1301 NCR53c7x0_address_io = (unsigned short) (host)->io_port; \
1302 NCR53c7x0_memory_mapped = ((struct NCR53c7x0_hostdata *) \
1303 host->hostdata)-> options & OPTION_MEMORY_MAPPED
1304
1305 #define NCR53c7x0_read8(address) \
1306 (NCR53c7x0_memory_mapped ? \
1307 *( (NCR53c7x0_address_memory) + (address)) : \
1308 inb(NCR53c7x0_address_io + (address)))
1309
1310 #define NCR53c7x0_read16(address) \
1311 (NCR53c7x0_memory_mapped ? \
1312 *((unsigned short *) (NCR53c7x0_address_memory) + (address)) : \
1313 inw(NCR53c7x0_address_io + (address)))
1314
1315 #define NCR53c7x0_read32(address) \
1316 (NCR53c7x0_memory_mapped ? \
1317 *((unsigned long *) (NCR53c7x0_address_memory) + (address)) : \
1318 inl(NCR53c7x0_address_io + (address)))
1319
1320 #define NCR53c7x0_write8(address,value) \
1321 (NCR53c7x0_memory_mapped ? \
1322 *((unsigned char *) (NCR53c7x0_address_memory) + (address)) = \
1323 (value) : \
1324 outb((value), NCR53c7x0_address_io + (address)))
1325
1326 #define NCR53c7x0_write16(address,value) \
1327 (NCR53c7x0_memory_mapped ? \
1328 *((unsigned short *) (NCR53c7x0_address_memory) + (address)) = \
1329 (value) : \
1330 outw((value), NCR53c7x0_address_io + (address)))
1331
1332 #define NCR53c7x0_write32(address,value) \
1333 (NCR53c7x0_memory_mapped ? \
1334 *((unsigned long *) (NCR53c7x0_address_memory) + (address)) = \
1335 (value) : \
1336 outl((value), NCR53c7x0_address_io + (address)))
1337
1338 #define patch_abs_32(script, offset, symbol, value) \
1339 for (i = 0; i < (sizeof (A_##symbol##_used) / sizeof \
1340 (unsigned long)); ++i) { \
1341 (script)[A_##symbol##_used[i] - (offset)] += (value); \
1342 if (hostdata->options & OPTION_DEBUG_FIXUP) \
1343 printk("scsi%d : %s reference %d at 0x%lx in %s is now 0x%lx\n",\
1344 host->host_no, #symbol, i, A_##symbol##_used[i] - \
1345 (offset), #script, (script)[A_##symbol##_used[i] - \
1346 (offset)]); \
1347 }
1348
1349 #define patch_abs_rwri_data(script, offset, symbol, value) \
1350 for (i = 0; i < (sizeof (A_##symbol##_used) / sizeof \
1351 (unsigned long)); ++i) \
1352 (script)[A_##symbol##_used[i] - (offset)] = \
1353 ((script)[A_##symbol##_used[i] - (offset)] & \
1354 ~DBC_RWRI_IMMEDIATE_MASK) | \
1355 (((value) << DBC_RWRI_IMMEDIATE_SHIFT) & \
1356 DBC_RWRI_IMMEDIATE_MASK)
1357
1358 #define patch_dsa_32(dsa, symbol, word, value) \
1359 { \
1360 (dsa)[(hostdata->##symbol - hostdata->dsa_start) / sizeof(long) \
1361 + (word)] = (unsigned long) (value); \
1362 if (hostdata->options & OPTION_DEBUG_DSA) \
1363 printk("scsi : dsa %s symbol %s(%ld) word %d now 0x%lx\n", \
1364 #dsa, #symbol, (long) hostdata->##symbol, \
1365 (int) (word), (long) (value)); \
1366 }
1367
1368
1369
1370 #endif
1371 #endif