1#define ASC_VERSION "3.3G"
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757#ifndef LINUX_VERSION_CODE
758#include <linux/version.h>
759#endif
760
761
762#define ASC_LINUX_VERSION(V, P, S) (((V) * 65536) + ((P) * 256) + (S))
763#define ASC_LINUX_KERNEL22 (LINUX_VERSION_CODE < ASC_LINUX_VERSION(2,4,0))
764#define ASC_LINUX_KERNEL24 (LINUX_VERSION_CODE >= ASC_LINUX_VERSION(2,4,0))
765
766
767#if LINUX_VERSION_CODE < ASC_LINUX_VERSION(2,2,0) || \
768 (LINUX_VERSION_CODE > ASC_LINUX_VERSION(2,3,0) && \
769 LINUX_VERSION_CODE < ASC_LINUX_VERSION(2,4,0))
770#error "AdvanSys driver supported only in 2.2 and 2.4 or greater kernels."
771#endif
772
773
774
775
776
777#include <linux/config.h>
778#include <linux/module.h>
779
780#if defined(CONFIG_X86) && !defined(CONFIG_ISA)
781#define CONFIG_ISA
782#endif
783
784#include <linux/string.h>
785#include <linux/sched.h>
786#include <linux/kernel.h>
787#include <linux/types.h>
788#include <linux/ioport.h>
789#include <linux/delay.h>
790#include <linux/slab.h>
791#include <linux/mm.h>
792#include <linux/proc_fs.h>
793#include <linux/init.h>
794#include <asm/io.h>
795#include <asm/system.h>
796#include <asm/dma.h>
797#include <linux/blk.h>
798#include <linux/stat.h>
799#if ASC_LINUX_KERNEL24
800#include <linux/spinlock.h>
801#elif ASC_LINUX_KERNEL22
802#include <asm/spinlock.h>
803#endif
804#include "scsi.h"
805#include "hosts.h"
806#include "sd.h"
807#include "advansys.h"
808#ifdef CONFIG_PCI
809#include <linux/pci.h>
810#endif
811
812
813
814
815
816
817
818#define ADVANSYS_ASSERT
819
820
821#define ADVANSYS_STATS
822
823
824
825
826
827
828
829
830
831#ifdef ADVANSYS_DEBUG
832#define STATIC
833#else
834#define STATIC static
835#endif
836
837
838
839
840
841
842#define ASC_LIB_VERSION_MAJOR 1
843#define ASC_LIB_VERSION_MINOR 24
844#define ASC_LIB_SERIAL_NUMBER 123
845
846
847
848
849
850
851
852
853
854
855#define ASC_PADDR __u32
856#define ASC_VADDR __u32
857#define ASC_DCNT __u32
858#define ASC_SDCNT __s32
859
860
861
862
863
864
865
866
867
868#define ASC_VADDR_TO_U32 virt_to_bus
869#define ASC_U32_TO_VADDR bus_to_virt
870
871typedef unsigned char uchar;
872
873#ifndef NULL
874#define NULL (0)
875#endif
876#ifndef TRUE
877#define TRUE (1)
878#endif
879#ifndef FALSE
880#define FALSE (0)
881#endif
882
883#define EOF (-1)
884#define ERR (-1)
885#define UW_ERR (uint)(0xFFFF)
886#define isodd_word(val) ((((uint)val) & (uint)0x0001) != 0)
887#define AscPCIConfigVendorIDRegister 0x0000
888#define AscPCIConfigDeviceIDRegister 0x0002
889#define AscPCIConfigCommandRegister 0x0004
890#define AscPCIConfigStatusRegister 0x0006
891#define AscPCIConfigRevisionIDRegister 0x0008
892#define AscPCIConfigCacheSize 0x000C
893#define AscPCIConfigLatencyTimer 0x000D
894#define AscPCIIOBaseRegister 0x0010
895#define AscPCICmdRegBits_IOMemBusMaster 0x0007
896#define ASC_PCI_ID2BUS(id) ((id) & 0xFF)
897#define ASC_PCI_ID2DEV(id) (((id) >> 11) & 0x1F)
898#define ASC_PCI_ID2FUNC(id) (((id) >> 8) & 0x7)
899#define ASC_PCI_MKID(bus, dev, func) ((((dev) & 0x1F) << 11) | (((func) & 0x7) << 8) | ((bus) & 0xFF))
900#define ASC_PCI_VENDORID 0x10CD
901#define ASC_PCI_DEVICEID_1200A 0x1100
902#define ASC_PCI_DEVICEID_1200B 0x1200
903#define ASC_PCI_DEVICEID_ULTRA 0x1300
904#define ASC_PCI_REVISION_3150 0x02
905#define ASC_PCI_REVISION_3050 0x03
906
907#define ASC_DVCLIB_CALL_DONE (1)
908#define ASC_DVCLIB_CALL_FAILED (0)
909#define ASC_DVCLIB_CALL_ERROR (-1)
910
911
912
913
914
915
916
917#define CC_VERY_LONG_SG_LIST 0
918#define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)
919
920#define PortAddr unsigned short
921#define inp(port) inb(port)
922#define outp(port, byte) outb((byte), (port))
923
924#define inpw(port) inw(port)
925#define outpw(port, word) outw((word), (port))
926
927#define ASC_MAX_SG_QUEUE 7
928#define ASC_MAX_SG_LIST 255
929
930#define ASC_CS_TYPE unsigned short
931
932#define ASC_IS_ISA (0x0001)
933#define ASC_IS_ISAPNP (0x0081)
934#define ASC_IS_EISA (0x0002)
935#define ASC_IS_PCI (0x0004)
936#define ASC_IS_PCI_ULTRA (0x0104)
937#define ASC_IS_PCMCIA (0x0008)
938#define ASC_IS_MCA (0x0020)
939#define ASC_IS_VL (0x0040)
940#define ASC_ISA_PNP_PORT_ADDR (0x279)
941#define ASC_ISA_PNP_PORT_WRITE (ASC_ISA_PNP_PORT_ADDR+0x800)
942#define ASC_IS_WIDESCSI_16 (0x0100)
943#define ASC_IS_WIDESCSI_32 (0x0200)
944#define ASC_IS_BIG_ENDIAN (0x8000)
945#define ASC_CHIP_MIN_VER_VL (0x01)
946#define ASC_CHIP_MAX_VER_VL (0x07)
947#define ASC_CHIP_MIN_VER_PCI (0x09)
948#define ASC_CHIP_MAX_VER_PCI (0x0F)
949#define ASC_CHIP_VER_PCI_BIT (0x08)
950#define ASC_CHIP_MIN_VER_ISA (0x11)
951#define ASC_CHIP_MIN_VER_ISA_PNP (0x21)
952#define ASC_CHIP_MAX_VER_ISA (0x27)
953#define ASC_CHIP_VER_ISA_BIT (0x30)
954#define ASC_CHIP_VER_ISAPNP_BIT (0x20)
955#define ASC_CHIP_VER_ASYN_BUG (0x21)
956#define ASC_CHIP_VER_PCI 0x08
957#define ASC_CHIP_VER_PCI_ULTRA_3150 (ASC_CHIP_VER_PCI | 0x02)
958#define ASC_CHIP_VER_PCI_ULTRA_3050 (ASC_CHIP_VER_PCI | 0x03)
959#define ASC_CHIP_MIN_VER_EISA (0x41)
960#define ASC_CHIP_MAX_VER_EISA (0x47)
961#define ASC_CHIP_VER_EISA_BIT (0x40)
962#define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)
963#define ASC_MAX_LIB_SUPPORTED_ISA_CHIP_VER 0x21
964#define ASC_MAX_LIB_SUPPORTED_PCI_CHIP_VER 0x0A
965#define ASC_MAX_VL_DMA_ADDR (0x07FFFFFFL)
966#define ASC_MAX_VL_DMA_COUNT (0x07FFFFFFL)
967#define ASC_MAX_PCI_DMA_ADDR (0xFFFFFFFFL)
968#define ASC_MAX_PCI_DMA_COUNT (0xFFFFFFFFL)
969#define ASC_MAX_ISA_DMA_ADDR (0x00FFFFFFL)
970#define ASC_MAX_ISA_DMA_COUNT (0x00FFFFFFL)
971#define ASC_MAX_EISA_DMA_ADDR (0x07FFFFFFL)
972#define ASC_MAX_EISA_DMA_COUNT (0x07FFFFFFL)
973
974#define ASC_SCSI_ID_BITS 3
975#define ASC_SCSI_TIX_TYPE uchar
976#define ASC_ALL_DEVICE_BIT_SET 0xFF
977#define ASC_SCSI_BIT_ID_TYPE uchar
978#define ASC_MAX_TID 7
979#define ASC_MAX_LUN 7
980#define ASC_SCSI_WIDTH_BIT_SET 0xFF
981#define ASC_MAX_SENSE_LEN 32
982#define ASC_MIN_SENSE_LEN 14
983#define ASC_MAX_CDB_LEN 12
984#define ASC_SCSI_RESET_HOLD_TIME_US 60
985#define SCSICMD_TestUnitReady 0x00
986#define SCSICMD_Rewind 0x01
987#define SCSICMD_Rezero 0x01
988#define SCSICMD_RequestSense 0x03
989#define SCSICMD_Format 0x04
990#define SCSICMD_FormatUnit 0x04
991#define SCSICMD_Read6 0x08
992#define SCSICMD_Write6 0x0A
993#define SCSICMD_Seek6 0x0B
994#define SCSICMD_Inquiry 0x12
995#define SCSICMD_Verify6 0x13
996#define SCSICMD_ModeSelect6 0x15
997#define SCSICMD_ModeSense6 0x1A
998#define SCSICMD_StartStopUnit 0x1B
999#define SCSICMD_LoadUnloadTape 0x1B
1000#define SCSICMD_ReadCapacity 0x25
1001#define SCSICMD_Read10 0x28
1002#define SCSICMD_Write10 0x2A
1003#define SCSICMD_Seek10 0x2B
1004#define SCSICMD_Erase10 0x2C
1005#define SCSICMD_WriteAndVerify10 0x2E
1006#define SCSICMD_Verify10 0x2F
1007#define SCSICMD_WriteBuffer 0x3B
1008#define SCSICMD_ReadBuffer 0x3C
1009#define SCSICMD_ReadLong 0x3E
1010#define SCSICMD_WriteLong 0x3F
1011#define SCSICMD_ReadTOC 0x43
1012#define SCSICMD_ReadHeader 0x44
1013#define SCSICMD_ModeSelect10 0x55
1014#define SCSICMD_ModeSense10 0x5A
1015
1016
1017#define SCSI_TYPE_DASD 0x00
1018#define SCSI_TYPE_SASD 0x01
1019#define SCSI_TYPE_PRN 0x02
1020#define SCSI_TYPE_PROC 0x03
1021#define SCSI_TYPE_WORM 0x04
1022#define SCSI_TYPE_CDROM 0x05
1023#define SCSI_TYPE_SCANNER 0x06
1024#define SCSI_TYPE_OPTMEM 0x07
1025#define SCSI_TYPE_MED_CHG 0x08
1026#define SCSI_TYPE_COMM 0x09
1027#define SCSI_TYPE_UNKNOWN 0x1F
1028
1029#define ADV_INQ_CLOCKING_ST_ONLY 0x0
1030#define ADV_INQ_CLOCKING_DT_ONLY 0x1
1031#define ADV_INQ_CLOCKING_ST_AND_DT 0x3
1032
1033
1034
1035
1036
1037#define ADV_INQ_RTN_VPD_AND_CMDDT 0x3
1038#define ADV_INQ_RTN_CMDDT_FOR_OP_CODE 0x2
1039#define ADV_INQ_RTN_VPD_FOR_PG_CODE 0x1
1040#define ADV_INQ_RTN_STD_INQUIRY_DATA 0x0
1041
1042#define ASC_SCSIDIR_NOCHK 0x00
1043#define ASC_SCSIDIR_T2H 0x08
1044#define ASC_SCSIDIR_H2T 0x10
1045#define ASC_SCSIDIR_NODATA 0x18
1046#define SCSI_SENKEY_NO_SENSE 0x00
1047#define SCSI_SENKEY_UNDEFINED 0x01
1048#define SCSI_SENKEY_NOT_READY 0x02
1049#define SCSI_SENKEY_MEDIUM_ERR 0x03
1050#define SCSI_SENKEY_HW_ERR 0x04
1051#define SCSI_SENKEY_ILLEGAL 0x05
1052#define SCSI_SENKEY_ATTENTION 0x06
1053#define SCSI_SENKEY_PROTECTED 0x07
1054#define SCSI_SENKEY_BLANK 0x08
1055#define SCSI_SENKEY_V_UNIQUE 0x09
1056#define SCSI_SENKEY_CPY_ABORT 0x0A
1057#define SCSI_SENKEY_ABORT 0x0B
1058#define SCSI_SENKEY_EQUAL 0x0C
1059#define SCSI_SENKEY_VOL_OVERFLOW 0x0D
1060#define SCSI_SENKEY_MISCOMP 0x0E
1061#define SCSI_SENKEY_RESERVED 0x0F
1062#define SCSI_ASC_NOMEDIA 0x3A
1063#define ASC_SRB_HOST(x) ((uchar)((uchar)(x) >> 4))
1064#define ASC_SRB_TID(x) ((uchar)((uchar)(x) & (uchar)0x0F))
1065#define ASC_SRB_LUN(x) ((uchar)((uint)(x) >> 13))
1066#define PUT_CDB1(x) ((uchar)((uint)(x) >> 8))
1067#define SS_GOOD 0x00
1068#define SS_CHK_CONDITION 0x02
1069#define SS_CONDITION_MET 0x04
1070#define SS_TARGET_BUSY 0x08
1071#define SS_INTERMID 0x10
1072#define SS_INTERMID_COND_MET 0x14
1073#define SS_RSERV_CONFLICT 0x18
1074#define SS_CMD_TERMINATED 0x22
1075#define SS_QUEUE_FULL 0x28
1076#define MS_CMD_DONE 0x00
1077#define MS_EXTEND 0x01
1078#define MS_SDTR_LEN 0x03
1079#define MS_SDTR_CODE 0x01
1080#define MS_WDTR_LEN 0x02
1081#define MS_WDTR_CODE 0x03
1082#define MS_MDP_LEN 0x05
1083#define MS_MDP_CODE 0x00
1084#define M1_SAVE_DATA_PTR 0x02
1085#define M1_RESTORE_PTRS 0x03
1086#define M1_DISCONNECT 0x04
1087#define M1_INIT_DETECTED_ERR 0x05
1088#define M1_ABORT 0x06
1089#define M1_MSG_REJECT 0x07
1090#define M1_NO_OP 0x08
1091#define M1_MSG_PARITY_ERR 0x09
1092#define M1_LINK_CMD_DONE 0x0A
1093#define M1_LINK_CMD_DONE_WFLAG 0x0B
1094#define M1_BUS_DVC_RESET 0x0C
1095#define M1_ABORT_TAG 0x0D
1096#define M1_CLR_QUEUE 0x0E
1097#define M1_INIT_RECOVERY 0x0F
1098#define M1_RELEASE_RECOVERY 0x10
1099#define M1_KILL_IO_PROC 0x11
1100#define M2_QTAG_MSG_SIMPLE 0x20
1101#define M2_QTAG_MSG_HEAD 0x21
1102#define M2_QTAG_MSG_ORDERED 0x22
1103#define M2_IGNORE_WIDE_RESIDUE 0x23
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113#define ASC_INQ_DVC_TYPE(inq) ((inq)->periph & 0x1f)
1114#define ASC_INQ_QUALIFIER(inq) (((inq)->periph & 0xe0) >> 5)
1115#define ASC_INQ_DVC_TYPE_MOD(inq) ((inq)->devtype & 0x7f)
1116#define ASC_INQ_REMOVABLE(inq) ((inq)->devtype & 0x80)
1117#define ASC_INQ_ANSI_VER(inq) ((inq)->ver & 0x07)
1118#define ASC_INQ_ECMA_VER(inq) (((inq)->ver & 0x38) >> 3)
1119#define ASC_INQ_ISO_VER(inq) (((inq)->ver & 0xc0) >> 6)
1120#define ASC_INQ_RESPONSE_FMT(inq) ((inq)->byte3 & 0x0f)
1121#define ASC_INQ_TERM_IO(inq) ((inq)->byte3 & 0x40)
1122#define ASC_INQ_ASYNC_NOTIF(inq) ((inq)->byte3 & 0x80)
1123#define ASC_INQ_SOFT_RESET(inq) ((inq)->flags & 0x01)
1124#define ASC_INQ_CMD_QUEUE(inq) ((inq)->flags & 0x02)
1125#define ASC_INQ_LINK_CMD(inq) ((inq)->flags & 0x08)
1126#define ASC_INQ_SYNC(inq) ((inq)->flags & 0x10)
1127#define ASC_INQ_WIDE16(inq) ((inq)->flags & 0x20)
1128#define ASC_INQ_WIDE32(inq) ((inq)->flags & 0x40)
1129#define ASC_INQ_REL_ADDR(inq) ((inq)->flags & 0x80)
1130#define ASC_INQ_INFO_UNIT(inq) ((inq)->info & 0x01)
1131#define ASC_INQ_QUICK_ARB(inq) ((inq)->info & 0x02)
1132#define ASC_INQ_CLOCKING(inq) (((inq)->info & 0x0c) >> 2)
1133
1134typedef struct {
1135 uchar periph;
1136 uchar devtype;
1137 uchar ver;
1138 uchar byte3;
1139 uchar add_len;
1140 uchar res1;
1141 uchar res2;
1142 uchar flags;
1143 uchar vendor_id[8];
1144 uchar product_id[16];
1145 uchar product_rev_level[4];
1146} ASC_SCSI_INQUIRY;
1147
1148#define ASC_SG_LIST_PER_Q 7
1149#define QS_FREE 0x00
1150#define QS_READY 0x01
1151#define QS_DISC1 0x02
1152#define QS_DISC2 0x04
1153#define QS_BUSY 0x08
1154#define QS_ABORTED 0x40
1155#define QS_DONE 0x80
1156#define QC_NO_CALLBACK 0x01
1157#define QC_SG_SWAP_QUEUE 0x02
1158#define QC_SG_HEAD 0x04
1159#define QC_DATA_IN 0x08
1160#define QC_DATA_OUT 0x10
1161#define QC_URGENT 0x20
1162#define QC_MSG_OUT 0x40
1163#define QC_REQ_SENSE 0x80
1164#define QCSG_SG_XFER_LIST 0x02
1165#define QCSG_SG_XFER_MORE 0x04
1166#define QCSG_SG_XFER_END 0x08
1167#define QD_IN_PROGRESS 0x00
1168#define QD_NO_ERROR 0x01
1169#define QD_ABORTED_BY_HOST 0x02
1170#define QD_WITH_ERROR 0x04
1171#define QD_INVALID_REQUEST 0x80
1172#define QD_INVALID_HOST_NUM 0x81
1173#define QD_INVALID_DEVICE 0x82
1174#define QD_ERR_INTERNAL 0xFF
1175#define QHSTA_NO_ERROR 0x00
1176#define QHSTA_M_SEL_TIMEOUT 0x11
1177#define QHSTA_M_DATA_OVER_RUN 0x12
1178#define QHSTA_M_DATA_UNDER_RUN 0x12
1179#define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
1180#define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14
1181#define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21
1182#define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22
1183#define QHSTA_D_HOST_ABORT_FAILED 0x23
1184#define QHSTA_D_EXE_SCSI_Q_FAILED 0x24
1185#define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25
1186#define QHSTA_D_ASPI_NO_BUF_POOL 0x26
1187#define QHSTA_M_WTM_TIMEOUT 0x41
1188#define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
1189#define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
1190#define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
1191#define QHSTA_M_TARGET_STATUS_BUSY 0x45
1192#define QHSTA_M_BAD_TAG_CODE 0x46
1193#define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47
1194#define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48
1195#define QHSTA_D_LRAM_CMP_ERROR 0x81
1196#define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1
1197#define ASC_FLAG_SCSIQ_REQ 0x01
1198#define ASC_FLAG_BIOS_SCSIQ_REQ 0x02
1199#define ASC_FLAG_BIOS_ASYNC_IO 0x04
1200#define ASC_FLAG_SRB_LINEAR_ADDR 0x08
1201#define ASC_FLAG_WIN16 0x10
1202#define ASC_FLAG_WIN32 0x20
1203#define ASC_FLAG_ISA_OVER_16MB 0x40
1204#define ASC_FLAG_DOS_VM_CALLBACK 0x80
1205#define ASC_TAG_FLAG_EXTRA_BYTES 0x10
1206#define ASC_TAG_FLAG_DISABLE_DISCONNECT 0x04
1207#define ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08
1208#define ASC_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40
1209#define ASC_SCSIQ_CPY_BEG 4
1210#define ASC_SCSIQ_SGHD_CPY_BEG 2
1211#define ASC_SCSIQ_B_FWD 0
1212#define ASC_SCSIQ_B_BWD 1
1213#define ASC_SCSIQ_B_STATUS 2
1214#define ASC_SCSIQ_B_QNO 3
1215#define ASC_SCSIQ_B_CNTL 4
1216#define ASC_SCSIQ_B_SG_QUEUE_CNT 5
1217#define ASC_SCSIQ_D_DATA_ADDR 8
1218#define ASC_SCSIQ_D_DATA_CNT 12
1219#define ASC_SCSIQ_B_SENSE_LEN 20
1220#define ASC_SCSIQ_DONE_INFO_BEG 22
1221#define ASC_SCSIQ_D_SRBPTR 22
1222#define ASC_SCSIQ_B_TARGET_IX 26
1223#define ASC_SCSIQ_B_CDB_LEN 28
1224#define ASC_SCSIQ_B_TAG_CODE 29
1225#define ASC_SCSIQ_W_VM_ID 30
1226#define ASC_SCSIQ_DONE_STATUS 32
1227#define ASC_SCSIQ_HOST_STATUS 33
1228#define ASC_SCSIQ_SCSI_STATUS 34
1229#define ASC_SCSIQ_CDB_BEG 36
1230#define ASC_SCSIQ_DW_REMAIN_XFER_ADDR 56
1231#define ASC_SCSIQ_DW_REMAIN_XFER_CNT 60
1232#define ASC_SCSIQ_B_FIRST_SG_WK_QP 48
1233#define ASC_SCSIQ_B_SG_WK_QP 49
1234#define ASC_SCSIQ_B_SG_WK_IX 50
1235#define ASC_SCSIQ_W_ALT_DC1 52
1236#define ASC_SCSIQ_B_LIST_CNT 6
1237#define ASC_SCSIQ_B_CUR_LIST_CNT 7
1238#define ASC_SGQ_B_SG_CNTL 4
1239#define ASC_SGQ_B_SG_HEAD_QP 5
1240#define ASC_SGQ_B_SG_LIST_CNT 6
1241#define ASC_SGQ_B_SG_CUR_LIST_CNT 7
1242#define ASC_SGQ_LIST_BEG 8
1243#define ASC_DEF_SCSI1_QNG 4
1244#define ASC_MAX_SCSI1_QNG 4
1245#define ASC_DEF_SCSI2_QNG 16
1246#define ASC_MAX_SCSI2_QNG 32
1247#define ASC_TAG_CODE_MASK 0x23
1248#define ASC_STOP_REQ_RISC_STOP 0x01
1249#define ASC_STOP_ACK_RISC_STOP 0x03
1250#define ASC_STOP_CLEAN_UP_BUSY_Q 0x10
1251#define ASC_STOP_CLEAN_UP_DISC_Q 0x20
1252#define ASC_STOP_HOST_REQ_RISC_HALT 0x40
1253#define ASC_TIDLUN_TO_IX(tid, lun) (ASC_SCSI_TIX_TYPE)((tid) + ((lun)<<ASC_SCSI_ID_BITS))
1254#define ASC_TID_TO_TARGET_ID(tid) (ASC_SCSI_BIT_ID_TYPE)(0x01 << (tid))
1255#define ASC_TIX_TO_TARGET_ID(tix) (0x01 << ((tix) & ASC_MAX_TID))
1256#define ASC_TIX_TO_TID(tix) ((tix) & ASC_MAX_TID)
1257#define ASC_TID_TO_TIX(tid) ((tid) & ASC_MAX_TID)
1258#define ASC_TIX_TO_LUN(tix) (((tix) >> ASC_SCSI_ID_BITS) & ASC_MAX_LUN)
1259#define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
1260
1261typedef struct asc_scsiq_1 {
1262 uchar status;
1263 uchar q_no;
1264 uchar cntl;
1265 uchar sg_queue_cnt;
1266 uchar target_id;
1267 uchar target_lun;
1268 ASC_PADDR data_addr;
1269 ASC_DCNT data_cnt;
1270 ASC_PADDR sense_addr;
1271 uchar sense_len;
1272 uchar extra_bytes;
1273} ASC_SCSIQ_1;
1274
1275typedef struct asc_scsiq_2 {
1276 ASC_VADDR srb_ptr;
1277 uchar target_ix;
1278 uchar flag;
1279 uchar cdb_len;
1280 uchar tag_code;
1281 ushort vm_id;
1282} ASC_SCSIQ_2;
1283
1284typedef struct asc_scsiq_3 {
1285 uchar done_stat;
1286 uchar host_stat;
1287 uchar scsi_stat;
1288 uchar scsi_msg;
1289} ASC_SCSIQ_3;
1290
1291typedef struct asc_scsiq_4 {
1292 uchar cdb[ASC_MAX_CDB_LEN];
1293 uchar y_first_sg_list_qp;
1294 uchar y_working_sg_qp;
1295 uchar y_working_sg_ix;
1296 uchar y_res;
1297 ushort x_req_count;
1298 ushort x_reconnect_rtn;
1299 ASC_PADDR x_saved_data_addr;
1300 ASC_DCNT x_saved_data_cnt;
1301} ASC_SCSIQ_4;
1302
1303typedef struct asc_q_done_info {
1304 ASC_SCSIQ_2 d2;
1305 ASC_SCSIQ_3 d3;
1306 uchar q_status;
1307 uchar q_no;
1308 uchar cntl;
1309 uchar sense_len;
1310 uchar extra_bytes;
1311 uchar res;
1312 ASC_DCNT remain_bytes;
1313} ASC_QDONE_INFO;
1314
1315typedef struct asc_sg_list {
1316 ASC_PADDR addr;
1317 ASC_DCNT bytes;
1318} ASC_SG_LIST;
1319
1320typedef struct asc_sg_head {
1321 ushort entry_cnt;
1322 ushort queue_cnt;
1323 ushort entry_to_copy;
1324 ushort res;
1325 ASC_SG_LIST sg_list[ASC_MAX_SG_LIST];
1326} ASC_SG_HEAD;
1327
1328#define ASC_MIN_SG_LIST 2
1329
1330typedef struct asc_min_sg_head {
1331 ushort entry_cnt;
1332 ushort queue_cnt;
1333 ushort entry_to_copy;
1334 ushort res;
1335 ASC_SG_LIST sg_list[ASC_MIN_SG_LIST];
1336} ASC_MIN_SG_HEAD;
1337
1338#define QCX_SORT (0x0001)
1339#define QCX_COALEASE (0x0002)
1340
1341typedef struct asc_scsi_q {
1342 ASC_SCSIQ_1 q1;
1343 ASC_SCSIQ_2 q2;
1344 uchar *cdbptr;
1345 ASC_SG_HEAD *sg_head;
1346 ushort remain_sg_entry_cnt;
1347 ushort next_sg_index;
1348} ASC_SCSI_Q;
1349
1350typedef struct asc_scsi_req_q {
1351 ASC_SCSIQ_1 r1;
1352 ASC_SCSIQ_2 r2;
1353 uchar *cdbptr;
1354 ASC_SG_HEAD *sg_head;
1355 uchar *sense_ptr;
1356 ASC_SCSIQ_3 r3;
1357 uchar cdb[ASC_MAX_CDB_LEN];
1358 uchar sense[ASC_MIN_SENSE_LEN];
1359} ASC_SCSI_REQ_Q;
1360
1361typedef struct asc_scsi_bios_req_q {
1362 ASC_SCSIQ_1 r1;
1363 ASC_SCSIQ_2 r2;
1364 uchar *cdbptr;
1365 ASC_SG_HEAD *sg_head;
1366 uchar *sense_ptr;
1367 ASC_SCSIQ_3 r3;
1368 uchar cdb[ASC_MAX_CDB_LEN];
1369 uchar sense[ASC_MIN_SENSE_LEN];
1370} ASC_SCSI_BIOS_REQ_Q;
1371
1372typedef struct asc_risc_q {
1373 uchar fwd;
1374 uchar bwd;
1375 ASC_SCSIQ_1 i1;
1376 ASC_SCSIQ_2 i2;
1377 ASC_SCSIQ_3 i3;
1378 ASC_SCSIQ_4 i4;
1379} ASC_RISC_Q;
1380
1381typedef struct asc_sg_list_q {
1382 uchar seq_no;
1383 uchar q_no;
1384 uchar cntl;
1385 uchar sg_head_qp;
1386 uchar sg_list_cnt;
1387 uchar sg_cur_list_cnt;
1388} ASC_SG_LIST_Q;
1389
1390typedef struct asc_risc_sg_list_q {
1391 uchar fwd;
1392 uchar bwd;
1393 ASC_SG_LIST_Q sg;
1394 ASC_SG_LIST sg_list[7];
1395} ASC_RISC_SG_LIST_Q;
1396
1397#define ASC_EXE_SCSI_IO_MAX_IDLE_LOOP 0x1000000UL
1398#define ASC_EXE_SCSI_IO_MAX_WAIT_LOOP 1024
1399#define ASCQ_ERR_NO_ERROR 0
1400#define ASCQ_ERR_IO_NOT_FOUND 1
1401#define ASCQ_ERR_LOCAL_MEM 2
1402#define ASCQ_ERR_CHKSUM 3
1403#define ASCQ_ERR_START_CHIP 4
1404#define ASCQ_ERR_INT_TARGET_ID 5
1405#define ASCQ_ERR_INT_LOCAL_MEM 6
1406#define ASCQ_ERR_HALT_RISC 7
1407#define ASCQ_ERR_GET_ASPI_ENTRY 8
1408#define ASCQ_ERR_CLOSE_ASPI 9
1409#define ASCQ_ERR_HOST_INQUIRY 0x0A
1410#define ASCQ_ERR_SAVED_SRB_BAD 0x0B
1411#define ASCQ_ERR_QCNTL_SG_LIST 0x0C
1412#define ASCQ_ERR_Q_STATUS 0x0D
1413#define ASCQ_ERR_WR_SCSIQ 0x0E
1414#define ASCQ_ERR_PC_ADDR 0x0F
1415#define ASCQ_ERR_SYN_OFFSET 0x10
1416#define ASCQ_ERR_SYN_XFER_TIME 0x11
1417#define ASCQ_ERR_LOCK_DMA 0x12
1418#define ASCQ_ERR_UNLOCK_DMA 0x13
1419#define ASCQ_ERR_VDS_CHK_INSTALL 0x14
1420#define ASCQ_ERR_MICRO_CODE_HALT 0x15
1421#define ASCQ_ERR_SET_LRAM_ADDR 0x16
1422#define ASCQ_ERR_CUR_QNG 0x17
1423#define ASCQ_ERR_SG_Q_LINKS 0x18
1424#define ASCQ_ERR_SCSIQ_PTR 0x19
1425#define ASCQ_ERR_ISR_RE_ENTRY 0x1A
1426#define ASCQ_ERR_CRITICAL_RE_ENTRY 0x1B
1427#define ASCQ_ERR_ISR_ON_CRITICAL 0x1C
1428#define ASCQ_ERR_SG_LIST_ODD_ADDRESS 0x1D
1429#define ASCQ_ERR_XFER_ADDRESS_TOO_BIG 0x1E
1430#define ASCQ_ERR_SCSIQ_NULL_PTR 0x1F
1431#define ASCQ_ERR_SCSIQ_BAD_NEXT_PTR 0x20
1432#define ASCQ_ERR_GET_NUM_OF_FREE_Q 0x21
1433#define ASCQ_ERR_SEND_SCSI_Q 0x22
1434#define ASCQ_ERR_HOST_REQ_RISC_HALT 0x23
1435#define ASCQ_ERR_RESET_SDTR 0x24
1436
1437
1438
1439
1440#define ASC_WARN_NO_ERROR 0x0000
1441#define ASC_WARN_IO_PORT_ROTATE 0x0001
1442#define ASC_WARN_EEPROM_CHKSUM 0x0002
1443#define ASC_WARN_IRQ_MODIFIED 0x0004
1444#define ASC_WARN_AUTO_CONFIG 0x0008
1445#define ASC_WARN_CMD_QNG_CONFLICT 0x0010
1446#define ASC_WARN_EEPROM_RECOVER 0x0020
1447#define ASC_WARN_CFG_MSW_RECOVER 0x0040
1448#define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080
1449
1450
1451
1452
1453#define ASC_IERR_WRITE_EEPROM 0x0001
1454#define ASC_IERR_MCODE_CHKSUM 0x0002
1455#define ASC_IERR_SET_PC_ADDR 0x0004
1456#define ASC_IERR_START_STOP_CHIP 0x0008
1457#define ASC_IERR_IRQ_NO 0x0010
1458#define ASC_IERR_SET_IRQ_NO 0x0020
1459#define ASC_IERR_CHIP_VERSION 0x0040
1460#define ASC_IERR_SET_SCSI_ID 0x0080
1461#define ASC_IERR_GET_PHY_ADDR 0x0100
1462#define ASC_IERR_BAD_SIGNATURE 0x0200
1463#define ASC_IERR_NO_BUS_TYPE 0x0400
1464#define ASC_IERR_SCAM 0x0800
1465#define ASC_IERR_SET_SDTR 0x1000
1466#define ASC_IERR_RW_LRAM 0x8000
1467
1468#define ASC_DEF_IRQ_NO 10
1469#define ASC_MAX_IRQ_NO 15
1470#define ASC_MIN_IRQ_NO 10
1471#define ASC_MIN_REMAIN_Q (0x02)
1472#define ASC_DEF_MAX_TOTAL_QNG (0xF0)
1473#define ASC_MIN_TAG_Q_PER_DVC (0x04)
1474#define ASC_DEF_TAG_Q_PER_DVC (0x04)
1475#define ASC_MIN_FREE_Q ASC_MIN_REMAIN_Q
1476#define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
1477#define ASC_MAX_TOTAL_QNG 240
1478#define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
1479#define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
1480#define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
1481#define ASC_MAX_INRAM_TAG_QNG 16
1482#define ASC_IOADR_TABLE_MAX_IX 11
1483#define ASC_IOADR_GAP 0x10
1484#define ASC_SEARCH_IOP_GAP 0x10
1485#define ASC_MIN_IOP_ADDR (PortAddr)0x0100
1486#define ASC_MAX_IOP_ADDR (PortAddr)0x3F0
1487#define ASC_IOADR_1 (PortAddr)0x0110
1488#define ASC_IOADR_2 (PortAddr)0x0130
1489#define ASC_IOADR_3 (PortAddr)0x0150
1490#define ASC_IOADR_4 (PortAddr)0x0190
1491#define ASC_IOADR_5 (PortAddr)0x0210
1492#define ASC_IOADR_6 (PortAddr)0x0230
1493#define ASC_IOADR_7 (PortAddr)0x0250
1494#define ASC_IOADR_8 (PortAddr)0x0330
1495#define ASC_IOADR_DEF ASC_IOADR_8
1496#define ASC_LIB_SCSIQ_WK_SP 256
1497#define ASC_MAX_SYN_XFER_NO 16
1498#define ASC_SYN_MAX_OFFSET 0x0F
1499#define ASC_DEF_SDTR_OFFSET 0x0F
1500#define ASC_DEF_SDTR_INDEX 0x00
1501#define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
1502#define SYN_XFER_NS_0 25
1503#define SYN_XFER_NS_1 30
1504#define SYN_XFER_NS_2 35
1505#define SYN_XFER_NS_3 40
1506#define SYN_XFER_NS_4 50
1507#define SYN_XFER_NS_5 60
1508#define SYN_XFER_NS_6 70
1509#define SYN_XFER_NS_7 85
1510#define SYN_ULTRA_XFER_NS_0 12
1511#define SYN_ULTRA_XFER_NS_1 19
1512#define SYN_ULTRA_XFER_NS_2 25
1513#define SYN_ULTRA_XFER_NS_3 32
1514#define SYN_ULTRA_XFER_NS_4 38
1515#define SYN_ULTRA_XFER_NS_5 44
1516#define SYN_ULTRA_XFER_NS_6 50
1517#define SYN_ULTRA_XFER_NS_7 57
1518#define SYN_ULTRA_XFER_NS_8 63
1519#define SYN_ULTRA_XFER_NS_9 69
1520#define SYN_ULTRA_XFER_NS_10 75
1521#define SYN_ULTRA_XFER_NS_11 82
1522#define SYN_ULTRA_XFER_NS_12 88
1523#define SYN_ULTRA_XFER_NS_13 94
1524#define SYN_ULTRA_XFER_NS_14 100
1525#define SYN_ULTRA_XFER_NS_15 107
1526
1527typedef struct ext_msg {
1528 uchar msg_type;
1529 uchar msg_len;
1530 uchar msg_req;
1531 union {
1532 struct {
1533 uchar sdtr_xfer_period;
1534 uchar sdtr_req_ack_offset;
1535 } sdtr;
1536 struct {
1537 uchar wdtr_width;
1538 } wdtr;
1539 struct {
1540 uchar mdp_b3;
1541 uchar mdp_b2;
1542 uchar mdp_b1;
1543 uchar mdp_b0;
1544 } mdp;
1545 } u_ext_msg;
1546 uchar res;
1547} EXT_MSG;
1548
1549#define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
1550#define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
1551#define wdtr_width u_ext_msg.wdtr.wdtr_width
1552#define mdp_b3 u_ext_msg.mdp_b3
1553#define mdp_b2 u_ext_msg.mdp_b2
1554#define mdp_b1 u_ext_msg.mdp_b1
1555#define mdp_b0 u_ext_msg.mdp_b0
1556
1557typedef struct asc_dvc_cfg {
1558 ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
1559 ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
1560 ASC_SCSI_BIT_ID_TYPE disc_enable;
1561 ASC_SCSI_BIT_ID_TYPE sdtr_enable;
1562 uchar chip_scsi_id;
1563 uchar isa_dma_speed;
1564 uchar isa_dma_channel;
1565 uchar chip_version;
1566 ushort pci_device_id;
1567 ushort lib_serial_no;
1568 ushort lib_version;
1569 ushort mcode_date;
1570 ushort mcode_version;
1571 uchar max_tag_qng[ASC_MAX_TID + 1];
1572 uchar *overrun_buf;
1573 uchar sdtr_period_offset[ASC_MAX_TID + 1];
1574 ushort pci_slot_info;
1575 uchar adapter_info[6];
1576} ASC_DVC_CFG;
1577
1578#define ASC_DEF_DVC_CNTL 0xFFFF
1579#define ASC_DEF_CHIP_SCSI_ID 7
1580#define ASC_DEF_ISA_DMA_SPEED 4
1581#define ASC_INIT_STATE_NULL 0x0000
1582#define ASC_INIT_STATE_BEG_GET_CFG 0x0001
1583#define ASC_INIT_STATE_END_GET_CFG 0x0002
1584#define ASC_INIT_STATE_BEG_SET_CFG 0x0004
1585#define ASC_INIT_STATE_END_SET_CFG 0x0008
1586#define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
1587#define ASC_INIT_STATE_END_LOAD_MC 0x0020
1588#define ASC_INIT_STATE_BEG_INQUIRY 0x0040
1589#define ASC_INIT_STATE_END_INQUIRY 0x0080
1590#define ASC_INIT_RESET_SCSI_DONE 0x0100
1591#define ASC_INIT_STATE_WITHOUT_EEP 0x8000
1592#define ASC_PCI_DEVICE_ID_REV_A 0x1100
1593#define ASC_PCI_DEVICE_ID_REV_B 0x1200
1594#define ASC_BUG_FIX_IF_NOT_DWB 0x0001
1595#define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
1596#define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
1597#define ASC_MIN_TAGGED_CMD 7
1598#define ASC_MAX_SCSI_RESET_WAIT 30
1599
1600struct asc_dvc_var;
1601
1602typedef void (* ASC_ISR_CALLBACK)(struct asc_dvc_var *, ASC_QDONE_INFO *);
1603typedef int (* ASC_EXE_CALLBACK)(struct asc_dvc_var *, ASC_SCSI_Q *);
1604
1605typedef struct asc_dvc_var {
1606 PortAddr iop_base;
1607 ushort err_code;
1608 ushort dvc_cntl;
1609 ushort bug_fix_cntl;
1610 ushort bus_type;
1611 ASC_ISR_CALLBACK isr_callback;
1612 ASC_EXE_CALLBACK exe_callback;
1613 ASC_SCSI_BIT_ID_TYPE init_sdtr;
1614 ASC_SCSI_BIT_ID_TYPE sdtr_done;
1615 ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
1616 ASC_SCSI_BIT_ID_TYPE unit_not_ready;
1617 ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
1618 ASC_SCSI_BIT_ID_TYPE start_motor;
1619 uchar scsi_reset_wait;
1620 uchar chip_no;
1621 char is_in_int;
1622 uchar max_total_qng;
1623 uchar cur_total_qng;
1624 uchar in_critical_cnt;
1625 uchar irq_no;
1626 uchar last_q_shortage;
1627 ushort init_state;
1628 uchar cur_dvc_qng[ASC_MAX_TID + 1];
1629 uchar max_dvc_qng[ASC_MAX_TID + 1];
1630 ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
1631 ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
1632 uchar sdtr_period_tbl[ASC_MAX_SYN_XFER_NO];
1633 ASC_DVC_CFG *cfg;
1634 ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
1635 char redo_scam;
1636 ushort res2;
1637 uchar dos_int13_table[ASC_MAX_TID + 1];
1638 ASC_DCNT max_dma_count;
1639 ASC_SCSI_BIT_ID_TYPE no_scam;
1640 ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
1641 uchar max_sdtr_index;
1642 uchar host_init_sdtr_index;
1643 struct asc_board *drv_ptr;
1644 ASC_DCNT uc_break;
1645} ASC_DVC_VAR;
1646
1647typedef struct asc_dvc_inq_info {
1648 uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
1649} ASC_DVC_INQ_INFO;
1650
1651typedef struct asc_cap_info {
1652 ASC_DCNT lba;
1653 ASC_DCNT blk_size;
1654} ASC_CAP_INFO;
1655
1656typedef struct asc_cap_info_array {
1657 ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
1658} ASC_CAP_INFO_ARRAY;
1659
1660#define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
1661#define ASC_MCNTL_NULL_TARGET (ushort)0x0002
1662#define ASC_CNTL_INITIATOR (ushort)0x0001
1663#define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
1664#define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
1665#define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
1666#define ASC_CNTL_NO_SCAM (ushort)0x0010
1667#define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
1668#define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
1669#define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
1670#define ASC_CNTL_RESET_SCSI (ushort)0x0200
1671#define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
1672#define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
1673#define ASC_CNTL_SCSI_PARITY (ushort)0x1000
1674#define ASC_CNTL_BURST_MODE (ushort)0x2000
1675#define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
1676#define ASC_EEP_DVC_CFG_BEG_VL 2
1677#define ASC_EEP_MAX_DVC_ADDR_VL 15
1678#define ASC_EEP_DVC_CFG_BEG 32
1679#define ASC_EEP_MAX_DVC_ADDR 45
1680#define ASC_EEP_DEFINED_WORDS 10
1681#define ASC_EEP_MAX_ADDR 63
1682#define ASC_EEP_RES_WORDS 0
1683#define ASC_EEP_MAX_RETRY 20
1684#define ASC_MAX_INIT_BUSY_RETRY 8
1685#define ASC_EEP_ISA_PNP_WSIZE 16
1686
1687
1688
1689
1690
1691
1692
1693
1694#define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
1695#define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
1696#define ASC_EEP_SET_CHIP_ID(cfg, sid) \
1697 ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
1698#define ASC_EEP_SET_DMA_SPD(cfg, spd) \
1699 ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
1700
1701typedef struct asceep_config {
1702 ushort cfg_lsw;
1703 ushort cfg_msw;
1704 uchar init_sdtr;
1705 uchar disc_enable;
1706 uchar use_cmd_qng;
1707 uchar start_motor;
1708 uchar max_total_qng;
1709 uchar max_tag_qng;
1710 uchar bios_scan;
1711 uchar power_up_wait;
1712 uchar no_scam;
1713 uchar id_speed;
1714
1715 uchar dos_int13_table[ASC_MAX_TID + 1];
1716 uchar adapter_info[6];
1717 ushort cntl;
1718 ushort chksum;
1719} ASCEEP_CONFIG;
1720
1721#define ASC_PCI_CFG_LSW_SCSI_PARITY 0x0800
1722#define ASC_PCI_CFG_LSW_BURST_MODE 0x0080
1723#define ASC_PCI_CFG_LSW_INTR_ABLE 0x0020
1724
1725#define ASC_EEP_CMD_READ 0x80
1726#define ASC_EEP_CMD_WRITE 0x40
1727#define ASC_EEP_CMD_WRITE_ABLE 0x30
1728#define ASC_EEP_CMD_WRITE_DISABLE 0x00
1729#define ASC_OVERRUN_BSIZE 0x00000048UL
1730#define ASC_CTRL_BREAK_ONCE 0x0001
1731#define ASC_CTRL_BREAK_STAY_IDLE 0x0002
1732#define ASCV_MSGOUT_BEG 0x0000
1733#define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
1734#define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
1735#define ASCV_BREAK_SAVED_CODE (ushort)0x0006
1736#define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
1737#define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
1738#define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
1739#define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
1740#define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
1741#define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
1742#define ASCV_BREAK_ADDR (ushort)0x0028
1743#define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
1744#define ASCV_BREAK_CONTROL (ushort)0x002C
1745#define ASCV_BREAK_HIT_COUNT (ushort)0x002E
1746
1747#define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
1748#define ASCV_MCODE_CHKSUM_W (ushort)0x0032
1749#define ASCV_MCODE_SIZE_W (ushort)0x0034
1750#define ASCV_STOP_CODE_B (ushort)0x0036
1751#define ASCV_DVC_ERR_CODE_B (ushort)0x0037
1752#define ASCV_OVERRUN_PADDR_D (ushort)0x0038
1753#define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
1754#define ASCV_HALTCODE_W (ushort)0x0040
1755#define ASCV_CHKSUM_W (ushort)0x0042
1756#define ASCV_MC_DATE_W (ushort)0x0044
1757#define ASCV_MC_VER_W (ushort)0x0046
1758#define ASCV_NEXTRDY_B (ushort)0x0048
1759#define ASCV_DONENEXT_B (ushort)0x0049
1760#define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
1761#define ASCV_SCSIBUSY_B (ushort)0x004B
1762#define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
1763#define ASCV_CURCDB_B (ushort)0x004D
1764#define ASCV_RCLUN_B (ushort)0x004E
1765#define ASCV_BUSY_QHEAD_B (ushort)0x004F
1766#define ASCV_DISC1_QHEAD_B (ushort)0x0050
1767#define ASCV_DISC_ENABLE_B (ushort)0x0052
1768#define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
1769#define ASCV_HOSTSCSI_ID_B (ushort)0x0055
1770#define ASCV_MCODE_CNTL_B (ushort)0x0056
1771#define ASCV_NULL_TARGET_B (ushort)0x0057
1772#define ASCV_FREE_Q_HEAD_W (ushort)0x0058
1773#define ASCV_DONE_Q_TAIL_W (ushort)0x005A
1774#define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
1775#define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
1776#define ASCV_HOST_FLAG_B (ushort)0x005D
1777#define ASCV_TOTAL_READY_Q_B (ushort)0x0064
1778#define ASCV_VER_SERIAL_B (ushort)0x0065
1779#define ASCV_HALTCODE_SAVED_W (ushort)0x0066
1780#define ASCV_WTM_FLAG_B (ushort)0x0068
1781#define ASCV_RISC_FLAG_B (ushort)0x006A
1782#define ASCV_REQ_SG_LIST_QP (ushort)0x006B
1783#define ASC_HOST_FLAG_IN_ISR 0x01
1784#define ASC_HOST_FLAG_ACK_INT 0x02
1785#define ASC_RISC_FLAG_GEN_INT 0x01
1786#define ASC_RISC_FLAG_REQ_SG_LIST 0x02
1787#define IOP_CTRL (0x0F)
1788#define IOP_STATUS (0x0E)
1789#define IOP_INT_ACK IOP_STATUS
1790#define IOP_REG_IFC (0x0D)
1791#define IOP_SYN_OFFSET (0x0B)
1792#define IOP_EXTRA_CONTROL (0x0D)
1793#define IOP_REG_PC (0x0C)
1794#define IOP_RAM_ADDR (0x0A)
1795#define IOP_RAM_DATA (0x08)
1796#define IOP_EEP_DATA (0x06)
1797#define IOP_EEP_CMD (0x07)
1798#define IOP_VERSION (0x03)
1799#define IOP_CONFIG_HIGH (0x04)
1800#define IOP_CONFIG_LOW (0x02)
1801#define IOP_SIG_BYTE (0x01)
1802#define IOP_SIG_WORD (0x00)
1803#define IOP_REG_DC1 (0x0E)
1804#define IOP_REG_DC0 (0x0C)
1805#define IOP_REG_SB (0x0B)
1806#define IOP_REG_DA1 (0x0A)
1807#define IOP_REG_DA0 (0x08)
1808#define IOP_REG_SC (0x09)
1809#define IOP_DMA_SPEED (0x07)
1810#define IOP_REG_FLAG (0x07)
1811#define IOP_FIFO_H (0x06)
1812#define IOP_FIFO_L (0x04)
1813#define IOP_REG_ID (0x05)
1814#define IOP_REG_QP (0x03)
1815#define IOP_REG_IH (0x02)
1816#define IOP_REG_IX (0x01)
1817#define IOP_REG_AX (0x00)
1818#define IFC_REG_LOCK (0x00)
1819#define IFC_REG_UNLOCK (0x09)
1820#define IFC_WR_EN_FILTER (0x10)
1821#define IFC_RD_NO_EEPROM (0x10)
1822#define IFC_SLEW_RATE (0x20)
1823#define IFC_ACT_NEG (0x40)
1824#define IFC_INP_FILTER (0x80)
1825#define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
1826#define SC_SEL (uchar)(0x80)
1827#define SC_BSY (uchar)(0x40)
1828#define SC_ACK (uchar)(0x20)
1829#define SC_REQ (uchar)(0x10)
1830#define SC_ATN (uchar)(0x08)
1831#define SC_IO (uchar)(0x04)
1832#define SC_CD (uchar)(0x02)
1833#define SC_MSG (uchar)(0x01)
1834#define SEC_SCSI_CTL (uchar)(0x80)
1835#define SEC_ACTIVE_NEGATE (uchar)(0x40)
1836#define SEC_SLEW_RATE (uchar)(0x20)
1837#define SEC_ENABLE_FILTER (uchar)(0x10)
1838#define ASC_HALT_EXTMSG_IN (ushort)0x8000
1839#define ASC_HALT_CHK_CONDITION (ushort)0x8100
1840#define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
1841#define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
1842#define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
1843#define ASC_HALT_SDTR_REJECTED (ushort)0x4000
1844#define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
1845#define ASC_MAX_QNO 0xF8
1846#define ASC_DATA_SEC_BEG (ushort)0x0080
1847#define ASC_DATA_SEC_END (ushort)0x0080
1848#define ASC_CODE_SEC_BEG (ushort)0x0080
1849#define ASC_CODE_SEC_END (ushort)0x0080
1850#define ASC_QADR_BEG (0x4000)
1851#define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
1852#define ASC_QADR_END (ushort)0x7FFF
1853#define ASC_QLAST_ADR (ushort)0x7FC0
1854#define ASC_QBLK_SIZE 0x40
1855#define ASC_BIOS_DATA_QBEG 0xF8
1856#define ASC_MIN_ACTIVE_QNO 0x01
1857#define ASC_QLINK_END 0xFF
1858#define ASC_EEPROM_WORDS 0x10
1859#define ASC_MAX_MGS_LEN 0x10
1860#define ASC_BIOS_ADDR_DEF 0xDC00
1861#define ASC_BIOS_SIZE 0x3800
1862#define ASC_BIOS_RAM_OFF 0x3800
1863#define ASC_BIOS_RAM_SIZE 0x800
1864#define ASC_BIOS_MIN_ADDR 0xC000
1865#define ASC_BIOS_MAX_ADDR 0xEC00
1866#define ASC_BIOS_BANK_SIZE 0x0400
1867#define ASC_MCODE_START_ADDR 0x0080
1868#define ASC_CFG0_HOST_INT_ON 0x0020
1869#define ASC_CFG0_BIOS_ON 0x0040
1870#define ASC_CFG0_VERA_BURST_ON 0x0080
1871#define ASC_CFG0_SCSI_PARITY_ON 0x0800
1872#define ASC_CFG1_SCSI_TARGET_ON 0x0080
1873#define ASC_CFG1_LRAM_8BITS_ON 0x0800
1874#define ASC_CFG_MSW_CLR_MASK 0x3080
1875#define CSW_TEST1 (ASC_CS_TYPE)0x8000
1876#define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
1877#define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
1878#define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
1879#define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
1880#define CSW_TEST2 (ASC_CS_TYPE)0x0400
1881#define CSW_TEST3 (ASC_CS_TYPE)0x0200
1882#define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
1883#define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
1884#define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
1885#define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
1886#define CSW_HALTED (ASC_CS_TYPE)0x0010
1887#define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
1888#define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
1889#define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
1890#define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
1891#define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
1892#define CIW_INT_ACK (ASC_CS_TYPE)0x0100
1893#define CIW_TEST1 (ASC_CS_TYPE)0x0200
1894#define CIW_TEST2 (ASC_CS_TYPE)0x0400
1895#define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
1896#define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
1897#define CC_CHIP_RESET (uchar)0x80
1898#define CC_SCSI_RESET (uchar)0x40
1899#define CC_HALT (uchar)0x20
1900#define CC_SINGLE_STEP (uchar)0x10
1901#define CC_DMA_ABLE (uchar)0x08
1902#define CC_TEST (uchar)0x04
1903#define CC_BANK_ONE (uchar)0x02
1904#define CC_DIAG (uchar)0x01
1905#define ASC_1000_ID0W 0x04C1
1906#define ASC_1000_ID0W_FIX 0x00C1
1907#define ASC_1000_ID1B 0x25
1908#define ASC_EISA_BIG_IOP_GAP (0x1C30-0x0C50)
1909#define ASC_EISA_SMALL_IOP_GAP (0x0020)
1910#define ASC_EISA_MIN_IOP_ADDR (0x0C30)
1911#define ASC_EISA_MAX_IOP_ADDR (0xFC50)
1912#define ASC_EISA_REV_IOP_MASK (0x0C83)
1913#define ASC_EISA_PID_IOP_MASK (0x0C80)
1914#define ASC_EISA_CFG_IOP_MASK (0x0C86)
1915#define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
1916#define ASC_EISA_ID_740 0x01745004UL
1917#define ASC_EISA_ID_750 0x01755004UL
1918#define INS_HALTINT (ushort)0x6281
1919#define INS_HALT (ushort)0x6280
1920#define INS_SINT (ushort)0x6200
1921#define INS_RFLAG_WTM (ushort)0x7380
1922#define ASC_MC_SAVE_CODE_WSIZE 0x500
1923#define ASC_MC_SAVE_DATA_WSIZE 0x40
1924
1925typedef struct asc_mc_saved {
1926 ushort data[ASC_MC_SAVE_DATA_WSIZE];
1927 ushort code[ASC_MC_SAVE_CODE_WSIZE];
1928} ASC_MC_SAVED;
1929
1930#define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
1931#define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
1932#define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
1933#define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
1934#define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
1935#define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
1936#define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
1937#define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
1938#define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
1939#define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
1940#define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data));
1941#define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id));
1942#define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data);
1943#define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id));
1944#define AscSynIndexToPeriod(index) (uchar)(asc_dvc->sdtr_period_tbl[ (index) ])
1945#define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
1946#define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
1947#define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
1948#define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
1949#define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
1950#define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
1951#define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
1952#define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
1953#define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
1954#define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
1955#define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
1956#define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
1957#define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
1958#define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
1959#define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
1960#define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
1961#define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
1962#define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
1963#define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
1964#define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
1965#define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
1966#define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
1967#define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
1968#define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
1969#define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
1970#define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
1971#define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
1972#define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
1973#define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
1974#define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
1975#define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
1976#define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
1977#define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
1978#define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
1979#define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
1980#define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
1981#define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
1982#define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
1983#define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
1984#define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
1985#define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
1986#define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
1987#define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
1988#define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
1989#define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
1990#define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
1991#define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
1992#define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
1993#define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
1994#define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
1995#define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
1996#define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
1997#define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
1998
1999STATIC int AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg);
2000STATIC int AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg);
2001STATIC void AscWaitEEPRead(void);
2002STATIC void AscWaitEEPWrite(void);
2003STATIC ushort AscReadEEPWord(PortAddr, uchar);
2004STATIC ushort AscWriteEEPWord(PortAddr, uchar, ushort);
2005STATIC ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
2006STATIC int AscSetEEPConfigOnce(PortAddr, ASCEEP_CONFIG *, ushort);
2007STATIC int AscSetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
2008STATIC int AscStartChip(PortAddr);
2009STATIC int AscStopChip(PortAddr);
2010STATIC void AscSetChipIH(PortAddr, ushort);
2011STATIC int AscIsChipHalted(PortAddr);
2012STATIC void AscAckInterrupt(PortAddr);
2013STATIC void AscDisableInterrupt(PortAddr);
2014STATIC void AscEnableInterrupt(PortAddr);
2015STATIC void AscSetBank(PortAddr, uchar);
2016STATIC int AscResetChipAndScsiBus(ASC_DVC_VAR *);
2017#ifdef CONFIG_ISA
2018STATIC ushort AscGetIsaDmaChannel(PortAddr);
2019STATIC ushort AscSetIsaDmaChannel(PortAddr, ushort);
2020STATIC uchar AscSetIsaDmaSpeed(PortAddr, uchar);
2021STATIC uchar AscGetIsaDmaSpeed(PortAddr);
2022#endif
2023STATIC uchar AscReadLramByte(PortAddr, ushort);
2024STATIC ushort AscReadLramWord(PortAddr, ushort);
2025#if CC_VERY_LONG_SG_LIST
2026STATIC ASC_DCNT AscReadLramDWord(PortAddr, ushort);
2027#endif
2028STATIC void AscWriteLramWord(PortAddr, ushort, ushort);
2029STATIC void AscWriteLramByte(PortAddr, ushort, uchar);
2030STATIC ASC_DCNT AscMemSumLramWord(PortAddr, ushort, int);
2031STATIC void AscMemWordSetLram(PortAddr, ushort, ushort, int);
2032STATIC void AscMemWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
2033STATIC void AscMemDWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
2034STATIC void AscMemWordCopyPtrFromLram(PortAddr, ushort, uchar *, int);
2035STATIC ushort AscInitAscDvcVar(ASC_DVC_VAR *);
2036STATIC ushort AscInitFromEEP(ASC_DVC_VAR *);
2037STATIC ushort AscInitFromAscDvcVar(ASC_DVC_VAR *);
2038STATIC ushort AscInitMicroCodeVar(ASC_DVC_VAR *);
2039STATIC int AscTestExternalLram(ASC_DVC_VAR *);
2040STATIC uchar AscMsgOutSDTR(ASC_DVC_VAR *, uchar, uchar);
2041STATIC uchar AscCalSDTRData(ASC_DVC_VAR *, uchar, uchar);
2042STATIC void AscSetChipSDTR(PortAddr, uchar, uchar);
2043STATIC uchar AscGetSynPeriodIndex(ASC_DVC_VAR *, uchar);
2044STATIC uchar AscAllocFreeQueue(PortAddr, uchar);
2045STATIC uchar AscAllocMultipleFreeQueue(PortAddr, uchar, uchar);
2046STATIC int AscHostReqRiscHalt(PortAddr);
2047STATIC int AscStopQueueExe(PortAddr);
2048STATIC int AscSendScsiQueue(ASC_DVC_VAR *,
2049 ASC_SCSI_Q * scsiq,
2050 uchar n_q_required);
2051STATIC int AscPutReadyQueue(ASC_DVC_VAR *,
2052 ASC_SCSI_Q *, uchar);
2053STATIC int AscPutReadySgListQueue(ASC_DVC_VAR *,
2054 ASC_SCSI_Q *, uchar);
2055STATIC int AscSetChipSynRegAtID(PortAddr, uchar, uchar);
2056STATIC int AscSetRunChipSynRegAtID(PortAddr, uchar, uchar);
2057STATIC ushort AscInitLram(ASC_DVC_VAR *);
2058STATIC ushort AscInitQLinkVar(ASC_DVC_VAR *);
2059STATIC int AscSetLibErrorCode(ASC_DVC_VAR *, ushort);
2060STATIC int AscIsrChipHalted(ASC_DVC_VAR *);
2061STATIC uchar _AscCopyLramScsiDoneQ(PortAddr, ushort,
2062 ASC_QDONE_INFO *, ASC_DCNT);
2063STATIC int AscIsrQDone(ASC_DVC_VAR *);
2064STATIC int AscCompareString(uchar *, uchar *, int);
2065#ifdef CONFIG_ISA
2066STATIC ushort AscGetEisaChipCfg(PortAddr);
2067STATIC ASC_DCNT AscGetEisaProductID(PortAddr);
2068STATIC PortAddr AscSearchIOPortAddrEISA(PortAddr);
2069STATIC PortAddr AscSearchIOPortAddr11(PortAddr);
2070STATIC PortAddr AscSearchIOPortAddr(PortAddr, ushort);
2071STATIC void AscSetISAPNPWaitForKey(void);
2072#endif
2073STATIC uchar AscGetChipScsiCtrl(PortAddr);
2074STATIC uchar AscSetChipScsiID(PortAddr, uchar);
2075STATIC uchar AscGetChipVersion(PortAddr, ushort);
2076STATIC ushort AscGetChipBusType(PortAddr);
2077STATIC ASC_DCNT AscLoadMicroCode(PortAddr, ushort, uchar *, ushort);
2078STATIC int AscFindSignature(PortAddr);
2079STATIC void AscToggleIRQAct(PortAddr);
2080STATIC uchar AscGetChipIRQ(PortAddr, ushort);
2081STATIC uchar AscSetChipIRQ(PortAddr, uchar, ushort);
2082STATIC ushort AscGetChipBiosAddress(PortAddr, ushort);
2083STATIC inline ulong DvcEnterCritical(void);
2084STATIC inline void DvcLeaveCritical(ulong);
2085#ifdef CONFIG_PCI
2086STATIC uchar DvcReadPCIConfigByte(ASC_DVC_VAR *, ushort);
2087STATIC void DvcWritePCIConfigByte(ASC_DVC_VAR *,
2088 ushort, uchar);
2089#endif
2090STATIC ushort AscGetChipBiosAddress(PortAddr, ushort);
2091STATIC void DvcSleepMilliSecond(ASC_DCNT);
2092STATIC void DvcDelayNanoSecond(ASC_DVC_VAR *, ASC_DCNT);
2093STATIC void DvcPutScsiQ(PortAddr, ushort, uchar *, int);
2094STATIC void DvcGetQinfo(PortAddr, ushort, uchar *, int);
2095STATIC ushort AscInitGetConfig(ASC_DVC_VAR *);
2096STATIC ushort AscInitSetConfig(ASC_DVC_VAR *);
2097STATIC ushort AscInitAsc1000Driver(ASC_DVC_VAR *);
2098STATIC void AscAsyncFix(ASC_DVC_VAR *, uchar,
2099 ASC_SCSI_INQUIRY *);
2100STATIC int AscTagQueuingSafe(ASC_SCSI_INQUIRY *);
2101STATIC void AscInquiryHandling(ASC_DVC_VAR *,
2102 uchar, ASC_SCSI_INQUIRY *);
2103STATIC int AscExeScsiQueue(ASC_DVC_VAR *, ASC_SCSI_Q *);
2104STATIC int AscISR(ASC_DVC_VAR *);
2105STATIC uint AscGetNumOfFreeQueue(ASC_DVC_VAR *, uchar,
2106 uchar);
2107STATIC int AscSgListToQueue(int);
2108#ifdef CONFIG_ISA
2109STATIC void AscEnableIsaDma(uchar);
2110#endif
2111STATIC ASC_DCNT AscGetMaxDmaCount(ushort);
2112
2113
2114
2115
2116
2117
2118#define ADV_LIB_VERSION_MAJOR 5
2119#define ADV_LIB_VERSION_MINOR 14
2120
2121
2122#define ADV_OS_LINUX
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137#define ADV_PADDR __u32
2138#define ADV_VADDR __u32
2139#define ADV_DCNT __u32
2140#define ADV_SDCNT __s32
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150#define ADV_VADDR_TO_U32 virt_to_bus
2151#define ADV_U32_TO_VADDR bus_to_virt
2152
2153#define AdvPortAddr ulong
2154
2155
2156
2157
2158#define ADV_MEM_READB(addr) readb(addr)
2159#define ADV_MEM_READW(addr) readw(addr)
2160#define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
2161#define ADV_MEM_WRITEW(addr, word) writew(word, addr)
2162#define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
2163
2164#define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
2165
2166
2167
2168
2169
2170#define ADV_MAX_CDB_LEN 16
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182#define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
2183
2184
2185
2186
2187
2188#define ADV_MAX_SG_LIST 255
2189
2190
2191#define ADV_NUM_SG_BLOCK \
2192 ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK)
2193
2194
2195#define ADV_SG_TOTAL_MEM_SIZE \
2196 (sizeof(ADV_SG_BLOCK) * ADV_NUM_SG_BLOCK)
2197
2198#define ADV_PAGE_SIZE PAGE_SIZE
2199
2200#define ADV_NUM_PAGE_CROSSING \
2201 ((ADV_SG_TOTAL_MEM_SIZE + (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
2202
2203
2204#define ADV_PCI_VENDOR_ID 0x10CD
2205#define ADV_PCI_DEVICE_ID_REV_A 0x2300
2206#define ADV_PCI_DEVID_38C0800_REV1 0x2500
2207#define ADV_PCI_DEVID_38C1600_REV1 0x2700
2208
2209#define ADV_EEP_DVC_CFG_BEGIN (0x00)
2210#define ADV_EEP_DVC_CFG_END (0x15)
2211#define ADV_EEP_DVC_CTL_BEGIN (0x16)
2212#define ADV_EEP_MAX_WORD_ADDR (0x1E)
2213
2214#define ADV_EEP_DELAY_MS 100
2215
2216#define ADV_EEPROM_BIG_ENDIAN 0x8000
2217#define ADV_EEPROM_BIOS_ENABLE 0x4000
2218
2219
2220
2221
2222
2223#define ADV_EEPROM_TERM_POL 0x2000
2224#define ADV_EEPROM_CIS_LD 0x2000
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236#define ADV_EEPROM_INTAB 0x0800
2237
2238typedef struct adveep_3550_config
2239{
2240
2241
2242 ushort cfg_lsw;
2243
2244
2245
2246 ushort cfg_msw;
2247 ushort disc_enable;
2248 ushort wdtr_able;
2249 ushort sdtr_able;
2250 ushort start_motor;
2251 ushort tagqng_able;
2252 ushort bios_scan;
2253 ushort scam_tolerant;
2254
2255 uchar adapter_scsi_id;
2256 uchar bios_boot_delay;
2257
2258 uchar scsi_reset_delay;
2259 uchar bios_id_lun;
2260
2261
2262
2263 uchar termination;
2264
2265
2266
2267
2268
2269 uchar reserved1;
2270
2271 ushort bios_ctrl;
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288 ushort ultra_able;
2289 ushort reserved2;
2290 uchar max_host_qng;
2291 uchar max_dvc_qng;
2292 ushort dvc_cntl;
2293 ushort bug_fix;
2294 ushort serial_number_word1;
2295 ushort serial_number_word2;
2296 ushort serial_number_word3;
2297 ushort check_sum;
2298 uchar oem_name[16];
2299 ushort dvc_err_code;
2300 ushort adv_err_code;
2301 ushort adv_err_addr;
2302 ushort saved_dvc_err_code;
2303 ushort saved_adv_err_code;
2304 ushort saved_adv_err_addr;
2305 ushort num_of_err;
2306} ADVEEP_3550_CONFIG;
2307
2308typedef struct adveep_38C0800_config
2309{
2310
2311
2312 ushort cfg_lsw;
2313
2314
2315
2316 ushort cfg_msw;
2317 ushort disc_enable;
2318 ushort wdtr_able;
2319 ushort sdtr_speed1;
2320 ushort start_motor;
2321 ushort tagqng_able;
2322 ushort bios_scan;
2323 ushort scam_tolerant;
2324
2325 uchar adapter_scsi_id;
2326 uchar bios_boot_delay;
2327
2328 uchar scsi_reset_delay;
2329 uchar bios_id_lun;
2330
2331
2332
2333 uchar termination_se;
2334
2335
2336
2337
2338
2339 uchar termination_lvd;
2340
2341
2342
2343
2344
2345 ushort bios_ctrl;
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362 ushort sdtr_speed2;
2363 ushort sdtr_speed3;
2364 uchar max_host_qng;
2365 uchar max_dvc_qng;
2366 ushort dvc_cntl;
2367 ushort sdtr_speed4;
2368 ushort serial_number_word1;
2369 ushort serial_number_word2;
2370 ushort serial_number_word3;
2371 ushort check_sum;
2372 uchar oem_name[16];
2373 ushort dvc_err_code;
2374 ushort adv_err_code;
2375 ushort adv_err_addr;
2376 ushort saved_dvc_err_code;
2377 ushort saved_adv_err_code;
2378 ushort saved_adv_err_addr;
2379 ushort reserved36;
2380 ushort reserved37;
2381 ushort reserved38;
2382 ushort reserved39;
2383 ushort reserved40;
2384 ushort reserved41;
2385 ushort reserved42;
2386 ushort reserved43;
2387 ushort reserved44;
2388 ushort reserved45;
2389 ushort reserved46;
2390 ushort reserved47;
2391 ushort reserved48;
2392 ushort reserved49;
2393 ushort reserved50;
2394 ushort reserved51;
2395 ushort reserved52;
2396 ushort reserved53;
2397 ushort reserved54;
2398 ushort reserved55;
2399 ushort cisptr_lsw;
2400 ushort cisprt_msw;
2401 ushort subsysvid;
2402 ushort subsysid;
2403 ushort reserved60;
2404 ushort reserved61;
2405 ushort reserved62;
2406 ushort reserved63;
2407} ADVEEP_38C0800_CONFIG;
2408
2409typedef struct adveep_38C1600_config
2410{
2411
2412
2413 ushort cfg_lsw;
2414
2415
2416
2417
2418
2419 ushort cfg_msw;
2420 ushort disc_enable;
2421 ushort wdtr_able;
2422 ushort sdtr_speed1;
2423 ushort start_motor;
2424 ushort tagqng_able;
2425 ushort bios_scan;
2426 ushort scam_tolerant;
2427
2428 uchar adapter_scsi_id;
2429 uchar bios_boot_delay;
2430
2431 uchar scsi_reset_delay;
2432 uchar bios_id_lun;
2433
2434
2435
2436 uchar termination_se;
2437
2438
2439
2440
2441
2442 uchar termination_lvd;
2443
2444
2445
2446
2447
2448 ushort bios_ctrl;
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465 ushort sdtr_speed2;
2466 ushort sdtr_speed3;
2467 uchar max_host_qng;
2468 uchar max_dvc_qng;
2469 ushort dvc_cntl;
2470 ushort sdtr_speed4;
2471 ushort serial_number_word1;
2472 ushort serial_number_word2;
2473 ushort serial_number_word3;
2474 ushort check_sum;
2475 uchar oem_name[16];
2476 ushort dvc_err_code;
2477 ushort adv_err_code;
2478 ushort adv_err_addr;
2479 ushort saved_dvc_err_code;
2480 ushort saved_adv_err_code;
2481 ushort saved_adv_err_addr;
2482 ushort reserved36;
2483 ushort reserved37;
2484 ushort reserved38;
2485 ushort reserved39;
2486 ushort reserved40;
2487 ushort reserved41;
2488 ushort reserved42;
2489 ushort reserved43;
2490 ushort reserved44;
2491 ushort reserved45;
2492 ushort reserved46;
2493 ushort reserved47;
2494 ushort reserved48;
2495 ushort reserved49;
2496 ushort reserved50;
2497 ushort reserved51;
2498 ushort reserved52;
2499 ushort reserved53;
2500 ushort reserved54;
2501 ushort reserved55;
2502 ushort cisptr_lsw;
2503 ushort cisprt_msw;
2504 ushort subsysvid;
2505 ushort subsysid;
2506 ushort reserved60;
2507 ushort reserved61;
2508 ushort reserved62;
2509 ushort reserved63;
2510} ADVEEP_38C1600_CONFIG;
2511
2512
2513
2514
2515#define ASC_EEP_CMD_DONE 0x0200
2516#define ASC_EEP_CMD_DONE_ERR 0x0001
2517
2518
2519#define EEP_CFG_WORD_BIG_ENDIAN 0x8000
2520
2521
2522#define BIOS_CTRL_BIOS 0x0001
2523#define BIOS_CTRL_EXTENDED_XLAT 0x0002
2524#define BIOS_CTRL_GT_2_DISK 0x0004
2525#define BIOS_CTRL_BIOS_REMOVABLE 0x0008
2526#define BIOS_CTRL_BOOTABLE_CD 0x0010
2527#define BIOS_CTRL_MULTIPLE_LUN 0x0040
2528#define BIOS_CTRL_DISPLAY_MSG 0x0080
2529#define BIOS_CTRL_NO_SCAM 0x0100
2530#define BIOS_CTRL_RESET_SCSI_BUS 0x0200
2531#define BIOS_CTRL_INIT_VERBOSE 0x0800
2532#define BIOS_CTRL_SCSI_PARITY 0x1000
2533#define BIOS_CTRL_AIPP_DIS 0x2000
2534
2535#define ADV_3550_MEMSIZE 0x2000
2536#define ADV_3550_IOLEN 0x40
2537
2538#define ADV_38C0800_MEMSIZE 0x4000
2539#define ADV_38C0800_IOLEN 0x100
2540
2541
2542
2543
2544
2545
2546
2547
2548#define ADV_38C1600_MEMSIZE 0x4000
2549#define ADV_38C1600_IOLEN 0x100
2550#define ADV_38C1600_MEMLEN 0x1000
2551
2552
2553
2554
2555#define IOPB_INTR_STATUS_REG 0x00
2556#define IOPB_CHIP_ID_1 0x01
2557#define IOPB_INTR_ENABLES 0x02
2558#define IOPB_CHIP_TYPE_REV 0x03
2559#define IOPB_RES_ADDR_4 0x04
2560#define IOPB_RES_ADDR_5 0x05
2561#define IOPB_RAM_DATA 0x06
2562#define IOPB_RES_ADDR_7 0x07
2563#define IOPB_FLAG_REG 0x08
2564#define IOPB_RES_ADDR_9 0x09
2565#define IOPB_RISC_CSR 0x0A
2566#define IOPB_RES_ADDR_B 0x0B
2567#define IOPB_RES_ADDR_C 0x0C
2568#define IOPB_RES_ADDR_D 0x0D
2569#define IOPB_SOFT_OVER_WR 0x0E
2570#define IOPB_RES_ADDR_F 0x0F
2571#define IOPB_MEM_CFG 0x10
2572#define IOPB_RES_ADDR_11 0x11
2573#define IOPB_GPIO_DATA 0x12
2574#define IOPB_RES_ADDR_13 0x13
2575#define IOPB_FLASH_PAGE 0x14
2576#define IOPB_RES_ADDR_15 0x15
2577#define IOPB_GPIO_CNTL 0x16
2578#define IOPB_RES_ADDR_17 0x17
2579#define IOPB_FLASH_DATA 0x18
2580#define IOPB_RES_ADDR_19 0x19
2581#define IOPB_RES_ADDR_1A 0x1A
2582#define IOPB_RES_ADDR_1B 0x1B
2583#define IOPB_RES_ADDR_1C 0x1C
2584#define IOPB_RES_ADDR_1D 0x1D
2585#define IOPB_RES_ADDR_1E 0x1E
2586#define IOPB_RES_ADDR_1F 0x1F
2587#define IOPB_DMA_CFG0 0x20
2588#define IOPB_DMA_CFG1 0x21
2589#define IOPB_TICKLE 0x22
2590#define IOPB_DMA_REG_WR 0x23
2591#define IOPB_SDMA_STATUS 0x24
2592#define IOPB_SCSI_BYTE_CNT 0x25
2593#define IOPB_HOST_BYTE_CNT 0x26
2594#define IOPB_BYTE_LEFT_TO_XFER 0x27
2595#define IOPB_BYTE_TO_XFER_0 0x28
2596#define IOPB_BYTE_TO_XFER_1 0x29
2597#define IOPB_BYTE_TO_XFER_2 0x2A
2598#define IOPB_BYTE_TO_XFER_3 0x2B
2599#define IOPB_ACC_GRP 0x2C
2600#define IOPB_RES_ADDR_2D 0x2D
2601#define IOPB_DEV_ID 0x2E
2602#define IOPB_RES_ADDR_2F 0x2F
2603#define IOPB_SCSI_DATA 0x30
2604#define IOPB_RES_ADDR_31 0x31
2605#define IOPB_RES_ADDR_32 0x32
2606#define IOPB_SCSI_DATA_HSHK 0x33
2607#define IOPB_SCSI_CTRL 0x34
2608#define IOPB_RES_ADDR_35 0x35
2609#define IOPB_RES_ADDR_36 0x36
2610#define IOPB_RES_ADDR_37 0x37
2611#define IOPB_RAM_BIST 0x38
2612#define IOPB_PLL_TEST 0x39
2613#define IOPB_PCI_INT_CFG 0x3A
2614#define IOPB_RES_ADDR_3B 0x3B
2615#define IOPB_RFIFO_CNT 0x3C
2616#define IOPB_RES_ADDR_3D 0x3D
2617#define IOPB_RES_ADDR_3E 0x3E
2618#define IOPB_RES_ADDR_3F 0x3F
2619
2620
2621
2622
2623#define IOPW_CHIP_ID_0 0x00
2624#define IOPW_CTRL_REG 0x02
2625#define IOPW_RAM_ADDR 0x04
2626#define IOPW_RAM_DATA 0x06
2627#define IOPW_RES_ADDR_08 0x08
2628#define IOPW_RISC_CSR 0x0A
2629#define IOPW_SCSI_CFG0 0x0C
2630#define IOPW_SCSI_CFG1 0x0E
2631#define IOPW_RES_ADDR_10 0x10
2632#define IOPW_SEL_MASK 0x12
2633#define IOPW_RES_ADDR_14 0x14
2634#define IOPW_FLASH_ADDR 0x16
2635#define IOPW_RES_ADDR_18 0x18
2636#define IOPW_EE_CMD 0x1A
2637#define IOPW_EE_DATA 0x1C
2638#define IOPW_SFIFO_CNT 0x1E
2639#define IOPW_RES_ADDR_20 0x20
2640#define IOPW_Q_BASE 0x22
2641#define IOPW_QP 0x24
2642#define IOPW_IX 0x26
2643#define IOPW_SP 0x28
2644#define IOPW_PC 0x2A
2645#define IOPW_RES_ADDR_2C 0x2C
2646#define IOPW_RES_ADDR_2E 0x2E
2647#define IOPW_SCSI_DATA 0x30
2648#define IOPW_SCSI_DATA_HSHK 0x32
2649#define IOPW_SCSI_CTRL 0x34
2650#define IOPW_HSHK_CFG 0x36
2651#define IOPW_SXFR_STATUS 0x36
2652#define IOPW_SXFR_CNTL 0x38
2653#define IOPW_SXFR_CNTH 0x3A
2654#define IOPW_RES_ADDR_3C 0x3C
2655#define IOPW_RFIFO_DATA 0x3E
2656
2657
2658
2659
2660#define IOPDW_RES_ADDR_0 0x00
2661#define IOPDW_RAM_DATA 0x04
2662#define IOPDW_RES_ADDR_8 0x08
2663#define IOPDW_RES_ADDR_C 0x0C
2664#define IOPDW_RES_ADDR_10 0x10
2665#define IOPDW_COMMA 0x14
2666#define IOPDW_COMMB 0x18
2667#define IOPDW_RES_ADDR_1C 0x1C
2668#define IOPDW_SDMA_ADDR0 0x20
2669#define IOPDW_SDMA_ADDR1 0x24
2670#define IOPDW_SDMA_COUNT 0x28
2671#define IOPDW_SDMA_ERROR 0x2C
2672#define IOPDW_RDMA_ADDR0 0x30
2673#define IOPDW_RDMA_ADDR1 0x34
2674#define IOPDW_RDMA_COUNT 0x38
2675#define IOPDW_RDMA_ERROR 0x3C
2676
2677#define ADV_CHIP_ID_BYTE 0x25
2678#define ADV_CHIP_ID_WORD 0x04C1
2679
2680#define ADV_SC_SCSI_BUS_RESET 0x2000
2681
2682#define ADV_INTR_ENABLE_HOST_INTR 0x01
2683#define ADV_INTR_ENABLE_SEL_INTR 0x02
2684#define ADV_INTR_ENABLE_DPR_INTR 0x04
2685#define ADV_INTR_ENABLE_RTA_INTR 0x08
2686#define ADV_INTR_ENABLE_RMA_INTR 0x10
2687#define ADV_INTR_ENABLE_RST_INTR 0x20
2688#define ADV_INTR_ENABLE_DPE_INTR 0x40
2689#define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
2690
2691#define ADV_INTR_STATUS_INTRA 0x01
2692#define ADV_INTR_STATUS_INTRB 0x02
2693#define ADV_INTR_STATUS_INTRC 0x04
2694
2695#define ADV_RISC_CSR_STOP (0x0000)
2696#define ADV_RISC_TEST_COND (0x2000)
2697#define ADV_RISC_CSR_RUN (0x4000)
2698#define ADV_RISC_CSR_SINGLE_STEP (0x8000)
2699
2700#define ADV_CTRL_REG_HOST_INTR 0x0100
2701#define ADV_CTRL_REG_SEL_INTR 0x0200
2702#define ADV_CTRL_REG_DPR_INTR 0x0400
2703#define ADV_CTRL_REG_RTA_INTR 0x0800
2704#define ADV_CTRL_REG_RMA_INTR 0x1000
2705#define ADV_CTRL_REG_RES_BIT14 0x2000
2706#define ADV_CTRL_REG_DPE_INTR 0x4000
2707#define ADV_CTRL_REG_POWER_DONE 0x8000
2708#define ADV_CTRL_REG_ANY_INTR 0xFF00
2709
2710#define ADV_CTRL_REG_CMD_RESET 0x00C6
2711#define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
2712#define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
2713#define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
2714#define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
2715
2716#define ADV_TICKLE_NOP 0x00
2717#define ADV_TICKLE_A 0x01
2718#define ADV_TICKLE_B 0x02
2719#define ADV_TICKLE_C 0x03
2720
2721#define ADV_SCSI_CTRL_RSTOUT 0x2000
2722
2723#define AdvIsIntPending(port) \
2724 (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
2725
2726
2727
2728
2729#define TIMER_MODEAB 0xC000
2730#define PARITY_EN 0x2000
2731#define EVEN_PARITY 0x1000
2732#define WD_LONG 0x0800
2733#define QUEUE_128 0x0400
2734#define PRIM_MODE 0x0100
2735#define SCAM_EN 0x0080
2736#define SEL_TMO_LONG 0x0040
2737#define CFRM_ID 0x0020
2738#define OUR_ID_EN 0x0010
2739#define OUR_ID 0x000F
2740
2741
2742
2743
2744#define BIG_ENDIAN 0x8000
2745#define TERM_POL 0x2000
2746#define SLEW_RATE 0x1000
2747#define FILTER_SEL 0x0C00
2748#define FLTR_DISABLE 0x0000
2749#define FLTR_11_TO_20NS 0x0800
2750#define FLTR_21_TO_39NS 0x0C00
2751#define ACTIVE_DBL 0x0200
2752#define DIFF_MODE 0x0100
2753#define DIFF_SENSE 0x0080
2754#define TERM_CTL_SEL 0x0040
2755#define TERM_CTL 0x0030
2756#define TERM_CTL_H 0x0020
2757#define TERM_CTL_L 0x0010
2758#define CABLE_DETECT 0x000F
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771#define DIS_TERM_DRV 0x4000
2772#define HVD_LVD_SE 0x1C00
2773#define HVD 0x1000
2774#define LVD 0x0800
2775#define SE 0x0400
2776#define TERM_LVD 0x00C0
2777#define TERM_LVD_HI 0x0080
2778#define TERM_LVD_LO 0x0040
2779#define TERM_SE 0x0030
2780#define TERM_SE_HI 0x0020
2781#define TERM_SE_LO 0x0010
2782#define C_DET_LVD 0x000C
2783#define C_DET3 0x0008
2784#define C_DET2 0x0004
2785#define C_DET_SE 0x0003
2786#define C_DET1 0x0002
2787#define C_DET0 0x0001
2788
2789
2790#define CABLE_ILLEGAL_A 0x7
2791
2792
2793#define CABLE_ILLEGAL_B 0xB
2794
2795
2796
2797
2798
2799#define BIOS_EN 0x40
2800#define FAST_EE_CLK 0x20
2801#define RAM_SZ 0x1C
2802#define RAM_SZ_2KB 0x00
2803#define RAM_SZ_4KB 0x04
2804#define RAM_SZ_8KB 0x08
2805#define RAM_SZ_16KB 0x0C
2806#define RAM_SZ_32KB 0x10
2807#define RAM_SZ_64KB 0x14
2808
2809
2810
2811
2812
2813
2814#define BC_THRESH_ENB 0x80
2815#define FIFO_THRESH 0x70
2816#define FIFO_THRESH_16B 0x00
2817#define FIFO_THRESH_32B 0x20
2818#define FIFO_THRESH_48B 0x30
2819#define FIFO_THRESH_64B 0x40
2820#define FIFO_THRESH_80B 0x50
2821#define FIFO_THRESH_96B 0x60
2822#define FIFO_THRESH_112B 0x70
2823#define START_CTL 0x0C
2824#define START_CTL_TH 0x00
2825#define START_CTL_ID 0x04
2826#define START_CTL_THID 0x08
2827#define START_CTL_EMFU 0x0C
2828#define READ_CMD 0x03
2829#define READ_CMD_MR 0x00
2830#define READ_CMD_MRL 0x02
2831#define READ_CMD_MRM 0x03
2832
2833
2834
2835
2836#define RAM_TEST_MODE 0x80
2837#define PRE_TEST_MODE 0x40
2838#define NORMAL_MODE 0x00
2839#define RAM_TEST_DONE 0x10
2840#define RAM_TEST_STATUS 0x0F
2841#define RAM_TEST_HOST_ERROR 0x08
2842#define RAM_TEST_INTRAM_ERROR 0x04
2843#define RAM_TEST_RISC_ERROR 0x02
2844#define RAM_TEST_SCSI_ERROR 0x01
2845#define RAM_TEST_SUCCESS 0x00
2846#define PRE_TEST_VALUE 0x05
2847#define NORMAL_VALUE 0x00
2848
2849
2850
2851
2852
2853
2854
2855#define INTAB_LD 0x80
2856
2857
2858
2859
2860
2861
2862
2863#define TOTEMPOLE 0x02
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874#define INTAB 0x01
2875
2876
2877
2878
2879
2880
2881#define ADV_TRUE 1
2882#define ADV_FALSE 0
2883#define ADV_NOERROR 1
2884#define ADV_SUCCESS 1
2885#define ADV_BUSY 0
2886#define ADV_ERROR (-1)
2887
2888
2889
2890
2891
2892#define ASC_WARN_BUSRESET_ERROR 0x0001
2893#define ASC_WARN_EEPROM_CHKSUM 0x0002
2894#define ASC_WARN_EEPROM_TERMINATION 0x0004
2895#define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080
2896#define ASC_WARN_ERROR 0xFFFF
2897
2898#define ADV_MAX_TID 15
2899#define ADV_MAX_LUN 7
2900
2901
2902
2903
2904#define ASC_IERR_WRITE_EEPROM 0x0001
2905#define ASC_IERR_MCODE_CHKSUM 0x0002
2906#define ASC_IERR_NO_CARRIER 0x0004
2907#define ASC_IERR_START_STOP_CHIP 0x0008
2908#define ASC_IERR_CHIP_VERSION 0x0040
2909#define ASC_IERR_SET_SCSI_ID 0x0080
2910#define ASC_IERR_HVD_DEVICE 0x0100
2911#define ASC_IERR_BAD_SIGNATURE 0x0200
2912#define ASC_IERR_ILLEGAL_CONNECTION 0x0400
2913#define ASC_IERR_SINGLE_END_DEVICE 0x0800
2914#define ASC_IERR_REVERSED_CABLE 0x1000
2915#define ASC_IERR_BIST_PRE_TEST 0x2000
2916#define ASC_IERR_BIST_RAM_TEST 0x4000
2917#define ASC_IERR_BAD_CHIPTYPE 0x8000
2918
2919
2920
2921
2922#define ASC_MC_CODE_BEGIN_ADDR 0x0028
2923#define ASC_MC_CODE_END_ADDR 0x002A
2924#define ASC_MC_CODE_CHK_SUM 0x002C
2925#define ASC_MC_VERSION_DATE 0x0038
2926#define ASC_MC_VERSION_NUM 0x003A
2927#define ASC_MC_BIOSMEM 0x0040
2928#define ASC_MC_BIOSLEN 0x0050
2929#define ASC_MC_BIOS_SIGNATURE 0x0058
2930#define ASC_MC_BIOS_VERSION 0x005A
2931#define ASC_MC_SDTR_SPEED1 0x0090
2932#define ASC_MC_SDTR_SPEED2 0x0092
2933#define ASC_MC_SDTR_SPEED3 0x0094
2934#define ASC_MC_SDTR_SPEED4 0x0096
2935#define ASC_MC_CHIP_TYPE 0x009A
2936#define ASC_MC_INTRB_CODE 0x009B
2937#define ASC_MC_WDTR_ABLE 0x009C
2938#define ASC_MC_SDTR_ABLE 0x009E
2939#define ASC_MC_TAGQNG_ABLE 0x00A0
2940#define ASC_MC_DISC_ENABLE 0x00A2
2941#define ASC_MC_IDLE_CMD_STATUS 0x00A4
2942#define ASC_MC_IDLE_CMD 0x00A6
2943#define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
2944#define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
2945#define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
2946#define ASC_MC_DEFAULT_MEM_CFG 0x00B0
2947#define ASC_MC_DEFAULT_SEL_MASK 0x00B2
2948#define ASC_MC_SDTR_DONE 0x00B6
2949#define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
2950#define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
2951#define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
2952#define ASC_MC_CONTROL_FLAG 0x0122
2953#define ASC_MC_WDTR_DONE 0x0124
2954#define ASC_MC_CAM_MODE_MASK 0x015E
2955#define ASC_MC_ICQ 0x0160
2956#define ASC_MC_IRQ 0x0164
2957#define ASC_MC_PPR_ABLE 0x017A
2958
2959
2960
2961
2962#define BIOS_CODESEG 0x54
2963#define BIOS_CODELEN 0x56
2964#define BIOS_SIGNATURE 0x58
2965#define BIOS_VERSION 0x5A
2966
2967
2968
2969
2970
2971
2972
2973#define CONTROL_FLAG_IGNORE_PERR 0x0001
2974#define CONTROL_FLAG_ENABLE_AIPP 0x0002
2975
2976
2977
2978
2979#define HSHK_CFG_WIDE_XFR 0x8000
2980#define HSHK_CFG_RATE 0x0F00
2981#define HSHK_CFG_OFFSET 0x001F
2982
2983#define ASC_DEF_MAX_HOST_QNG 0xFD
2984#define ASC_DEF_MIN_HOST_QNG 0x10
2985#define ASC_DEF_MAX_DVC_QNG 0x3F
2986#define ASC_DEF_MIN_DVC_QNG 0x04
2987
2988#define ASC_QC_DATA_CHECK 0x01
2989#define ASC_QC_DATA_OUT 0x02
2990#define ASC_QC_START_MOTOR 0x04
2991#define ASC_QC_NO_OVERRUN 0x08
2992#define ASC_QC_FREEZE_TIDQ 0x10
2993
2994#define ASC_QSC_NO_DISC 0x01
2995#define ASC_QSC_NO_TAGMSG 0x02
2996#define ASC_QSC_NO_SYNC 0x04
2997#define ASC_QSC_NO_WIDE 0x08
2998#define ASC_QSC_REDO_DTR 0x10
2999
3000
3001
3002
3003#define ASC_QSC_HEAD_TAG 0x40
3004#define ASC_QSC_ORDERED_TAG 0x80
3005
3006
3007
3008
3009
3010typedef struct adv_carr_t
3011{
3012 ADV_VADDR carr_va;
3013 ADV_PADDR carr_pa;
3014 ADV_VADDR areq_vpa;
3015
3016
3017
3018
3019
3020
3021 ADV_VADDR next_vpa;
3022} ADV_CARR_T;
3023
3024
3025
3026
3027#define ASC_NEXT_VPA_MASK 0xFFFFFFF0
3028
3029#define ASC_RQ_DONE 0x00000001
3030#define ASC_RQ_GOOD 0x00000002
3031#define ASC_CQ_STOPPER 0x00000000
3032
3033#define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
3034
3035#define ADV_CARRIER_NUM_PAGE_CROSSING \
3036 (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + \
3037 (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
3038
3039#define ADV_CARRIER_BUFSIZE \
3040 ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
3041
3042
3043
3044
3045
3046
3047
3048#define ADV_POLL_REQUEST 0x01
3049#define ADV_SCSIQ_DONE 0x02
3050#define ADV_DONT_RETRY 0x08
3051
3052#define ADV_CHIP_ASC3550 0x01
3053#define ADV_CHIP_ASC38C0800 0x02
3054#define ADV_CHIP_ASC38C1600 0x03
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067typedef struct adv_dvc_cfg {
3068 ushort disc_enable;
3069 uchar chip_version;
3070 uchar termination;
3071 ushort pci_device_id;
3072 ushort lib_version;
3073 ushort control_flag;
3074 ushort mcode_date;
3075 ushort mcode_version;
3076 ushort pci_slot_info;
3077
3078
3079 ushort serial1;
3080 ushort serial2;
3081 ushort serial3;
3082} ADV_DVC_CFG;
3083
3084struct adv_dvc_var;
3085struct adv_scsi_req_q;
3086
3087typedef void (* ADV_ISR_CALLBACK)
3088 (struct adv_dvc_var *, struct adv_scsi_req_q *);
3089
3090typedef void (* ADV_ASYNC_CALLBACK)
3091 (struct adv_dvc_var *, uchar);
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105typedef struct adv_dvc_var {
3106 AdvPortAddr iop_base;
3107 ushort err_code;
3108 ushort bios_ctrl;
3109 ADV_ISR_CALLBACK isr_callback;
3110 ADV_ASYNC_CALLBACK async_callback;
3111 ushort wdtr_able;
3112 ushort sdtr_able;
3113 ushort ultra_able;
3114 ushort sdtr_speed1;
3115 ushort sdtr_speed2;
3116 ushort sdtr_speed3;
3117 ushort sdtr_speed4;
3118 ushort tagqng_able;
3119 ushort ppr_able;
3120 uchar max_dvc_qng;
3121 ushort start_motor;
3122 uchar scsi_reset_wait;
3123 uchar chip_no;
3124 uchar max_host_qng;
3125 uchar irq_no;
3126 ushort no_scam;
3127 struct asc_board *drv_ptr;
3128 uchar chip_scsi_id;
3129 uchar chip_type;
3130 uchar bist_err_code;
3131 ADV_CARR_T *carrier_buf;
3132 ADV_CARR_T *carr_freelist;
3133 ADV_CARR_T *icq_sp;
3134 ADV_CARR_T *irq_sp;
3135 ushort carr_pending_cnt;
3136
3137
3138
3139
3140 ADV_DVC_CFG *cfg;
3141} ADV_DVC_VAR;
3142
3143#define NO_OF_SG_PER_BLOCK 15
3144
3145typedef struct asc_sg_block {
3146 uchar reserved1;
3147 uchar reserved2;
3148 uchar reserved3;
3149 uchar sg_cnt;
3150 ADV_PADDR sg_ptr;
3151 struct {
3152 ADV_PADDR sg_addr;
3153 ADV_DCNT sg_count;
3154 } sg_list[NO_OF_SG_PER_BLOCK];
3155} ADV_SG_BLOCK;
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168typedef struct adv_scsi_req_q {
3169 uchar cntl;
3170 uchar target_cmd;
3171 uchar target_id;
3172 uchar target_lun;
3173 ADV_PADDR data_addr;
3174 ADV_DCNT data_cnt;
3175 ADV_PADDR sense_addr;
3176 ADV_PADDR carr_pa;
3177 uchar mflag;
3178 uchar sense_len;
3179 uchar cdb_len;
3180 uchar scsi_cntl;
3181 uchar done_status;
3182 uchar scsi_status;
3183 uchar host_status;
3184 uchar sg_working_ix;
3185 uchar cdb[12];
3186 ADV_PADDR sg_real_addr;
3187 ADV_PADDR scsiq_rptr;
3188 uchar cdb16[4];
3189 ADV_VADDR scsiq_ptr;
3190 ADV_VADDR carr_va;
3191
3192
3193
3194
3195 ADV_VADDR srb_ptr;
3196 ADV_SG_BLOCK *sg_list_ptr;
3197 char *vdata_addr;
3198 uchar a_flag;
3199 uchar pad[2];
3200} ADV_SCSI_REQ_Q;
3201
3202
3203
3204
3205#define IDLE_CMD_COMPLETED 0
3206#define IDLE_CMD_STOP_CHIP 0x0001
3207#define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
3208#define IDLE_CMD_SEND_INT 0x0004
3209#define IDLE_CMD_ABORT 0x0008
3210#define IDLE_CMD_DEVICE_RESET 0x0010
3211#define IDLE_CMD_SCSI_RESET_START 0x0020
3212#define IDLE_CMD_SCSI_RESET_END 0x0040
3213#define IDLE_CMD_SCSIREQ 0x0080
3214
3215#define IDLE_CMD_STATUS_SUCCESS 0x0001
3216#define IDLE_CMD_STATUS_FAILURE 0x0002
3217
3218
3219
3220
3221#define ADV_NOWAIT 0x01
3222
3223
3224
3225
3226#define SCSI_WAIT_10_SEC 10UL
3227#define SCSI_WAIT_100_MSEC 100UL
3228#define SCSI_US_PER_MSEC 1000
3229#define SCSI_MS_PER_SEC 1000UL
3230#define SCSI_MAX_RETRY 10
3231
3232#define ADV_ASYNC_RDMA_FAILURE 0x01
3233#define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02
3234#define ADV_ASYNC_CARRIER_READY_FAILURE 0x03
3235#define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04
3236
3237
3238#define ADV_HOST_SCSI_BUS_RESET 0x80
3239
3240
3241
3242
3243STATIC inline ulong DvcEnterCritical(void);
3244STATIC inline void DvcLeaveCritical(ulong);
3245STATIC void DvcSleepMilliSecond(ADV_DCNT);
3246STATIC uchar DvcAdvReadPCIConfigByte(ADV_DVC_VAR *, ushort);
3247STATIC void DvcAdvWritePCIConfigByte(ADV_DVC_VAR *, ushort, uchar);
3248STATIC ADV_PADDR DvcGetPhyAddr(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *,
3249 uchar *, ASC_SDCNT *, int);
3250STATIC void DvcDelayMicroSecond(ADV_DVC_VAR *, ushort);
3251
3252
3253
3254
3255STATIC int AdvExeScsiQueue(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
3256STATIC int AdvISR(ADV_DVC_VAR *);
3257STATIC int AdvInitGetConfig(ADV_DVC_VAR *);
3258STATIC int AdvInitAsc3550Driver(ADV_DVC_VAR *);
3259STATIC int AdvInitAsc38C0800Driver(ADV_DVC_VAR *);
3260STATIC int AdvInitAsc38C1600Driver(ADV_DVC_VAR *);
3261STATIC int AdvResetChipAndSB(ADV_DVC_VAR *);
3262STATIC int AdvResetSB(ADV_DVC_VAR *asc_dvc);
3263
3264
3265
3266
3267STATIC int AdvSendIdleCmd(ADV_DVC_VAR *, ushort, ADV_DCNT);
3268STATIC void AdvInquiryHandling(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
3269STATIC int AdvInitFrom3550EEP(ADV_DVC_VAR *);
3270STATIC int AdvInitFrom38C0800EEP(ADV_DVC_VAR *);
3271STATIC int AdvInitFrom38C1600EEP(ADV_DVC_VAR *);
3272STATIC ushort AdvGet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
3273STATIC void AdvSet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
3274STATIC ushort AdvGet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
3275STATIC void AdvSet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
3276STATIC ushort AdvGet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
3277STATIC void AdvSet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
3278STATIC void AdvWaitEEPCmd(AdvPortAddr);
3279STATIC ushort AdvReadEEPWord(AdvPortAddr, int);
3280
3281
3282
3283
3284#define AscPCICmdRegBits_BusMastering 0x0007
3285#define AscPCICmdRegBits_ParErrRespCtrl 0x0040
3286
3287
3288#define AdvReadByteRegister(iop_base, reg_off) \
3289 (ADV_MEM_READB((iop_base) + (reg_off)))
3290
3291
3292#define AdvWriteByteRegister(iop_base, reg_off, byte) \
3293 (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
3294
3295
3296#define AdvReadWordRegister(iop_base, reg_off) \
3297 (ADV_MEM_READW((iop_base) + (reg_off)))
3298
3299
3300#define AdvWriteWordRegister(iop_base, reg_off, word) \
3301 (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
3302
3303
3304#define AdvWriteDWordRegister(iop_base, reg_off, dword) \
3305 (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
3306
3307
3308#define AdvReadByteLram(iop_base, addr, byte) \
3309do { \
3310 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
3311 (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
3312} while (0)
3313
3314
3315#define AdvWriteByteLram(iop_base, addr, byte) \
3316 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
3317 ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
3318
3319
3320#define AdvReadWordLram(iop_base, addr, word) \
3321do { \
3322 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
3323 (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
3324} while (0)
3325
3326
3327#define AdvWriteWordLram(iop_base, addr, word) \
3328 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
3329 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
3330
3331
3332
3333#define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
3334 ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
3335 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
3336 cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
3337 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
3338 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
3339 cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
3340
3341
3342#define AdvReadWordAutoIncLram(iop_base) \
3343 (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
3344
3345
3346#define AdvWriteWordAutoIncLram(iop_base, word) \
3347 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
3348
3349
3350
3351
3352
3353
3354
3355
3356#define AdvFindSignature(iop_base) \
3357 (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
3358 ADV_CHIP_ID_BYTE) && \
3359 (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
3360 ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
3361
3362
3363
3364
3365
3366
3367#define AdvGetChipVersion(iop_base, bus_type) \
3368 AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382#define AdvAbortQueue(asc_dvc, scsiq) \
3383 AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
3384 (ADV_DCNT) (scsiq))
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397#define AdvResetDevice(asc_dvc, target_id) \
3398 AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
3399 (ADV_DCNT) (target_id))
3400
3401
3402
3403
3404#define ADV_SCSI_BIT_ID_TYPE ushort
3405
3406
3407
3408
3409#define ADV_SCAN_LUN 0x01
3410#define ADV_CAPINFO_NOLUN 0x02
3411
3412
3413
3414
3415#define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
3416
3417
3418
3419
3420
3421#define QD_NO_STATUS 0x00
3422#define QD_NO_ERROR 0x01
3423#define QD_ABORTED_BY_HOST 0x02
3424#define QD_WITH_ERROR 0x04
3425
3426#define QHSTA_NO_ERROR 0x00
3427#define QHSTA_M_SEL_TIMEOUT 0x11
3428#define QHSTA_M_DATA_OVER_RUN 0x12
3429#define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
3430#define QHSTA_M_QUEUE_ABORTED 0x15
3431#define QHSTA_M_SXFR_SDMA_ERR 0x16
3432#define QHSTA_M_SXFR_SXFR_PERR 0x17
3433#define QHSTA_M_RDMA_PERR 0x18
3434#define QHSTA_M_SXFR_OFF_UFLW 0x19
3435#define QHSTA_M_SXFR_OFF_OFLW 0x20
3436#define QHSTA_M_SXFR_WD_TMO 0x21
3437#define QHSTA_M_SXFR_DESELECTED 0x22
3438
3439#define QHSTA_M_SXFR_XFR_OFLW 0x12
3440#define QHSTA_M_SXFR_XFR_PH_ERR 0x24
3441#define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25
3442#define QHSTA_M_SCSI_BUS_RESET 0x30
3443#define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31
3444#define QHSTA_M_BUS_DEVICE_RESET 0x32
3445#define QHSTA_M_DIRECTION_ERR 0x35
3446#define QHSTA_M_DIRECTION_ERR_HUNG 0x36
3447#define QHSTA_M_WTM_TIMEOUT 0x41
3448#define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
3449#define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
3450#define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
3451#define QHSTA_M_INVALID_DEVICE 0x45
3452#define QHSTA_M_FROZEN_TIDQ 0x46
3453#define QHSTA_M_SGBACKUP_ERROR 0x47
3454
3455
3456
3457
3458
3459extern ADVEEP_3550_CONFIG Default_3550_EEPROM_Config;
3460extern ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config;
3461extern ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config;
3462
3463
3464
3465
3466#define ADV_IS_SCSIQ_FLAG 0x01
3467#define ADV_ASCGETSGLIST_VADDR 0x02
3468#define ADV_IS_SENSE_FLAG 0x04
3469#define ADV_IS_DATA_FLAG 0x08
3470#define ADV_IS_SGLIST_FLAG 0x10
3471#define ADV_IS_CARRIER_FLAG 0x20
3472
3473
3474#define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
3475#define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
3476#define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486#define ADV_SG_LIST_MAX_BYTE_SIZE \
3487 (sizeof(ADV_SG_BLOCK) * \
3488 ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499#define ADV_INQ_DVC_TYPE(inq) ((inq)->periph & 0x1f)
3500#define ADV_INQ_QUALIFIER(inq) (((inq)->periph & 0xe0) >> 5)
3501#define ADV_INQ_DVC_TYPE_MOD(inq) ((inq)->devtype & 0x7f)
3502#define ADV_INQ_REMOVABLE(inq) ((inq)->devtype & 0x80)
3503#define ADV_INQ_ANSI_VER(inq) ((inq)->ver & 0x07)
3504#define ADV_INQ_ECMA_VER(inq) (((inq)->ver & 0x38) >> 3)
3505#define ADV_INQ_ISO_VER(inq) (((inq)->ver & 0xc0) >> 6)
3506#define ADV_INQ_RESPONSE_FMT(inq) ((inq)->byte3 & 0x0f)
3507#define ADV_INQ_TERM_IO(inq) ((inq)->byte3 & 0x40)
3508#define ADV_INQ_ASYNC_NOTIF(inq) ((inq)->byte3 & 0x80)
3509#define ADV_INQ_SOFT_RESET(inq) ((inq)->flags & 0x01)
3510#define ADV_INQ_CMD_QUEUE(inq) ((inq)->flags & 0x02)
3511#define ADV_INQ_LINK_CMD(inq) ((inq)->flags & 0x08)
3512#define ADV_INQ_SYNC(inq) ((inq)->flags & 0x10)
3513#define ADV_INQ_WIDE16(inq) ((inq)->flags & 0x20)
3514#define ADV_INQ_WIDE32(inq) ((inq)->flags & 0x40)
3515#define ADV_INQ_REL_ADDR(inq) ((inq)->flags & 0x80)
3516#define ADV_INQ_INFO_UNIT(inq) ((inq)->info & 0x01)
3517#define ADV_INQ_QUICK_ARB(inq) ((inq)->info & 0x02)
3518#define ADV_INQ_CLOCKING(inq) (((inq)->info & 0x0c) >> 2)
3519
3520typedef struct {
3521 uchar periph;
3522
3523 uchar devtype;
3524
3525 uchar ver;
3526
3527
3528 uchar byte3;
3529
3530
3531
3532
3533
3534
3535
3536 uchar add_len;
3537 uchar res1;
3538 uchar res2;
3539 uchar flags;
3540
3541
3542
3543
3544
3545
3546
3547 uchar vendor_id[8];
3548 uchar product_id[16];
3549 uchar product_rev_level[4];
3550 uchar vendor_specific[20];
3551 uchar info;
3552
3553
3554
3555 uchar res3;
3556} ADV_SCSI_INQUIRY;
3557
3558
3559
3560
3561
3562
3563#define ASC_NUM_BOARD_SUPPORTED 16
3564#define ASC_NUM_IOPORT_PROBE 4
3565#define ASC_NUM_BUS 4
3566
3567
3568#define ASC_BOARDP(host) ((asc_board_t *) &((host)->hostdata))
3569
3570
3571#define ASC_HOST_IN_RESET 0x01
3572#define ASC_IS_WIDE_BOARD 0x04
3573#define ASC_SELECT_QUEUE_DEPTHS 0x08
3574
3575#define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
3576#define ASC_WIDE_BOARD(boardp) ((boardp)->flags & ASC_IS_WIDE_BOARD)
3577
3578#define NO_ISA_DMA 0xff
3579
3580
3581
3582
3583
3584
3585#if ASC_LINUX_KERNEL24
3586#define ASC_INITFUNC(type, func) type __init func
3587#elif ASC_LINUX_KERNEL22
3588#define ASC_INITFUNC(type, func) __initfunc(type func)
3589#endif
3590#define ASC_INITDATA __initdata
3591#define ASC_INIT __init
3592
3593#define ASC_INFO_SIZE 128
3594
3595#ifdef CONFIG_PROC_FS
3596
3597#define ASC_PRTBUF_SIZE 2048
3598#define ASC_PRTLINE_SIZE 160
3599
3600#define ASC_PRT_NEXT() \
3601 if (cp) { \
3602 totlen += len; \
3603 leftlen -= len; \
3604 if (leftlen == 0) { \
3605 return totlen; \
3606 } \
3607 cp += len; \
3608 }
3609
3610#define ASC_MIN(a, b) (((a) < (b)) ? (a) : (b))
3611#endif
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629#define ASC_UNLOCK_IO_REQUEST_LOCK \
3630 { \
3631 ulong flags; \
3632 save_flags(flags); \
3633 spin_unlock_irqrestore(&io_request_lock, flags); \
3634 sti(); \
3635 }
3636
3637#define ASC_LOCK_IO_REQUEST_LOCK \
3638 { \
3639 ulong flags; \
3640 spin_lock_irqsave(&io_request_lock, flags); \
3641 }
3642
3643
3644#define ASC_TRUE 1
3645#define ASC_FALSE 0
3646#define ASC_NOERROR 1
3647#define ASC_BUSY 0
3648#define ASC_ERROR (-1)
3649
3650
3651#define STATUS_BYTE(byte) (byte)
3652#define MSG_BYTE(byte) ((byte) << 8)
3653#define HOST_BYTE(byte) ((byte) << 16)
3654#define DRIVER_BYTE(byte) ((byte) << 24)
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667typedef Scsi_Cmnd REQ, *REQP;
3668#define REQPNEXT(reqp) ((REQP) ((reqp)->host_scribble))
3669#define REQPNEXTP(reqp) ((REQP *) &((reqp)->host_scribble))
3670#define REQPTID(reqp) ((reqp)->target)
3671#define REQPTIME(reqp) ((reqp)->SCp.this_residual)
3672#define REQTIMESTAMP() (jiffies)
3673
3674#define REQTIMESTAT(function, ascq, reqp, tid) \
3675{ \
3676
3677
3678
3679 \
3680 if (REQPTIME(reqp) <= REQTIMESTAMP()) { \
3681 REQPTIME(reqp) = REQTIMESTAMP() - REQPTIME(reqp); \
3682 } else { \
3683 \
3684 ASC_ASSERT(REQPTIME(reqp) <= REQTIMESTAMP()); \
3685 REQPTIME(reqp) = 0; \
3686 } \
3687 \
3688 if (((ascq)->q_tot_cnt[tid] == 1) || \
3689 (REQPTIME(reqp) < (ascq)->q_min_tim[tid])) { \
3690 (ascq)->q_min_tim[tid] = REQPTIME(reqp); \
3691 ASC_DBG3(1, "%s: new q_min_tim[%d] %u\n", \
3692 (function), (tid), (ascq)->q_min_tim[tid]); \
3693 } \
3694 if (REQPTIME(reqp) > (ascq)->q_max_tim[tid]) { \
3695 (ascq)->q_max_tim[tid] = REQPTIME(reqp); \
3696 ASC_DBG3(1, "%s: new q_max_tim[%d] %u\n", \
3697 (function), tid, (ascq)->q_max_tim[tid]); \
3698 } \
3699 (ascq)->q_tot_tim[tid] += REQPTIME(reqp); \
3700 \
3701 REQPTIME(reqp) = 0; \
3702}
3703
3704
3705#define ASC_FRONT 1
3706#define ASC_BACK 2
3707
3708
3709#define ASC_TID_ALL (-1)
3710
3711
3712#define ASC_QUEUE_EMPTY(ascq) ((ascq)->q_tidmask == 0)
3713
3714
3715
3716#define PCI_BASE_CLASS_PREDEFINED 0x00
3717#define PCI_BASE_CLASS_MASS_STORAGE 0x01
3718#define PCI_BASE_CLASS_NETWORK 0x02
3719#define PCI_BASE_CLASS_DISPLAY 0x03
3720#define PCI_BASE_CLASS_MULTIMEDIA 0x04
3721#define PCI_BASE_CLASS_MEMORY_CONTROLLER 0x05
3722#define PCI_BASE_CLASS_BRIDGE_DEVICE 0x06
3723
3724
3725#define PCI_SUB_CLASS_SCSI_CONTROLLER 0x00
3726#define PCI_SUB_CLASS_IDE_CONTROLLER 0x01
3727#define PCI_SUB_CLASS_FLOPPY_DISK_CONTROLLER 0x02
3728#define PCI_SUB_CLASS_IPI_BUS_CONTROLLER 0x03
3729#define PCI_SUB_CLASS_OTHER_MASS_CONTROLLER 0x80
3730
3731
3732#define PCI_SUB_CLASS_ETHERNET_CONTROLLER 0x00
3733#define PCI_SUB_CLASS_TOKEN_RING_CONTROLLER 0x01
3734#define PCI_SUB_CLASS_FDDI_CONTROLLER 0x02
3735#define PCI_SUB_CLASS_OTHER_NETWORK_CONTROLLER 0x80
3736
3737
3738#define PCI_SUB_CLASS_VGA_CONTROLLER 0x00
3739#define PCI_SUB_CLASS_XGA_CONTROLLER 0x01
3740#define PCI_SUB_CLASS_OTHER_DISPLAY_CONTROLLER 0x80
3741
3742
3743#define PCI_SUB_CLASS_VIDEO_DEVICE 0x00
3744#define PCI_SUB_CLASS_AUDIO_DEVICE 0x01
3745#define PCI_SUB_CLASS_OTHER_MULTIMEDIA_DEVICE 0x80
3746
3747
3748#define PCI_SUB_CLASS_RAM_CONTROLLER 0x00
3749#define PCI_SUB_CLASS_FLASH_CONTROLLER 0x01
3750#define PCI_SUB_CLASS_OTHER_MEMORY_CONTROLLER 0x80
3751
3752
3753#define PCI_SUB_CLASS_HOST_BRIDGE_CONTROLLER 0x00
3754#define PCI_SUB_CLASS_ISA_BRIDGE_CONTROLLER 0x01
3755#define PCI_SUB_CLASS_EISA_BRIDGE_CONTROLLER 0x02
3756#define PCI_SUB_CLASS_MC_BRIDGE_CONTROLLER 0x03
3757#define PCI_SUB_CLASS_PCI_TO_PCI_BRIDGE_CONTROLLER 0x04
3758#define PCI_SUB_CLASS_PCMCIA_BRIDGE_CONTROLLER 0x05
3759#define PCI_SUB_CLASS_OTHER_BRIDGE_CONTROLLER 0x80
3760
3761#define PCI_MAX_SLOT 0x1F
3762#define PCI_MAX_BUS 0xFF
3763#define PCI_IOADDRESS_MASK 0xFFFE
3764#define ASC_PCI_VENDORID 0x10CD
3765#define ASC_PCI_DEVICE_ID_CNT 6
3766#define ASC_PCI_DEVICE_ID_1100 0x1100
3767#define ASC_PCI_DEVICE_ID_1200 0x1200
3768#define ASC_PCI_DEVICE_ID_1300 0x1300
3769#define ASC_PCI_DEVICE_ID_2300 0x2300
3770#define ASC_PCI_DEVICE_ID_2500 0x2500
3771#define ASC_PCI_DEVICE_ID_2700 0x2700
3772
3773
3774
3775#define PCI_CONFIG_ADDRESS_MECH1 0x0CF8
3776#define PCI_CONFIG_DATA_MECH1 0x0CFC
3777
3778#define PCI_CONFIG_FORWARD_REGISTER 0x0CFA
3779
3780#define PCI_CONFIG_BUS_NUMBER_MASK 0x00FF0000
3781#define PCI_CONFIG_DEVICE_FUNCTION_MASK 0x0000FF00
3782#define PCI_CONFIG_REGISTER_NUMBER_MASK 0x000000F8
3783
3784#define PCI_DEVICE_FOUND 0x0000
3785#define PCI_DEVICE_NOT_FOUND 0xffff
3786
3787#define SUBCLASS_OFFSET 0x0A
3788#define CLASSCODE_OFFSET 0x0B
3789#define VENDORID_OFFSET 0x00
3790#define DEVICEID_OFFSET 0x02
3791
3792#ifndef ADVANSYS_STATS
3793#define ASC_STATS(shp, counter)
3794#define ASC_STATS_ADD(shp, counter, count)
3795#else
3796#define ASC_STATS(shp, counter) \
3797 (ASC_BOARDP(shp)->asc_stats.counter++)
3798
3799#define ASC_STATS_ADD(shp, counter, count) \
3800 (ASC_BOARDP(shp)->asc_stats.counter += (count))
3801#endif
3802
3803#define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
3804
3805
3806#define ASC_TENTHS(num, den) \
3807 (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
3808 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
3809
3810
3811
3812
3813#define ASC_PRINT(s) \
3814 { \
3815 printk("advansys: "); \
3816 printk(s); \
3817 }
3818
3819#define ASC_PRINT1(s, a1) \
3820 { \
3821 printk("advansys: "); \
3822 printk((s), (a1)); \
3823 }
3824
3825#define ASC_PRINT2(s, a1, a2) \
3826 { \
3827 printk("advansys: "); \
3828 printk((s), (a1), (a2)); \
3829 }
3830
3831#define ASC_PRINT3(s, a1, a2, a3) \
3832 { \
3833 printk("advansys: "); \
3834 printk((s), (a1), (a2), (a3)); \
3835 }
3836
3837#define ASC_PRINT4(s, a1, a2, a3, a4) \
3838 { \
3839 printk("advansys: "); \
3840 printk((s), (a1), (a2), (a3), (a4)); \
3841 }
3842
3843
3844#ifndef ADVANSYS_DEBUG
3845
3846#define ASC_DBG(lvl, s)
3847#define ASC_DBG1(lvl, s, a1)
3848#define ASC_DBG2(lvl, s, a1, a2)
3849#define ASC_DBG3(lvl, s, a1, a2, a3)
3850#define ASC_DBG4(lvl, s, a1, a2, a3, a4)
3851#define ASC_DBG_PRT_SCSI_HOST(lvl, s)
3852#define ASC_DBG_PRT_SCSI_CMND(lvl, s)
3853#define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
3854#define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
3855#define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
3856#define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
3857#define ASC_DBG_PRT_HEX(lvl, name, start, length)
3858#define ASC_DBG_PRT_CDB(lvl, cdb, len)
3859#define ASC_DBG_PRT_SENSE(lvl, sense, len)
3860#define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
3861
3862#else
3863
3864
3865
3866
3867
3868
3869
3870
3871#define ASC_DBG(lvl, s) \
3872 { \
3873 if (asc_dbglvl >= (lvl)) { \
3874 printk(s); \
3875 } \
3876 }
3877
3878#define ASC_DBG1(lvl, s, a1) \
3879 { \
3880 if (asc_dbglvl >= (lvl)) { \
3881 printk((s), (a1)); \
3882 } \
3883 }
3884
3885#define ASC_DBG2(lvl, s, a1, a2) \
3886 { \
3887 if (asc_dbglvl >= (lvl)) { \
3888 printk((s), (a1), (a2)); \
3889 } \
3890 }
3891
3892#define ASC_DBG3(lvl, s, a1, a2, a3) \
3893 { \
3894 if (asc_dbglvl >= (lvl)) { \
3895 printk((s), (a1), (a2), (a3)); \
3896 } \
3897 }
3898
3899#define ASC_DBG4(lvl, s, a1, a2, a3, a4) \
3900 { \
3901 if (asc_dbglvl >= (lvl)) { \
3902 printk((s), (a1), (a2), (a3), (a4)); \
3903 } \
3904 }
3905
3906#define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
3907 { \
3908 if (asc_dbglvl >= (lvl)) { \
3909 asc_prt_scsi_host(s); \
3910 } \
3911 }
3912
3913#define ASC_DBG_PRT_SCSI_CMND(lvl, s) \
3914 { \
3915 if (asc_dbglvl >= (lvl)) { \
3916 asc_prt_scsi_cmnd(s); \
3917 } \
3918 }
3919
3920#define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
3921 { \
3922 if (asc_dbglvl >= (lvl)) { \
3923 asc_prt_asc_scsi_q(scsiqp); \
3924 } \
3925 }
3926
3927#define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
3928 { \
3929 if (asc_dbglvl >= (lvl)) { \
3930 asc_prt_asc_qdone_info(qdone); \
3931 } \
3932 }
3933
3934#define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
3935 { \
3936 if (asc_dbglvl >= (lvl)) { \
3937 asc_prt_adv_scsi_req_q(scsiqp); \
3938 } \
3939 }
3940
3941#define ASC_DBG_PRT_HEX(lvl, name, start, length) \
3942 { \
3943 if (asc_dbglvl >= (lvl)) { \
3944 asc_prt_hex((name), (start), (length)); \
3945 } \
3946 }
3947
3948#define ASC_DBG_PRT_CDB(lvl, cdb, len) \
3949 ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
3950
3951#define ASC_DBG_PRT_SENSE(lvl, sense, len) \
3952 ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
3953
3954#define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
3955 ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
3956#endif
3957
3958#ifndef ADVANSYS_ASSERT
3959#define ASC_ASSERT(a)
3960#else
3961
3962#define ASC_ASSERT(a) \
3963 { \
3964 if (!(a)) { \
3965 printk("ASC_ASSERT() Failure: file %s, line %d\n", \
3966 __FILE__, __LINE__); \
3967 } \
3968 }
3969
3970#endif
3971
3972
3973
3974
3975
3976
3977#ifdef ADVANSYS_STATS
3978
3979
3980struct asc_stats {
3981
3982 ADV_DCNT queuecommand;
3983 ADV_DCNT reset;
3984 ADV_DCNT biosparam;
3985 ADV_DCNT interrupt;
3986 ADV_DCNT callback;
3987 ADV_DCNT done;
3988 ADV_DCNT build_error;
3989 ADV_DCNT adv_build_noreq;
3990 ADV_DCNT adv_build_nosg;
3991
3992 ADV_DCNT exe_noerror;
3993 ADV_DCNT exe_busy;
3994 ADV_DCNT exe_error;
3995 ADV_DCNT exe_unknown;
3996
3997 ADV_DCNT cont_cnt;
3998 ADV_DCNT cont_xfer;
3999 ADV_DCNT sg_cnt;
4000 ADV_DCNT sg_elem;
4001 ADV_DCNT sg_xfer;
4002};
4003#endif
4004
4005
4006
4007
4008typedef struct asc_queue {
4009 ADV_SCSI_BIT_ID_TYPE q_tidmask;
4010 REQP q_first[ADV_MAX_TID+1];
4011 REQP q_last[ADV_MAX_TID+1];
4012#ifdef ADVANSYS_STATS
4013 short q_cur_cnt[ADV_MAX_TID+1];
4014 short q_max_cnt[ADV_MAX_TID+1];
4015 ADV_DCNT q_tot_cnt[ADV_MAX_TID+1];
4016 ADV_DCNT q_tot_tim[ADV_MAX_TID+1];
4017 ushort q_max_tim[ADV_MAX_TID+1];
4018 ushort q_min_tim[ADV_MAX_TID+1];
4019#endif
4020} asc_queue_t;
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039typedef struct adv_sgblk {
4040 ADV_SG_BLOCK sg_block;
4041 uchar align[32];
4042 struct adv_sgblk *next_sgblkp;
4043} adv_sgblk_t;
4044
4045typedef struct adv_req {
4046 ADV_SCSI_REQ_Q scsi_req_q;
4047 uchar align[32];
4048 Scsi_Cmnd *cmndp;
4049 adv_sgblk_t *sgblkp;
4050 struct adv_req *next_reqp;
4051} adv_req_t;
4052
4053
4054
4055
4056
4057
4058
4059
4060typedef struct asc_board {
4061 int id;
4062 uint flags;
4063 union {
4064 ASC_DVC_VAR asc_dvc_var;
4065 ADV_DVC_VAR adv_dvc_var;
4066 } dvc_var;
4067 union {
4068 ASC_DVC_CFG asc_dvc_cfg;
4069 ADV_DVC_CFG adv_dvc_cfg;
4070 } dvc_cfg;
4071 ushort asc_n_io_port;
4072 asc_queue_t active;
4073 asc_queue_t waiting;
4074 asc_queue_t done;
4075 ADV_SCSI_BIT_ID_TYPE init_tidmask;
4076 Scsi_Device *device[ADV_MAX_TID+1];
4077 ushort reqcnt[ADV_MAX_TID+1];
4078 ADV_SCSI_BIT_ID_TYPE queue_full;
4079 ushort queue_full_cnt[ADV_MAX_TID+1];
4080 union {
4081 ASCEEP_CONFIG asc_eep;
4082 ADVEEP_3550_CONFIG adv_3550_eep;
4083 ADVEEP_38C0800_CONFIG adv_38C0800_eep;
4084 ADVEEP_38C1600_CONFIG adv_38C1600_eep;
4085 } eep_config;
4086 ulong last_reset;
4087 spinlock_t lock;
4088#ifdef CONFIG_PROC_FS
4089
4090 char *prtbuf;
4091#endif
4092#ifdef ADVANSYS_STATS
4093 struct asc_stats asc_stats;
4094#endif
4095
4096
4097
4098
4099 ASC_SCSI_REQ_Q scsireqq;
4100 ASC_CAP_INFO cap_info;
4101 ASC_SCSI_INQUIRY inquiry;
4102 uchar sdtr_data[ASC_MAX_TID+1];
4103
4104
4105
4106 void *ioremap_addr;
4107 ushort ioport;
4108 ADV_CARR_T *orig_carrp;
4109 adv_req_t *orig_reqp;
4110 adv_req_t *adv_reqp;
4111 adv_sgblk_t *adv_sgblkp;
4112 ushort bios_signature;
4113 ushort bios_version;
4114 ushort bios_codeseg;
4115 ushort bios_codelen;
4116} asc_board_t;
4117
4118
4119
4120
4121typedef struct _PCI_DATA_
4122{
4123 uchar type;
4124 uchar bus;
4125 uchar slot;
4126 uchar func;
4127 uchar offset;
4128} PCI_DATA;
4129
4130typedef struct _PCI_DEVICE_
4131{
4132 ushort vendorID;
4133 ushort deviceID;
4134 ushort slotNumber;
4135 ushort slotFound;
4136 uchar busNumber;
4137 uchar maxBusNumber;
4138 uchar devFunc;
4139 ushort startSlot;
4140 ushort endSlot;
4141 uchar bridge;
4142 uchar type;
4143} PCI_DEVICE;
4144
4145typedef struct _PCI_CONFIG_SPACE_
4146{
4147 ushort vendorID;
4148 ushort deviceID;
4149 ushort command;
4150 ushort status;
4151 uchar revision;
4152 uchar classCode[3];
4153 uchar cacheSize;
4154 uchar latencyTimer;
4155 uchar headerType;
4156 uchar bist;
4157 ADV_PADDR baseAddress[6];
4158 ushort reserved[4];
4159 ADV_PADDR optionRomAddr;
4160 ushort reserved2[4];
4161 uchar irqLine;
4162 uchar irqPin;
4163 uchar minGnt;
4164 uchar maxLatency;
4165} PCI_CONFIG_SPACE;
4166
4167
4168
4169
4170
4171
4172
4173
4174#if ASC_LINUX_KERNEL22
4175#ifdef CONFIG_PROC_FS
4176struct proc_dir_entry proc_scsi_advansys =
4177{
4178 PROC_SCSI_ADVANSYS,
4179 8,
4180 "advansys",
4181 S_IFDIR | S_IRUGO | S_IXUGO,
4182 2
4183};
4184#endif
4185#endif
4186
4187
4188STATIC int asc_board_count = 0;
4189STATIC struct Scsi_Host *asc_host[ASC_NUM_BOARD_SUPPORTED] = { 0 };
4190
4191
4192STATIC uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
4193
4194
4195
4196
4197STATIC ASC_SCSI_Q asc_scsi_q = { { 0 } };
4198STATIC ASC_SG_HEAD asc_sg_head = { 0 };
4199
4200
4201STATIC ushort asc_bus[ASC_NUM_BUS] ASC_INITDATA = {
4202 ASC_IS_ISA,
4203 ASC_IS_VL,
4204 ASC_IS_EISA,
4205 ASC_IS_PCI,
4206};
4207
4208
4209
4210
4211
4212STATIC int asc_iopflag = ASC_FALSE;
4213STATIC int asc_ioport[ASC_NUM_IOPORT_PROBE] = { 0, 0, 0, 0 };
4214
4215#ifdef ADVANSYS_DEBUG
4216STATIC char *
4217asc_bus_name[ASC_NUM_BUS] = {
4218 "ASC_IS_ISA",
4219 "ASC_IS_VL",
4220 "ASC_IS_EISA",
4221 "ASC_IS_PCI",
4222};
4223
4224STATIC int asc_dbglvl = 3;
4225#endif
4226
4227
4228STATIC PortAddr _asc_def_iop_base[];
4229
4230
4231
4232
4233
4234
4235
4236
4237STATIC void advansys_interrupt(int, void *, struct pt_regs *);
4238STATIC void advansys_select_queue_depths(struct Scsi_Host *,
4239 Scsi_Device *);
4240STATIC void asc_scsi_done_list(Scsi_Cmnd *);
4241STATIC int asc_execute_scsi_cmnd(Scsi_Cmnd *);
4242STATIC int asc_build_req(asc_board_t *, Scsi_Cmnd *);
4243STATIC int adv_build_req(asc_board_t *, Scsi_Cmnd *, ADV_SCSI_REQ_Q **);
4244STATIC int adv_get_sglist(asc_board_t *, adv_req_t *, Scsi_Cmnd *);
4245STATIC void asc_isr_callback(ASC_DVC_VAR *, ASC_QDONE_INFO *);
4246STATIC void adv_isr_callback(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
4247STATIC void adv_async_callback(ADV_DVC_VAR *, uchar);
4248STATIC void asc_enqueue(asc_queue_t *, REQP, int);
4249STATIC REQP asc_dequeue(asc_queue_t *, int);
4250STATIC REQP asc_dequeue_list(asc_queue_t *, REQP *, int);
4251STATIC int asc_rmqueue(asc_queue_t *, REQP);
4252STATIC void asc_execute_queue(asc_queue_t *);
4253#ifdef CONFIG_PROC_FS
4254STATIC int asc_proc_copy(off_t, off_t, char *, int , char *, int);
4255STATIC int asc_prt_board_devices(struct Scsi_Host *, char *, int);
4256STATIC int asc_prt_adv_bios(struct Scsi_Host *, char *, int);
4257STATIC int asc_get_eeprom_string(ushort *serialnum, uchar *cp);
4258STATIC int asc_prt_asc_board_eeprom(struct Scsi_Host *, char *, int);
4259STATIC int asc_prt_adv_board_eeprom(struct Scsi_Host *, char *, int);
4260STATIC int asc_prt_driver_conf(struct Scsi_Host *, char *, int);
4261STATIC int asc_prt_asc_board_info(struct Scsi_Host *, char *, int);
4262STATIC int asc_prt_adv_board_info(struct Scsi_Host *, char *, int);
4263STATIC int asc_prt_line(char *, int, char *fmt, ...);
4264#endif
4265
4266
4267STATIC int AscFindSignature(PortAddr);
4268STATIC ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
4269
4270
4271#ifdef ADVANSYS_STATS
4272#ifdef CONFIG_PROC_FS
4273STATIC int asc_prt_board_stats(struct Scsi_Host *, char *, int);
4274STATIC int asc_prt_target_stats(struct Scsi_Host *, int, char *, int);
4275#endif
4276#endif
4277
4278
4279#ifdef ADVANSYS_DEBUG
4280STATIC void asc_prt_scsi_host(struct Scsi_Host *);
4281STATIC void asc_prt_scsi_cmnd(Scsi_Cmnd *);
4282STATIC void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *);
4283STATIC void asc_prt_asc_dvc_var(ASC_DVC_VAR *);
4284STATIC void asc_prt_asc_scsi_q(ASC_SCSI_Q *);
4285STATIC void asc_prt_asc_qdone_info(ASC_QDONE_INFO *);
4286STATIC void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *);
4287STATIC void asc_prt_adv_dvc_var(ADV_DVC_VAR *);
4288STATIC void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *);
4289STATIC void asc_prt_adv_sgblock(int, ADV_SG_BLOCK *);
4290STATIC void asc_prt_hex(char *f, uchar *, int);
4291#endif
4292
4293
4294
4295
4296
4297
4298#ifdef CONFIG_PROC_FS
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319int
4320advansys_proc_info(char *buffer, char **start, off_t offset, int length,
4321 int hostno, int inout)
4322{
4323 struct Scsi_Host *shp;
4324 asc_board_t *boardp;
4325 int i;
4326 char *cp;
4327 int cplen;
4328 int cnt;
4329 int totcnt;
4330 int leftlen;
4331 char *curbuf;
4332 off_t advoffset;
4333 Scsi_Device *scd;
4334#ifdef ADVANSYS_STATS
4335 int tgt_id;
4336#endif
4337
4338 ASC_DBG(1, "advansys_proc_info: begin\n");
4339
4340
4341
4342
4343 if (inout == TRUE) {
4344 return(-ENOSYS);
4345 }
4346
4347
4348
4349
4350
4351
4352 for (i = 0; i < asc_board_count; i++) {
4353 if (asc_host[i]->host_no == hostno) {
4354 break;
4355 }
4356 }
4357 if (i == asc_board_count) {
4358 return(-ENOENT);
4359 }
4360
4361 shp = asc_host[i];
4362 boardp = ASC_BOARDP(shp);
4363
4364
4365 *start = buffer;
4366 curbuf = buffer;
4367 advoffset = 0;
4368 totcnt = 0;
4369 leftlen = length;
4370
4371
4372
4373
4374
4375
4376 cp = (char *) advansys_info(shp);
4377 strcat(cp, "\n");
4378 cplen = strlen(cp);
4379
4380 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4381 totcnt += cnt;
4382 leftlen -= cnt;
4383 if (leftlen == 0) {
4384 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4385 return totcnt;
4386 }
4387 advoffset += cplen;
4388 curbuf += cnt;
4389
4390
4391
4392
4393 if (ASC_WIDE_BOARD(boardp)) {
4394 cp = boardp->prtbuf;
4395 cplen = asc_prt_adv_bios(shp, cp, ASC_PRTBUF_SIZE);
4396 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
4397 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4398 totcnt += cnt;
4399 leftlen -= cnt;
4400 if (leftlen == 0) {
4401 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4402 return totcnt;
4403 }
4404 advoffset += cplen;
4405 curbuf += cnt;
4406 }
4407
4408
4409
4410
4411 cp = boardp->prtbuf;
4412 cplen = asc_prt_board_devices(shp, cp, ASC_PRTBUF_SIZE);
4413 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
4414 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4415 totcnt += cnt;
4416 leftlen -= cnt;
4417 if (leftlen == 0) {
4418 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4419 return totcnt;
4420 }
4421 advoffset += cplen;
4422 curbuf += cnt;
4423
4424
4425
4426
4427
4428 for (scd = shp->host_queue; scd; scd = scd->next)
4429 {
4430 if (scd->host == shp) {
4431 cp = boardp->prtbuf;
4432
4433
4434
4435
4436 proc_print_scsidevice(scd, cp, &cplen, 0);
4437 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
4438 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4439 totcnt += cnt;
4440 leftlen -= cnt;
4441 if (leftlen == 0) {
4442 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4443 return totcnt;
4444 }
4445 advoffset += cplen;
4446 curbuf += cnt;
4447 }
4448 }
4449
4450
4451
4452
4453 cp = boardp->prtbuf;
4454 if (ASC_NARROW_BOARD(boardp)) {
4455 cplen = asc_prt_asc_board_eeprom(shp, cp, ASC_PRTBUF_SIZE);
4456 } else {
4457 cplen = asc_prt_adv_board_eeprom(shp, cp, ASC_PRTBUF_SIZE);
4458 }
4459 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
4460 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4461 totcnt += cnt;
4462 leftlen -= cnt;
4463 if (leftlen == 0) {
4464 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4465 return totcnt;
4466 }
4467 advoffset += cplen;
4468 curbuf += cnt;
4469
4470
4471
4472
4473 cp = boardp->prtbuf;
4474 cplen = asc_prt_driver_conf(shp, cp, ASC_PRTBUF_SIZE);
4475 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
4476 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4477 totcnt += cnt;
4478 leftlen -= cnt;
4479 if (leftlen == 0) {
4480 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4481 return totcnt;
4482 }
4483 advoffset += cplen;
4484 curbuf += cnt;
4485
4486#ifdef ADVANSYS_STATS
4487
4488
4489
4490 cp = boardp->prtbuf;
4491 cplen = asc_prt_board_stats(shp, cp, ASC_PRTBUF_SIZE);
4492 ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE);
4493 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4494 totcnt += cnt;
4495 leftlen -= cnt;
4496 if (leftlen == 0) {
4497 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4498 return totcnt;
4499 }
4500 advoffset += cplen;
4501 curbuf += cnt;
4502
4503
4504
4505
4506 for (tgt_id = 0; tgt_id <= ADV_MAX_TID; tgt_id++) {
4507 cp = boardp->prtbuf;
4508 cplen = asc_prt_target_stats(shp, tgt_id, cp, ASC_PRTBUF_SIZE);
4509 ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE);
4510 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4511 totcnt += cnt;
4512 leftlen -= cnt;
4513 if (leftlen == 0) {
4514 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4515 return totcnt;
4516 }
4517 advoffset += cplen;
4518 curbuf += cnt;
4519 }
4520#endif
4521
4522
4523
4524
4525
4526 cp = boardp->prtbuf;
4527 if (ASC_NARROW_BOARD(boardp)) {
4528 cplen = asc_prt_asc_board_info(shp, cp, ASC_PRTBUF_SIZE);
4529 } else {
4530 cplen = asc_prt_adv_board_info(shp, cp, ASC_PRTBUF_SIZE);
4531 }
4532 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
4533 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4534 totcnt += cnt;
4535 leftlen -= cnt;
4536 if (leftlen == 0) {
4537 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4538 return totcnt;
4539 }
4540 advoffset += cplen;
4541 curbuf += cnt;
4542
4543 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4544
4545 return totcnt;
4546}
4547#endif
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562ASC_INITFUNC(
4563int,
4564advansys_detect(Scsi_Host_Template *tpnt)
4565)
4566{
4567 static int detect_called = ASC_FALSE;
4568 int iop;
4569 int bus;
4570 struct Scsi_Host *shp = NULL;
4571 asc_board_t *boardp = NULL;
4572 ASC_DVC_VAR *asc_dvc_varp = NULL;
4573 ADV_DVC_VAR *adv_dvc_varp = NULL;
4574 adv_sgblk_t *sgp = NULL;
4575 int ioport = 0;
4576 int share_irq = FALSE;
4577 int iolen = 0;
4578#ifdef CONFIG_PCI
4579 int pci_init_search = 0;
4580 struct pci_dev *pci_devicep[ASC_NUM_BOARD_SUPPORTED];
4581 int pci_card_cnt_max = 0;
4582 int pci_card_cnt = 0;
4583 struct pci_dev *pci_devp = NULL;
4584 int pci_device_id_cnt = 0;
4585 unsigned int pci_device_id[ASC_PCI_DEVICE_ID_CNT] = {
4586 ASC_PCI_DEVICE_ID_1100,
4587 ASC_PCI_DEVICE_ID_1200,
4588 ASC_PCI_DEVICE_ID_1300,
4589 ASC_PCI_DEVICE_ID_2300,
4590 ASC_PCI_DEVICE_ID_2500,
4591 ASC_PCI_DEVICE_ID_2700
4592 };
4593 ADV_PADDR pci_memory_address;
4594#endif
4595 int warn_code, err_code;
4596 int ret;
4597
4598 if (detect_called == ASC_FALSE) {
4599 detect_called = ASC_TRUE;
4600 } else {
4601 printk("AdvanSys SCSI: advansys_detect() multiple calls ignored\n");
4602 return 0;
4603 }
4604
4605 ASC_DBG(1, "advansys_detect: begin\n");
4606
4607
4608
4609
4610
4611
4612 ASC_UNLOCK_IO_REQUEST_LOCK
4613
4614#if ASC_LINUX_KERNEL24
4615 tpnt->proc_name = "advansys";
4616#elif ASC_LINUX_KERNEL22
4617 tpnt->proc_dir = &proc_scsi_advansys;
4618#endif
4619
4620 asc_board_count = 0;
4621
4622
4623
4624
4625
4626 if (asc_iopflag == ASC_TRUE) {
4627 for (ioport = 0; ioport < ASC_NUM_IOPORT_PROBE; ioport++) {
4628 ASC_DBG2(1, "advansys_detect: asc_ioport[%d] 0x%x\n",
4629 ioport, asc_ioport[ioport]);
4630 if (asc_ioport[ioport] != 0) {
4631 for (iop = 0; iop < ASC_IOADR_TABLE_MAX_IX; iop++) {
4632 if (_asc_def_iop_base[iop] == asc_ioport[ioport]) {
4633 break;
4634 }
4635 }
4636 if (iop == ASC_IOADR_TABLE_MAX_IX) {
4637 printk(
4638"AdvanSys SCSI: specified I/O Port 0x%X is invalid\n",
4639 asc_ioport[ioport]);
4640 asc_ioport[ioport] = 0;
4641 }
4642 }
4643 }
4644 ioport = 0;
4645 }
4646
4647 for (bus = 0; bus < ASC_NUM_BUS; bus++) {
4648
4649 ASC_DBG2(1, "advansys_detect: bus search type %d (%s)\n",
4650 bus, asc_bus_name[bus]);
4651 iop = 0;
4652
4653 while (asc_board_count < ASC_NUM_BOARD_SUPPORTED) {
4654
4655 ASC_DBG1(2, "advansys_detect: asc_board_count %d\n",
4656 asc_board_count);
4657
4658 switch (asc_bus[bus]) {
4659 case ASC_IS_ISA:
4660 case ASC_IS_VL:
4661#ifdef CONFIG_ISA
4662 if (asc_iopflag == ASC_FALSE) {
4663 iop = AscSearchIOPortAddr(iop, asc_bus[bus]);
4664 } else {
4665
4666
4667
4668
4669
4670
4671 ASC_DBG(1, "advansys_detect: I/O port scanning modified\n");
4672 ioport_try_again:
4673 iop = 0;
4674 for (; ioport < ASC_NUM_IOPORT_PROBE; ioport++) {
4675 if ((iop = asc_ioport[ioport]) != 0) {
4676 break;
4677 }
4678 }
4679 if (iop) {
4680 ASC_DBG1(1,
4681 "advansys_detect: probing I/O port 0x%x...\n",
4682 iop);
4683 if (check_region(iop, ASC_IOADR_GAP) != 0) {
4684 printk(
4685"AdvanSys SCSI: specified I/O Port 0x%X is busy\n", iop);
4686
4687 asc_ioport[ioport] = 0;
4688 goto ioport_try_again;
4689 } else if (AscFindSignature(iop) == ASC_FALSE) {
4690 printk(
4691"AdvanSys SCSI: specified I/O Port 0x%X has no adapter\n", iop);
4692
4693 asc_ioport[ioport] = 0;
4694 goto ioport_try_again;
4695 } else {
4696
4697
4698
4699
4700
4701
4702 if (asc_bus[bus] == ASC_IS_ISA &&
4703 (AscGetChipVersion(iop, ASC_IS_ISA) &
4704 ASC_CHIP_VER_ISA_BIT) == 0) {
4705
4706
4707
4708
4709
4710 ioport++;
4711 goto ioport_try_again;
4712 }
4713 }
4714
4715
4716
4717
4718
4719 asc_ioport[ioport++] = 0;
4720 }
4721 }
4722#endif
4723 break;
4724
4725 case ASC_IS_EISA:
4726#ifdef CONFIG_ISA
4727 iop = AscSearchIOPortAddr(iop, asc_bus[bus]);
4728#endif
4729 break;
4730
4731 case ASC_IS_PCI:
4732#ifdef CONFIG_PCI
4733 if (pci_init_search == 0) {
4734 int i, j;
4735
4736 pci_init_search = 1;
4737
4738
4739 while (pci_device_id_cnt < ASC_PCI_DEVICE_ID_CNT) {
4740 if ((pci_devp = pci_find_device(ASC_PCI_VENDORID,
4741 pci_device_id[pci_device_id_cnt], pci_devp)) ==
4742 NULL) {
4743 pci_device_id_cnt++;
4744 } else {
4745#if ASC_LINUX_KERNEL24
4746 if (pci_enable_device(pci_devp) == 0) {
4747 pci_devicep[pci_card_cnt_max++] = pci_devp;
4748 }
4749#elif ASC_LINUX_KERNEL22
4750 pci_devicep[pci_card_cnt_max++] = pci_devp;
4751#endif
4752 }
4753 }
4754
4755
4756
4757
4758
4759 for (i = 0; i < pci_card_cnt_max - 1; i++)
4760 {
4761 for (j = i + 1; j < pci_card_cnt_max; j++) {
4762 if ((pci_devicep[j]->bus->number <
4763 pci_devicep[i]->bus->number) ||
4764 ((pci_devicep[j]->bus->number ==
4765 pci_devicep[i]->bus->number) &&
4766 (pci_devicep[j]->devfn <
4767 pci_devicep[i]->devfn))) {
4768 pci_devp = pci_devicep[i];
4769 pci_devicep[i] = pci_devicep[j];
4770 pci_devicep[j] = pci_devp;
4771 }
4772 }
4773 }
4774
4775 pci_card_cnt = 0;
4776 } else {
4777 pci_card_cnt++;
4778 }
4779
4780 if (pci_card_cnt == pci_card_cnt_max) {
4781 iop = 0;
4782 } else {
4783 pci_devp = pci_devicep[pci_card_cnt];
4784
4785 ASC_DBG2(2,
4786 "advansys_detect: devfn %d, bus number %d\n",
4787 pci_devp->devfn, pci_devp->bus->number);
4788#if ASC_LINUX_KERNEL24
4789 iop = pci_resource_start(pci_devp, 0);
4790#elif ASC_LINUX_KERNEL22
4791 iop = pci_devp->base_address[0] & PCI_IOADDRESS_MASK;
4792#endif
4793 ASC_DBG2(1,
4794 "advansys_detect: vendorID %X, deviceID %X\n",
4795 pci_devp->vendor, pci_devp->device);
4796 ASC_DBG2(2, "advansys_detect: iop %X, irqLine %d\n",
4797 iop, pci_devp->irq);
4798 }
4799#endif
4800 break;
4801
4802 default:
4803 ASC_PRINT1("advansys_detect: unknown bus type: %d\n",
4804 asc_bus[bus]);
4805 break;
4806 }
4807 ASC_DBG1(1, "advansys_detect: iop 0x%x\n", iop);
4808
4809
4810
4811
4812 if (iop == 0) {
4813 break;
4814 }
4815
4816
4817
4818
4819
4820
4821
4822 ASC_DBG(2, "advansys_detect: scsi_register()\n");
4823 shp = scsi_register(tpnt, sizeof(asc_board_t));
4824
4825 if (shp == NULL) {
4826 continue;
4827 }
4828#ifdef CONFIG_PCI
4829 scsi_set_pci_device(shp, pci_devp);
4830#endif
4831
4832
4833 asc_host[asc_board_count++] = shp;
4834
4835
4836 boardp = ASC_BOARDP(shp);
4837 memset(boardp, 0, sizeof(asc_board_t));
4838 boardp->id = asc_board_count - 1;
4839
4840
4841 boardp->lock = SPIN_LOCK_UNLOCKED;
4842
4843
4844
4845
4846
4847
4848
4849
4850#ifdef CONFIG_PCI
4851 if (asc_bus[bus] == ASC_IS_PCI &&
4852 (pci_devp->device == ASC_PCI_DEVICE_ID_2300 ||
4853 pci_devp->device == ASC_PCI_DEVICE_ID_2500 ||
4854 pci_devp->device == ASC_PCI_DEVICE_ID_2700))
4855 {
4856 boardp->flags |= ASC_IS_WIDE_BOARD;
4857 }
4858#endif
4859
4860 if (ASC_NARROW_BOARD(boardp)) {
4861 ASC_DBG(1, "advansys_detect: narrow board\n");
4862 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
4863 asc_dvc_varp->bus_type = asc_bus[bus];
4864 asc_dvc_varp->drv_ptr = boardp;
4865 asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
4866 asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
4867 asc_dvc_varp->iop_base = iop;
4868 asc_dvc_varp->isr_callback = asc_isr_callback;
4869 } else {
4870 ASC_DBG(1, "advansys_detect: wide board\n");
4871 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
4872 adv_dvc_varp->drv_ptr = boardp;
4873 adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
4874 adv_dvc_varp->isr_callback = adv_isr_callback;
4875 adv_dvc_varp->async_callback = adv_async_callback;
4876#ifdef CONFIG_PCI
4877 if (pci_devp->device == ASC_PCI_DEVICE_ID_2300)
4878 {
4879 ASC_DBG(1, "advansys_detect: ASC-3550\n");
4880 adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
4881 } else if (pci_devp->device == ASC_PCI_DEVICE_ID_2500)
4882 {
4883 ASC_DBG(1, "advansys_detect: ASC-38C0800\n");
4884 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
4885 } else
4886 {
4887 ASC_DBG(1, "advansys_detect: ASC-38C1600\n");
4888 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
4889 }
4890#endif
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
4904 {
4905 iolen = ADV_3550_IOLEN;
4906 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
4907 {
4908 iolen = ADV_38C0800_IOLEN;
4909 } else
4910 {
4911 iolen = ADV_38C1600_IOLEN;
4912 }
4913#ifdef CONFIG_PCI
4914#if ASC_LINUX_KERNEL24
4915 pci_memory_address = pci_resource_start(pci_devp, 1);
4916#elif ASC_LINUX_KERNEL22
4917 pci_memory_address = pci_devp->base_address[1];
4918#endif
4919 ASC_DBG1(1, "advansys_detect: pci_memory_address: 0x%lx\n",
4920 (ulong) pci_memory_address);
4921 if ((boardp->ioremap_addr =
4922 ioremap(pci_memory_address & PAGE_MASK,
4923 PAGE_SIZE)) == 0) {
4924 ASC_PRINT3(
4925"advansys_detect: board %d: ioremap(%x, %d) returned NULL\n",
4926 boardp->id, pci_memory_address, iolen);
4927 scsi_unregister(shp);
4928 asc_board_count--;
4929 continue;
4930 }
4931 ASC_DBG1(1, "advansys_detect: ioremap_addr: 0x%lx\n",
4932 (ulong) boardp->ioremap_addr);
4933 adv_dvc_varp->iop_base = (AdvPortAddr)
4934 (boardp->ioremap_addr +
4935 (pci_memory_address - (pci_memory_address & PAGE_MASK)));
4936 ASC_DBG1(1, "advansys_detect: iop_base: 0x%lx\n",
4937 adv_dvc_varp->iop_base);
4938#endif
4939
4940
4941
4942
4943
4944
4945 boardp->ioport = iop;
4946
4947 ASC_DBG2(1,
4948"advansys_detect: iopb_chip_id_1 0x%x, iopw_chip_id_0 0x%x\n",
4949 (ushort) inp(iop + 1), (ushort) inpw(iop));
4950 }
4951
4952#ifdef CONFIG_PROC_FS
4953
4954
4955
4956
4957 if ((boardp->prtbuf =
4958 kmalloc(ASC_PRTBUF_SIZE, GFP_ATOMIC)) == NULL) {
4959 ASC_PRINT3(
4960"advansys_detect: board %d: kmalloc(%d, %d) returned NULL\n",
4961 boardp->id, ASC_PRTBUF_SIZE, GFP_ATOMIC);
4962 scsi_unregister(shp);
4963 asc_board_count--;
4964 continue;
4965 }
4966#endif
4967
4968 if (ASC_NARROW_BOARD(boardp)) {
4969
4970
4971
4972
4973 switch (asc_dvc_varp->bus_type) {
4974#ifdef CONFIG_ISA
4975 case ASC_IS_ISA:
4976 shp->unchecked_isa_dma = TRUE;
4977 share_irq = FALSE;
4978 break;
4979 case ASC_IS_VL:
4980 shp->unchecked_isa_dma = FALSE;
4981 share_irq = FALSE;
4982 break;
4983 case ASC_IS_EISA:
4984 shp->unchecked_isa_dma = FALSE;
4985 share_irq = TRUE;
4986 break;
4987#endif
4988#ifdef CONFIG_PCI
4989 case ASC_IS_PCI:
4990 shp->irq = asc_dvc_varp->irq_no = pci_devp->irq;
4991 asc_dvc_varp->cfg->pci_device_id = pci_devp->device;
4992 asc_dvc_varp->cfg->pci_slot_info =
4993 ASC_PCI_MKID(pci_devp->bus->number,
4994 PCI_SLOT(pci_devp->devfn),
4995 PCI_FUNC(pci_devp->devfn));
4996 shp->unchecked_isa_dma = FALSE;
4997 share_irq = TRUE;
4998 break;
4999#endif
5000 default:
5001 ASC_PRINT2(
5002"advansys_detect: board %d: unknown adapter type: %d\n",
5003 boardp->id, asc_dvc_varp->bus_type);
5004 shp->unchecked_isa_dma = TRUE;
5005 share_irq = FALSE;
5006 break;
5007 }
5008 } else {
5009
5010
5011
5012
5013#ifdef CONFIG_PCI
5014 shp->irq = adv_dvc_varp->irq_no = pci_devp->irq;
5015 adv_dvc_varp->cfg->pci_device_id = pci_devp->device;
5016 adv_dvc_varp->cfg->pci_slot_info =
5017 ASC_PCI_MKID(pci_devp->bus->number,
5018 PCI_SLOT(pci_devp->devfn),
5019 PCI_FUNC(pci_devp->devfn));
5020 shp->unchecked_isa_dma = FALSE;
5021 share_irq = TRUE;
5022#endif
5023 }
5024
5025
5026
5027
5028 if (ASC_NARROW_BOARD(boardp)) {
5029
5030
5031
5032
5033
5034
5035 ASC_DBG(2, "advansys_detect: AscInitGetConfig()\n");
5036 switch(ret = AscInitGetConfig(asc_dvc_varp)) {
5037 case 0:
5038 break;
5039 case ASC_WARN_IO_PORT_ROTATE:
5040 ASC_PRINT1(
5041"AscInitGetConfig: board %d: I/O port address modified\n",
5042 boardp->id);
5043 break;
5044 case ASC_WARN_AUTO_CONFIG:
5045 ASC_PRINT1(
5046"AscInitGetConfig: board %d: I/O port increment switch enabled\n",
5047 boardp->id);
5048 break;
5049 case ASC_WARN_EEPROM_CHKSUM:
5050 ASC_PRINT1(
5051"AscInitGetConfig: board %d: EEPROM checksum error\n",
5052 boardp->id);
5053 break;
5054 case ASC_WARN_IRQ_MODIFIED:
5055 ASC_PRINT1(
5056"AscInitGetConfig: board %d: IRQ modified\n",
5057 boardp->id);
5058 break;
5059 case ASC_WARN_CMD_QNG_CONFLICT:
5060 ASC_PRINT1(
5061"AscInitGetConfig: board %d: tag queuing enabled w/o disconnects\n",
5062 boardp->id);
5063 break;
5064 default:
5065 ASC_PRINT2(
5066"AscInitGetConfig: board %d: unknown warning: 0x%x\n",
5067 boardp->id, ret);
5068 break;
5069 }
5070 if ((err_code = asc_dvc_varp->err_code) != 0) {
5071 ASC_PRINT3(
5072"AscInitGetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
5073 boardp->id, asc_dvc_varp->init_state,
5074 asc_dvc_varp->err_code);
5075 }
5076 } else {
5077 ASC_DBG(2, "advansys_detect: AdvInitGetConfig()\n");
5078 if ((ret = AdvInitGetConfig(adv_dvc_varp)) != 0) {
5079 ASC_PRINT2("AdvInitGetConfig: board %d: warning: 0x%x\n",
5080 boardp->id, ret);
5081 }
5082 if ((err_code = adv_dvc_varp->err_code) != 0) {
5083 ASC_PRINT2(
5084"AdvInitGetConfig: board %d error: err_code 0x%x\n",
5085 boardp->id, adv_dvc_varp->err_code);
5086 }
5087 }
5088
5089 if (err_code != 0) {
5090#ifdef CONFIG_PROC_FS
5091 kfree(boardp->prtbuf);
5092#endif
5093 scsi_unregister(shp);
5094 asc_board_count--;
5095 continue;
5096 }
5097
5098
5099
5100
5101
5102 if (ASC_NARROW_BOARD(boardp)) {
5103
5104 ASCEEP_CONFIG *ep;
5105
5106
5107
5108
5109 boardp->init_tidmask |=
5110 ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
5111
5112
5113
5114
5115 ep = &boardp->eep_config.asc_eep;
5116
5117 ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
5118 ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
5119 ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
5120 ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
5121 ep->start_motor = asc_dvc_varp->start_motor;
5122 ep->cntl = asc_dvc_varp->dvc_cntl;
5123 ep->no_scam = asc_dvc_varp->no_scam;
5124 ep->max_total_qng = asc_dvc_varp->max_total_qng;
5125 ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
5126
5127 ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
5128 ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
5129 ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
5130 ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
5131 ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
5132 ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
5133 ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
5134
5135
5136
5137
5138 ASC_DBG(2, "advansys_detect: AscInitSetConfig()\n");
5139 switch (ret = AscInitSetConfig(asc_dvc_varp)) {
5140 case 0:
5141 break;
5142 case ASC_WARN_IO_PORT_ROTATE:
5143 ASC_PRINT1(
5144"AscInitSetConfig: board %d: I/O port address modified\n",
5145 boardp->id);
5146 break;
5147 case ASC_WARN_AUTO_CONFIG:
5148 ASC_PRINT1(
5149"AscInitSetConfig: board %d: I/O port increment switch enabled\n",
5150 boardp->id);
5151 break;
5152 case ASC_WARN_EEPROM_CHKSUM:
5153 ASC_PRINT1(
5154"AscInitSetConfig: board %d: EEPROM checksum error\n",
5155 boardp->id);
5156 break;
5157 case ASC_WARN_IRQ_MODIFIED:
5158 ASC_PRINT1(
5159"AscInitSetConfig: board %d: IRQ modified\n",
5160 boardp->id);
5161 break;
5162 case ASC_WARN_CMD_QNG_CONFLICT:
5163 ASC_PRINT1(
5164"AscInitSetConfig: board %d: tag queuing w/o disconnects\n",
5165 boardp->id);
5166 break;
5167 default:
5168 ASC_PRINT2(
5169"AscInitSetConfig: board %d: unknown warning: 0x%x\n",
5170 boardp->id, ret);
5171 break;
5172 }
5173 if (asc_dvc_varp->err_code != 0) {
5174 ASC_PRINT3(
5175"AscInitSetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
5176 boardp->id, asc_dvc_varp->init_state,
5177 asc_dvc_varp->err_code);
5178#ifdef CONFIG_PROC_FS
5179 kfree(boardp->prtbuf);
5180#endif
5181 scsi_unregister(shp);
5182 asc_board_count--;
5183 continue;
5184 }
5185
5186
5187
5188
5189
5190 if ((asc_dvc_varp->bus_type & ASC_IS_PCI) == 0) {
5191 shp->irq = asc_dvc_varp->irq_no;
5192 }
5193 } else {
5194 ADVEEP_3550_CONFIG *ep_3550;
5195 ADVEEP_38C0800_CONFIG *ep_38C0800;
5196 ADVEEP_38C1600_CONFIG *ep_38C1600;
5197
5198
5199
5200
5201 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
5202 {
5203 ep_3550 = &boardp->eep_config.adv_3550_eep;
5204
5205 ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
5206 ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
5207 ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
5208 ep_3550->termination = adv_dvc_varp->cfg->termination;
5209 ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
5210 ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
5211 ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
5212 ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
5213 ep_3550->ultra_able = adv_dvc_varp->ultra_able;
5214 ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
5215 ep_3550->start_motor = adv_dvc_varp->start_motor;
5216 ep_3550->scsi_reset_delay = adv_dvc_varp->scsi_reset_wait;
5217 ep_3550->serial_number_word1 =
5218 adv_dvc_varp->cfg->serial1;
5219 ep_3550->serial_number_word2 =
5220 adv_dvc_varp->cfg->serial2;
5221 ep_3550->serial_number_word3 =
5222 adv_dvc_varp->cfg->serial3;
5223 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
5224 {
5225 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
5226
5227 ep_38C0800->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
5228 ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
5229 ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
5230 ep_38C0800->termination_lvd =
5231 adv_dvc_varp->cfg->termination;
5232 ep_38C0800->disc_enable = adv_dvc_varp->cfg->disc_enable;
5233 ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
5234 ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
5235 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
5236 ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
5237 ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
5238 ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
5239 ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
5240 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
5241 ep_38C0800->start_motor = adv_dvc_varp->start_motor;
5242 ep_38C0800->scsi_reset_delay =
5243 adv_dvc_varp->scsi_reset_wait;
5244 ep_38C0800->serial_number_word1 =
5245 adv_dvc_varp->cfg->serial1;
5246 ep_38C0800->serial_number_word2 =
5247 adv_dvc_varp->cfg->serial2;
5248 ep_38C0800->serial_number_word3 =
5249 adv_dvc_varp->cfg->serial3;
5250 } else
5251 {
5252 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
5253
5254 ep_38C1600->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
5255 ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
5256 ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
5257 ep_38C1600->termination_lvd =
5258 adv_dvc_varp->cfg->termination;
5259 ep_38C1600->disc_enable = adv_dvc_varp->cfg->disc_enable;
5260 ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
5261 ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
5262 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
5263 ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
5264 ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
5265 ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
5266 ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
5267 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
5268 ep_38C1600->start_motor = adv_dvc_varp->start_motor;
5269 ep_38C1600->scsi_reset_delay =
5270 adv_dvc_varp->scsi_reset_wait;
5271 ep_38C1600->serial_number_word1 =
5272 adv_dvc_varp->cfg->serial1;
5273 ep_38C1600->serial_number_word2 =
5274 adv_dvc_varp->cfg->serial2;
5275 ep_38C1600->serial_number_word3 =
5276 adv_dvc_varp->cfg->serial3;
5277 }
5278
5279
5280
5281
5282 boardp->init_tidmask |=
5283 ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
5284
5285
5286
5287
5288 shp->irq = adv_dvc_varp->irq_no;
5289 }
5290
5291
5292
5293
5294
5295
5296 shp->max_channel = 0;
5297 if (ASC_NARROW_BOARD(boardp)) {
5298 shp->max_id = ASC_MAX_TID + 1;
5299 shp->max_lun = ASC_MAX_LUN + 1;
5300
5301 shp->io_port = asc_dvc_varp->iop_base;
5302 boardp->asc_n_io_port = ASC_IOADR_GAP;
5303 shp->this_id = asc_dvc_varp->cfg->chip_scsi_id;
5304
5305
5306 shp->can_queue = asc_dvc_varp->max_total_qng;
5307 } else {
5308 shp->max_id = ADV_MAX_TID + 1;
5309 shp->max_lun = ADV_MAX_LUN + 1;
5310
5311
5312
5313
5314
5315
5316
5317 shp->io_port = iop;
5318 boardp->asc_n_io_port = iolen;
5319
5320 shp->this_id = adv_dvc_varp->chip_scsi_id;
5321
5322
5323 shp->can_queue = adv_dvc_varp->max_host_qng;
5324 }
5325
5326
5327
5328
5329
5330
5331
5332 shp->n_io_port = boardp->asc_n_io_port <= 255 ?
5333 boardp->asc_n_io_port : 255;
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344#ifdef MODULE
5345 shp->cmd_per_lun = 1;
5346#else
5347 shp->cmd_per_lun = 0;
5348#endif
5349
5350
5351
5352
5353 shp->select_queue_depths = advansys_select_queue_depths;
5354
5355
5356
5357
5358
5359 if (ASC_NARROW_BOARD(boardp)) {
5360
5361
5362
5363
5364
5365
5366 shp->sg_tablesize =
5367 (((asc_dvc_varp->max_total_qng - 2) / 2) *
5368 ASC_SG_LIST_PER_Q) + 1;
5369 } else {
5370 shp->sg_tablesize = ADV_MAX_SG_LIST;
5371 }
5372
5373
5374
5375
5376
5377
5378
5379 if (shp->sg_tablesize > SG_ALL) {
5380 shp->sg_tablesize = SG_ALL;
5381 }
5382
5383 ASC_DBG1(1, "advansys_detect: sg_tablesize: %d\n",
5384 shp->sg_tablesize);
5385
5386
5387 if (ASC_NARROW_BOARD(boardp)) {
5388#if ASC_LINUX_KERNEL24
5389 shp->base =
5390#elif ASC_LINUX_KERNEL22
5391 shp->base = (char *)
5392#endif
5393 ((ulong) AscGetChipBiosAddress(
5394 asc_dvc_varp->iop_base,
5395 asc_dvc_varp->bus_type));
5396 } else {
5397
5398
5399
5400
5401 AdvReadWordLram(adv_dvc_varp->iop_base, BIOS_SIGNATURE,
5402 boardp->bios_signature);
5403 AdvReadWordLram(adv_dvc_varp->iop_base, BIOS_VERSION,
5404 boardp->bios_version);
5405 AdvReadWordLram(adv_dvc_varp->iop_base, BIOS_CODESEG,
5406 boardp->bios_codeseg);
5407 AdvReadWordLram(adv_dvc_varp->iop_base, BIOS_CODELEN,
5408 boardp->bios_codelen);
5409
5410 ASC_DBG2(1,
5411 "advansys_detect: bios_signature 0x%x, bios_version 0x%x\n",
5412 boardp->bios_signature, boardp->bios_version);
5413
5414 ASC_DBG2(1,
5415 "advansys_detect: bios_codeseg 0x%x, bios_codelen 0x%x\n",
5416 boardp->bios_codeseg, boardp->bios_codelen);
5417
5418
5419
5420
5421
5422 if (boardp->bios_signature == 0x55AA) {
5423
5424
5425
5426
5427 shp->base =
5428#if ASC_LINUX_KERNEL22
5429 (char *)
5430#endif
5431 ((ulong) boardp->bios_codeseg << 4);
5432 } else {
5433 shp->base = 0;
5434 }
5435 }
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449 ASC_DBG2(2,
5450 "advansys_detect: request_region port 0x%lx, len 0x%x\n",
5451 (ulong) shp->io_port, boardp->asc_n_io_port);
5452#if ASC_LINUX_KERNEL24
5453 if (request_region(shp->io_port, boardp->asc_n_io_port,
5454 "advansys") == NULL) {
5455 ASC_PRINT3(
5456"advansys_detect: board %d: request_region() failed, port 0x%lx, len 0x%x\n",
5457 boardp->id, (ulong) shp->io_port, boardp->asc_n_io_port);
5458#ifdef CONFIG_PROC_FS
5459 kfree(boardp->prtbuf);
5460#endif
5461 scsi_unregister(shp);
5462 asc_board_count--;
5463 continue;
5464 }
5465#elif ASC_LINUX_KERNEL22
5466 request_region(shp->io_port, boardp->asc_n_io_port, "advansys");
5467#endif
5468
5469
5470 shp->dma_channel = NO_ISA_DMA;
5471#ifdef CONFIG_ISA
5472 if (ASC_NARROW_BOARD(boardp)) {
5473
5474 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
5475 shp->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
5476 if ((ret =
5477 request_dma(shp->dma_channel, "advansys")) != 0) {
5478 ASC_PRINT3(
5479"advansys_detect: board %d: request_dma() %d failed %d\n",
5480 boardp->id, shp->dma_channel, ret);
5481 release_region(shp->io_port, boardp->asc_n_io_port);
5482#ifdef CONFIG_PROC_FS
5483 kfree(boardp->prtbuf);
5484#endif
5485 scsi_unregister(shp);
5486 asc_board_count--;
5487 continue;
5488 }
5489 AscEnableIsaDma(shp->dma_channel);
5490 }
5491 }
5492#endif
5493
5494
5495 ASC_DBG1(2, "advansys_detect: request_irq() %d\n", shp->irq);
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505 if (((ret = request_irq(shp->irq, advansys_interrupt,
5506 SA_INTERRUPT | (share_irq == TRUE ? SA_SHIRQ : 0),
5507 "advansys", boardp)) != 0) &&
5508 ((ret = request_irq(shp->irq, advansys_interrupt,
5509 (share_irq == TRUE ? SA_SHIRQ : 0),
5510 "advansys", boardp)) != 0))
5511 {
5512 if (ret == -EBUSY) {
5513 ASC_PRINT2(
5514"advansys_detect: board %d: request_irq(): IRQ 0x%x already in use.\n",
5515 boardp->id, shp->irq);
5516 } else if (ret == -EINVAL) {
5517 ASC_PRINT2(
5518"advansys_detect: board %d: request_irq(): IRQ 0x%x not valid.\n",
5519 boardp->id, shp->irq);
5520 } else {
5521 ASC_PRINT3(
5522"advansys_detect: board %d: request_irq(): IRQ 0x%x failed with %d\n",
5523 boardp->id, shp->irq, ret);
5524 }
5525 release_region(shp->io_port, boardp->asc_n_io_port);
5526 iounmap(boardp->ioremap_addr);
5527 if (shp->dma_channel != NO_ISA_DMA) {
5528 free_dma(shp->dma_channel);
5529 }
5530#ifdef CONFIG_PROC_FS
5531 kfree(boardp->prtbuf);
5532#endif
5533 scsi_unregister(shp);
5534 asc_board_count--;
5535 continue;
5536 }
5537
5538
5539
5540
5541 if (ASC_NARROW_BOARD(boardp)) {
5542 ASC_DBG(2, "advansys_detect: AscInitAsc1000Driver()\n");
5543 warn_code = AscInitAsc1000Driver(asc_dvc_varp);
5544 err_code = asc_dvc_varp->err_code;
5545
5546 if (warn_code || err_code) {
5547 ASC_PRINT4(
5548"advansys_detect: board %d error: init_state 0x%x, warn 0x%x, error 0x%x\n",
5549 boardp->id, asc_dvc_varp->init_state,
5550 warn_code, err_code);
5551 }
5552 } else {
5553 ADV_CARR_T *carrp;
5554 int req_cnt;
5555 adv_req_t *reqp = NULL;
5556 int sg_cnt = 0;
5557
5558
5559
5560
5561
5562 carrp =
5563 (ADV_CARR_T *) kmalloc(ADV_CARRIER_BUFSIZE, GFP_ATOMIC);
5564 ASC_DBG1(1, "advansys_detect: carrp 0x%lx\n", (ulong) carrp);
5565
5566 if (carrp == NULL) {
5567 goto kmalloc_error;
5568 }
5569
5570
5571
5572
5573
5574
5575
5576 for (req_cnt = adv_dvc_varp->max_host_qng;
5577 req_cnt > 0; req_cnt--) {
5578
5579 reqp = (adv_req_t *)
5580 kmalloc(sizeof(adv_req_t) * req_cnt, GFP_ATOMIC);
5581
5582 ASC_DBG3(1,
5583 "advansys_detect: reqp 0x%lx, req_cnt %d, bytes %lu\n",
5584 (ulong) reqp, req_cnt,
5585 (ulong) sizeof(adv_req_t) * req_cnt);
5586
5587 if (reqp != NULL) {
5588 break;
5589 }
5590 }
5591 if (reqp == NULL)
5592 {
5593 goto kmalloc_error;
5594 }
5595
5596
5597
5598
5599
5600 boardp->adv_sgblkp = NULL;
5601 for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
5602
5603 sgp = (adv_sgblk_t *)
5604 kmalloc(sizeof(adv_sgblk_t), GFP_ATOMIC);
5605
5606 if (sgp == NULL) {
5607 break;
5608 }
5609
5610 sgp->next_sgblkp = boardp->adv_sgblkp;
5611 boardp->adv_sgblkp = sgp;
5612
5613 }
5614 ASC_DBG3(1,
5615 "advansys_detect: sg_cnt %d * %u = %u bytes\n",
5616 sg_cnt, sizeof(adv_sgblk_t),
5617 (unsigned) (sizeof(adv_sgblk_t) * sg_cnt));
5618
5619
5620
5621
5622
5623
5624 kmalloc_error:
5625 if (carrp == NULL)
5626 {
5627 ASC_PRINT1(
5628"advansys_detect: board %d error: failed to kmalloc() carrier buffer.\n",
5629 boardp->id);
5630 err_code = ADV_ERROR;
5631 } else if (reqp == NULL) {
5632 kfree(carrp);
5633 ASC_PRINT1(
5634"advansys_detect: board %d error: failed to kmalloc() adv_req_t buffer.\n",
5635 boardp->id);
5636 err_code = ADV_ERROR;
5637 } else if (boardp->adv_sgblkp == NULL) {
5638 kfree(carrp);
5639 kfree(reqp);
5640 ASC_PRINT1(
5641"advansys_detect: board %d error: failed to kmalloc() adv_sgblk_t buffers.\n",
5642 boardp->id);
5643 err_code = ADV_ERROR;
5644 } else {
5645
5646
5647 boardp->orig_carrp = carrp;
5648
5649
5650
5651
5652
5653 boardp->orig_reqp = reqp;
5654
5655 adv_dvc_varp->carrier_buf = carrp;
5656
5657
5658
5659
5660
5661 req_cnt--;
5662 reqp[req_cnt].next_reqp = NULL;
5663 for (; req_cnt > 0; req_cnt--) {
5664 reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
5665 }
5666 boardp->adv_reqp = &reqp[0];
5667
5668 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
5669 {
5670 ASC_DBG(2,
5671 "advansys_detect: AdvInitAsc3550Driver()\n");
5672 warn_code = AdvInitAsc3550Driver(adv_dvc_varp);
5673 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
5674 ASC_DBG(2,
5675 "advansys_detect: AdvInitAsc38C0800Driver()\n");
5676 warn_code = AdvInitAsc38C0800Driver(adv_dvc_varp);
5677 } else {
5678 ASC_DBG(2,
5679 "advansys_detect: AdvInitAsc38C1600Driver()\n");
5680 warn_code = AdvInitAsc38C1600Driver(adv_dvc_varp);
5681 }
5682 err_code = adv_dvc_varp->err_code;
5683
5684 if (warn_code || err_code) {
5685 ASC_PRINT3(
5686"advansys_detect: board %d error: warn 0x%x, error 0x%x\n",
5687 boardp->id, warn_code, err_code);
5688 }
5689 }
5690 }
5691
5692 if (err_code != 0) {
5693 release_region(shp->io_port, boardp->asc_n_io_port);
5694 if (ASC_WIDE_BOARD(boardp)) {
5695 iounmap(boardp->ioremap_addr);
5696 if (boardp->orig_carrp) {
5697 kfree(boardp->orig_carrp);
5698 boardp->orig_carrp = NULL;
5699 }
5700 if (boardp->orig_reqp) {
5701 kfree(boardp->orig_reqp);
5702 boardp->orig_reqp = boardp->adv_reqp = NULL;
5703 }
5704 while ((sgp = boardp->adv_sgblkp) != NULL)
5705 {
5706 boardp->adv_sgblkp = sgp->next_sgblkp;
5707 kfree(sgp);
5708 }
5709 }
5710 if (shp->dma_channel != NO_ISA_DMA) {
5711 free_dma(shp->dma_channel);
5712 }
5713#ifdef CONFIG_PROC_FS
5714 kfree(boardp->prtbuf);
5715#endif
5716 free_irq(shp->irq, boardp);
5717 scsi_unregister(shp);
5718 asc_board_count--;
5719 continue;
5720 }
5721 ASC_DBG_PRT_SCSI_HOST(2, shp);
5722 }
5723 }
5724
5725
5726
5727
5728
5729
5730 ASC_LOCK_IO_REQUEST_LOCK
5731
5732 ASC_DBG1(1, "advansys_detect: done: asc_board_count %d\n", asc_board_count);
5733 return asc_board_count;
5734}
5735
5736
5737
5738
5739
5740
5741int
5742advansys_release(struct Scsi_Host *shp)
5743{
5744 asc_board_t *boardp;
5745
5746 ASC_DBG(1, "advansys_release: begin\n");
5747 boardp = ASC_BOARDP(shp);
5748 free_irq(shp->irq, boardp);
5749 if (shp->dma_channel != NO_ISA_DMA) {
5750 ASC_DBG(1, "advansys_release: free_dma()\n");
5751 free_dma(shp->dma_channel);
5752 }
5753 release_region(shp->io_port, boardp->asc_n_io_port);
5754 if (ASC_WIDE_BOARD(boardp)) {
5755 adv_sgblk_t *sgp = NULL;
5756
5757 iounmap(boardp->ioremap_addr);
5758 if (boardp->orig_carrp) {
5759 kfree(boardp->orig_carrp);
5760 boardp->orig_carrp = NULL;
5761 }
5762 if (boardp->orig_reqp) {
5763 kfree(boardp->orig_reqp);
5764 boardp->orig_reqp = boardp->adv_reqp = NULL;
5765 }
5766 while ((sgp = boardp->adv_sgblkp) != NULL)
5767 {
5768 boardp->adv_sgblkp = sgp->next_sgblkp;
5769 kfree(sgp);
5770 }
5771 }
5772#ifdef CONFIG_PROC_FS
5773 ASC_ASSERT(boardp->prtbuf != NULL);
5774 kfree(boardp->prtbuf);
5775#endif
5776 scsi_unregister(shp);
5777 ASC_DBG(1, "advansys_release: end\n");
5778 return 0;
5779}
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790const char *
5791advansys_info(struct Scsi_Host *shp)
5792{
5793 static char info[ASC_INFO_SIZE];
5794 asc_board_t *boardp;
5795 ASC_DVC_VAR *asc_dvc_varp;
5796 ADV_DVC_VAR *adv_dvc_varp;
5797 char *busname;
5798 int iolen;
5799 char *widename = NULL;
5800
5801 boardp = ASC_BOARDP(shp);
5802 if (ASC_NARROW_BOARD(boardp)) {
5803 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
5804 ASC_DBG(1, "advansys_info: begin\n");
5805 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
5806 if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) == ASC_IS_ISAPNP) {
5807 busname = "ISA PnP";
5808 } else {
5809 busname = "ISA";
5810 }
5811
5812 sprintf(info,
5813"AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
5814 ASC_VERSION, busname,
5815 (ulong) shp->io_port,
5816 (ulong) shp->io_port + boardp->asc_n_io_port - 1,
5817 shp->irq, shp->dma_channel);
5818 } else {
5819 if (asc_dvc_varp->bus_type & ASC_IS_VL) {
5820 busname = "VL";
5821 } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
5822 busname = "EISA";
5823 } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
5824 if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
5825 == ASC_IS_PCI_ULTRA) {
5826 busname = "PCI Ultra";
5827 } else {
5828 busname = "PCI";
5829 }
5830 } else {
5831 busname = "?";
5832 ASC_PRINT2( "advansys_info: board %d: unknown bus type %d\n",
5833 boardp->id, asc_dvc_varp->bus_type);
5834 }
5835
5836 sprintf(info,
5837 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
5838 ASC_VERSION, busname,
5839 (ulong) shp->io_port,
5840 (ulong) shp->io_port + boardp->asc_n_io_port - 1,
5841 shp->irq);
5842 }
5843 } else {
5844
5845
5846
5847
5848
5849
5850
5851 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
5852 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
5853 {
5854 iolen = ADV_3550_IOLEN;
5855 widename = "Ultra-Wide";
5856 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
5857 {
5858 iolen = ADV_38C0800_IOLEN;
5859 widename = "Ultra2-Wide";
5860 } else
5861 {
5862 iolen = ADV_38C1600_IOLEN;
5863 widename = "Ultra3-Wide";
5864 }
5865 sprintf(info, "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
5866 ASC_VERSION,
5867 widename,
5868 (ulong) adv_dvc_varp->iop_base,
5869 (ulong) adv_dvc_varp->iop_base + iolen - 1,
5870 shp->irq);
5871 }
5872 ASC_ASSERT(strlen(info) < ASC_INFO_SIZE);
5873 ASC_DBG(1, "advansys_info: end\n");
5874 return info;
5875}
5876
5877
5878
5879
5880
5881
5882
5883int
5884advansys_queuecommand(Scsi_Cmnd *scp, void (*done)(Scsi_Cmnd *))
5885{
5886 struct Scsi_Host *shp;
5887 asc_board_t *boardp;
5888 ulong flags;
5889 Scsi_Cmnd *done_scp;
5890
5891 shp = scp->host;
5892 boardp = ASC_BOARDP(shp);
5893 ASC_STATS(shp, queuecommand);
5894
5895
5896
5897
5898
5899
5900 ASC_UNLOCK_IO_REQUEST_LOCK
5901
5902 spin_lock_irqsave(&boardp->lock, flags);
5903
5904
5905
5906
5907 if (boardp->flags & ASC_HOST_IN_RESET) {
5908 ASC_DBG1(1,
5909 "advansys_queuecommand: scp 0x%lx blocked for reset request\n",
5910 (ulong) scp);
5911 scp->result = HOST_BYTE(DID_RESET);
5912
5913
5914
5915
5916
5917
5918 asc_enqueue(&boardp->done, scp, ASC_BACK);
5919 spin_unlock_irqrestore(&boardp->lock, flags);
5920 return 0;
5921 }
5922
5923
5924
5925
5926 if (!ASC_QUEUE_EMPTY(&boardp->waiting)) {
5927 ASC_DBG(1,
5928 "advansys_queuecommand: before asc_execute_queue() waiting\n");
5929 asc_execute_queue(&boardp->waiting);
5930 }
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948 scp->scsi_done = done;
5949 switch (asc_execute_scsi_cmnd(scp)) {
5950 case ASC_NOERROR:
5951 break;
5952 case ASC_BUSY:
5953 asc_enqueue(&boardp->waiting, scp, ASC_BACK);
5954 break;
5955 case ASC_ERROR:
5956 default:
5957 done_scp = asc_dequeue_list(&boardp->done, NULL, ASC_TID_ALL);
5958
5959 asc_scsi_done_list(done_scp);
5960 break;
5961 }
5962
5963 spin_unlock_irqrestore(&boardp->lock, flags);
5964
5965
5966
5967
5968
5969
5970 ASC_LOCK_IO_REQUEST_LOCK
5971
5972 return 0;
5973}
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984int
5985advansys_reset(Scsi_Cmnd *scp)
5986{
5987 struct Scsi_Host *shp;
5988 asc_board_t *boardp;
5989 ASC_DVC_VAR *asc_dvc_varp;
5990 ADV_DVC_VAR *adv_dvc_varp;
5991 ulong flags;
5992 Scsi_Cmnd *done_scp = NULL, *last_scp = NULL;
5993 Scsi_Cmnd *tscp, *new_last_scp;
5994 int status;
5995 int ret = SUCCESS;
5996
5997 ASC_DBG1(1, "advansys_reset: 0x%lx\n", (ulong) scp);
5998
5999#ifdef ADVANSYS_STATS
6000 if (scp->host != NULL) {
6001 ASC_STATS(scp->host, reset);
6002 }
6003#endif
6004
6005 if ((shp = scp->host) == NULL) {
6006 scp->result = HOST_BYTE(DID_ERROR);
6007 return FAILED;
6008 }
6009
6010 boardp = ASC_BOARDP(shp);
6011
6012 ASC_PRINT1("advansys_reset: board %d: SCSI bus reset started...\n",
6013 boardp->id);
6014
6015
6016
6017 spin_lock_irqsave(&boardp->lock, flags);
6018 if (boardp->flags & ASC_HOST_IN_RESET) {
6019 spin_unlock_irqrestore(&boardp->lock, flags);
6020 return FAILED;
6021 }
6022 boardp->flags |= ASC_HOST_IN_RESET;
6023 spin_unlock_irqrestore(&boardp->lock, flags);
6024
6025
6026
6027
6028
6029
6030 ASC_UNLOCK_IO_REQUEST_LOCK
6031
6032 if (ASC_NARROW_BOARD(boardp)) {
6033
6034
6035
6036 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
6037
6038
6039
6040
6041 ASC_DBG(1, "advansys_reset: before AscInitAsc1000Driver()\n");
6042 status = AscInitAsc1000Driver(asc_dvc_varp);
6043
6044
6045 if (asc_dvc_varp->err_code) {
6046 ASC_PRINT2(
6047 "advansys_reset: board %d: SCSI bus reset error: 0x%x\n",
6048 boardp->id, asc_dvc_varp->err_code);
6049 ret = FAILED;
6050 } else if (status) {
6051 ASC_PRINT2(
6052 "advansys_reset: board %d: SCSI bus reset warning: 0x%x\n",
6053 boardp->id, status);
6054 } else {
6055 ASC_PRINT1(
6056 "advansys_reset: board %d: SCSI bus reset successful.\n",
6057 boardp->id);
6058 }
6059
6060 ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
6061
6062
6063
6064
6065 spin_lock_irqsave(&boardp->lock, flags);
6066
6067 } else {
6068
6069
6070
6071
6072
6073
6074 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
6075
6076
6077
6078
6079 ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
6080 switch (AdvResetChipAndSB(adv_dvc_varp)) {
6081 case ASC_TRUE:
6082 ASC_PRINT1("advansys_reset: board %d: SCSI bus reset successful.\n",
6083 boardp->id);
6084 break;
6085 case ASC_FALSE:
6086 default:
6087 ASC_PRINT1("advansys_reset: board %d: SCSI bus reset error.\n",
6088 boardp->id);
6089 ret = FAILED;
6090 break;
6091 }
6092
6093
6094
6095
6096 spin_lock_irqsave(&boardp->lock, flags);
6097 (void) AdvISR(adv_dvc_varp);
6098 }
6099
6100
6101
6102
6103
6104
6105
6106 done_scp = asc_dequeue_list(&boardp->done, &last_scp, ASC_TID_ALL);
6107
6108
6109
6110
6111
6112
6113 if (done_scp == NULL) {
6114 done_scp = asc_dequeue_list(&boardp->active, &last_scp, ASC_TID_ALL);
6115 for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) {
6116 tscp->result = HOST_BYTE(DID_RESET);
6117 }
6118 } else {
6119
6120 ASC_ASSERT(last_scp != NULL);
6121 REQPNEXT(last_scp) = asc_dequeue_list(&boardp->active,
6122 &new_last_scp, ASC_TID_ALL);
6123 if (new_last_scp != NULL) {
6124 ASC_ASSERT(REQPNEXT(last_scp) != NULL);
6125 for (tscp = REQPNEXT(last_scp); tscp; tscp = REQPNEXT(tscp)) {
6126 tscp->result = HOST_BYTE(DID_RESET);
6127 }
6128 last_scp = new_last_scp;
6129 }
6130 }
6131
6132
6133
6134
6135
6136 if (done_scp == NULL) {
6137 done_scp = asc_dequeue_list(&boardp->waiting, &last_scp, ASC_TID_ALL);
6138 for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) {
6139 tscp->result = HOST_BYTE(DID_RESET);
6140 }
6141 } else {
6142
6143 ASC_ASSERT(last_scp != NULL);
6144 REQPNEXT(last_scp) = asc_dequeue_list(&boardp->waiting,
6145 &new_last_scp, ASC_TID_ALL);
6146 if (new_last_scp != NULL) {
6147 ASC_ASSERT(REQPNEXT(last_scp) != NULL);
6148 for (tscp = REQPNEXT(last_scp); tscp; tscp = REQPNEXT(tscp)) {
6149 tscp->result = HOST_BYTE(DID_RESET);
6150 }
6151 last_scp = new_last_scp;
6152 }
6153 }
6154
6155
6156 boardp->last_reset = jiffies;
6157
6158
6159 boardp->flags &= ~ASC_HOST_IN_RESET;
6160
6161
6162 spin_unlock_irqrestore(&boardp->lock, flags);
6163
6164
6165
6166
6167 if (done_scp != NULL) {
6168 asc_scsi_done_list(done_scp);
6169 }
6170
6171
6172
6173
6174
6175
6176 ASC_LOCK_IO_REQUEST_LOCK
6177
6178 ASC_DBG1(1, "advansys_reset: ret %d\n", ret);
6179
6180 return ret;
6181}
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194int
6195advansys_biosparam(Disk *dp, kdev_t dep, int ip[])
6196{
6197 asc_board_t *boardp;
6198
6199 ASC_DBG(1, "advansys_biosparam: begin\n");
6200 ASC_STATS(dp->device->host, biosparam);
6201 boardp = ASC_BOARDP(dp->device->host);
6202 if (ASC_NARROW_BOARD(boardp)) {
6203 if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
6204 ASC_CNTL_BIOS_GT_1GB) && dp->capacity > 0x200000) {
6205 ip[0] = 255;
6206 ip[1] = 63;
6207 } else {
6208 ip[0] = 64;
6209 ip[1] = 32;
6210 }
6211 } else {
6212 if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
6213 BIOS_CTRL_EXTENDED_XLAT) && dp->capacity > 0x200000) {
6214 ip[0] = 255;
6215 ip[1] = 63;
6216 } else {
6217 ip[0] = 64;
6218 ip[1] = 32;
6219 }
6220 }
6221 ip[2] = dp->capacity / (ip[0] * ip[1]);
6222 ASC_DBG(1, "advansys_biosparam: end\n");
6223 return 0;
6224}
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260ASC_INITFUNC(
6261void,
6262advansys_setup(char *str, int *ints)
6263)
6264{
6265 int i;
6266
6267 if (asc_iopflag == ASC_TRUE) {
6268 printk("AdvanSys SCSI: 'advansys' LILO option may appear only once\n");
6269 return;
6270 }
6271
6272 asc_iopflag = ASC_TRUE;
6273
6274 if (ints[0] > ASC_NUM_IOPORT_PROBE) {
6275#ifdef ADVANSYS_DEBUG
6276 if ((ints[0] == ASC_NUM_IOPORT_PROBE + 1) &&
6277 (ints[ASC_NUM_IOPORT_PROBE + 1] >> 4 == 0xdeb)) {
6278 asc_dbglvl = ints[ASC_NUM_IOPORT_PROBE + 1] & 0xf;
6279 } else {
6280#endif
6281 printk("AdvanSys SCSI: only %d I/O ports accepted\n",
6282 ASC_NUM_IOPORT_PROBE);
6283#ifdef ADVANSYS_DEBUG
6284 }
6285#endif
6286 }
6287
6288#ifdef ADVANSYS_DEBUG
6289 ASC_DBG1(1, "advansys_setup: ints[0] %d\n", ints[0]);
6290 for (i = 1; i < ints[0]; i++) {
6291 ASC_DBG2(1, " ints[%d] 0x%x", i, ints[i]);
6292 }
6293 ASC_DBG(1, "\n");
6294#endif
6295
6296 for (i = 1; i <= ints[0] && i <= ASC_NUM_IOPORT_PROBE; i++) {
6297 asc_ioport[i-1] = ints[i];
6298 ASC_DBG2(1, "advansys_setup: asc_ioport[%d] 0x%x\n",
6299 i - 1, asc_ioport[i-1]);
6300 }
6301}
6302
6303
6304
6305
6306
6307
6308#if ASC_LINUX_KERNEL24
6309static
6310#endif
6311#if ASC_LINUX_KERNEL24 || (ASC_LINUX_KERNEL22 && defined(MODULE))
6312Scsi_Host_Template driver_template = ADVANSYS;
6313# include "scsi_module.c"
6314#endif
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330STATIC void
6331advansys_interrupt(int irq, void *dev_id, struct pt_regs *regs)
6332{
6333 ulong flags;
6334 int i;
6335 asc_board_t *boardp;
6336 Scsi_Cmnd *done_scp = NULL, *last_scp = NULL;
6337 Scsi_Cmnd *new_last_scp;
6338
6339 ASC_DBG(1, "advansys_interrupt: begin\n");
6340
6341
6342
6343
6344
6345 for (i = 0; i < asc_board_count; i++) {
6346 boardp = ASC_BOARDP(asc_host[i]);
6347 ASC_DBG2(2, "advansys_interrupt: i %d, boardp 0x%lx\n",
6348 i, (ulong) boardp);
6349 spin_lock_irqsave(&boardp->lock, flags);
6350 if (ASC_NARROW_BOARD(boardp)) {
6351
6352
6353
6354 if (AscIsIntPending(asc_host[i]->io_port)) {
6355 ASC_STATS(asc_host[i], interrupt);
6356 ASC_DBG(1, "advansys_interrupt: before AscISR()\n");
6357 AscISR(&boardp->dvc_var.asc_dvc_var);
6358 }
6359 } else {
6360
6361
6362
6363 ASC_DBG(1, "advansys_interrupt: before AdvISR()\n");
6364 if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
6365 ASC_STATS(asc_host[i], interrupt);
6366 }
6367 }
6368
6369
6370
6371
6372
6373
6374
6375 if ((boardp->flags & ASC_HOST_IN_RESET) == 0) {
6376 ASC_DBG2(1, "advansys_interrupt: done_scp 0x%lx, last_scp 0x%lx\n",
6377 (ulong) done_scp, (ulong) last_scp);
6378
6379
6380 if (!ASC_QUEUE_EMPTY(&boardp->waiting)) {
6381 ASC_DBG(1, "advansys_interrupt: before asc_execute_queue()\n");
6382 asc_execute_queue(&boardp->waiting);
6383 }
6384
6385
6386
6387
6388
6389
6390
6391
6392 if (done_scp == NULL) {
6393 done_scp = asc_dequeue_list(&boardp->done, &last_scp,
6394 ASC_TID_ALL);
6395 } else {
6396 ASC_ASSERT(last_scp != NULL);
6397 REQPNEXT(last_scp) = asc_dequeue_list(&boardp->done,
6398 &new_last_scp, ASC_TID_ALL);
6399 if (new_last_scp != NULL) {
6400 ASC_ASSERT(REQPNEXT(last_scp) != NULL);
6401 last_scp = new_last_scp;
6402 }
6403 }
6404 }
6405 spin_unlock_irqrestore(&boardp->lock, flags);
6406 }
6407
6408
6409
6410
6411
6412
6413
6414 asc_scsi_done_list(done_scp);
6415
6416 ASC_DBG(1, "advansys_interrupt: end\n");
6417 return;
6418}
6419
6420
6421
6422
6423
6424STATIC void
6425advansys_select_queue_depths(struct Scsi_Host *shp, Scsi_Device *devicelist)
6426{
6427 Scsi_Device *device;
6428 asc_board_t *boardp;
6429
6430 boardp = ASC_BOARDP(shp);
6431 boardp->flags |= ASC_SELECT_QUEUE_DEPTHS;
6432 for (device = devicelist; device != NULL; device = device->next) {
6433 if (device->host != shp) {
6434 continue;
6435 }
6436
6437
6438
6439
6440 boardp->device[device->id] = device;
6441 if (ASC_NARROW_BOARD(boardp)) {
6442 device->queue_depth =
6443 boardp->dvc_var.asc_dvc_var.max_dvc_qng[device->id];
6444 } else {
6445 device->queue_depth =
6446 boardp->dvc_var.adv_dvc_var.max_dvc_qng;
6447 }
6448 ASC_DBG3(1,
6449 "advansys_select_queue_depths: shp 0x%lx, id %d, depth %d\n",
6450 (ulong) shp, device->id, device->queue_depth);
6451 }
6452}
6453
6454
6455
6456
6457
6458
6459
6460STATIC void
6461asc_scsi_done_list(Scsi_Cmnd *scp)
6462{
6463 Scsi_Cmnd *tscp;
6464
6465 ASC_DBG(2, "asc_scsi_done_list: begin\n");
6466 while (scp != NULL) {
6467 ASC_DBG1(3, "asc_scsi_done_list: scp 0x%lx\n", (ulong) scp);
6468 tscp = REQPNEXT(scp);
6469 REQPNEXT(scp) = NULL;
6470 ASC_STATS(scp->host, done);
6471 ASC_ASSERT(scp->scsi_done != NULL);
6472 scp->scsi_done(scp);
6473 scp = tscp;
6474 }
6475 ASC_DBG(2, "asc_scsi_done_list: done\n");
6476 return;
6477}
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525STATIC int
6526asc_execute_scsi_cmnd(Scsi_Cmnd *scp)
6527{
6528 asc_board_t *boardp;
6529 ASC_DVC_VAR *asc_dvc_varp;
6530 ADV_DVC_VAR *adv_dvc_varp;
6531 ADV_SCSI_REQ_Q *adv_scsiqp;
6532 Scsi_Device *device;
6533 int ret;
6534
6535 ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n",
6536 (ulong) scp, (ulong) scp->scsi_done);
6537
6538 boardp = ASC_BOARDP(scp->host);
6539 device = boardp->device[scp->target];
6540
6541 if (ASC_NARROW_BOARD(boardp)) {
6542
6543
6544
6545
6546 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558 if (asc_build_req(boardp, scp) == ASC_ERROR) {
6559 ASC_STATS(scp->host, build_error);
6560 return ASC_ERROR;
6561 }
6562
6563
6564
6565
6566
6567 switch (ret = AscExeScsiQueue(asc_dvc_varp, &asc_scsi_q)) {
6568 case ASC_NOERROR:
6569 ASC_STATS(scp->host, exe_noerror);
6570
6571
6572
6573
6574 boardp->reqcnt[scp->target]++;
6575 asc_enqueue(&boardp->active, scp, ASC_BACK);
6576 ASC_DBG(1,
6577 "asc_execute_scsi_cmnd: AscExeScsiQueue(), ASC_NOERROR\n");
6578 break;
6579 case ASC_BUSY:
6580
6581
6582
6583
6584 ASC_STATS(scp->host, exe_busy);
6585 break;
6586 case ASC_ERROR:
6587 ASC_PRINT2(
6588"asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
6589 boardp->id, asc_dvc_varp->err_code);
6590 ASC_STATS(scp->host, exe_error);
6591 scp->result = HOST_BYTE(DID_ERROR);
6592 asc_enqueue(&boardp->done, scp, ASC_BACK);
6593 break;
6594 default:
6595 ASC_PRINT2(
6596"asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() unknown, err_code 0x%x\n",
6597 boardp->id, asc_dvc_varp->err_code);
6598 ASC_STATS(scp->host, exe_unknown);
6599 scp->result = HOST_BYTE(DID_ERROR);
6600 asc_enqueue(&boardp->done, scp, ASC_BACK);
6601 break;
6602 }
6603 } else {
6604
6605
6606
6607 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
6608
6609
6610
6611
6612
6613
6614
6615 switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
6616 case ASC_NOERROR:
6617 ASC_DBG(3, "asc_execute_scsi_cmnd: adv_build_req ASC_NOERROR\n");
6618 break;
6619 case ASC_BUSY:
6620 ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req ASC_BUSY\n");
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630 return ASC_BUSY;
6631 case ASC_ERROR:
6632
6633
6634
6635
6636
6637 default:
6638 ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req ASC_ERROR\n");
6639 ASC_STATS(scp->host, build_error);
6640 return ASC_ERROR;
6641 }
6642
6643
6644
6645
6646
6647 switch (ret = AdvExeScsiQueue(adv_dvc_varp, adv_scsiqp)) {
6648 case ASC_NOERROR:
6649 ASC_STATS(scp->host, exe_noerror);
6650
6651
6652
6653
6654 boardp->reqcnt[scp->target]++;
6655 asc_enqueue(&boardp->active, scp, ASC_BACK);
6656 ASC_DBG(1,
6657 "asc_execute_scsi_cmnd: AdvExeScsiQueue(), ASC_NOERROR\n");
6658 break;
6659 case ASC_BUSY:
6660
6661
6662
6663
6664 ASC_STATS(scp->host, exe_busy);
6665 break;
6666 case ASC_ERROR:
6667 ASC_PRINT2(
6668"asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
6669 boardp->id, adv_dvc_varp->err_code);
6670 ASC_STATS(scp->host, exe_error);
6671 scp->result = HOST_BYTE(DID_ERROR);
6672 asc_enqueue(&boardp->done, scp, ASC_BACK);
6673 break;
6674 default:
6675 ASC_PRINT2(
6676"asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() unknown, err_code 0x%x\n",
6677 boardp->id, adv_dvc_varp->err_code);
6678 ASC_STATS(scp->host, exe_unknown);
6679 scp->result = HOST_BYTE(DID_ERROR);
6680 asc_enqueue(&boardp->done, scp, ASC_BACK);
6681 break;
6682 }
6683 }
6684
6685 ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");
6686 return ret;
6687}
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698STATIC int
6699asc_build_req(asc_board_t *boardp, Scsi_Cmnd *scp)
6700{
6701
6702
6703
6704
6705 memset(&asc_scsi_q, 0, sizeof(ASC_SCSI_Q));
6706
6707
6708
6709
6710 asc_scsi_q.q2.srb_ptr = ASC_VADDR_TO_U32(scp);
6711
6712
6713
6714
6715
6716
6717
6718 if (scp->cmd_len > ASC_MAX_CDB_LEN) {
6719 ASC_PRINT3(
6720"asc_build_req: board %d: cmd_len %d > ASC_MAX_CDB_LEN %d\n",
6721 boardp->id, scp->cmd_len, ASC_MAX_CDB_LEN);
6722 scp->result = HOST_BYTE(DID_ERROR);
6723 asc_enqueue(&boardp->done, scp, ASC_BACK);
6724 return ASC_ERROR;
6725 }
6726 asc_scsi_q.cdbptr = &scp->cmnd[0];
6727 asc_scsi_q.q2.cdb_len = scp->cmd_len;
6728 asc_scsi_q.q1.target_id = ASC_TID_TO_TARGET_ID(scp->target);
6729 asc_scsi_q.q1.target_lun = scp->lun;
6730 asc_scsi_q.q2.target_ix = ASC_TIDLUN_TO_IX(scp->target, scp->lun);
6731 asc_scsi_q.q1.sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
6732 asc_scsi_q.q1.sense_len = sizeof(scp->sense_buffer);
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745 if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->target] > 0) &&
6746 (boardp->reqcnt[scp->target] % 255) == 0) {
6747 asc_scsi_q.q2.tag_code = M2_QTAG_MSG_ORDERED;
6748 } else {
6749 asc_scsi_q.q2.tag_code = M2_QTAG_MSG_SIMPLE;
6750 }
6751
6752
6753
6754
6755
6756 if (scp->use_sg == 0) {
6757
6758
6759
6760 ASC_STATS(scp->host, cont_cnt);
6761 asc_scsi_q.q1.data_addr =
6762 cpu_to_le32(virt_to_bus(scp->request_buffer));
6763 asc_scsi_q.q1.data_cnt = cpu_to_le32(scp->request_bufflen);
6764 ASC_STATS_ADD(scp->host, cont_xfer,
6765 ASC_CEILING(scp->request_bufflen, 512));
6766 asc_scsi_q.q1.sg_queue_cnt = 0;
6767 asc_scsi_q.sg_head = NULL;
6768 } else {
6769
6770
6771
6772 int sgcnt;
6773 struct scatterlist *slp;
6774
6775 if (scp->use_sg > scp->host->sg_tablesize) {
6776 ASC_PRINT3(
6777"asc_build_req: board %d: use_sg %d > sg_tablesize %d\n",
6778 boardp->id, scp->use_sg, scp->host->sg_tablesize);
6779 scp->result = HOST_BYTE(DID_ERROR);
6780 asc_enqueue(&boardp->done, scp, ASC_BACK);
6781 return ASC_ERROR;
6782 }
6783
6784 ASC_STATS(scp->host, sg_cnt);
6785
6786
6787
6788
6789
6790 memset(&asc_sg_head, 0, sizeof(ASC_SG_HEAD));
6791
6792 asc_scsi_q.q1.cntl |= QC_SG_HEAD;
6793 asc_scsi_q.sg_head = &asc_sg_head;
6794 asc_scsi_q.q1.data_cnt = 0;
6795 asc_scsi_q.q1.data_addr = 0;
6796
6797 asc_sg_head.entry_cnt = asc_scsi_q.q1.sg_queue_cnt = scp->use_sg;
6798 ASC_STATS_ADD(scp->host, sg_elem, asc_sg_head.entry_cnt);
6799
6800
6801
6802
6803 slp = (struct scatterlist *) scp->request_buffer;
6804 for (sgcnt = 0; sgcnt < scp->use_sg; sgcnt++, slp++) {
6805 asc_sg_head.sg_list[sgcnt].addr =
6806 cpu_to_le32(virt_to_bus(slp->address));
6807 asc_sg_head.sg_list[sgcnt].bytes = cpu_to_le32(slp->length);
6808 ASC_STATS_ADD(scp->host, sg_xfer, ASC_CEILING(slp->length, 512));
6809 }
6810 }
6811
6812 ASC_DBG_PRT_ASC_SCSI_Q(2, &asc_scsi_q);
6813 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
6814
6815 return ASC_NOERROR;
6816}
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828STATIC int
6829adv_build_req(asc_board_t *boardp, Scsi_Cmnd *scp,
6830 ADV_SCSI_REQ_Q **adv_scsiqpp)
6831{
6832 adv_req_t *reqp;
6833 ADV_SCSI_REQ_Q *scsiqp;
6834 int i;
6835 int ret;
6836
6837
6838
6839
6840
6841 if (boardp->adv_reqp == NULL) {
6842 ASC_DBG(1, "adv_build_req: no free adv_req_t\n");
6843 ASC_STATS(scp->host, adv_build_noreq);
6844 return ASC_BUSY;
6845 } else {
6846 reqp = boardp->adv_reqp;
6847 boardp->adv_reqp = reqp->next_reqp;
6848 reqp->next_reqp = NULL;
6849 }
6850
6851
6852
6853
6854 scsiqp = (ADV_SCSI_REQ_Q *) ADV_32BALIGN(&reqp->scsi_req_q);
6855
6856
6857
6858
6859 scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
6860
6861
6862
6863
6864 scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
6865
6866
6867
6868
6869 reqp->cmndp = scp;
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880 if (scp->cmd_len > ADV_MAX_CDB_LEN) {
6881 ASC_PRINT3(
6882"adv_build_req: board %d: cmd_len %d > ADV_MAX_CDB_LEN %d\n",
6883 boardp->id, scp->cmd_len, ADV_MAX_CDB_LEN);
6884 scp->result = HOST_BYTE(DID_ERROR);
6885 asc_enqueue(&boardp->done, scp, ASC_BACK);
6886 return ASC_ERROR;
6887 }
6888 scsiqp->cdb_len = scp->cmd_len;
6889
6890 for (i = 0; i < scp->cmd_len && i < 12; i++) {
6891 scsiqp->cdb[i] = scp->cmnd[i];
6892 }
6893
6894 for (; i < scp->cmd_len; i++) {
6895 scsiqp->cdb16[i - 12] = scp->cmnd[i];
6896 }
6897
6898 scsiqp->target_id = scp->target;
6899 scsiqp->target_lun = scp->lun;
6900
6901 scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
6902 scsiqp->sense_len = sizeof(scp->sense_buffer);
6903
6904
6905
6906
6907
6908 scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
6909 scsiqp->vdata_addr = scp->request_buffer;
6910 scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
6911
6912 if (scp->use_sg == 0) {
6913
6914
6915
6916 reqp->sgblkp = NULL;
6917 scsiqp->sg_list_ptr = NULL;
6918 scsiqp->sg_real_addr = 0;
6919 ASC_STATS(scp->host, cont_cnt);
6920 ASC_STATS_ADD(scp->host, cont_xfer,
6921 ASC_CEILING(scp->request_bufflen, 512));
6922 } else {
6923
6924
6925
6926 if (scp->use_sg > ADV_MAX_SG_LIST) {
6927 ASC_PRINT3(
6928"adv_build_req: board %d: use_sg %d > ADV_MAX_SG_LIST %d\n",
6929 boardp->id, scp->use_sg, scp->host->sg_tablesize);
6930 scp->result = HOST_BYTE(DID_ERROR);
6931 asc_enqueue(&boardp->done, scp, ASC_BACK);
6932
6933
6934
6935
6936
6937 reqp->next_reqp = boardp->adv_reqp;
6938 boardp->adv_reqp = reqp;
6939
6940 return ASC_ERROR;
6941 }
6942
6943 if ((ret = adv_get_sglist(boardp, reqp, scp)) != ADV_SUCCESS) {
6944
6945
6946
6947
6948 reqp->next_reqp = boardp->adv_reqp;
6949 boardp->adv_reqp = reqp;
6950
6951 return ret;
6952 }
6953
6954 ASC_STATS(scp->host, sg_cnt);
6955 ASC_STATS_ADD(scp->host, sg_elem, scp->use_sg);
6956 }
6957
6958 ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
6959 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
6960
6961 *adv_scsiqpp = scsiqp;
6962
6963 return ASC_NOERROR;
6964}
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978STATIC int
6979adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, Scsi_Cmnd *scp)
6980{
6981 adv_sgblk_t *sgblkp;
6982 ADV_SCSI_REQ_Q *scsiqp;
6983 struct scatterlist *slp;
6984 int sg_elem_cnt;
6985 ADV_SG_BLOCK *sg_block, *prev_sg_block;
6986 ADV_PADDR sg_block_paddr;
6987 int i;
6988
6989 scsiqp = (ADV_SCSI_REQ_Q *) ADV_32BALIGN(&reqp->scsi_req_q);
6990 slp = (struct scatterlist *) scp->request_buffer;
6991 sg_elem_cnt = scp->use_sg;
6992 prev_sg_block = NULL;
6993 reqp->sgblkp = NULL;
6994
6995 do
6996 {
6997
6998
6999
7000
7001
7002 if ((sgblkp = boardp->adv_sgblkp) == NULL) {
7003 ASC_DBG(1, "adv_get_sglist: no free adv_sgblk_t\n");
7004 ASC_STATS(scp->host, adv_build_nosg);
7005
7006
7007
7008
7009
7010 while ((sgblkp = reqp->sgblkp) != NULL)
7011 {
7012
7013 reqp->sgblkp = sgblkp->next_sgblkp;
7014
7015
7016 sgblkp->next_sgblkp = boardp->adv_sgblkp;
7017 boardp->adv_sgblkp = sgblkp;
7018 }
7019 return ASC_BUSY;
7020 } else {
7021
7022 boardp->adv_sgblkp = sgblkp->next_sgblkp;
7023 sgblkp->next_sgblkp = NULL;
7024
7025
7026
7027
7028
7029 sg_block = (ADV_SG_BLOCK *) ADV_8BALIGN(&sgblkp->sg_block);
7030 sg_block_paddr = virt_to_bus(sg_block);
7031
7032
7033
7034
7035 if (reqp->sgblkp == NULL)
7036 {
7037
7038 reqp->sgblkp = sgblkp;
7039
7040
7041
7042
7043
7044 scsiqp->sg_list_ptr = sg_block;
7045 scsiqp->sg_real_addr = cpu_to_le32(sg_block_paddr);
7046 } else
7047 {
7048
7049 sgblkp->next_sgblkp = reqp->sgblkp;
7050 reqp->sgblkp = sgblkp;
7051
7052
7053
7054
7055
7056 ASC_ASSERT(prev_sg_block != NULL);
7057 prev_sg_block->sg_ptr = cpu_to_le32(sg_block_paddr);
7058 }
7059 }
7060
7061 for (i = 0; i < NO_OF_SG_PER_BLOCK; i++)
7062 {
7063 sg_block->sg_list[i].sg_addr =
7064 cpu_to_le32(virt_to_bus(slp->address));
7065 sg_block->sg_list[i].sg_count = cpu_to_le32(slp->length);
7066 ASC_STATS_ADD(scp->host, sg_xfer, ASC_CEILING(slp->length, 512));
7067
7068 if (--sg_elem_cnt == 0)
7069 {
7070 sg_block->sg_cnt = i + 1;
7071 sg_block->sg_ptr = 0L;
7072 return ADV_SUCCESS;
7073 }
7074 slp++;
7075 }
7076 sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
7077 prev_sg_block = sg_block;
7078 }
7079 while (1);
7080
7081}
7082
7083
7084
7085
7086
7087
7088STATIC void
7089asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
7090{
7091 asc_board_t *boardp;
7092 Scsi_Cmnd *scp;
7093 struct Scsi_Host *shp;
7094 int i;
7095
7096 ASC_DBG2(1, "asc_isr_callback: asc_dvc_varp 0x%lx, qdonep 0x%lx\n",
7097 (ulong) asc_dvc_varp, (ulong) qdonep);
7098 ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
7099
7100
7101
7102
7103
7104 scp = (Scsi_Cmnd *) ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
7105 ASC_DBG1(1, "asc_isr_callback: scp 0x%lx\n", (ulong) scp);
7106
7107 if (scp == NULL) {
7108 ASC_PRINT("asc_isr_callback: scp is NULL\n");
7109 return;
7110 }
7111 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
7112
7113
7114
7115
7116
7117 shp = scp->host;
7118 for (i = 0; i < asc_board_count; i++) {
7119 if (asc_host[i] == shp) {
7120 break;
7121 }
7122 }
7123 if (i == asc_board_count) {
7124 ASC_PRINT2(
7125 "asc_isr_callback: scp 0x%lx has bad host pointer, host 0x%lx\n",
7126 (ulong) scp, (ulong) shp);
7127 return;
7128 }
7129
7130 ASC_STATS(shp, callback);
7131 ASC_DBG1(1, "asc_isr_callback: shp 0x%lx\n", (ulong) shp);
7132
7133
7134
7135
7136
7137
7138 boardp = ASC_BOARDP(shp);
7139 ASC_ASSERT(asc_dvc_varp == &boardp->dvc_var.asc_dvc_var);
7140 if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) {
7141 ASC_PRINT2(
7142 "asc_isr_callback: board %d: scp 0x%lx not on active queue\n",
7143 boardp->id, (ulong) scp);
7144 return;
7145 }
7146
7147
7148
7149
7150 switch (qdonep->d3.done_stat) {
7151 case QD_NO_ERROR:
7152 ASC_DBG(2, "asc_isr_callback: QD_NO_ERROR\n");
7153 scp->result = 0;
7154
7155
7156
7157
7158
7159 if (scp->cmnd[0] == SCSICMD_Inquiry && scp->lun == 0 &&
7160 (scp->request_bufflen - qdonep->remain_bytes) >= 8)
7161 {
7162 AscInquiryHandling(asc_dvc_varp, scp->target & 0x7,
7163 (ASC_SCSI_INQUIRY *) scp->request_buffer);
7164 }
7165
7166#if ASC_LINUX_KERNEL24
7167
7168
7169
7170
7171
7172
7173 if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
7174 qdonep->remain_bytes <= scp->request_bufflen != 0) {
7175 ASC_DBG1(1, "asc_isr_callback: underrun condition %u bytes\n",
7176 (unsigned) qdonep->remain_bytes);
7177 scp->resid = qdonep->remain_bytes;
7178 }
7179#endif
7180 break;
7181
7182 case QD_WITH_ERROR:
7183 ASC_DBG(2, "asc_isr_callback: QD_WITH_ERROR\n");
7184 switch (qdonep->d3.host_stat) {
7185 case QHSTA_NO_ERROR:
7186 if (qdonep->d3.scsi_stat == SS_CHK_CONDITION) {
7187 ASC_DBG(2, "asc_isr_callback: SS_CHK_CONDITION\n");
7188 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
7189 sizeof(scp->sense_buffer));
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200 scp->result = DRIVER_BYTE(DRIVER_SENSE) |
7201 STATUS_BYTE(qdonep->d3.scsi_stat);
7202 } else {
7203 scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
7204 }
7205 break;
7206
7207 default:
7208
7209 ASC_DBG1(1, "asc_isr_callback: host_stat 0x%x\n",
7210 qdonep->d3.host_stat);
7211 scp->result = HOST_BYTE(DID_BAD_TARGET);
7212 break;
7213 }
7214 break;
7215
7216 case QD_ABORTED_BY_HOST:
7217 ASC_DBG(1, "asc_isr_callback: QD_ABORTED_BY_HOST\n");
7218 scp->result = HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.scsi_msg) |
7219 STATUS_BYTE(qdonep->d3.scsi_stat);
7220 break;
7221
7222 default:
7223 ASC_DBG1(1, "asc_isr_callback: done_stat 0x%x\n", qdonep->d3.done_stat);
7224 scp->result = HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.scsi_msg) |
7225 STATUS_BYTE(qdonep->d3.scsi_stat);
7226 break;
7227 }
7228
7229
7230
7231
7232
7233
7234 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->target)) == 0 &&
7235 qdonep->d3.done_stat == QD_NO_ERROR &&
7236 qdonep->d3.host_stat == QHSTA_NO_ERROR) {
7237 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->target);
7238 }
7239
7240
7241
7242
7243
7244
7245
7246 asc_enqueue(&boardp->done, scp, ASC_BACK);
7247
7248 return;
7249}
7250
7251
7252
7253
7254
7255
7256STATIC void
7257adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
7258{
7259 asc_board_t *boardp;
7260 adv_req_t *reqp;
7261 adv_sgblk_t *sgblkp;
7262 Scsi_Cmnd *scp;
7263 struct Scsi_Host *shp;
7264 int i;
7265#if ASC_LINUX_KERNEL24
7266 ADV_DCNT resid_cnt;
7267#endif
7268
7269
7270 ASC_DBG2(1, "adv_isr_callback: adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
7271 (ulong) adv_dvc_varp, (ulong) scsiqp);
7272 ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
7273
7274
7275
7276
7277
7278
7279 reqp = (adv_req_t *) ADV_U32_TO_VADDR(scsiqp->srb_ptr);
7280 ASC_DBG1(1, "adv_isr_callback: reqp 0x%lx\n", (ulong) reqp);
7281 if (reqp == NULL) {
7282 ASC_PRINT("adv_isr_callback: reqp is NULL\n");
7283 return;
7284 }
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294 scp = reqp->cmndp;
7295 ASC_DBG1(1, "adv_isr_callback: scp 0x%lx\n", (ulong) scp);
7296 if (scp == NULL) {
7297 ASC_PRINT("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
7298 return;
7299 }
7300 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
7301
7302
7303
7304
7305
7306 shp = scp->host;
7307 for (i = 0; i < asc_board_count; i++) {
7308 if (asc_host[i] == shp) {
7309 break;
7310 }
7311 }
7312
7313
7314
7315
7316 if (i == asc_board_count) {
7317 ASC_PRINT2(
7318 "adv_isr_callback: scp 0x%lx has bad host pointer, host 0x%lx\n",
7319 (ulong) scp, (ulong) shp);
7320 return;
7321 }
7322
7323 ASC_STATS(shp, callback);
7324 ASC_DBG1(1, "adv_isr_callback: shp 0x%lx\n", (ulong) shp);
7325
7326
7327
7328
7329
7330
7331
7332
7333 boardp = ASC_BOARDP(shp);
7334 ASC_ASSERT(adv_dvc_varp == &boardp->dvc_var.adv_dvc_var);
7335 if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) {
7336 ASC_PRINT2(
7337 "adv_isr_callback: board %d: scp 0x%lx not on active queue\n",
7338 boardp->id, (ulong) scp);
7339 return;
7340 }
7341
7342
7343
7344
7345 switch (scsiqp->done_status) {
7346 case QD_NO_ERROR:
7347 ASC_DBG(2, "adv_isr_callback: QD_NO_ERROR\n");
7348 scp->result = 0;
7349
7350#if ASC_LINUX_KERNEL24
7351
7352
7353
7354
7355
7356
7357 resid_cnt = le32_to_cpu(scsiqp->data_cnt);
7358 if (scp->request_bufflen != 0 && resid_cnt != 0 &&
7359 resid_cnt <= scp->request_bufflen) {
7360 ASC_DBG1(1, "adv_isr_callback: underrun condition %lu bytes\n",
7361 (ulong) resid_cnt);
7362 scp->resid = resid_cnt;
7363 }
7364#endif
7365 break;
7366
7367 case QD_WITH_ERROR:
7368 ASC_DBG(2, "adv_isr_callback: QD_WITH_ERROR\n");
7369 switch (scsiqp->host_status) {
7370 case QHSTA_NO_ERROR:
7371 if (scsiqp->scsi_status == SS_CHK_CONDITION) {
7372 ASC_DBG(2, "adv_isr_callback: SS_CHK_CONDITION\n");
7373 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
7374 sizeof(scp->sense_buffer));
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385 scp->result = DRIVER_BYTE(DRIVER_SENSE) |
7386 STATUS_BYTE(scsiqp->scsi_status);
7387 } else {
7388 scp->result = STATUS_BYTE(scsiqp->scsi_status);
7389 }
7390 break;
7391
7392 default:
7393
7394 ASC_DBG1(1, "adv_isr_callback: host_status 0x%x\n",
7395 scsiqp->host_status);
7396 scp->result = HOST_BYTE(DID_BAD_TARGET);
7397 break;
7398 }
7399 break;
7400
7401 case QD_ABORTED_BY_HOST:
7402 ASC_DBG(1, "adv_isr_callback: QD_ABORTED_BY_HOST\n");
7403 scp->result = HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
7404 break;
7405
7406 default:
7407 ASC_DBG1(1, "adv_isr_callback: done_status 0x%x\n", scsiqp->done_status);
7408 scp->result = HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
7409 break;
7410 }
7411
7412
7413
7414
7415
7416
7417 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->target)) == 0 &&
7418 scsiqp->done_status == QD_NO_ERROR &&
7419 scsiqp->host_status == QHSTA_NO_ERROR) {
7420 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->target);
7421 }
7422
7423
7424
7425
7426
7427
7428
7429 asc_enqueue(&boardp->done, scp, ASC_BACK);
7430
7431
7432
7433
7434 while ((sgblkp = reqp->sgblkp) != NULL)
7435 {
7436
7437 reqp->sgblkp = sgblkp->next_sgblkp;
7438
7439
7440 sgblkp->next_sgblkp = boardp->adv_sgblkp;
7441 boardp->adv_sgblkp = sgblkp;
7442 }
7443
7444
7445
7446
7447
7448 reqp->next_reqp = boardp->adv_reqp;
7449 boardp->adv_reqp = reqp;
7450
7451 ASC_DBG(1, "adv_isr_callback: done\n");
7452
7453 return;
7454}
7455
7456
7457
7458
7459STATIC void
7460adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
7461{
7462 switch (code)
7463 {
7464 case ADV_ASYNC_SCSI_BUS_RESET_DET:
7465
7466
7467
7468 ASC_DBG(0, "adv_async_callback: ADV_ASYNC_SCSI_BUS_RESET_DET\n");
7469 break;
7470
7471 case ADV_ASYNC_RDMA_FAILURE:
7472
7473
7474
7475
7476
7477 ASC_DBG(0, "adv_async_callback: ADV_ASYNC_RDMA_FAILURE\n");
7478 AdvResetChipAndSB(adv_dvc_varp);
7479 break;
7480
7481 case ADV_HOST_SCSI_BUS_RESET:
7482
7483
7484
7485 ASC_DBG(0, "adv_async_callback: ADV_HOST_SCSI_BUS_RESET\n");
7486 break;
7487
7488 default:
7489 ASC_DBG1(0, "DvcAsyncCallBack: unknown code 0x%x\n", code);
7490 break;
7491 }
7492}
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502STATIC void
7503asc_enqueue(asc_queue_t *ascq, REQP reqp, int flag)
7504{
7505 int tid;
7506
7507 ASC_DBG3(3, "asc_enqueue: ascq 0x%lx, reqp 0x%lx, flag %d\n",
7508 (ulong) ascq, (ulong) reqp, flag);
7509 ASC_ASSERT(reqp != NULL);
7510 ASC_ASSERT(flag == ASC_FRONT || flag == ASC_BACK);
7511 tid = REQPTID(reqp);
7512 ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
7513 if (flag == ASC_FRONT) {
7514 REQPNEXT(reqp) = ascq->q_first[tid];
7515 ascq->q_first[tid] = reqp;
7516
7517 if (ascq->q_last[tid] == NULL) {
7518 ascq->q_last[tid] = reqp;
7519 }
7520 } else {
7521 if (ascq->q_last[tid] != NULL) {
7522 REQPNEXT(ascq->q_last[tid]) = reqp;
7523 }
7524 ascq->q_last[tid] = reqp;
7525 REQPNEXT(reqp) = NULL;
7526
7527 if (ascq->q_first[tid] == NULL) {
7528 ascq->q_first[tid] = reqp;
7529 }
7530 }
7531
7532 ascq->q_tidmask |= ADV_TID_TO_TIDMASK(tid);
7533#ifdef ADVANSYS_STATS
7534
7535 ascq->q_tot_cnt[tid]++;
7536 ascq->q_cur_cnt[tid]++;
7537 if (ascq->q_cur_cnt[tid] > ascq->q_max_cnt[tid]) {
7538 ascq->q_max_cnt[tid] = ascq->q_cur_cnt[tid];
7539 ASC_DBG2(2, "asc_enqueue: new q_max_cnt[%d] %d\n",
7540 tid, ascq->q_max_cnt[tid]);
7541 }
7542 REQPTIME(reqp) = REQTIMESTAMP();
7543#endif
7544 ASC_DBG1(3, "asc_enqueue: reqp 0x%lx\n", (ulong) reqp);
7545 return;
7546}
7547
7548
7549
7550
7551
7552
7553
7554
7555STATIC REQP
7556asc_dequeue(asc_queue_t *ascq, int tid)
7557{
7558 REQP reqp;
7559
7560 ASC_DBG2(3, "asc_dequeue: ascq 0x%lx, tid %d\n", (ulong) ascq, tid);
7561 ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
7562 if ((reqp = ascq->q_first[tid]) != NULL) {
7563 ASC_ASSERT(ascq->q_tidmask & ADV_TID_TO_TIDMASK(tid));
7564 ascq->q_first[tid] = REQPNEXT(reqp);
7565
7566 if (ascq->q_first[tid] == NULL) {
7567 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
7568 ASC_ASSERT(ascq->q_last[tid] == reqp);
7569 ascq->q_last[tid] = NULL;
7570 }
7571#ifdef ADVANSYS_STATS
7572
7573 ascq->q_cur_cnt[tid]--;
7574 ASC_ASSERT(ascq->q_cur_cnt[tid] >= 0);
7575 REQTIMESTAT("asc_dequeue", ascq, reqp, tid);
7576#endif
7577 }
7578 ASC_DBG1(3, "asc_dequeue: reqp 0x%lx\n", (ulong) reqp);
7579 return reqp;
7580}
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602STATIC REQP
7603asc_dequeue_list(asc_queue_t *ascq, REQP *lastpp, int tid)
7604{
7605 REQP firstp, lastp;
7606 int i;
7607
7608 ASC_DBG2(3, "asc_dequeue_list: ascq 0x%lx, tid %d\n", (ulong) ascq, tid);
7609 ASC_ASSERT((tid == ASC_TID_ALL) || (tid >= 0 && tid <= ADV_MAX_TID));
7610
7611
7612
7613
7614
7615
7616 if (tid != ASC_TID_ALL) {
7617
7618 if ((ascq->q_tidmask & ADV_TID_TO_TIDMASK(tid)) == 0) {
7619
7620 firstp = lastp = NULL;
7621 } else {
7622 firstp = ascq->q_first[tid];
7623 lastp = ascq->q_last[tid];
7624 ascq->q_first[tid] = ascq->q_last[tid] = NULL;
7625 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
7626#ifdef ADVANSYS_STATS
7627 {
7628 REQP reqp;
7629 ascq->q_cur_cnt[tid] = 0;
7630 for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) {
7631 REQTIMESTAT("asc_dequeue_list", ascq, reqp, tid);
7632 }
7633 }
7634#endif
7635 }
7636 } else {
7637
7638 firstp = lastp = NULL;
7639 for (i = 0; i <= ADV_MAX_TID; i++) {
7640 if (ascq->q_tidmask & ADV_TID_TO_TIDMASK(i)) {
7641 if (firstp == NULL) {
7642 firstp = ascq->q_first[i];
7643 lastp = ascq->q_last[i];
7644 } else {
7645 ASC_ASSERT(lastp != NULL);
7646 REQPNEXT(lastp) = ascq->q_first[i];
7647 lastp = ascq->q_last[i];
7648 }
7649 ascq->q_first[i] = ascq->q_last[i] = NULL;
7650 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(i);
7651#ifdef ADVANSYS_STATS
7652 ascq->q_cur_cnt[i] = 0;
7653#endif
7654 }
7655 }
7656#ifdef ADVANSYS_STATS
7657 {
7658 REQP reqp;
7659 for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) {
7660 REQTIMESTAT("asc_dequeue_list", ascq, reqp, reqp->target);
7661 }
7662 }
7663#endif
7664 }
7665 if (lastpp) {
7666 *lastpp = lastp;
7667 }
7668 ASC_DBG1(3, "asc_dequeue_list: firstp 0x%lx\n", (ulong) firstp);
7669 return firstp;
7670}
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682STATIC int
7683asc_rmqueue(asc_queue_t *ascq, REQP reqp)
7684{
7685 REQP currp, prevp;
7686 int tid;
7687 int ret = ASC_FALSE;
7688
7689 ASC_DBG2(3, "asc_rmqueue: ascq 0x%lx, reqp 0x%lx\n",
7690 (ulong) ascq, (ulong) reqp);
7691 ASC_ASSERT(reqp != NULL);
7692
7693 tid = REQPTID(reqp);
7694 ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
7695
7696
7697
7698
7699
7700 if (reqp == ascq->q_first[tid]) {
7701 ret = ASC_TRUE;
7702 ascq->q_first[tid] = REQPNEXT(reqp);
7703
7704 if (ascq->q_first[tid] == NULL) {
7705 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
7706 ASC_ASSERT(ascq->q_last[tid] == reqp);
7707 ascq->q_last[tid] = NULL;
7708 }
7709 } else if (ascq->q_first[tid] != NULL) {
7710 ASC_ASSERT(ascq->q_last[tid] != NULL);
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720 for (prevp = ascq->q_first[tid], currp = REQPNEXT(prevp);
7721 currp; prevp = currp, currp = REQPNEXT(currp)) {
7722 if (currp == reqp) {
7723 ret = ASC_TRUE;
7724 REQPNEXT(prevp) = REQPNEXT(currp);
7725 REQPNEXT(reqp) = NULL;
7726 if (ascq->q_last[tid] == reqp) {
7727 ascq->q_last[tid] = prevp;
7728 }
7729 break;
7730 }
7731 }
7732 }
7733#ifdef ADVANSYS_STATS
7734
7735 if (ret == ASC_TRUE) {
7736 ascq->q_cur_cnt[tid]--;
7737 REQTIMESTAT("asc_rmqueue", ascq, reqp, tid);
7738 }
7739 ASC_ASSERT(ascq->q_cur_cnt[tid] >= 0);
7740#endif
7741 ASC_DBG2(3, "asc_rmqueue: reqp 0x%lx, ret %d\n", (ulong) reqp, ret);
7742 return ret;
7743}
7744
7745
7746
7747
7748
7749
7750STATIC void
7751asc_execute_queue(asc_queue_t *ascq)
7752{
7753 ADV_SCSI_BIT_ID_TYPE scan_tidmask;
7754 REQP reqp;
7755 int i;
7756
7757 ASC_DBG1(1, "asc_execute_queue: ascq 0x%lx\n", (ulong) ascq);
7758
7759
7760
7761
7762 scan_tidmask = ascq->q_tidmask;
7763 do {
7764 for (i = 0; i <= ADV_MAX_TID; i++) {
7765 if (scan_tidmask & ADV_TID_TO_TIDMASK(i)) {
7766 if ((reqp = asc_dequeue(ascq, i)) == NULL) {
7767 scan_tidmask &= ~ADV_TID_TO_TIDMASK(i);
7768 } else if (asc_execute_scsi_cmnd((Scsi_Cmnd *) reqp)
7769 == ASC_BUSY) {
7770 scan_tidmask &= ~ADV_TID_TO_TIDMASK(i);
7771
7772
7773
7774
7775 asc_enqueue(ascq, reqp, ASC_FRONT);
7776 }
7777 }
7778 }
7779 } while (scan_tidmask);
7780 return;
7781}
7782
7783#ifdef CONFIG_PROC_FS
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795STATIC int
7796asc_prt_board_devices(struct Scsi_Host *shp, char *cp, int cplen)
7797{
7798 asc_board_t *boardp;
7799 int leftlen;
7800 int totlen;
7801 int len;
7802 int chip_scsi_id;
7803 int i;
7804
7805 boardp = ASC_BOARDP(shp);
7806 leftlen = cplen;
7807 totlen = len = 0;
7808
7809 len = asc_prt_line(cp, leftlen,
7810"\nDevice Information for AdvanSys SCSI Host %d:\n", shp->host_no);
7811 ASC_PRT_NEXT();
7812
7813 if (ASC_NARROW_BOARD(boardp)) {
7814 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
7815 } else {
7816 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
7817 }
7818
7819 len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
7820 ASC_PRT_NEXT();
7821 for (i = 0; i <= ADV_MAX_TID; i++) {
7822 if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
7823 len = asc_prt_line(cp, leftlen, " %X,", i);
7824 ASC_PRT_NEXT();
7825 }
7826 }
7827 len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
7828 ASC_PRT_NEXT();
7829
7830 return totlen;
7831}
7832
7833
7834
7835
7836STATIC int
7837asc_prt_adv_bios(struct Scsi_Host *shp, char *cp, int cplen)
7838{
7839 asc_board_t *boardp;
7840 int leftlen;
7841 int totlen;
7842 int len;
7843 ushort major, minor, letter;
7844
7845 boardp = ASC_BOARDP(shp);
7846 leftlen = cplen;
7847 totlen = len = 0;
7848
7849 len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
7850 ASC_PRT_NEXT();
7851
7852
7853
7854
7855
7856 if (boardp->bios_signature != 0x55AA) {
7857 len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
7858 ASC_PRT_NEXT();
7859 len = asc_prt_line(cp, leftlen,
7860"BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
7861 ASC_PRT_NEXT();
7862 len = asc_prt_line(cp, leftlen,
7863"can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
7864 ASC_PRT_NEXT();
7865 } else {
7866 major = (boardp->bios_version >> 12) & 0xF;
7867 minor = (boardp->bios_version >> 8) & 0xF;
7868 letter = (boardp->bios_version & 0xFF);
7869
7870 len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
7871 major, minor, letter >= 26 ? '?' : letter + 'A');
7872 ASC_PRT_NEXT();
7873
7874
7875
7876
7877
7878
7879 if (major < 3 || (major <= 3 && minor < 1) ||
7880 (major <= 3 && minor <= 1 && letter < ('I'- 'A'))) {
7881 len = asc_prt_line(cp, leftlen,
7882"Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
7883 ASC_PRT_NEXT();
7884 len = asc_prt_line(cp, leftlen,
7885"ftp://ftp.connectcom.net/pub\n");
7886 ASC_PRT_NEXT();
7887 }
7888 }
7889
7890 return totlen;
7891}
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916STATIC int
7917asc_get_eeprom_string(ushort *serialnum, uchar *cp)
7918{
7919 ushort w, num;
7920
7921 if ((serialnum[1] & 0xFE00) != ((ushort) 0xAA << 8)) {
7922 return ASC_FALSE;
7923 } else {
7924
7925
7926
7927 w = serialnum[0];
7928
7929
7930 if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
7931
7932 *cp += 0x8;
7933 }
7934 cp++;
7935
7936
7937 *cp++ = 'A' + ((w & 0x1C00) >> 10);
7938
7939
7940 num = w & 0x3FF;
7941 *cp++ = '0' + (num / 100);
7942 num %= 100;
7943 *cp++ = '0' + (num / 10);
7944
7945
7946 *cp++ = 'A' + (num % 10);
7947
7948
7949
7950
7951 w = serialnum[1];
7952
7953
7954
7955
7956
7957
7958
7959 if (serialnum[2] & 0x8000) {
7960 *cp++ = '8' + ((w & 0x1C0) >> 6);
7961 } else {
7962 *cp++ = '0' + ((w & 0x1C0) >> 6);
7963 }
7964
7965
7966 num = w & 0x003F;
7967 *cp++ = '0' + num / 10;
7968 num %= 10;
7969 *cp++ = '0' + num;
7970
7971
7972
7973
7974 w = serialnum[2] & 0x7FFF;
7975
7976
7977 *cp++ = 'A' + (w / 1000);
7978
7979
7980 num = w % 1000;
7981 *cp++ = '0' + num / 100;
7982 num %= 100;
7983 *cp++ = '0' + num / 10;
7984 num %= 10;
7985 *cp++ = '0' + num;
7986
7987 *cp = '\0';
7988 return ASC_TRUE;
7989 }
7990}
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003STATIC int
8004asc_prt_asc_board_eeprom(struct Scsi_Host *shp, char *cp, int cplen)
8005{
8006 asc_board_t *boardp;
8007 ASC_DVC_VAR *asc_dvc_varp;
8008 int leftlen;
8009 int totlen;
8010 int len;
8011 ASCEEP_CONFIG *ep;
8012 int i;
8013#ifdef CONFIG_ISA
8014 int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
8015#endif
8016 uchar serialstr[13];
8017
8018 boardp = ASC_BOARDP(shp);
8019 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
8020 ep = &boardp->eep_config.asc_eep;
8021
8022 leftlen = cplen;
8023 totlen = len = 0;
8024
8025 len = asc_prt_line(cp, leftlen,
8026"\nEEPROM Settings for AdvanSys SCSI Host %d:\n", shp->host_no);
8027 ASC_PRT_NEXT();
8028
8029 if (asc_get_eeprom_string((ushort *) &ep->adapter_info[0], serialstr) ==
8030 ASC_TRUE) {
8031 len = asc_prt_line(cp, leftlen, " Serial Number: %s\n", serialstr);
8032 ASC_PRT_NEXT();
8033 } else {
8034 if (ep->adapter_info[5] == 0xBB) {
8035 len = asc_prt_line(cp, leftlen,
8036 " Default Settings Used for EEPROM-less Adapter.\n");
8037 ASC_PRT_NEXT();
8038 } else {
8039 len = asc_prt_line(cp, leftlen,
8040 " Serial Number Signature Not Present.\n");
8041 ASC_PRT_NEXT();
8042 }
8043 }
8044
8045 len = asc_prt_line(cp, leftlen,
8046" Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
8047 ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng, ep->max_tag_qng);
8048 ASC_PRT_NEXT();
8049
8050 len = asc_prt_line(cp, leftlen,
8051" cntl 0x%x, no_scam 0x%x\n",
8052 ep->cntl, ep->no_scam);
8053 ASC_PRT_NEXT();
8054
8055 len = asc_prt_line(cp, leftlen,
8056" Target ID: ");
8057 ASC_PRT_NEXT();
8058 for (i = 0; i <= ASC_MAX_TID; i++) {
8059 len = asc_prt_line(cp, leftlen, " %d", i);
8060 ASC_PRT_NEXT();
8061 }
8062 len = asc_prt_line(cp, leftlen, "\n");
8063 ASC_PRT_NEXT();
8064
8065 len = asc_prt_line(cp, leftlen,
8066" Disconnects: ");
8067 ASC_PRT_NEXT();
8068 for (i = 0; i <= ASC_MAX_TID; i++) {
8069 len = asc_prt_line(cp, leftlen, " %c",
8070 (ep->disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8071 ASC_PRT_NEXT();
8072 }
8073 len = asc_prt_line(cp, leftlen, "\n");
8074 ASC_PRT_NEXT();
8075
8076 len = asc_prt_line(cp, leftlen,
8077" Command Queuing: ");
8078 ASC_PRT_NEXT();
8079 for (i = 0; i <= ASC_MAX_TID; i++) {
8080 len = asc_prt_line(cp, leftlen, " %c",
8081 (ep->use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8082 ASC_PRT_NEXT();
8083 }
8084 len = asc_prt_line(cp, leftlen, "\n");
8085 ASC_PRT_NEXT();
8086
8087 len = asc_prt_line(cp, leftlen,
8088" Start Motor: ");
8089 ASC_PRT_NEXT();
8090 for (i = 0; i <= ASC_MAX_TID; i++) {
8091 len = asc_prt_line(cp, leftlen, " %c",
8092 (ep->start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8093 ASC_PRT_NEXT();
8094 }
8095 len = asc_prt_line(cp, leftlen, "\n");
8096 ASC_PRT_NEXT();
8097
8098 len = asc_prt_line(cp, leftlen,
8099" Synchronous Transfer:");
8100 ASC_PRT_NEXT();
8101 for (i = 0; i <= ASC_MAX_TID; i++) {
8102 len = asc_prt_line(cp, leftlen, " %c",
8103 (ep->init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8104 ASC_PRT_NEXT();
8105 }
8106 len = asc_prt_line(cp, leftlen, "\n");
8107 ASC_PRT_NEXT();
8108
8109#ifdef CONFIG_ISA
8110 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
8111 len = asc_prt_line(cp, leftlen,
8112" Host ISA DMA speed: %d MB/S\n",
8113 isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
8114 ASC_PRT_NEXT();
8115 }
8116#endif
8117
8118 return totlen;
8119}
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132STATIC int
8133asc_prt_adv_board_eeprom(struct Scsi_Host *shp, char *cp, int cplen)
8134{
8135 asc_board_t *boardp;
8136 ADV_DVC_VAR *adv_dvc_varp;
8137 int leftlen;
8138 int totlen;
8139 int len;
8140 int i;
8141 char *termstr;
8142 uchar serialstr[13];
8143 ADVEEP_3550_CONFIG *ep_3550 = NULL;
8144 ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
8145 ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
8146 ushort word;
8147 ushort *wordp;
8148 ushort sdtr_speed = 0;
8149
8150 boardp = ASC_BOARDP(shp);
8151 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
8152 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
8153 {
8154 ep_3550 = &boardp->eep_config.adv_3550_eep;
8155 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
8156 {
8157 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
8158 } else
8159 {
8160 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
8161 }
8162
8163 leftlen = cplen;
8164 totlen = len = 0;
8165
8166 len = asc_prt_line(cp, leftlen,
8167"\nEEPROM Settings for AdvanSys SCSI Host %d:\n", shp->host_no);
8168 ASC_PRT_NEXT();
8169
8170 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
8171 {
8172 wordp = &ep_3550->serial_number_word1;
8173 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
8174 {
8175 wordp = &ep_38C0800->serial_number_word1;
8176 } else
8177 {
8178 wordp = &ep_38C1600->serial_number_word1;
8179 }
8180
8181 if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
8182 len = asc_prt_line(cp, leftlen, " Serial Number: %s\n", serialstr);
8183 ASC_PRT_NEXT();
8184 } else {
8185 len = asc_prt_line(cp, leftlen,
8186 " Serial Number Signature Not Present.\n");
8187 ASC_PRT_NEXT();
8188 }
8189
8190 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
8191 {
8192 len = asc_prt_line(cp, leftlen,
8193" Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
8194 ep_3550->adapter_scsi_id, ep_3550->max_host_qng,
8195 ep_3550->max_dvc_qng);
8196 ASC_PRT_NEXT();
8197 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
8198 {
8199 len = asc_prt_line(cp, leftlen,
8200" Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
8201 ep_38C0800->adapter_scsi_id, ep_38C0800->max_host_qng,
8202 ep_38C0800->max_dvc_qng);
8203 ASC_PRT_NEXT();
8204 } else
8205 {
8206 len = asc_prt_line(cp, leftlen,
8207" Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
8208 ep_38C1600->adapter_scsi_id, ep_38C1600->max_host_qng,
8209 ep_38C1600->max_dvc_qng);
8210 ASC_PRT_NEXT();
8211 }
8212 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
8213 {
8214 word = ep_3550->termination;
8215 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
8216 {
8217 word = ep_38C0800->termination_lvd;
8218 } else
8219 {
8220 word = ep_38C1600->termination_lvd;
8221 }
8222 switch (word) {
8223 case 1:
8224 termstr = "Low Off/High Off";
8225 break;
8226 case 2:
8227 termstr = "Low Off/High On";
8228 break;
8229 case 3:
8230 termstr = "Low On/High On";
8231 break;
8232 default:
8233 case 0:
8234 termstr = "Automatic";
8235 break;
8236 }
8237
8238 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
8239 {
8240 len = asc_prt_line(cp, leftlen,
8241" termination: %u (%s), bios_ctrl: 0x%x\n",
8242 ep_3550->termination, termstr, ep_3550->bios_ctrl);
8243 ASC_PRT_NEXT();
8244 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
8245 {
8246 len = asc_prt_line(cp, leftlen,
8247" termination: %u (%s), bios_ctrl: 0x%x\n",
8248 ep_38C0800->termination_lvd, termstr, ep_38C0800->bios_ctrl);
8249 ASC_PRT_NEXT();
8250 } else
8251 {
8252 len = asc_prt_line(cp, leftlen,
8253" termination: %u (%s), bios_ctrl: 0x%x\n",
8254 ep_38C1600->termination_lvd, termstr, ep_38C1600->bios_ctrl);
8255 ASC_PRT_NEXT();
8256 }
8257
8258 len = asc_prt_line(cp, leftlen,
8259" Target ID: ");
8260 ASC_PRT_NEXT();
8261 for (i = 0; i <= ADV_MAX_TID; i++) {
8262 len = asc_prt_line(cp, leftlen, " %X", i);
8263 ASC_PRT_NEXT();
8264 }
8265 len = asc_prt_line(cp, leftlen, "\n");
8266 ASC_PRT_NEXT();
8267
8268 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
8269 {
8270 word = ep_3550->disc_enable;
8271 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
8272 {
8273 word = ep_38C0800->disc_enable;
8274 } else
8275 {
8276 word = ep_38C1600->disc_enable;
8277 }
8278 len = asc_prt_line(cp, leftlen,
8279" Disconnects: ");
8280 ASC_PRT_NEXT();
8281 for (i = 0; i <= ADV_MAX_TID; i++) {
8282 len = asc_prt_line(cp, leftlen, " %c",
8283 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8284 ASC_PRT_NEXT();
8285 }
8286 len = asc_prt_line(cp, leftlen, "\n");
8287 ASC_PRT_NEXT();
8288
8289 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
8290 {
8291 word = ep_3550->tagqng_able;
8292 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
8293 {
8294 word = ep_38C0800->tagqng_able;
8295 } else
8296 {
8297 word = ep_38C1600->tagqng_able;
8298 }
8299 len = asc_prt_line(cp, leftlen,
8300" Command Queuing: ");
8301 ASC_PRT_NEXT();
8302 for (i = 0; i <= ADV_MAX_TID; i++) {
8303 len = asc_prt_line(cp, leftlen, " %c",
8304 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8305 ASC_PRT_NEXT();
8306 }
8307 len = asc_prt_line(cp, leftlen, "\n");
8308 ASC_PRT_NEXT();
8309
8310 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
8311 {
8312 word = ep_3550->start_motor;
8313 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
8314 {
8315 word = ep_38C0800->start_motor;
8316 } else
8317 {
8318 word = ep_38C1600->start_motor;
8319 }
8320 len = asc_prt_line(cp, leftlen,
8321" Start Motor: ");
8322 ASC_PRT_NEXT();
8323 for (i = 0; i <= ADV_MAX_TID; i++) {
8324 len = asc_prt_line(cp, leftlen, " %c",
8325 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8326 ASC_PRT_NEXT();
8327 }
8328 len = asc_prt_line(cp, leftlen, "\n");
8329 ASC_PRT_NEXT();
8330
8331 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
8332 {
8333 len = asc_prt_line(cp, leftlen,
8334" Synchronous Transfer:");
8335 ASC_PRT_NEXT();
8336 for (i = 0; i <= ADV_MAX_TID; i++) {
8337 len = asc_prt_line(cp, leftlen, " %c",
8338 (ep_3550->sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8339 ASC_PRT_NEXT();
8340 }
8341 len = asc_prt_line(cp, leftlen, "\n");
8342 ASC_PRT_NEXT();
8343 }
8344
8345 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
8346 {
8347 len = asc_prt_line(cp, leftlen,
8348" Ultra Transfer: ");
8349 ASC_PRT_NEXT();
8350 for (i = 0; i <= ADV_MAX_TID; i++) {
8351 len = asc_prt_line(cp, leftlen, " %c",
8352 (ep_3550->ultra_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8353 ASC_PRT_NEXT();
8354 }
8355 len = asc_prt_line(cp, leftlen, "\n");
8356 ASC_PRT_NEXT();
8357 }
8358
8359 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
8360 {
8361 word = ep_3550->wdtr_able;
8362 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
8363 {
8364 word = ep_38C0800->wdtr_able;
8365 } else
8366 {
8367 word = ep_38C1600->wdtr_able;
8368 }
8369 len = asc_prt_line(cp, leftlen,
8370" Wide Transfer: ");
8371 ASC_PRT_NEXT();
8372 for (i = 0; i <= ADV_MAX_TID; i++) {
8373 len = asc_prt_line(cp, leftlen, " %c",
8374 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8375 ASC_PRT_NEXT();
8376 }
8377 len = asc_prt_line(cp, leftlen, "\n");
8378 ASC_PRT_NEXT();
8379
8380 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
8381 adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600)
8382 {
8383 len = asc_prt_line(cp, leftlen,
8384" Synchronous Transfer Speed (Mhz):\n ");
8385 ASC_PRT_NEXT();
8386 for (i = 0; i <= ADV_MAX_TID; i++) {
8387 char *speed_str;
8388
8389 if (i == 0)
8390 {
8391 sdtr_speed = adv_dvc_varp->sdtr_speed1;
8392 } else if (i == 4)
8393 {
8394 sdtr_speed = adv_dvc_varp->sdtr_speed2;
8395 } else if (i == 8)
8396 {
8397 sdtr_speed = adv_dvc_varp->sdtr_speed3;
8398 } else if (i == 12)
8399 {
8400 sdtr_speed = adv_dvc_varp->sdtr_speed4;
8401 }
8402 switch (sdtr_speed & ADV_MAX_TID)
8403 {
8404 case 0: speed_str = "Off"; break;
8405 case 1: speed_str = " 5"; break;
8406 case 2: speed_str = " 10"; break;
8407 case 3: speed_str = " 20"; break;
8408 case 4: speed_str = " 40"; break;
8409 case 5: speed_str = " 80"; break;
8410 default: speed_str = "Unk"; break;
8411 }
8412 len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
8413 ASC_PRT_NEXT();
8414 if (i == 7)
8415 {
8416 len = asc_prt_line(cp, leftlen, "\n ");
8417 ASC_PRT_NEXT();
8418 }
8419 sdtr_speed >>= 4;
8420 }
8421 len = asc_prt_line(cp, leftlen, "\n");
8422 ASC_PRT_NEXT();
8423 }
8424
8425 return totlen;
8426}
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437STATIC int
8438asc_prt_driver_conf(struct Scsi_Host *shp, char *cp, int cplen)
8439{
8440 asc_board_t *boardp;
8441 int leftlen;
8442 int totlen;
8443 int len;
8444 int chip_scsi_id;
8445 int i;
8446
8447 boardp = ASC_BOARDP(shp);
8448
8449 leftlen = cplen;
8450 totlen = len = 0;
8451
8452 len = asc_prt_line(cp, leftlen,
8453"\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
8454 shp->host_no);
8455 ASC_PRT_NEXT();
8456
8457 len = asc_prt_line(cp, leftlen,
8458" host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
8459 shp->host_busy, shp->last_reset, shp->max_id, shp->max_lun,
8460 shp->max_channel);
8461 ASC_PRT_NEXT();
8462
8463 len = asc_prt_line(cp, leftlen,
8464" unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
8465 shp->unique_id, shp->can_queue, shp->this_id, shp->sg_tablesize,
8466 shp->cmd_per_lun);
8467 ASC_PRT_NEXT();
8468
8469 len = asc_prt_line(cp, leftlen,
8470" unchecked_isa_dma %d, use_clustering %d, loaded_as_module %d\n",
8471 shp->unchecked_isa_dma, shp->use_clustering, shp->loaded_as_module);
8472 ASC_PRT_NEXT();
8473
8474 len = asc_prt_line(cp, leftlen,
8475" flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
8476 boardp->flags, boardp->last_reset, jiffies, boardp->asc_n_io_port);
8477 ASC_PRT_NEXT();
8478
8479
8480 len = asc_prt_line(cp, leftlen,
8481" io_port 0x%x, n_io_port 0x%x\n",
8482 shp->io_port, shp->n_io_port);
8483 ASC_PRT_NEXT();
8484
8485 if (ASC_NARROW_BOARD(boardp)) {
8486 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
8487 } else {
8488 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
8489 }
8490
8491 if (boardp->flags & ASC_SELECT_QUEUE_DEPTHS) {
8492 len = asc_prt_line(cp, leftlen, " queue_depth:");
8493 ASC_PRT_NEXT();
8494 for (i = 0; i <= ADV_MAX_TID; i++) {
8495 if ((chip_scsi_id == i) ||
8496 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8497 continue;
8498 }
8499 if (boardp->device[i] == NULL) {
8500 continue;
8501 }
8502 len = asc_prt_line(cp, leftlen, " %X:%d",
8503 i, boardp->device[i]->queue_depth);
8504 ASC_PRT_NEXT();
8505 }
8506 len = asc_prt_line(cp, leftlen, "\n");
8507 ASC_PRT_NEXT();
8508 }
8509
8510 return totlen;
8511}
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524STATIC int
8525asc_prt_asc_board_info(struct Scsi_Host *shp, char *cp, int cplen)
8526{
8527 asc_board_t *boardp;
8528 int chip_scsi_id;
8529 int leftlen;
8530 int totlen;
8531 int len;
8532 ASC_DVC_VAR *v;
8533 ASC_DVC_CFG *c;
8534 int i;
8535 int renegotiate = 0;
8536
8537 boardp = ASC_BOARDP(shp);
8538 v = &boardp->dvc_var.asc_dvc_var;
8539 c = &boardp->dvc_cfg.asc_dvc_cfg;
8540 chip_scsi_id = c->chip_scsi_id;
8541
8542 leftlen = cplen;
8543 totlen = len = 0;
8544
8545 len = asc_prt_line(cp, leftlen,
8546"\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
8547 shp->host_no);
8548 ASC_PRT_NEXT();
8549
8550 len = asc_prt_line(cp, leftlen,
8551" chip_version %u, lib_version 0x%x, lib_serial_no %u, mcode_date 0x%x\n",
8552 c->chip_version, c->lib_version, c->lib_serial_no, c->mcode_date);
8553 ASC_PRT_NEXT();
8554
8555 len = asc_prt_line(cp, leftlen,
8556" mcode_version 0x%x, err_code %u\n",
8557 c->mcode_version, v->err_code);
8558 ASC_PRT_NEXT();
8559
8560
8561 len = asc_prt_line(cp, leftlen,
8562" Total Command Pending: %d\n", v->cur_total_qng);
8563 ASC_PRT_NEXT();
8564
8565 len = asc_prt_line(cp, leftlen,
8566" Command Queuing:");
8567 ASC_PRT_NEXT();
8568 for (i = 0; i <= ASC_MAX_TID; i++) {
8569 if ((chip_scsi_id == i) ||
8570 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8571 continue;
8572 }
8573 len = asc_prt_line(cp, leftlen, " %X:%c",
8574 i, (v->use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8575 ASC_PRT_NEXT();
8576 }
8577 len = asc_prt_line(cp, leftlen, "\n");
8578 ASC_PRT_NEXT();
8579
8580
8581 len = asc_prt_line(cp, leftlen,
8582" Command Queue Pending:");
8583 ASC_PRT_NEXT();
8584 for (i = 0; i <= ASC_MAX_TID; i++) {
8585 if ((chip_scsi_id == i) ||
8586 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8587 continue;
8588 }
8589 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
8590 ASC_PRT_NEXT();
8591 }
8592 len = asc_prt_line(cp, leftlen, "\n");
8593 ASC_PRT_NEXT();
8594
8595
8596 len = asc_prt_line(cp, leftlen,
8597" Command Queue Limit:");
8598 ASC_PRT_NEXT();
8599 for (i = 0; i <= ASC_MAX_TID; i++) {
8600 if ((chip_scsi_id == i) ||
8601 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8602 continue;
8603 }
8604 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
8605 ASC_PRT_NEXT();
8606 }
8607 len = asc_prt_line(cp, leftlen, "\n");
8608 ASC_PRT_NEXT();
8609
8610
8611 len = asc_prt_line(cp, leftlen,
8612" Command Queue Full:");
8613 ASC_PRT_NEXT();
8614 for (i = 0; i <= ASC_MAX_TID; i++) {
8615 if ((chip_scsi_id == i) ||
8616 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8617 continue;
8618 }
8619 if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
8620 len = asc_prt_line(cp, leftlen, " %X:Y-%d",
8621 i, boardp->queue_full_cnt[i]);
8622 } else {
8623 len = asc_prt_line(cp, leftlen, " %X:N", i);
8624 }
8625 ASC_PRT_NEXT();
8626 }
8627 len = asc_prt_line(cp, leftlen, "\n");
8628 ASC_PRT_NEXT();
8629
8630 len = asc_prt_line(cp, leftlen,
8631" Synchronous Transfer:");
8632 ASC_PRT_NEXT();
8633 for (i = 0; i <= ASC_MAX_TID; i++) {
8634 if ((chip_scsi_id == i) ||
8635 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8636 continue;
8637 }
8638 len = asc_prt_line(cp, leftlen, " %X:%c",
8639 i, (v->sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8640 ASC_PRT_NEXT();
8641 }
8642 len = asc_prt_line(cp, leftlen, "\n");
8643 ASC_PRT_NEXT();
8644
8645 for (i = 0; i <= ASC_MAX_TID; i++) {
8646 uchar syn_period_ix;
8647
8648 if ((chip_scsi_id == i) ||
8649 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
8650 ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
8651 continue;
8652 }
8653
8654 len = asc_prt_line(cp, leftlen, " %X:", i);
8655 ASC_PRT_NEXT();
8656
8657 if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0)
8658 {
8659 len = asc_prt_line(cp, leftlen, " Asynchronous");
8660 ASC_PRT_NEXT();
8661 } else
8662 {
8663 syn_period_ix =
8664 (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index - 1);
8665
8666 len = asc_prt_line(cp, leftlen,
8667 " Transfer Period Factor: %d (%d.%d Mhz),",
8668 v->sdtr_period_tbl[syn_period_ix],
8669 250 / v->sdtr_period_tbl[syn_period_ix],
8670 ASC_TENTHS(250, v->sdtr_period_tbl[syn_period_ix]));
8671 ASC_PRT_NEXT();
8672
8673 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
8674 boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET);
8675 ASC_PRT_NEXT();
8676 }
8677
8678 if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
8679 len = asc_prt_line(cp, leftlen, "*\n");
8680 renegotiate = 1;
8681 } else
8682 {
8683 len = asc_prt_line(cp, leftlen, "\n");
8684 }
8685 ASC_PRT_NEXT();
8686 }
8687
8688 if (renegotiate)
8689 {
8690 len = asc_prt_line(cp, leftlen,
8691 " * = Re-negotiation pending before next command.\n");
8692 ASC_PRT_NEXT();
8693 }
8694
8695 return totlen;
8696}
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709STATIC int
8710asc_prt_adv_board_info(struct Scsi_Host *shp, char *cp, int cplen)
8711{
8712 asc_board_t *boardp;
8713 int leftlen;
8714 int totlen;
8715 int len;
8716 int i;
8717 ADV_DVC_VAR *v;
8718 ADV_DVC_CFG *c;
8719 AdvPortAddr iop_base;
8720 ushort chip_scsi_id;
8721 ushort lramword;
8722 uchar lrambyte;
8723 ushort tagqng_able;
8724 ushort sdtr_able, wdtr_able;
8725 ushort wdtr_done, sdtr_done;
8726 ushort period = 0;
8727 int renegotiate = 0;
8728
8729 boardp = ASC_BOARDP(shp);
8730 v = &boardp->dvc_var.adv_dvc_var;
8731 c = &boardp->dvc_cfg.adv_dvc_cfg;
8732 iop_base = v->iop_base;
8733 chip_scsi_id = v->chip_scsi_id;
8734
8735 leftlen = cplen;
8736 totlen = len = 0;
8737
8738 len = asc_prt_line(cp, leftlen,
8739"\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
8740 shp->host_no);
8741 ASC_PRT_NEXT();
8742
8743 len = asc_prt_line(cp, leftlen,
8744" iop_base 0x%lx, cable_detect: %X, err_code %u\n",
8745 v->iop_base,
8746 AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1) & CABLE_DETECT,
8747 v->err_code);
8748 ASC_PRT_NEXT();
8749
8750 len = asc_prt_line(cp, leftlen,
8751" chip_version %u, lib_version 0x%x, mcode_date 0x%x, mcode_version 0x%x\n",
8752 c->chip_version, c->lib_version, c->mcode_date, c->mcode_version);
8753 ASC_PRT_NEXT();
8754
8755 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
8756 len = asc_prt_line(cp, leftlen,
8757" Queuing Enabled:");
8758 ASC_PRT_NEXT();
8759 for (i = 0; i <= ADV_MAX_TID; i++) {
8760 if ((chip_scsi_id == i) ||
8761 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8762 continue;
8763 }
8764
8765 len = asc_prt_line(cp, leftlen, " %X:%c",
8766 i, (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8767 ASC_PRT_NEXT();
8768 }
8769 len = asc_prt_line(cp, leftlen, "\n");
8770 ASC_PRT_NEXT();
8771
8772 len = asc_prt_line(cp, leftlen,
8773" Queue Limit:");
8774 ASC_PRT_NEXT();
8775 for (i = 0; i <= ADV_MAX_TID; i++) {
8776 if ((chip_scsi_id == i) ||
8777 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8778 continue;
8779 }
8780
8781 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i, lrambyte);
8782
8783 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
8784 ASC_PRT_NEXT();
8785 }
8786 len = asc_prt_line(cp, leftlen, "\n");
8787 ASC_PRT_NEXT();
8788
8789 len = asc_prt_line(cp, leftlen,
8790" Command Pending:");
8791 ASC_PRT_NEXT();
8792 for (i = 0; i <= ADV_MAX_TID; i++) {
8793 if ((chip_scsi_id == i) ||
8794 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8795 continue;
8796 }
8797
8798 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i, lrambyte);
8799
8800 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
8801 ASC_PRT_NEXT();
8802 }
8803 len = asc_prt_line(cp, leftlen, "\n");
8804 ASC_PRT_NEXT();
8805
8806 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
8807 len = asc_prt_line(cp, leftlen,
8808" Wide Enabled:");
8809 ASC_PRT_NEXT();
8810 for (i = 0; i <= ADV_MAX_TID; i++) {
8811 if ((chip_scsi_id == i) ||
8812 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8813 continue;
8814 }
8815
8816 len = asc_prt_line(cp, leftlen, " %X:%c",
8817 i, (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8818 ASC_PRT_NEXT();
8819 }
8820 len = asc_prt_line(cp, leftlen, "\n");
8821 ASC_PRT_NEXT();
8822
8823 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
8824 len = asc_prt_line(cp, leftlen,
8825" Transfer Bit Width:");
8826 ASC_PRT_NEXT();
8827 for (i = 0; i <= ADV_MAX_TID; i++) {
8828 if ((chip_scsi_id == i) ||
8829 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8830 continue;
8831 }
8832
8833 AdvReadWordLram(iop_base, ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
8834 lramword);
8835
8836 len = asc_prt_line(cp, leftlen, " %X:%d",
8837 i, (lramword & 0x8000) ? 16 : 8);
8838 ASC_PRT_NEXT();
8839
8840 if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
8841 (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
8842 len = asc_prt_line(cp, leftlen, "*");
8843 ASC_PRT_NEXT();
8844 renegotiate = 1;
8845 }
8846 }
8847 len = asc_prt_line(cp, leftlen, "\n");
8848 ASC_PRT_NEXT();
8849
8850 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
8851 len = asc_prt_line(cp, leftlen,
8852" Synchronous Enabled:");
8853 ASC_PRT_NEXT();
8854 for (i = 0; i <= ADV_MAX_TID; i++) {
8855 if ((chip_scsi_id == i) ||
8856 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8857 continue;
8858 }
8859
8860 len = asc_prt_line(cp, leftlen, " %X:%c",
8861 i, (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8862 ASC_PRT_NEXT();
8863 }
8864 len = asc_prt_line(cp, leftlen, "\n");
8865 ASC_PRT_NEXT();
8866
8867 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
8868 for (i = 0; i <= ADV_MAX_TID; i++) {
8869
8870 AdvReadWordLram(iop_base, ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
8871 lramword);
8872 lramword &= ~0x8000;
8873
8874 if ((chip_scsi_id == i) ||
8875 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
8876 ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
8877 continue;
8878 }
8879
8880 len = asc_prt_line(cp, leftlen, " %X:", i);
8881 ASC_PRT_NEXT();
8882
8883 if ((lramword & 0x1F) == 0)
8884 {
8885 len = asc_prt_line(cp, leftlen, " Asynchronous");
8886 ASC_PRT_NEXT();
8887 } else
8888 {
8889 len = asc_prt_line(cp, leftlen, " Transfer Period Factor: ");
8890 ASC_PRT_NEXT();
8891
8892 if ((lramword & 0x1F00) == 0x1100)
8893 {
8894 len = asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
8895 ASC_PRT_NEXT();
8896 } else if ((lramword & 0x1F00) == 0x1000)
8897 {
8898 len = asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
8899 ASC_PRT_NEXT();
8900 } else
8901 {
8902 period = (((lramword >> 8) * 25) + 50)/4;
8903
8904 if (period == 0)
8905 {
8906 len = asc_prt_line(cp, leftlen, "%d (? Mhz), ");
8907 ASC_PRT_NEXT();
8908 } else
8909 {
8910 len = asc_prt_line(cp, leftlen,
8911 "%d (%d.%d Mhz),",
8912 period, 250/period, ASC_TENTHS(250, period));
8913 ASC_PRT_NEXT();
8914 }
8915 }
8916
8917 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
8918 lramword & 0x1F);
8919 ASC_PRT_NEXT();
8920 }
8921
8922 if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
8923 len = asc_prt_line(cp, leftlen, "*\n");
8924 renegotiate = 1;
8925 } else
8926 {
8927 len = asc_prt_line(cp, leftlen, "\n");
8928 }
8929 ASC_PRT_NEXT();
8930 }
8931
8932 if (renegotiate)
8933 {
8934 len = asc_prt_line(cp, leftlen,
8935 " * = Re-negotiation pending before next command.\n");
8936 ASC_PRT_NEXT();
8937 }
8938
8939 return totlen;
8940}
8941
8942
8943
8944
8945
8946
8947
8948STATIC int
8949asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
8950 char *cp, int cplen)
8951{
8952 int cnt = 0;
8953
8954 ASC_DBG3(2, "asc_proc_copy: offset %d, advoffset %d, cplen %d\n",
8955 (unsigned) offset, (unsigned) advoffset, cplen);
8956 if (offset <= advoffset) {
8957
8958 cnt = ASC_MIN(cplen, leftlen);
8959 ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
8960 (ulong) curbuf, (ulong) cp, cnt);
8961 memcpy(curbuf, cp, cnt);
8962 } else if (offset < advoffset + cplen) {
8963
8964 cnt = (advoffset + cplen) - offset;
8965 cp = (cp + cplen) - cnt;
8966 cnt = ASC_MIN(cnt, leftlen);
8967 ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
8968 (ulong) curbuf, (ulong) cp, cnt);
8969 memcpy(curbuf, cp, cnt);
8970 }
8971 return cnt;
8972}
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985STATIC int
8986asc_prt_line(char *buf, int buflen, char *fmt, ...)
8987{
8988 va_list args;
8989 int ret;
8990 char s[ASC_PRTLINE_SIZE];
8991
8992 va_start(args, fmt);
8993 ret = vsprintf(s, fmt, args);
8994 ASC_ASSERT(ret < ASC_PRTLINE_SIZE);
8995 if (buf == NULL) {
8996 (void) printk(s);
8997 ret = 0;
8998 } else {
8999 ret = ASC_MIN(buflen, ret);
9000 memcpy(buf, s, ret);
9001 }
9002 va_end(args);
9003 return ret;
9004}
9005#endif
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018STATIC void
9019DvcSleepMilliSecond(ADV_DCNT n)
9020{
9021 ASC_DBG1(4, "DvcSleepMilliSecond: %lu\n", (ulong) n);
9022 mdelay(n);
9023}
9024
9025
9026
9027
9028
9029STATIC inline ulong
9030DvcEnterCritical(void)
9031{
9032 return 0;
9033}
9034
9035
9036
9037
9038
9039STATIC inline void
9040DvcLeaveCritical(ulong flags)
9041{
9042 return;
9043}
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055STATIC void
9056DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
9057{
9058 int i;
9059
9060 ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
9061 AscSetChipLramAddr(iop_base, s_addr);
9062 for (i = 0; i < 2 * words; i += 2) {
9063 if (i == 4 || i == 20) {
9064 continue;
9065 }
9066 outpw(iop_base + IOP_RAM_DATA,
9067 ((ushort) outbuf[i + 1] << 8) | outbuf[i]);
9068 }
9069}
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081STATIC void
9082DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
9083{
9084 int i;
9085 ushort word;
9086
9087 AscSetChipLramAddr(iop_base, s_addr);
9088 for (i = 0; i < 2 * words; i += 2) {
9089 if (i == 10) {
9090 continue;
9091 }
9092 word = inpw(iop_base + IOP_RAM_DATA);
9093 inbuf[i] = word & 0xff;
9094 inbuf[i + 1] = (word >> 8) & 0xff;
9095 }
9096 ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
9097}
9098
9099
9100
9101
9102ASC_INITFUNC(
9103STATIC uchar,
9104DvcReadPCIConfigByte(
9105 ASC_DVC_VAR *asc_dvc,
9106 ushort offset)
9107)
9108{
9109#ifdef CONFIG_PCI
9110 uchar byte_data;
9111 pcibios_read_config_byte(ASC_PCI_ID2BUS(asc_dvc->cfg->pci_slot_info),
9112 PCI_DEVFN(ASC_PCI_ID2DEV(asc_dvc->cfg->pci_slot_info),
9113 ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info)),
9114 offset, &byte_data);
9115 return byte_data;
9116#else
9117 return 0;
9118#endif
9119}
9120
9121
9122
9123
9124ASC_INITFUNC(
9125STATIC void,
9126DvcWritePCIConfigByte(
9127 ASC_DVC_VAR *asc_dvc,
9128 ushort offset,
9129 uchar byte_data)
9130)
9131{
9132#ifdef CONFIG_PCI
9133 pcibios_write_config_byte(ASC_PCI_ID2BUS(asc_dvc->cfg->pci_slot_info),
9134 PCI_DEVFN(ASC_PCI_ID2DEV(asc_dvc->cfg->pci_slot_info),
9135 ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info)),
9136 offset, byte_data);
9137#endif
9138}
9139
9140
9141
9142
9143
9144ASC_INITFUNC(
9145STATIC ushort,
9146AscGetChipBiosAddress(
9147 PortAddr iop_base,
9148 ushort bus_type
9149)
9150)
9151{
9152 ushort cfg_lsw;
9153 ushort bios_addr;
9154
9155
9156
9157
9158
9159
9160 if (bus_type & ASC_IS_PCI)
9161 {
9162 return(0);
9163 }
9164
9165#ifdef CONFIG_ISA
9166 if((bus_type & ASC_IS_EISA) != 0)
9167 {
9168 cfg_lsw = AscGetEisaChipCfg(iop_base);
9169 cfg_lsw &= 0x000F;
9170 bios_addr = (ushort)(ASC_BIOS_MIN_ADDR +
9171 (cfg_lsw * ASC_BIOS_BANK_SIZE));
9172 return(bios_addr);
9173 }
9174#endif
9175
9176 cfg_lsw = AscGetChipCfgLsw(iop_base);
9177
9178
9179
9180
9181 if (bus_type == ASC_IS_ISAPNP)
9182 {
9183 cfg_lsw &= 0x7FFF;
9184 }
9185
9186 bios_addr = (ushort)(((cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE) +
9187 ASC_BIOS_MIN_ADDR);
9188 return(bios_addr);
9189}
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207ADV_PADDR
9208DvcGetPhyAddr(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq,
9209 uchar *vaddr, ADV_SDCNT *lenp, int flag)
9210{
9211 ADV_PADDR paddr;
9212
9213 paddr = virt_to_bus(vaddr);
9214
9215 ASC_DBG4(4,
9216 "DvcGetPhyAddr: vaddr 0x%lx, lenp 0x%lx *lenp %lu, paddr 0x%lx\n",
9217 (ulong) vaddr, (ulong) lenp, (ulong) *((ulong *) lenp), (ulong) paddr);
9218
9219 return paddr;
9220}
9221
9222
9223
9224
9225ASC_INITFUNC(
9226STATIC uchar,
9227DvcAdvReadPCIConfigByte(
9228 ADV_DVC_VAR *asc_dvc,
9229 ushort offset)
9230)
9231{
9232#ifdef CONFIG_PCI
9233 uchar byte_data;
9234 pcibios_read_config_byte(ASC_PCI_ID2BUS(asc_dvc->cfg->pci_slot_info),
9235 PCI_DEVFN(ASC_PCI_ID2DEV(asc_dvc->cfg->pci_slot_info),
9236 ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info)),
9237 offset, &byte_data);
9238 return byte_data;
9239#else
9240 return 0;
9241#endif
9242}
9243
9244
9245
9246
9247ASC_INITFUNC(
9248STATIC void,
9249DvcAdvWritePCIConfigByte(
9250 ADV_DVC_VAR *asc_dvc,
9251 ushort offset,
9252 uchar byte_data)
9253)
9254{
9255#ifdef CONFIG_PCI
9256 pcibios_write_config_byte(ASC_PCI_ID2BUS(asc_dvc->cfg->pci_slot_info),
9257 PCI_DEVFN(ASC_PCI_ID2DEV(asc_dvc->cfg->pci_slot_info),
9258 ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info)),
9259 offset, byte_data);
9260#else
9261 return 0;
9262#endif
9263}
9264
9265
9266
9267
9268
9269#ifdef ADVANSYS_STATS
9270#ifdef CONFIG_PROC_FS
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280STATIC int
9281asc_prt_board_stats(struct Scsi_Host *shp, char *cp, int cplen)
9282{
9283 int leftlen;
9284 int totlen;
9285 int len;
9286 struct asc_stats *s;
9287 asc_board_t *boardp;
9288
9289 leftlen = cplen;
9290 totlen = len = 0;
9291
9292 boardp = ASC_BOARDP(shp);
9293 s = &boardp->asc_stats;
9294
9295 len = asc_prt_line(cp, leftlen,
9296"\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n", shp->host_no);
9297 ASC_PRT_NEXT();
9298
9299 len = asc_prt_line(cp, leftlen,
9300" queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
9301 s->queuecommand, s->reset, s->biosparam, s->interrupt);
9302 ASC_PRT_NEXT();
9303
9304 len = asc_prt_line(cp, leftlen,
9305" callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
9306 s->callback, s->done, s->build_error, s->adv_build_noreq,
9307 s->adv_build_nosg);
9308 ASC_PRT_NEXT();
9309
9310 len = asc_prt_line(cp, leftlen,
9311" exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
9312 s->exe_noerror, s->exe_busy, s->exe_error, s->exe_unknown);
9313 ASC_PRT_NEXT();
9314
9315
9316
9317
9318 if (s->cont_cnt > 0) {
9319 len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
9320 ASC_PRT_NEXT();
9321
9322 len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
9323 s->cont_xfer/2,
9324 ASC_TENTHS(s->cont_xfer, 2));
9325 ASC_PRT_NEXT();
9326
9327
9328 len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
9329 (s->cont_xfer/2)/s->cont_cnt,
9330 ASC_TENTHS((s->cont_xfer/2), s->cont_cnt));
9331 ASC_PRT_NEXT();
9332 }
9333
9334 if (s->sg_cnt > 0) {
9335
9336 len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ",
9337 s->sg_cnt, s->sg_elem);
9338 ASC_PRT_NEXT();
9339
9340 len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n",
9341 s->sg_xfer/2,
9342 ASC_TENTHS(s->sg_xfer, 2));
9343 ASC_PRT_NEXT();
9344
9345
9346 len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
9347 s->sg_elem/s->sg_cnt,
9348 ASC_TENTHS(s->sg_elem, s->sg_cnt));
9349 ASC_PRT_NEXT();
9350
9351 len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
9352 (s->sg_xfer/2)/s->sg_elem,
9353 ASC_TENTHS((s->sg_xfer/2), s->sg_elem));
9354 ASC_PRT_NEXT();
9355
9356 len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
9357 (s->sg_xfer/2)/s->sg_cnt,
9358 ASC_TENTHS((s->sg_xfer/2), s->sg_cnt));
9359 ASC_PRT_NEXT();
9360 }
9361
9362
9363
9364
9365 len = asc_prt_line(cp, leftlen,
9366" Active and Waiting Request Queues (Time Unit: %d HZ):\n", HZ);
9367 ASC_PRT_NEXT();
9368
9369
9370 return totlen;
9371}
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385STATIC int
9386asc_prt_target_stats(struct Scsi_Host *shp, int tgt_id, char *cp, int cplen)
9387{
9388 int leftlen;
9389 int totlen;
9390 int len;
9391 struct asc_stats *s;
9392 ushort chip_scsi_id;
9393 asc_board_t *boardp;
9394 asc_queue_t *active;
9395 asc_queue_t *waiting;
9396
9397 leftlen = cplen;
9398 totlen = len = 0;
9399
9400 boardp = ASC_BOARDP(shp);
9401 s = &boardp->asc_stats;
9402
9403 active = &ASC_BOARDP(shp)->active;
9404 waiting = &ASC_BOARDP(shp)->waiting;
9405
9406 if (ASC_NARROW_BOARD(boardp)) {
9407 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
9408 } else {
9409 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
9410 }
9411
9412 if ((chip_scsi_id == tgt_id) ||
9413 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(tgt_id)) == 0)) {
9414 return 0;
9415 }
9416
9417 do {
9418 if (active->q_tot_cnt[tgt_id] > 0 || waiting->q_tot_cnt[tgt_id] > 0) {
9419 len = asc_prt_line(cp, leftlen, " target %d\n", tgt_id);
9420 ASC_PRT_NEXT();
9421
9422 len = asc_prt_line(cp, leftlen,
9423" active: cnt [cur %d, max %d, tot %u], time [min %d, max %d, avg %lu.%01lu]\n",
9424 active->q_cur_cnt[tgt_id], active->q_max_cnt[tgt_id],
9425 active->q_tot_cnt[tgt_id],
9426 active->q_min_tim[tgt_id], active->q_max_tim[tgt_id],
9427 (active->q_tot_cnt[tgt_id] == 0) ? 0 :
9428 (active->q_tot_tim[tgt_id]/active->q_tot_cnt[tgt_id]),
9429 (active->q_tot_cnt[tgt_id] == 0) ? 0 :
9430 ASC_TENTHS(active->q_tot_tim[tgt_id],
9431 active->q_tot_cnt[tgt_id]));
9432 ASC_PRT_NEXT();
9433
9434 len = asc_prt_line(cp, leftlen,
9435" waiting: cnt [cur %d, max %d, tot %u], time [min %u, max %u, avg %lu.%01lu]\n",
9436 waiting->q_cur_cnt[tgt_id], waiting->q_max_cnt[tgt_id],
9437 waiting->q_tot_cnt[tgt_id],
9438 waiting->q_min_tim[tgt_id], waiting->q_max_tim[tgt_id],
9439 (waiting->q_tot_cnt[tgt_id] == 0) ? 0 :
9440 (waiting->q_tot_tim[tgt_id]/waiting->q_tot_cnt[tgt_id]),
9441 (waiting->q_tot_cnt[tgt_id] == 0) ? 0 :
9442 ASC_TENTHS(waiting->q_tot_tim[tgt_id],
9443 waiting->q_tot_cnt[tgt_id]));
9444 ASC_PRT_NEXT();
9445 }
9446 } while (0);
9447
9448 return totlen;
9449}
9450#endif
9451#endif
9452
9453#ifdef ADVANSYS_DEBUG
9454
9455
9456
9457STATIC void
9458asc_prt_scsi_host(struct Scsi_Host *s)
9459{
9460 asc_board_t *boardp;
9461
9462 boardp = ASC_BOARDP(s);
9463
9464 printk("Scsi_Host at addr 0x%lx\n", (ulong) s);
9465 printk(
9466" next 0x%lx, extra_bytes %u, host_busy %u, host_no %d, last_reset %d,\n",
9467 (ulong) s->next, s->extra_bytes, s->host_busy, s->host_no,
9468 (unsigned) s->last_reset);
9469
9470#if ASC_LINUX_KERNEL24
9471 printk(
9472" host_queue 0x%lx, hostt 0x%lx\n",
9473 (ulong) s->host_queue, (ulong) s->hostt);
9474#elif ASC_LINUX_KERNEL22
9475 printk(
9476" host_queue 0x%lx, hostt 0x%lx, block 0x%lx,\n",
9477 (ulong) s->host_queue, (ulong) s->hostt, (ulong) s->block);
9478#endif
9479
9480 printk(
9481" base 0x%lx, io_port 0x%lx, n_io_port %u, irq 0x%x,\n",
9482 (ulong) s->base, (ulong) s->io_port, s->n_io_port, s->irq);
9483
9484 printk(
9485" dma_channel %d, this_id %d, can_queue %d,\n",
9486 s->dma_channel, s->this_id, s->can_queue);
9487
9488 printk(
9489" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d, loaded_as_module %d\n",
9490 s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma,
9491 s->loaded_as_module);
9492
9493 if (ASC_NARROW_BOARD(boardp)) {
9494 asc_prt_asc_dvc_var(&ASC_BOARDP(s)->dvc_var.asc_dvc_var);
9495 asc_prt_asc_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.asc_dvc_cfg);
9496 } else {
9497 asc_prt_adv_dvc_var(&ASC_BOARDP(s)->dvc_var.adv_dvc_var);
9498 asc_prt_adv_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.adv_dvc_cfg);
9499 }
9500}
9501
9502
9503
9504
9505STATIC void
9506asc_prt_scsi_cmnd(Scsi_Cmnd *s)
9507{
9508 printk("Scsi_Cmnd at addr 0x%lx\n", (ulong) s);
9509
9510 printk(
9511" host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n",
9512 (ulong) s->host, (ulong) s->device, s->target, s->lun,
9513 s->channel);
9514
9515 asc_prt_hex(" CDB", s->cmnd, s->cmd_len);
9516
9517#if ASC_LINUX_KERNEL24
9518 printk (
9519"sc_data_direction %u, resid %d\n",
9520 s->sc_data_direction, s->resid);
9521#endif
9522
9523 printk(
9524" use_sg %u, sglist_len %u, abort_reason 0x%x\n",
9525 s->use_sg, s->sglist_len, s->abort_reason);
9526
9527 printk(
9528" serial_number 0x%x, serial_number_at_timeout 0x%x, retries %d, allowed %d\n",
9529 (unsigned) s->serial_number, (unsigned) s->serial_number_at_timeout,
9530 s->retries, s->allowed);
9531
9532 printk(
9533" timeout_per_command %d, timeout_total %d, timeout %d\n",
9534 s->timeout_per_command, s->timeout_total, s->timeout);
9535
9536#if ASC_LINUX_KERNEL24
9537 printk(
9538" internal_timeout %u, flags %u\n",
9539 s->internal_timeout, s->flags);
9540#elif ASC_LINUX_KERNEL22
9541 printk(
9542" internal_timeout %u, flags %u, this_count %d\n",
9543 s->internal_timeout, s->flags,s->this_count);
9544#endif
9545
9546 printk(
9547" scsi_done 0x%lx, done 0x%lx, host_scribble 0x%lx, result 0x%x\n",
9548 (ulong) s->scsi_done, (ulong) s->done,
9549 (ulong) s->host_scribble, s->result);
9550
9551 printk(
9552" tag %u, pid %u\n",
9553 (unsigned) s->tag, (unsigned) s->pid);
9554}
9555
9556
9557
9558
9559STATIC void
9560asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
9561{
9562 printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong) h);
9563
9564 printk(
9565" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl %d,\n",
9566 h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
9567
9568 printk(
9569" bus_type %d, isr_callback 0x%lx, exe_callback 0x%lx, init_sdtr 0x%x,\n",
9570 h->bus_type, (ulong) h->isr_callback, (ulong) h->exe_callback,
9571 (unsigned) h->init_sdtr);
9572
9573 printk(
9574" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, chip_no 0x%x,\n",
9575 (unsigned) h->sdtr_done, (unsigned) h->use_tagged_qng,
9576 (unsigned) h->unit_not_ready, (unsigned) h->chip_no);
9577
9578 printk(
9579" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait %u,\n",
9580 (unsigned) h->queue_full_or_busy, (unsigned) h->start_motor,
9581 (unsigned) h->scsi_reset_wait);
9582
9583 printk(
9584" is_in_int %u, max_total_qng %u, cur_total_qng %u, in_critical_cnt %u,\n",
9585 (unsigned) h->is_in_int, (unsigned) h->max_total_qng,
9586 (unsigned) h->cur_total_qng, (unsigned) h->in_critical_cnt);
9587
9588 printk(
9589" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, pci_fix_asyn_xfer 0x%x,\n",
9590 (unsigned) h->last_q_shortage, (unsigned) h->init_state,
9591 (unsigned) h->no_scam, (unsigned) h->pci_fix_asyn_xfer);
9592
9593 printk(
9594" cfg 0x%lx, irq_no 0x%x\n",
9595 (ulong) h->cfg, (unsigned) h->irq_no);
9596}
9597
9598
9599
9600
9601STATIC void
9602asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
9603{
9604 printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong) h);
9605
9606 printk(
9607" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
9608 h->can_tagged_qng, h->cmd_qng_enabled);
9609 printk(
9610" disc_enable 0x%x, sdtr_enable 0x%x,\n",
9611 h->disc_enable, h->sdtr_enable);
9612
9613 printk(
9614" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, chip_version %d,\n",
9615 h->chip_scsi_id, h->isa_dma_speed, h->isa_dma_channel,
9616 h->chip_version);
9617
9618 printk(
9619" pci_device_id %d, lib_serial_no %u, lib_version %u, mcode_date 0x%x,\n",
9620 h->pci_device_id, h->lib_serial_no, h->lib_version, h->mcode_date);
9621
9622 printk(
9623" mcode_version %d, overrun_buf 0x%lx\n",
9624 h->mcode_version, (ulong) h->overrun_buf);
9625}
9626
9627
9628
9629
9630STATIC void
9631asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
9632{
9633 ASC_SG_HEAD *sgp;
9634 int i;
9635
9636 printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong) q);
9637
9638 printk(
9639" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
9640 q->q2.target_ix, q->q1.target_lun,
9641 (ulong) q->q2.srb_ptr, q->q2.tag_code);
9642
9643 printk(
9644" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
9645 (ulong) le32_to_cpu(q->q1.data_addr),
9646 (ulong) le32_to_cpu(q->q1.data_cnt),
9647 (ulong) le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
9648
9649 printk(
9650" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
9651 (ulong) q->cdbptr, q->q2.cdb_len,
9652 (ulong) q->sg_head, q->q1.sg_queue_cnt);
9653
9654 if (q->sg_head) {
9655 sgp = q->sg_head;
9656 printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong) sgp);
9657 printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt, sgp->queue_cnt);
9658 for (i = 0; i < sgp->entry_cnt; i++) {
9659 printk(" [%u]: addr 0x%lx, bytes %lu\n",
9660 i, (ulong) le32_to_cpu(sgp->sg_list[i].addr),
9661 (ulong) le32_to_cpu(sgp->sg_list[i].bytes));
9662 }
9663
9664 }
9665}
9666
9667
9668
9669
9670STATIC void
9671asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
9672{
9673 printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong) q);
9674 printk(
9675" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
9676 (ulong) q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
9677 q->d2.tag_code);
9678 printk(
9679" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
9680 q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
9681}
9682
9683
9684
9685
9686
9687
9688STATIC void
9689asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
9690{
9691 printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong) h);
9692
9693 printk(
9694" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
9695 (ulong) h->iop_base, h->err_code, (unsigned) h->ultra_able);
9696
9697 printk(
9698" isr_callback 0x%lx, sdtr_able 0x%x, wdtr_able 0x%x\n",
9699 (ulong) h->isr_callback, (unsigned) h->sdtr_able,
9700 (unsigned) h->wdtr_able);
9701
9702 printk(
9703" start_motor 0x%x, scsi_reset_wait 0x%x, irq_no 0x%x,\n",
9704 (unsigned) h->start_motor,
9705 (unsigned) h->scsi_reset_wait, (unsigned) h->irq_no);
9706
9707 printk(
9708" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
9709 (unsigned) h->max_host_qng, (unsigned) h->max_dvc_qng,
9710 (ulong) h->carr_freelist);
9711
9712 printk(
9713" icq_sp 0x%lx, irq_sp 0x%lx\n",
9714 (ulong) h->icq_sp, (ulong) h->irq_sp);
9715
9716 printk(
9717" no_scam 0x%x, tagqng_able 0x%x\n",
9718 (unsigned) h->no_scam, (unsigned) h->tagqng_able);
9719
9720 printk(
9721" chip_scsi_id 0x%x, cfg 0x%lx\n",
9722 (unsigned) h->chip_scsi_id, (ulong) h->cfg);
9723}
9724
9725
9726
9727
9728
9729
9730STATIC void
9731asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
9732{
9733 printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong) h);
9734
9735 printk(
9736" disc_enable 0x%x, termination 0x%x\n",
9737 h->disc_enable, h->termination);
9738
9739 printk(
9740" chip_version 0x%x, mcode_date 0x%x\n",
9741 h->chip_version, h->mcode_date);
9742
9743 printk(
9744" mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n",
9745 h->mcode_version, h->pci_device_id, h->lib_version);
9746
9747 printk(
9748" control_flag 0x%x, pci_slot_info 0x%x\n",
9749 h->control_flag, h->pci_slot_info);
9750}
9751
9752
9753
9754
9755
9756
9757STATIC void
9758asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
9759{
9760 int sg_blk_cnt;
9761 struct asc_sg_block *sg_ptr;
9762
9763 printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong) q);
9764
9765 printk(
9766" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
9767 q->target_id, q->target_lun, (ulong) q->srb_ptr, q->a_flag);
9768
9769 printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
9770 q->cntl, (ulong) le32_to_cpu(q->data_addr), (ulong) q->vdata_addr);
9771
9772 printk(
9773" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
9774 (ulong) le32_to_cpu(q->data_cnt),
9775 (ulong) le32_to_cpu(q->sense_addr), q->sense_len);
9776
9777 printk(
9778" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
9779 q->cdb_len, q->done_status, q->host_status, q->scsi_status);
9780
9781 printk(
9782" sg_working_ix 0x%x, target_cmd %u\n",
9783 q->sg_working_ix, q->target_cmd);
9784
9785 printk(
9786" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
9787 (ulong) le32_to_cpu(q->scsiq_rptr),
9788 (ulong) le32_to_cpu(q->sg_real_addr), (ulong) q->sg_list_ptr);
9789
9790
9791 if (q->sg_list_ptr != NULL)
9792 {
9793 sg_blk_cnt = 0;
9794 while (1) {
9795
9796
9797
9798
9799
9800
9801
9802 sg_ptr = &(((ADV_SG_BLOCK *) (q->sg_list_ptr))[sg_blk_cnt]);
9803 asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
9804 if (sg_ptr->sg_ptr == 0)
9805 {
9806 break;
9807 }
9808 sg_blk_cnt++;
9809 }
9810 }
9811}
9812
9813
9814
9815
9816
9817
9818STATIC void
9819asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
9820{
9821 int i;
9822
9823 printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
9824 (ulong) b, sgblockno);
9825 printk(" sg_cnt %u, sg_ptr 0x%lx\n",
9826 b->sg_cnt, (ulong) le32_to_cpu(b->sg_ptr));
9827 ASC_ASSERT(b->sg_cnt <= NO_OF_SG_PER_BLOCK);
9828 if (b->sg_ptr != 0)
9829 {
9830 ASC_ASSERT(b->sg_cnt == NO_OF_SG_PER_BLOCK);
9831 }
9832 for (i = 0; i < b->sg_cnt; i++) {
9833 printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
9834 i, (ulong) b->sg_list[i].sg_addr, (ulong) b->sg_list[i].sg_count);
9835 }
9836}
9837
9838
9839
9840
9841
9842
9843
9844STATIC void
9845asc_prt_hex(char *f, uchar *s, int l)
9846{
9847 int i;
9848 int j;
9849 int k;
9850 int m;
9851
9852 printk("%s: (%d bytes)\n", f, l);
9853
9854 for (i = 0; i < l; i += 32) {
9855
9856
9857 if ((k = (l - i) / 4) >= 8) {
9858 k = 8;
9859 m = 0;
9860 } else {
9861 m = (l - i) % 4;
9862 }
9863
9864 for (j = 0; j < k; j++) {
9865 printk(" %2.2X%2.2X%2.2X%2.2X",
9866 (unsigned) s[i+(j*4)], (unsigned) s[i+(j*4)+1],
9867 (unsigned) s[i+(j*4)+2], (unsigned) s[i+(j*4)+3]);
9868 }
9869
9870 switch (m) {
9871 case 0:
9872 default:
9873 break;
9874 case 1:
9875 printk(" %2.2X",
9876 (unsigned) s[i+(j*4)]);
9877 break;
9878 case 2:
9879 printk(" %2.2X%2.2X",
9880 (unsigned) s[i+(j*4)],
9881 (unsigned) s[i+(j*4)+1]);
9882 break;
9883 case 3:
9884 printk(" %2.2X%2.2X%2.2X",
9885 (unsigned) s[i+(j*4)+1],
9886 (unsigned) s[i+(j*4)+2],
9887 (unsigned) s[i+(j*4)+3]);
9888 break;
9889 }
9890
9891 printk("\n");
9892 }
9893}
9894#endif
9895
9896
9897
9898
9899
9900ASC_INITFUNC(
9901STATIC ushort,
9902AscGetEisaChipCfg(
9903 PortAddr iop_base
9904)
9905)
9906{
9907 PortAddr eisa_cfg_iop;
9908
9909 eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
9910 (PortAddr) (ASC_EISA_CFG_IOP_MASK);
9911 return (inpw(eisa_cfg_iop));
9912}
9913
9914ASC_INITFUNC(
9915STATIC uchar,
9916AscSetChipScsiID(
9917 PortAddr iop_base,
9918 uchar new_host_id
9919)
9920)
9921{
9922 ushort cfg_lsw;
9923
9924 if (AscGetChipScsiID(iop_base) == new_host_id) {
9925 return (new_host_id);
9926 }
9927 cfg_lsw = AscGetChipCfgLsw(iop_base);
9928 cfg_lsw &= 0xF8FF;
9929 cfg_lsw |= (ushort) ((new_host_id & ASC_MAX_TID) << 8);
9930 AscSetChipCfgLsw(iop_base, cfg_lsw);
9931 return (AscGetChipScsiID(iop_base));
9932}
9933
9934ASC_INITFUNC(
9935STATIC uchar,
9936AscGetChipScsiCtrl(
9937 PortAddr iop_base
9938)
9939)
9940{
9941 uchar sc;
9942
9943 AscSetBank(iop_base, 1);
9944 sc = inp(iop_base + IOP_REG_SC);
9945 AscSetBank(iop_base, 0);
9946 return (sc);
9947}
9948
9949ASC_INITFUNC(
9950STATIC uchar,
9951AscGetChipVersion(
9952 PortAddr iop_base,
9953 ushort bus_type
9954)
9955)
9956{
9957 if ((bus_type & ASC_IS_EISA) != 0) {
9958 PortAddr eisa_iop;
9959 uchar revision;
9960 eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
9961 (PortAddr) ASC_EISA_REV_IOP_MASK;
9962 revision = inp(eisa_iop);
9963 return ((uchar) ((ASC_CHIP_MIN_VER_EISA - 1) + revision));
9964 }
9965 return (AscGetChipVerNo(iop_base));
9966}
9967
9968ASC_INITFUNC(
9969STATIC ushort,
9970AscGetChipBusType(
9971 PortAddr iop_base
9972)
9973)
9974{
9975 ushort chip_ver;
9976
9977 chip_ver = AscGetChipVerNo(iop_base);
9978 if (
9979 (chip_ver >= ASC_CHIP_MIN_VER_VL)
9980 && (chip_ver <= ASC_CHIP_MAX_VER_VL)
9981) {
9982 if (
9983 ((iop_base & 0x0C30) == 0x0C30)
9984 || ((iop_base & 0x0C50) == 0x0C50)
9985) {
9986 return (ASC_IS_EISA);
9987 }
9988 return (ASC_IS_VL);
9989 }
9990 if ((chip_ver >= ASC_CHIP_MIN_VER_ISA) &&
9991 (chip_ver <= ASC_CHIP_MAX_VER_ISA)) {
9992 if (chip_ver >= ASC_CHIP_MIN_VER_ISA_PNP) {
9993 return (ASC_IS_ISAPNP);
9994 }
9995 return (ASC_IS_ISA);
9996 } else if ((chip_ver >= ASC_CHIP_MIN_VER_PCI) &&
9997 (chip_ver <= ASC_CHIP_MAX_VER_PCI)) {
9998 return (ASC_IS_PCI);
9999 }
10000 return (0);
10001}
10002
10003STATIC ASC_DCNT
10004AscLoadMicroCode(
10005 PortAddr iop_base,
10006 ushort s_addr,
10007 uchar *mcode_buf,
10008 ushort mcode_size
10009)
10010{
10011 ASC_DCNT chksum;
10012 ushort mcode_word_size;
10013 ushort mcode_chksum;
10014
10015
10016 mcode_word_size = (ushort) (mcode_size >> 1);
10017 AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
10018 AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
10019
10020 chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
10021 ASC_DBG1(1, "AscLoadMicroCode: chksum 0x%lx\n", (ulong) chksum);
10022 mcode_chksum = (ushort) AscMemSumLramWord(iop_base,
10023 (ushort) ASC_CODE_SEC_BEG,
10024 (ushort) ((mcode_size - s_addr - (ushort) ASC_CODE_SEC_BEG) / 2));
10025 ASC_DBG1(1, "AscLoadMicroCode: mcode_chksum 0x%lx\n",
10026 (ulong) mcode_chksum);
10027 AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
10028 AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
10029 return (chksum);
10030}
10031
10032STATIC int
10033AscFindSignature(
10034 PortAddr iop_base
10035)
10036{
10037 ushort sig_word;
10038
10039 ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureByte(0x%x) 0x%x\n",
10040 iop_base, AscGetChipSignatureByte(iop_base));
10041 if (AscGetChipSignatureByte(iop_base) == (uchar) ASC_1000_ID1B) {
10042 ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureWord(0x%x) 0x%x\n",
10043 iop_base, AscGetChipSignatureWord(iop_base));
10044 sig_word = AscGetChipSignatureWord(iop_base);
10045 if ((sig_word == (ushort) ASC_1000_ID0W) ||
10046 (sig_word == (ushort) ASC_1000_ID0W_FIX)) {
10047 return (1);
10048 }
10049 }
10050 return (0);
10051}
10052
10053STATIC PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] ASC_INITDATA =
10054{
10055 0x100, ASC_IOADR_1, 0x120, ASC_IOADR_2, 0x140, ASC_IOADR_3, ASC_IOADR_4,
10056 ASC_IOADR_5, ASC_IOADR_6, ASC_IOADR_7, ASC_IOADR_8
10057};
10058
10059#ifdef CONFIG_ISA
10060STATIC uchar _isa_pnp_inited ASC_INITDATA = 0;
10061
10062ASC_INITFUNC(
10063STATIC PortAddr,
10064AscSearchIOPortAddr(
10065 PortAddr iop_beg,
10066 ushort bus_type
10067)
10068)
10069{
10070 if (bus_type & ASC_IS_VL) {
10071 while ((iop_beg = AscSearchIOPortAddr11(iop_beg)) != 0) {
10072 if (AscGetChipVersion(iop_beg, bus_type) <= ASC_CHIP_MAX_VER_VL) {
10073 return (iop_beg);
10074 }
10075 }
10076 return (0);
10077 }
10078 if (bus_type & ASC_IS_ISA) {
10079 if (_isa_pnp_inited == 0) {
10080 AscSetISAPNPWaitForKey();
10081 _isa_pnp_inited++;
10082 }
10083 while ((iop_beg = AscSearchIOPortAddr11(iop_beg)) != 0) {
10084 if ((AscGetChipVersion(iop_beg, bus_type) & ASC_CHIP_VER_ISA_BIT) != 0) {
10085 return (iop_beg);
10086 }
10087 }
10088 return (0);
10089 }
10090 if (bus_type & ASC_IS_EISA) {
10091 if ((iop_beg = AscSearchIOPortAddrEISA(iop_beg)) != 0) {
10092 return (iop_beg);
10093 }
10094 return (0);
10095 }
10096 return (0);
10097}
10098
10099ASC_INITFUNC(
10100STATIC PortAddr,
10101AscSearchIOPortAddr11(
10102 PortAddr s_addr
10103)
10104)
10105{
10106 int i;
10107 PortAddr iop_base;
10108
10109 for (i = 0; i < ASC_IOADR_TABLE_MAX_IX; i++) {
10110 if (_asc_def_iop_base[i] > s_addr) {
10111 break;
10112 }
10113 }
10114 for (; i < ASC_IOADR_TABLE_MAX_IX; i++) {
10115 iop_base = _asc_def_iop_base[i];
10116 if (check_region(iop_base, ASC_IOADR_GAP) != 0) {
10117 ASC_DBG1(1,
10118 "AscSearchIOPortAddr11: check_region() failed I/O port 0x%x\n",
10119 iop_base);
10120 continue;
10121 }
10122 ASC_DBG1(1, "AscSearchIOPortAddr11: probing I/O port 0x%x\n", iop_base);
10123 if (AscFindSignature(iop_base)) {
10124 return (iop_base);
10125 }
10126 }
10127 return (0);
10128}
10129
10130ASC_INITFUNC(
10131STATIC void,
10132AscSetISAPNPWaitForKey(
10133 void)
10134)
10135{
10136 outp(ASC_ISA_PNP_PORT_ADDR, 0x02);
10137 outp(ASC_ISA_PNP_PORT_WRITE, 0x02);
10138 return;
10139}
10140#endif
10141
10142ASC_INITFUNC(
10143STATIC void,
10144AscToggleIRQAct(
10145 PortAddr iop_base
10146)
10147)
10148{
10149 AscSetChipStatus(iop_base, CIW_IRQ_ACT);
10150 AscSetChipStatus(iop_base, 0);
10151 return;
10152}
10153
10154ASC_INITFUNC(
10155STATIC uchar,
10156AscGetChipIRQ(
10157 PortAddr iop_base,
10158 ushort bus_type
10159)
10160)
10161{
10162 ushort cfg_lsw;
10163 uchar chip_irq;
10164
10165 if ((bus_type & ASC_IS_EISA) != 0) {
10166 cfg_lsw = AscGetEisaChipCfg(iop_base);
10167 chip_irq = (uchar) (((cfg_lsw >> 8) & 0x07) + 10);
10168 if ((chip_irq == 13) || (chip_irq > 15)) {
10169 return (0);
10170 }
10171 return (chip_irq);
10172 }
10173 if ((bus_type & ASC_IS_VL) != 0) {
10174 cfg_lsw = AscGetChipCfgLsw(iop_base);
10175 chip_irq = (uchar) (((cfg_lsw >> 2) & 0x07));
10176 if ((chip_irq == 0) ||
10177 (chip_irq == 4) ||
10178 (chip_irq == 7)) {
10179 return (0);
10180 }
10181 return ((uchar) (chip_irq + (ASC_MIN_IRQ_NO - 1)));
10182 }
10183 cfg_lsw = AscGetChipCfgLsw(iop_base);
10184 chip_irq = (uchar) (((cfg_lsw >> 2) & 0x03));
10185 if (chip_irq == 3)
10186 chip_irq += (uchar) 2;
10187 return ((uchar) (chip_irq + ASC_MIN_IRQ_NO));
10188}
10189
10190ASC_INITFUNC(
10191STATIC uchar,
10192AscSetChipIRQ(
10193 PortAddr iop_base,
10194 uchar irq_no,
10195 ushort bus_type
10196)
10197)
10198{
10199 ushort cfg_lsw;
10200
10201 if ((bus_type & ASC_IS_VL) != 0) {
10202 if (irq_no != 0) {
10203 if ((irq_no < ASC_MIN_IRQ_NO) || (irq_no > ASC_MAX_IRQ_NO)) {
10204 irq_no = 0;
10205 } else {
10206 irq_no -= (uchar) ((ASC_MIN_IRQ_NO - 1));
10207 }
10208 }
10209 cfg_lsw = (ushort) (AscGetChipCfgLsw(iop_base) & 0xFFE3);
10210 cfg_lsw |= (ushort) 0x0010;
10211 AscSetChipCfgLsw(iop_base, cfg_lsw);
10212 AscToggleIRQAct(iop_base);
10213 cfg_lsw = (ushort) (AscGetChipCfgLsw(iop_base) & 0xFFE0);
10214 cfg_lsw |= (ushort) ((irq_no & 0x07) << 2);
10215 AscSetChipCfgLsw(iop_base, cfg_lsw);
10216 AscToggleIRQAct(iop_base);
10217 return (AscGetChipIRQ(iop_base, bus_type));
10218 }
10219 if ((bus_type & (ASC_IS_ISA)) != 0) {
10220 if (irq_no == 15)
10221 irq_no -= (uchar) 2;
10222 irq_no -= (uchar) ASC_MIN_IRQ_NO;
10223 cfg_lsw = (ushort) (AscGetChipCfgLsw(iop_base) & 0xFFF3);
10224 cfg_lsw |= (ushort) ((irq_no & 0x03) << 2);
10225 AscSetChipCfgLsw(iop_base, cfg_lsw);
10226 return (AscGetChipIRQ(iop_base, bus_type));
10227 }
10228 return (0);
10229}
10230
10231#ifdef CONFIG_ISA
10232ASC_INITFUNC(
10233STATIC void,
10234AscEnableIsaDma(
10235 uchar dma_channel
10236)
10237)
10238{
10239 if (dma_channel < 4) {
10240 outp(0x000B, (ushort) (0xC0 | dma_channel));
10241 outp(0x000A, dma_channel);
10242 } else if (dma_channel < 8) {
10243 outp(0x00D6, (ushort) (0xC0 | (dma_channel - 4)));
10244 outp(0x00D4, (ushort) (dma_channel - 4));
10245 }
10246 return;
10247}
10248#endif
10249
10250STATIC int
10251AscIsrChipHalted(
10252 ASC_DVC_VAR *asc_dvc
10253)
10254{
10255 EXT_MSG ext_msg;
10256 EXT_MSG out_msg;
10257 ushort halt_q_addr;
10258 int sdtr_accept;
10259 ushort int_halt_code;
10260 ASC_SCSI_BIT_ID_TYPE scsi_busy;
10261 ASC_SCSI_BIT_ID_TYPE target_id;
10262 PortAddr iop_base;
10263 uchar tag_code;
10264 uchar q_status;
10265 uchar halt_qp;
10266 uchar sdtr_data;
10267 uchar target_ix;
10268 uchar q_cntl, tid_no;
10269 uchar cur_dvc_qng;
10270 uchar asyn_sdtr;
10271 uchar scsi_status;
10272 asc_board_t *boardp;
10273
10274 ASC_ASSERT(asc_dvc->drv_ptr != NULL);
10275 boardp = asc_dvc->drv_ptr;
10276
10277 iop_base = asc_dvc->iop_base;
10278 int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
10279
10280 halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
10281 halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
10282 target_ix = AscReadLramByte(iop_base,
10283 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_TARGET_IX));
10284 q_cntl = AscReadLramByte(iop_base,
10285 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL));
10286 tid_no = ASC_TIX_TO_TID(target_ix);
10287 target_id = (uchar) ASC_TID_TO_TARGET_ID(tid_no);
10288 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
10289 asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
10290 } else {
10291 asyn_sdtr = 0;
10292 }
10293 if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
10294 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
10295 AscSetChipSDTR(iop_base, 0, tid_no);
10296 boardp->sdtr_data[tid_no] = 0;
10297 }
10298 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
10299 return (0);
10300 } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
10301 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
10302 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
10303 boardp->sdtr_data[tid_no] = asyn_sdtr;
10304 }
10305 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
10306 return (0);
10307 } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
10308
10309 AscMemWordCopyPtrFromLram(iop_base,
10310 ASCV_MSGIN_BEG,
10311 (uchar *) &ext_msg,
10312 sizeof(EXT_MSG) >> 1);
10313
10314 if (ext_msg.msg_type == MS_EXTEND &&
10315 ext_msg.msg_req == MS_SDTR_CODE &&
10316 ext_msg.msg_len == MS_SDTR_LEN) {
10317 sdtr_accept = TRUE;
10318 if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
10319
10320 sdtr_accept = FALSE;
10321 ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
10322 }
10323 if ((ext_msg.xfer_period <
10324 asc_dvc->sdtr_period_tbl[asc_dvc->host_init_sdtr_index]) ||
10325 (ext_msg.xfer_period >
10326 asc_dvc->sdtr_period_tbl[asc_dvc->max_sdtr_index])) {
10327 sdtr_accept = FALSE;
10328 ext_msg.xfer_period =
10329 asc_dvc->sdtr_period_tbl[asc_dvc->host_init_sdtr_index];
10330 }
10331 if (sdtr_accept) {
10332 sdtr_data = AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
10333 ext_msg.req_ack_offset);
10334 if ((sdtr_data == 0xFF)) {
10335
10336 q_cntl |= QC_MSG_OUT;
10337 asc_dvc->init_sdtr &= ~target_id;
10338 asc_dvc->sdtr_done &= ~target_id;
10339 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
10340 boardp->sdtr_data[tid_no] = asyn_sdtr;
10341 }
10342 }
10343 if (ext_msg.req_ack_offset == 0) {
10344
10345 q_cntl &= ~QC_MSG_OUT;
10346 asc_dvc->init_sdtr &= ~target_id;
10347 asc_dvc->sdtr_done &= ~target_id;
10348 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
10349 } else {
10350 if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
10351
10352 q_cntl &= ~QC_MSG_OUT;
10353 asc_dvc->sdtr_done |= target_id;
10354 asc_dvc->init_sdtr |= target_id;
10355 asc_dvc->pci_fix_asyn_xfer &= ~target_id;
10356 sdtr_data = AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
10357 ext_msg.req_ack_offset);
10358 AscSetChipSDTR(iop_base, sdtr_data, tid_no);
10359 boardp->sdtr_data[tid_no] = sdtr_data;
10360 } else {
10361
10362 q_cntl |= QC_MSG_OUT;
10363 AscMsgOutSDTR(asc_dvc,
10364 ext_msg.xfer_period,
10365 ext_msg.req_ack_offset);
10366 asc_dvc->pci_fix_asyn_xfer &= ~target_id;
10367 sdtr_data = AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
10368 ext_msg.req_ack_offset);
10369 AscSetChipSDTR(iop_base, sdtr_data, tid_no);
10370 boardp->sdtr_data[tid_no] = sdtr_data;
10371 asc_dvc->sdtr_done |= target_id;
10372 asc_dvc->init_sdtr |= target_id;
10373 }
10374 }
10375
10376 AscWriteLramByte(iop_base,
10377 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL),
10378 q_cntl);
10379 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
10380 return (0);
10381 } else if (ext_msg.msg_type == MS_EXTEND &&
10382 ext_msg.msg_req == MS_WDTR_CODE &&
10383 ext_msg.msg_len == MS_WDTR_LEN) {
10384
10385 ext_msg.wdtr_width = 0;
10386 AscMemWordCopyPtrToLram(iop_base,
10387 ASCV_MSGOUT_BEG,
10388 (uchar *) &ext_msg,
10389 sizeof(EXT_MSG) >> 1);
10390 q_cntl |= QC_MSG_OUT;
10391 AscWriteLramByte(iop_base,
10392 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL),
10393 q_cntl);
10394 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
10395 return (0);
10396 } else {
10397
10398 ext_msg.msg_type = M1_MSG_REJECT;
10399 AscMemWordCopyPtrToLram(iop_base,
10400 ASCV_MSGOUT_BEG,
10401 (uchar *) &ext_msg,
10402 sizeof(EXT_MSG) >> 1);
10403 q_cntl |= QC_MSG_OUT;
10404 AscWriteLramByte(iop_base,
10405 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL),
10406 q_cntl);
10407 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
10408 return (0);
10409 }
10410 } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
10411
10412 q_cntl |= QC_REQ_SENSE;
10413
10414 if ((asc_dvc->init_sdtr & target_id) != 0) {
10415
10416 asc_dvc->sdtr_done &= ~target_id;
10417
10418 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
10419 q_cntl |= QC_MSG_OUT;
10420 AscMsgOutSDTR(asc_dvc,
10421 asc_dvc->sdtr_period_tbl[(sdtr_data >> 4) &
10422 (uchar) (asc_dvc->max_sdtr_index - 1)],
10423 (uchar) (sdtr_data & (uchar) ASC_SYN_MAX_OFFSET));
10424 }
10425
10426 AscWriteLramByte(iop_base,
10427 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL),
10428 q_cntl);
10429
10430 tag_code = AscReadLramByte(iop_base,
10431 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_TAG_CODE));
10432 tag_code &= 0xDC;
10433 if (
10434 (asc_dvc->pci_fix_asyn_xfer & target_id)
10435 && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
10436) {
10437
10438 tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
10439 | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
10440
10441 }
10442 AscWriteLramByte(iop_base,
10443 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_TAG_CODE),
10444 tag_code);
10445
10446 q_status = AscReadLramByte(iop_base,
10447 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_STATUS));
10448 q_status |= (QS_READY | QS_BUSY);
10449 AscWriteLramByte(iop_base,
10450 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_STATUS),
10451 q_status);
10452
10453 scsi_busy = AscReadLramByte(iop_base,
10454 (ushort) ASCV_SCSIBUSY_B);
10455 scsi_busy &= ~target_id;
10456 AscWriteLramByte(iop_base, (ushort) ASCV_SCSIBUSY_B, scsi_busy);
10457
10458 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
10459 return (0);
10460 } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
10461
10462 AscMemWordCopyPtrFromLram(iop_base,
10463 ASCV_MSGOUT_BEG,
10464 (uchar *) &out_msg,
10465 sizeof(EXT_MSG) >> 1);
10466
10467 if ((out_msg.msg_type == MS_EXTEND) &&
10468 (out_msg.msg_len == MS_SDTR_LEN) &&
10469 (out_msg.msg_req == MS_SDTR_CODE)) {
10470
10471 asc_dvc->init_sdtr &= ~target_id;
10472 asc_dvc->sdtr_done &= ~target_id;
10473 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
10474 boardp->sdtr_data[tid_no] = asyn_sdtr;
10475 }
10476 q_cntl &= ~QC_MSG_OUT;
10477 AscWriteLramByte(iop_base,
10478 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL),
10479 q_cntl);
10480 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
10481 return (0);
10482 } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
10483
10484 scsi_status = AscReadLramByte(iop_base,
10485 (ushort) ((ushort) halt_q_addr + (ushort) ASC_SCSIQ_SCSI_STATUS));
10486 cur_dvc_qng = AscReadLramByte(iop_base,
10487 (ushort) ((ushort) ASC_QADR_BEG + (ushort) target_ix));
10488 if ((cur_dvc_qng > 0) &&
10489 (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
10490
10491 scsi_busy = AscReadLramByte(iop_base,
10492 (ushort) ASCV_SCSIBUSY_B);
10493 scsi_busy |= target_id;
10494 AscWriteLramByte(iop_base,
10495 (ushort) ASCV_SCSIBUSY_B, scsi_busy);
10496 asc_dvc->queue_full_or_busy |= target_id;
10497
10498 if (scsi_status == SS_QUEUE_FULL) {
10499 if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
10500 cur_dvc_qng -= 1;
10501 asc_dvc->max_dvc_qng[tid_no] = cur_dvc_qng;
10502
10503 AscWriteLramByte(iop_base,
10504 (ushort) ((ushort) ASCV_MAX_DVC_QNG_BEG +
10505 (ushort) tid_no),
10506 cur_dvc_qng);
10507
10508
10509
10510
10511
10512
10513 boardp->queue_full |= target_id;
10514 boardp->queue_full_cnt[tid_no] = cur_dvc_qng;
10515 }
10516 }
10517 }
10518 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
10519 return (0);
10520 }
10521#if CC_VERY_LONG_SG_LIST
10522 else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC)
10523 {
10524 uchar q_no;
10525 ushort q_addr;
10526 uchar sg_wk_q_no;
10527 uchar first_sg_wk_q_no;
10528 ASC_SCSI_Q *scsiq;
10529 ASC_SG_HEAD *sg_head;
10530 ASC_SG_LIST_Q scsi_sg_q;
10531 ushort sg_list_dwords;
10532 ushort sg_entry_cnt;
10533 uchar next_qp;
10534 int i;
10535
10536 q_no = AscReadLramByte(iop_base, (ushort) ASCV_REQ_SG_LIST_QP);
10537 if (q_no == ASC_QLINK_END)
10538 {
10539 return(0);
10540 }
10541
10542 q_addr = ASC_QNO_TO_QADDR(q_no);
10543
10544
10545
10546
10547
10548
10549
10550
10551 scsiq = (ASC_SCSI_Q *)
10552 ASC_SRB2SCSIQ(
10553 ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
10554 (ushort) (q_addr + ASC_SCSIQ_D_SRBPTR))));
10555
10556
10557
10558
10559 sg_wk_q_no = AscReadLramByte(iop_base,
10560 (ushort) (q_addr + ASC_SCSIQ_B_SG_WK_QP));
10561
10562 first_sg_wk_q_no = AscReadLramByte(iop_base,
10563 (ushort) (q_addr + ASC_SCSIQ_B_FIRST_SG_WK_QP));
10564
10565
10566
10567
10568
10569 AscWriteLramByte(iop_base,
10570 (ushort) (q_addr + (ushort) ASC_SCSIQ_B_SG_WK_QP),
10571 first_sg_wk_q_no);
10572
10573 sg_head = scsiq->sg_head;
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584 if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1))
10585 {
10586 sg_entry_cnt = ASC_MAX_SG_LIST - 1;
10587
10588
10589
10590
10591
10592 scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
10593 } else
10594 {
10595 sg_entry_cnt = scsiq->remain_sg_entry_cnt;
10596 scsiq->remain_sg_entry_cnt = 0;
10597 }
10598
10599
10600
10601
10602
10603
10604 next_qp = first_sg_wk_q_no;
10605 q_addr = ASC_QNO_TO_QADDR(next_qp);
10606 scsi_sg_q.sg_head_qp = q_no;
10607 scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
10608 for( i = 0; i < sg_head->queue_cnt; i++)
10609 {
10610 scsi_sg_q.seq_no = i + 1;
10611 if (sg_entry_cnt > ASC_SG_LIST_PER_Q)
10612 {
10613 sg_list_dwords = (uchar) (ASC_SG_LIST_PER_Q * 2);
10614 sg_entry_cnt -= ASC_SG_LIST_PER_Q;
10615
10616
10617
10618
10619
10620
10621
10622 scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
10623 scsi_sg_q.sg_cur_list_cnt = ASC_SG_LIST_PER_Q - 1;
10624 } else {
10625
10626
10627
10628
10629
10630
10631 if (scsiq->remain_sg_entry_cnt != 0)
10632 {
10633 scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
10634 } else
10635 {
10636 scsi_sg_q.cntl |= QCSG_SG_XFER_END;
10637 }
10638
10639 sg_list_dwords = sg_entry_cnt << 1;
10640 scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
10641 scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
10642 sg_entry_cnt = 0;
10643 }
10644
10645 scsi_sg_q.q_no = next_qp;
10646 AscMemWordCopyPtrToLram(iop_base,
10647 q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
10648 (uchar *) &scsi_sg_q,
10649 sizeof(ASC_SG_LIST_Q) >> 1);
10650
10651 AscMemDWordCopyPtrToLram(iop_base,
10652 q_addr + ASC_SGQ_LIST_BEG,
10653 (uchar *) &sg_head->sg_list[scsiq->next_sg_index],
10654 sg_list_dwords);
10655
10656 scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
10657
10658
10659
10660
10661
10662
10663 if (scsi_sg_q.cntl & QCSG_SG_XFER_END)
10664 {
10665 break;
10666 }
10667
10668 next_qp = AscReadLramByte( iop_base,
10669 ( ushort )( q_addr+ASC_SCSIQ_B_FWD ) );
10670 q_addr = ASC_QNO_TO_QADDR( next_qp );
10671 }
10672
10673
10674
10675
10676
10677 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
10678 return(0);
10679 }
10680#endif
10681 return (0);
10682}
10683
10684STATIC uchar
10685_AscCopyLramScsiDoneQ(
10686 PortAddr iop_base,
10687 ushort q_addr,
10688 ASC_QDONE_INFO * scsiq,
10689 ASC_DCNT max_dma_count
10690)
10691{
10692 ushort _val;
10693 uchar sg_queue_cnt;
10694
10695 DvcGetQinfo(iop_base,
10696 q_addr + ASC_SCSIQ_DONE_INFO_BEG,
10697 (uchar *) scsiq,
10698 (sizeof (ASC_SCSIQ_2) + sizeof (ASC_SCSIQ_3)) / 2);
10699
10700 _val = AscReadLramWord(iop_base,
10701 (ushort) (q_addr + (ushort) ASC_SCSIQ_B_STATUS));
10702 scsiq->q_status = (uchar) _val;
10703 scsiq->q_no = (uchar) (_val >> 8);
10704 _val = AscReadLramWord(iop_base,
10705 (ushort) (q_addr + (ushort) ASC_SCSIQ_B_CNTL));
10706 scsiq->cntl = (uchar) _val;
10707 sg_queue_cnt = (uchar) (_val >> 8);
10708 _val = AscReadLramWord(iop_base,
10709 (ushort) (q_addr + (ushort) ASC_SCSIQ_B_SENSE_LEN));
10710 scsiq->sense_len = (uchar) _val;
10711 scsiq->extra_bytes = (uchar) (_val >> 8);
10712
10713
10714
10715
10716 scsiq->remain_bytes = (((ADV_DCNT) AscReadLramWord( iop_base,
10717 (ushort) (q_addr+ (ushort) ASC_SCSIQ_W_ALT_DC1))) << 16);
10718
10719
10720
10721 scsiq->remain_bytes += AscReadLramWord(iop_base,
10722 (ushort) (q_addr+ (ushort) ASC_SCSIQ_DW_REMAIN_XFER_CNT));
10723
10724 scsiq->remain_bytes &= max_dma_count;
10725 return (sg_queue_cnt);
10726}
10727
10728STATIC int
10729AscIsrQDone(
10730 ASC_DVC_VAR *asc_dvc
10731)
10732{
10733 uchar next_qp;
10734 uchar n_q_used;
10735 uchar sg_list_qp;
10736 uchar sg_queue_cnt;
10737 uchar q_cnt;
10738 uchar done_q_tail;
10739 uchar tid_no;
10740 ASC_SCSI_BIT_ID_TYPE scsi_busy;
10741 ASC_SCSI_BIT_ID_TYPE target_id;
10742 PortAddr iop_base;
10743 ushort q_addr;
10744 ushort sg_q_addr;
10745 uchar cur_target_qng;
10746 ASC_QDONE_INFO scsiq_buf;
10747 ASC_QDONE_INFO *scsiq;
10748 int false_overrun;
10749 ASC_ISR_CALLBACK asc_isr_callback;
10750
10751 iop_base = asc_dvc->iop_base;
10752 asc_isr_callback = asc_dvc->isr_callback;
10753 n_q_used = 1;
10754 scsiq = (ASC_QDONE_INFO *) & scsiq_buf;
10755 done_q_tail = (uchar) AscGetVarDoneQTail(iop_base);
10756 q_addr = ASC_QNO_TO_QADDR(done_q_tail);
10757 next_qp = AscReadLramByte(iop_base,
10758 (ushort) (q_addr + (ushort) ASC_SCSIQ_B_FWD));
10759 if (next_qp != ASC_QLINK_END) {
10760 AscPutVarDoneQTail(iop_base, next_qp);
10761 q_addr = ASC_QNO_TO_QADDR(next_qp);
10762 sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
10763 asc_dvc->max_dma_count);
10764 AscWriteLramByte(iop_base,
10765 (ushort) (q_addr + (ushort) ASC_SCSIQ_B_STATUS),
10766 (uchar) (scsiq->q_status & (uchar) ~ (QS_READY | QS_ABORTED)));
10767 tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
10768 target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
10769 if ((scsiq->cntl & QC_SG_HEAD) != 0) {
10770 sg_q_addr = q_addr;
10771 sg_list_qp = next_qp;
10772 for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
10773 sg_list_qp = AscReadLramByte(iop_base,
10774 (ushort) (sg_q_addr + (ushort) ASC_SCSIQ_B_FWD));
10775 sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
10776 if (sg_list_qp == ASC_QLINK_END) {
10777 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_SG_Q_LINKS);
10778 scsiq->d3.done_stat = QD_WITH_ERROR;
10779 scsiq->d3.host_stat = QHSTA_D_QDONE_SG_LIST_CORRUPTED;
10780 goto FATAL_ERR_QDONE;
10781 }
10782 AscWriteLramByte(iop_base,
10783 (ushort) (sg_q_addr + (ushort) ASC_SCSIQ_B_STATUS),
10784 QS_FREE);
10785 }
10786 n_q_used = sg_queue_cnt + 1;
10787 AscPutVarDoneQTail(iop_base, sg_list_qp);
10788 }
10789 if (asc_dvc->queue_full_or_busy & target_id) {
10790 cur_target_qng = AscReadLramByte(iop_base,
10791 (ushort) ((ushort) ASC_QADR_BEG + (ushort) scsiq->d2.target_ix));
10792 if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
10793 scsi_busy = AscReadLramByte(iop_base,
10794 (ushort) ASCV_SCSIBUSY_B);
10795 scsi_busy &= ~target_id;
10796 AscWriteLramByte(iop_base,
10797 (ushort) ASCV_SCSIBUSY_B, scsi_busy);
10798 asc_dvc->queue_full_or_busy &= ~target_id;
10799 }
10800 }
10801 if (asc_dvc->cur_total_qng >= n_q_used) {
10802 asc_dvc->cur_total_qng -= n_q_used;
10803 if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
10804 asc_dvc->cur_dvc_qng[tid_no]--;
10805 }
10806 } else {
10807 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
10808 scsiq->d3.done_stat = QD_WITH_ERROR;
10809 goto FATAL_ERR_QDONE;
10810 }
10811 if ((scsiq->d2.srb_ptr == 0UL) ||
10812 ((scsiq->q_status & QS_ABORTED) != 0)) {
10813 return (0x11);
10814 } else if (scsiq->q_status == QS_DONE) {
10815 false_overrun = FALSE;
10816 if (scsiq->extra_bytes != 0) {
10817 scsiq->remain_bytes += (ADV_DCNT) scsiq->extra_bytes;
10818 }
10819 if (scsiq->d3.done_stat == QD_WITH_ERROR) {
10820 if (scsiq->d3.host_stat == QHSTA_M_DATA_OVER_RUN) {
10821 if ((scsiq->cntl & (QC_DATA_IN | QC_DATA_OUT)) == 0) {
10822 scsiq->d3.done_stat = QD_NO_ERROR;
10823 scsiq->d3.host_stat = QHSTA_NO_ERROR;
10824 } else if (false_overrun) {
10825 scsiq->d3.done_stat = QD_NO_ERROR;
10826 scsiq->d3.host_stat = QHSTA_NO_ERROR;
10827 }
10828 } else if (scsiq->d3.host_stat ==
10829 QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
10830 AscStopChip(iop_base);
10831 AscSetChipControl(iop_base,
10832 (uchar) (CC_SCSI_RESET | CC_HALT));
10833 DvcDelayNanoSecond(asc_dvc, 60000);
10834 AscSetChipControl(iop_base, CC_HALT);
10835 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
10836 AscSetChipStatus(iop_base, 0);
10837 AscSetChipControl(iop_base, 0);
10838 }
10839 }
10840 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
10841 (*asc_isr_callback) (asc_dvc, scsiq);
10842 } else {
10843 if ((AscReadLramByte(iop_base,
10844 (ushort) (q_addr + (ushort) ASC_SCSIQ_CDB_BEG)) ==
10845 SCSICMD_StartStopUnit)) {
10846 asc_dvc->unit_not_ready &= ~target_id;
10847 if (scsiq->d3.done_stat != QD_NO_ERROR) {
10848 asc_dvc->start_motor &= ~target_id;
10849 }
10850 }
10851 }
10852 return (1);
10853 } else {
10854 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
10855 FATAL_ERR_QDONE:
10856 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
10857 (*asc_isr_callback) (asc_dvc, scsiq);
10858 }
10859 return (0x80);
10860 }
10861 }
10862 return (0);
10863}
10864
10865STATIC int
10866AscISR(
10867 ASC_DVC_VAR *asc_dvc
10868)
10869{
10870 ASC_CS_TYPE chipstat;
10871 PortAddr iop_base;
10872 ushort saved_ram_addr;
10873 uchar ctrl_reg;
10874 uchar saved_ctrl_reg;
10875 int int_pending;
10876 int status;
10877 uchar host_flag;
10878
10879 iop_base = asc_dvc->iop_base;
10880 int_pending = FALSE;
10881
10882 if (AscIsIntPending(iop_base) == 0)
10883 {
10884 return int_pending;
10885 }
10886
10887 if (((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0)
10888 || (asc_dvc->isr_callback == 0)
10889) {
10890 return (ERR);
10891 }
10892 if (asc_dvc->in_critical_cnt != 0) {
10893 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
10894 return (ERR);
10895 }
10896 if (asc_dvc->is_in_int) {
10897 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
10898 return (ERR);
10899 }
10900 asc_dvc->is_in_int = TRUE;
10901 ctrl_reg = AscGetChipControl(iop_base);
10902 saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
10903 CC_SINGLE_STEP | CC_DIAG | CC_TEST));
10904 chipstat = AscGetChipStatus(iop_base);
10905 if (chipstat & CSW_SCSI_RESET_LATCH) {
10906 if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
10907 int i = 10;
10908 int_pending = TRUE;
10909 asc_dvc->sdtr_done = 0;
10910 saved_ctrl_reg &= (uchar) (~CC_HALT);
10911 while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE) &&
10912 (i-- > 0))
10913 {
10914 DvcSleepMilliSecond(100);
10915 }
10916 AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
10917 AscSetChipControl(iop_base, CC_HALT);
10918 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
10919 AscSetChipStatus(iop_base, 0);
10920 chipstat = AscGetChipStatus(iop_base);
10921 }
10922 }
10923 saved_ram_addr = AscGetChipLramAddr(iop_base);
10924 host_flag = AscReadLramByte(iop_base,
10925 ASCV_HOST_FLAG_B) & (uchar) (~ASC_HOST_FLAG_IN_ISR);
10926 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
10927 (uchar) (host_flag | (uchar) ASC_HOST_FLAG_IN_ISR));
10928 if ((chipstat & CSW_INT_PENDING)
10929 || (int_pending)
10930) {
10931 AscAckInterrupt(iop_base);
10932 int_pending = TRUE;
10933 if ((chipstat & CSW_HALTED) &&
10934 (ctrl_reg & CC_SINGLE_STEP)) {
10935 if (AscIsrChipHalted(asc_dvc) == ERR) {
10936 goto ISR_REPORT_QDONE_FATAL_ERROR;
10937 } else {
10938 saved_ctrl_reg &= (uchar) (~CC_HALT);
10939 }
10940 } else {
10941 ISR_REPORT_QDONE_FATAL_ERROR:
10942 if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
10943 while (((status = AscIsrQDone(asc_dvc)) & 0x01) != 0) {
10944 }
10945 } else {
10946 do {
10947 if ((status = AscIsrQDone(asc_dvc)) == 1) {
10948 break;
10949 }
10950 } while (status == 0x11);
10951 }
10952 if ((status & 0x80) != 0)
10953 int_pending = ERR;
10954 }
10955 }
10956 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
10957 AscSetChipLramAddr(iop_base, saved_ram_addr);
10958 AscSetChipControl(iop_base, saved_ctrl_reg);
10959 asc_dvc->is_in_int = FALSE;
10960 return (int_pending);
10961}
10962
10963
10964STATIC uchar _asc_mcode_buf[] =
10965{
10966 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10967 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10968 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10969 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10970 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00,
10971 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10972 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
10973 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00,
10974 0x80, 0x73, 0x48, 0x04, 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40,
10975 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2, 0xC2, 0x00, 0x92, 0x80,
10976 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98, 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80,
10977 0x4F, 0x00, 0xF5, 0x00, 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62,
10978 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8, 0xCD, 0x04, 0x4D, 0x00,
10979 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1,
10980 0x80, 0x73, 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88,
10981 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00, 0x84, 0x97, 0x07, 0xA6,
10982 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00,
10983 0x69, 0x60, 0xCE, 0x00, 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6,
10984 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6, 0x34, 0x01, 0x00, 0x33,
10985 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01, 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04,
10986 0x04, 0x85, 0x05, 0xD8, 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23,
10987 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01, 0x00, 0x33, 0x0A, 0x00,
10988 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01, 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04,
10989 0x36, 0x2D, 0x00, 0x33, 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01,
10990 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3, 0x3C, 0x01, 0x00, 0x05,
10991 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6, 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01,
10992 0xBE, 0x81, 0xFD, 0x23, 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0,
10993 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00, 0xC2, 0x88, 0x06, 0x23,
10994 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01, 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0,
10995 0xDA, 0x01, 0xE6, 0x84, 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61,
10996 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC, 0x4F, 0x00, 0x84, 0x97,
10997 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01, 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80,
10998 0xF0, 0x97, 0x00, 0x46, 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29,
10999 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88, 0x04, 0x98, 0xF0, 0x80,
11000 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02, 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6,
11001 0x4C, 0x04, 0x46, 0x82, 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95,
11002 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02, 0x07, 0xA6, 0x5A, 0x02,
11003 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02, 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96,
11004 0x48, 0x82, 0x04, 0x23, 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC,
11005 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01, 0x6F, 0x00, 0xA5, 0x01,
11006 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01, 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02,
11007 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02,
11008 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E, 0x80, 0x63, 0x00, 0x43,
11009 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01, 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01,
11010 0x10, 0x31, 0x12, 0x35, 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82,
11011 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8, 0x00, 0x33, 0x1F, 0x00,
11012 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39, 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6,
11013 0x14, 0x03, 0x00, 0xA6, 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6,
11014 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0xEE, 0x82,
11015 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42, 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8,
11016 0x31, 0x05, 0x07, 0x01, 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98,
11017 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6, 0x3C, 0x04, 0x06, 0xA6,
11018 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33, 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83,
11019 0x60, 0x96, 0x32, 0x83, 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33,
11020 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05, 0xFF, 0xA2, 0x7A, 0x03,
11021 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83, 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03,
11022 0xEC, 0x00, 0x6E, 0x00, 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03,
11023 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6, 0xA4, 0x03, 0x00, 0xA6,
11024 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42, 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03,
11025 0xD4, 0x83, 0x7C, 0x95, 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42,
11026 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95, 0xC0, 0x83, 0x00, 0x33,
11027 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32, 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23,
11028 0xA1, 0x01, 0x10, 0x84, 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
11029 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04, 0x06, 0xA6, 0x0A, 0x04,
11030 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84,
11031 0x07, 0xF0, 0x06, 0xA4, 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63,
11032 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6, 0x38, 0x04, 0x00, 0x33,
11033 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84, 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC,
11034 0x00, 0x33, 0x00, 0x84, 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63,
11035 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x80, 0x63, 0xA3, 0x01,
11036 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2, 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00,
11037 0x00, 0x33, 0x1D, 0x00, 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00,
11038 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04, 0x08, 0x23, 0x22, 0xA3,
11039 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04, 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23,
11040 0xF8, 0x88, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98,
11041 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20, 0x81, 0x62, 0xE8, 0x81,
11042 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE, 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81,
11043 0xC0, 0x20, 0x81, 0x62, 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23,
11044 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3, 0xF4, 0x04, 0x00, 0x33,
11045 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC, 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01,
11046 0x04, 0x98, 0x26, 0x95, 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05,
11047 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85, 0x46, 0x97, 0xCD, 0x04,
11048 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01, 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85,
11049 0x02, 0x23, 0xA0, 0x01, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6,
11050 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01, 0x49, 0x00, 0x81, 0x01,
11051 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01, 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01,
11052 0xC9, 0x00, 0x00, 0x05, 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00,
11053 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63, 0x07, 0xA4, 0xF8, 0x05,
11054 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85, 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0,
11055 0xB8, 0x05, 0x80, 0x63, 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05,
11056 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00, 0x62, 0x97, 0x04, 0x85,
11057 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85, 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0,
11058 0xC4, 0x05, 0xF4, 0x85, 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0,
11059 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05, 0x80, 0x67, 0x80, 0x63,
11060 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23, 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23,
11061 0x80, 0x00, 0x06, 0x87, 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00,
11062 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23, 0x07, 0x41, 0x83, 0x03,
11063 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33, 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6,
11064 0x20, 0x23, 0x63, 0x60, 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05,
11065 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00, 0x52, 0x00, 0x06, 0x61,
11066 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA, 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01,
11067 0x04, 0xCC, 0x00, 0x33, 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63,
11068 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23, 0xDF, 0x00, 0x06, 0xA6,
11069 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20,
11070 0x81, 0x62, 0x00, 0x63, 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06,
11071 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B, 0x40, 0x0E, 0x80, 0x63,
11072 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43,
11073 0x00, 0xA0, 0xA2, 0x06, 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E,
11074 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x07, 0xA6, 0xD6, 0x06,
11075 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6,
11076 0xE8, 0x06, 0x00, 0x33, 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E,
11077 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20, 0x81, 0x62, 0x04, 0x01,
11078 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33,
11079 0x2C, 0x00, 0xC2, 0x88, 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6,
11080 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88, 0x00, 0x00, 0x80, 0x67,
11081 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61,
11082 0x84, 0x01, 0xE6, 0x84, 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00,
11083 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04, 0x80, 0x05, 0x81, 0x05,
11084 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01,
11085 0x70, 0x04, 0x71, 0x00, 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01,
11086 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01, 0xF1, 0x00, 0x70, 0x00,
11087 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01, 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00,
11088 0x81, 0x01, 0x70, 0x04, 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01,
11089 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1, 0xC4, 0x07, 0x00, 0x33,
11090 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05, 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01,
11091 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07,
11092 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01, 0x05, 0x05, 0x00, 0x63,
11093 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02,
11094 0x77, 0x04, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0,
11095 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63, 0xF3, 0x04,
11096 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43, 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08,
11097 0x74, 0x04, 0x02, 0x01, 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98,
11098 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04, 0x5A, 0x88, 0x02, 0x01,
11099 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95, 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08,
11100 0x00, 0x05, 0x4E, 0x88, 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08,
11101 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x38, 0x2B,
11102 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09, 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09,
11103 0x00, 0x63, 0x00, 0x32, 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36,
11104 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32, 0x40, 0x36, 0x40, 0x3A,
11105 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40, 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3,
11106 0x00, 0x63, 0x80, 0x73, 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73,
11107 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01, 0xA1, 0x23, 0xA1, 0x01,
11108 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77, 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2,
11109 0xF1, 0xC7, 0x41, 0x23, 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84,
11110};
11111
11112STATIC ushort _asc_mcode_size = sizeof(_asc_mcode_buf);
11113STATIC ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
11114
11115#define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
11116STATIC uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] =
11117{
11118 SCSICMD_Inquiry,
11119 SCSICMD_RequestSense,
11120 SCSICMD_ReadCapacity,
11121 SCSICMD_ReadTOC,
11122 SCSICMD_ModeSelect6,
11123 SCSICMD_ModeSense6,
11124 SCSICMD_ModeSelect10,
11125 SCSICMD_ModeSense10,
11126 0xFF,
11127 0xFF,
11128 0xFF,
11129 0xFF,
11130 0xFF,
11131 0xFF,
11132 0xFF,
11133 0xFF
11134};
11135
11136STATIC int
11137AscExeScsiQueue(
11138 ASC_DVC_VAR *asc_dvc,
11139 ASC_SCSI_Q *scsiq
11140)
11141{
11142 PortAddr iop_base;
11143 ulong last_int_level;
11144 int sta;
11145 int n_q_required;
11146 int disable_syn_offset_one_fix;
11147 int i;
11148 ASC_PADDR addr;
11149 ASC_EXE_CALLBACK asc_exe_callback;
11150 ushort sg_entry_cnt = 0;
11151 ushort sg_entry_cnt_minus_one = 0;
11152 uchar target_ix;
11153 uchar tid_no;
11154 uchar sdtr_data;
11155 uchar extra_bytes;
11156 uchar scsi_cmd;
11157 uchar disable_cmd;
11158 ASC_SG_HEAD *sg_head;
11159 ASC_DCNT data_cnt;
11160
11161 iop_base = asc_dvc->iop_base;
11162 sg_head = scsiq->sg_head;
11163 asc_exe_callback = asc_dvc->exe_callback;
11164 if (asc_dvc->err_code != 0)
11165 return (ERR);
11166 if (scsiq == (ASC_SCSI_Q *) 0L) {
11167 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_SCSIQ_NULL_PTR);
11168 return (ERR);
11169 }
11170 scsiq->q1.q_no = 0;
11171 if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
11172 scsiq->q1.extra_bytes = 0;
11173 }
11174 sta = 0;
11175 target_ix = scsiq->q2.target_ix;
11176 tid_no = ASC_TIX_TO_TID(target_ix);
11177 n_q_required = 1;
11178 if (scsiq->cdbptr[0] == SCSICMD_RequestSense) {
11179 if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
11180 asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
11181 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
11182 AscMsgOutSDTR(asc_dvc,
11183 asc_dvc->sdtr_period_tbl[(sdtr_data >> 4) &
11184 (uchar) (asc_dvc->max_sdtr_index - 1)],
11185 (uchar) (sdtr_data & (uchar) ASC_SYN_MAX_OFFSET));
11186 scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
11187 }
11188 }
11189 last_int_level = DvcEnterCritical();
11190 if (asc_dvc->in_critical_cnt != 0) {
11191 DvcLeaveCritical(last_int_level);
11192 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
11193 return (ERR);
11194 }
11195 asc_dvc->in_critical_cnt++;
11196 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
11197 if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
11198 asc_dvc->in_critical_cnt--;
11199 DvcLeaveCritical(last_int_level);
11200 return (ERR);
11201 }
11202#if !CC_VERY_LONG_SG_LIST
11203 if (sg_entry_cnt > ASC_MAX_SG_LIST)
11204 {
11205 asc_dvc->in_critical_cnt--;
11206 DvcLeaveCritical(last_int_level);
11207 return(ERR);
11208 }
11209#endif
11210 if (sg_entry_cnt == 1) {
11211 scsiq->q1.data_addr = (ADV_PADDR) sg_head->sg_list[0].addr;
11212 scsiq->q1.data_cnt = (ADV_DCNT) sg_head->sg_list[0].bytes;
11213 scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
11214 }
11215 sg_entry_cnt_minus_one = sg_entry_cnt - 1;
11216 }
11217 scsi_cmd = scsiq->cdbptr[0];
11218 disable_syn_offset_one_fix = FALSE;
11219 if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
11220 !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
11221 if (scsiq->q1.cntl & QC_SG_HEAD) {
11222 data_cnt = 0;
11223 for (i = 0; i < sg_entry_cnt; i++) {
11224 data_cnt += (ADV_DCNT) le32_to_cpu(sg_head->sg_list[i].bytes);
11225 }
11226 } else {
11227 data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
11228 }
11229 if (data_cnt != 0UL) {
11230 if (data_cnt < 512UL) {
11231 disable_syn_offset_one_fix = TRUE;
11232 } else {
11233 for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST; i++) {
11234 disable_cmd = _syn_offset_one_disable_cmd[i];
11235 if (disable_cmd == 0xFF) {
11236 break;
11237 }
11238 if (scsi_cmd == disable_cmd) {
11239 disable_syn_offset_one_fix = TRUE;
11240 break;
11241 }
11242 }
11243 }
11244 }
11245 }
11246 if (disable_syn_offset_one_fix) {
11247 scsiq->q2.tag_code &= ~M2_QTAG_MSG_SIMPLE;
11248 scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
11249 ASC_TAG_FLAG_DISABLE_DISCONNECT);
11250 } else {
11251 scsiq->q2.tag_code &= 0x27;
11252 }
11253 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
11254 if (asc_dvc->bug_fix_cntl) {
11255 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
11256 if ((scsi_cmd == SCSICMD_Read6) ||
11257 (scsi_cmd == SCSICMD_Read10)) {
11258 addr =
11259 (ADV_PADDR) le32_to_cpu(
11260 sg_head->sg_list[sg_entry_cnt_minus_one].addr) +
11261 (ADV_DCNT) le32_to_cpu(
11262 sg_head->sg_list[sg_entry_cnt_minus_one].bytes);
11263 extra_bytes = (uchar) ((ushort) addr & 0x0003);
11264 if ((extra_bytes != 0) &&
11265 ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES)
11266 == 0)) {
11267 scsiq->q2.tag_code |= ASC_TAG_FLAG_EXTRA_BYTES;
11268 scsiq->q1.extra_bytes = extra_bytes;
11269 data_cnt = le32_to_cpu(
11270 sg_head->sg_list[sg_entry_cnt_minus_one].bytes);
11271 data_cnt -= (ASC_DCNT) extra_bytes;
11272 sg_head->sg_list[sg_entry_cnt_minus_one].bytes =
11273 cpu_to_le32(data_cnt);
11274 }
11275 }
11276 }
11277 }
11278 sg_head->entry_to_copy = sg_head->entry_cnt;
11279#if CC_VERY_LONG_SG_LIST
11280
11281
11282
11283
11284
11285 if (sg_entry_cnt > ASC_MAX_SG_LIST)
11286 {
11287 sg_entry_cnt = ASC_MAX_SG_LIST;
11288 }
11289#endif
11290 n_q_required = AscSgListToQueue(sg_entry_cnt);
11291 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
11292 (uint) n_q_required) || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
11293 if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
11294 n_q_required)) == 1) {
11295 asc_dvc->in_critical_cnt--;
11296 if (asc_exe_callback != 0) {
11297 (*asc_exe_callback) (asc_dvc, scsiq);
11298 }
11299 DvcLeaveCritical(last_int_level);
11300 return (sta);
11301 }
11302 }
11303 } else {
11304 if (asc_dvc->bug_fix_cntl) {
11305 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
11306 if ((scsi_cmd == SCSICMD_Read6) ||
11307 (scsi_cmd == SCSICMD_Read10)) {
11308 addr = le32_to_cpu(scsiq->q1.data_addr) +
11309 le32_to_cpu(scsiq->q1.data_cnt);
11310 extra_bytes = (uchar) ((ushort) addr & 0x0003);
11311 if ((extra_bytes != 0) &&
11312 ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES)
11313 == 0)) {
11314 data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
11315 if (((ushort) data_cnt & 0x01FF) == 0) {
11316 scsiq->q2.tag_code |= ASC_TAG_FLAG_EXTRA_BYTES;
11317 data_cnt -= (ASC_DCNT) extra_bytes;
11318 scsiq->q1.data_cnt = cpu_to_le32(data_cnt);
11319 scsiq->q1.extra_bytes = extra_bytes;
11320 }
11321 }
11322 }
11323 }
11324 }
11325 n_q_required = 1;
11326 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
11327 ((scsiq->q1.cntl & QC_URGENT) != 0)) {
11328 if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
11329 n_q_required)) == 1) {
11330 asc_dvc->in_critical_cnt--;
11331 if (asc_exe_callback != 0) {
11332 (*asc_exe_callback) (asc_dvc, scsiq);
11333 }
11334 DvcLeaveCritical(last_int_level);
11335 return (sta);
11336 }
11337 }
11338 }
11339 asc_dvc->in_critical_cnt--;
11340 DvcLeaveCritical(last_int_level);
11341 return (sta);
11342}
11343
11344STATIC int
11345AscSendScsiQueue(
11346 ASC_DVC_VAR *asc_dvc,
11347 ASC_SCSI_Q *scsiq,
11348 uchar n_q_required
11349)
11350{
11351 PortAddr iop_base;
11352 uchar free_q_head;
11353 uchar next_qp;
11354 uchar tid_no;
11355 uchar target_ix;
11356 int sta;
11357
11358 iop_base = asc_dvc->iop_base;
11359 target_ix = scsiq->q2.target_ix;
11360 tid_no = ASC_TIX_TO_TID(target_ix);
11361 sta = 0;
11362 free_q_head = (uchar) AscGetVarFreeQHead(iop_base);
11363 if (n_q_required > 1) {
11364 if ((next_qp = AscAllocMultipleFreeQueue(iop_base,
11365 free_q_head, (uchar) (n_q_required)))
11366 != (uchar) ASC_QLINK_END) {
11367 asc_dvc->last_q_shortage = 0;
11368 scsiq->sg_head->queue_cnt = n_q_required - 1;
11369 scsiq->q1.q_no = free_q_head;
11370 if ((sta = AscPutReadySgListQueue(asc_dvc, scsiq,
11371 free_q_head)) == 1) {
11372 AscPutVarFreeQHead(iop_base, next_qp);
11373 asc_dvc->cur_total_qng += (uchar) (n_q_required);
11374 asc_dvc->cur_dvc_qng[tid_no]++;
11375 }
11376 return (sta);
11377 }
11378 } else if (n_q_required == 1) {
11379 if ((next_qp = AscAllocFreeQueue(iop_base,
11380 free_q_head)) != ASC_QLINK_END) {
11381 scsiq->q1.q_no = free_q_head;
11382 if ((sta = AscPutReadyQueue(asc_dvc, scsiq,
11383 free_q_head)) == 1) {
11384 AscPutVarFreeQHead(iop_base, next_qp);
11385 asc_dvc->cur_total_qng++;
11386 asc_dvc->cur_dvc_qng[tid_no]++;
11387 }
11388 return (sta);
11389 }
11390 }
11391 return (sta);
11392}
11393
11394STATIC int
11395AscSgListToQueue(
11396 int sg_list
11397)
11398{
11399 int n_sg_list_qs;
11400
11401 n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
11402 if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
11403 n_sg_list_qs++;
11404 return (n_sg_list_qs + 1);
11405}
11406
11407
11408STATIC uint
11409AscGetNumOfFreeQueue(
11410 ASC_DVC_VAR *asc_dvc,
11411 uchar target_ix,
11412 uchar n_qs
11413)
11414{
11415 uint cur_used_qs;
11416 uint cur_free_qs;
11417 ASC_SCSI_BIT_ID_TYPE target_id;
11418 uchar tid_no;
11419
11420 target_id = ASC_TIX_TO_TARGET_ID(target_ix);
11421 tid_no = ASC_TIX_TO_TID(target_ix);
11422 if ((asc_dvc->unit_not_ready & target_id) ||
11423 (asc_dvc->queue_full_or_busy & target_id)) {
11424 return (0);
11425 }
11426 if (n_qs == 1) {
11427 cur_used_qs = (uint) asc_dvc->cur_total_qng +
11428 (uint) asc_dvc->last_q_shortage +
11429 (uint) ASC_MIN_FREE_Q;
11430 } else {
11431 cur_used_qs = (uint) asc_dvc->cur_total_qng +
11432 (uint) ASC_MIN_FREE_Q;
11433 }
11434 if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
11435 cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
11436 if (asc_dvc->cur_dvc_qng[tid_no] >=
11437 asc_dvc->max_dvc_qng[tid_no]) {
11438 return (0);
11439 }
11440 return (cur_free_qs);
11441 }
11442 if (n_qs > 1) {
11443 if ((n_qs > asc_dvc->last_q_shortage) && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
11444 asc_dvc->last_q_shortage = n_qs;
11445 }
11446 }
11447 return (0);
11448}
11449
11450STATIC int
11451AscPutReadyQueue(
11452 ASC_DVC_VAR *asc_dvc,
11453 ASC_SCSI_Q *scsiq,
11454 uchar q_no
11455)
11456{
11457 ushort q_addr;
11458 uchar tid_no;
11459 uchar sdtr_data;
11460 uchar syn_period_ix;
11461 uchar syn_offset;
11462 PortAddr iop_base;
11463
11464 iop_base = asc_dvc->iop_base;
11465 if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
11466 ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
11467 tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
11468 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
11469 syn_period_ix = (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
11470 syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
11471 AscMsgOutSDTR(asc_dvc,
11472 asc_dvc->sdtr_period_tbl[syn_period_ix],
11473 syn_offset);
11474 scsiq->q1.cntl |= QC_MSG_OUT;
11475 }
11476 q_addr = ASC_QNO_TO_QADDR(q_no);
11477 if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
11478 scsiq->q2.tag_code &= ~M2_QTAG_MSG_SIMPLE;
11479 }
11480 scsiq->q1.status = QS_FREE;
11481 AscMemWordCopyPtrToLram(iop_base,
11482 q_addr + ASC_SCSIQ_CDB_BEG,
11483 (uchar *) scsiq->cdbptr,
11484 scsiq->q2.cdb_len >> 1);
11485
11486 DvcPutScsiQ(iop_base,
11487 q_addr + ASC_SCSIQ_CPY_BEG,
11488 (uchar *) &scsiq->q1.cntl,
11489 ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
11490 AscWriteLramWord(iop_base,
11491 (ushort) (q_addr + (ushort) ASC_SCSIQ_B_STATUS),
11492 (ushort) (((ushort) scsiq->q1.q_no << 8) | (ushort) QS_READY));
11493 return (1);
11494}
11495
11496STATIC int
11497AscPutReadySgListQueue(
11498 ASC_DVC_VAR *asc_dvc,
11499 ASC_SCSI_Q *scsiq,
11500 uchar q_no
11501)
11502{
11503 int sta;
11504 int i;
11505 ASC_SG_HEAD *sg_head;
11506 ASC_SG_LIST_Q scsi_sg_q;
11507 ASC_DCNT saved_data_addr;
11508 ASC_DCNT saved_data_cnt;
11509 PortAddr iop_base;
11510 ushort sg_list_dwords;
11511 ushort sg_index;
11512 ushort sg_entry_cnt;
11513 ushort q_addr;
11514 uchar next_qp;
11515
11516 iop_base = asc_dvc->iop_base;
11517 sg_head = scsiq->sg_head;
11518 saved_data_addr = scsiq->q1.data_addr;
11519 saved_data_cnt = scsiq->q1.data_cnt;
11520 scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
11521 scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
11522#if CC_VERY_LONG_SG_LIST
11523
11524
11525
11526
11527
11528
11529 if (sg_head->entry_cnt > ASC_MAX_SG_LIST)
11530 {
11531
11532
11533
11534
11535
11536
11537
11538 sg_entry_cnt = ASC_MAX_SG_LIST - 1;
11539
11540
11541
11542
11543
11544 scsiq->remain_sg_entry_cnt = sg_head->entry_cnt - ASC_MAX_SG_LIST;
11545 } else
11546 {
11547#endif
11548
11549
11550
11551
11552
11553 sg_entry_cnt = sg_head->entry_cnt - 1;
11554#if CC_VERY_LONG_SG_LIST
11555 }
11556#endif
11557 if (sg_entry_cnt != 0) {
11558 scsiq->q1.cntl |= QC_SG_HEAD;
11559 q_addr = ASC_QNO_TO_QADDR(q_no);
11560 sg_index = 1;
11561 scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
11562 scsi_sg_q.sg_head_qp = q_no;
11563 scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
11564 for (i = 0; i < sg_head->queue_cnt; i++) {
11565 scsi_sg_q.seq_no = i + 1;
11566 if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
11567 sg_list_dwords = (uchar) (ASC_SG_LIST_PER_Q * 2);
11568 sg_entry_cnt -= ASC_SG_LIST_PER_Q;
11569 if (i == 0) {
11570 scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q;
11571 scsi_sg_q.sg_cur_list_cnt = ASC_SG_LIST_PER_Q;
11572 } else {
11573 scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
11574 scsi_sg_q.sg_cur_list_cnt = ASC_SG_LIST_PER_Q - 1;
11575 }
11576 } else {
11577#if CC_VERY_LONG_SG_LIST
11578
11579
11580
11581
11582
11583
11584 if (sg_head->entry_cnt > ASC_MAX_SG_LIST)
11585 {
11586 scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
11587 } else
11588 {
11589#endif
11590 scsi_sg_q.cntl |= QCSG_SG_XFER_END;
11591#if CC_VERY_LONG_SG_LIST
11592 }
11593#endif
11594 sg_list_dwords = sg_entry_cnt << 1;
11595 if (i == 0) {
11596 scsi_sg_q.sg_list_cnt = sg_entry_cnt;
11597 scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt;
11598 } else {
11599 scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
11600 scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
11601 }
11602 sg_entry_cnt = 0;
11603 }
11604 next_qp = AscReadLramByte(iop_base,
11605 (ushort) (q_addr + ASC_SCSIQ_B_FWD));
11606 scsi_sg_q.q_no = next_qp;
11607 q_addr = ASC_QNO_TO_QADDR(next_qp);
11608 AscMemWordCopyPtrToLram(iop_base,
11609 q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
11610 (uchar *) &scsi_sg_q,
11611 sizeof(ASC_SG_LIST_Q) >> 1);
11612 AscMemDWordCopyPtrToLram(iop_base,
11613 q_addr + ASC_SGQ_LIST_BEG,
11614 (uchar *) &sg_head->sg_list[sg_index],
11615 sg_list_dwords);
11616 sg_index += ASC_SG_LIST_PER_Q;
11617 scsiq->next_sg_index = sg_index;
11618 }
11619 } else {
11620 scsiq->q1.cntl &= ~QC_SG_HEAD;
11621 }
11622 sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
11623 scsiq->q1.data_addr = saved_data_addr;
11624 scsiq->q1.data_cnt = saved_data_cnt;
11625 return (sta);
11626}
11627
11628STATIC int
11629AscSetRunChipSynRegAtID(
11630 PortAddr iop_base,
11631 uchar tid_no,
11632 uchar sdtr_data
11633)
11634{
11635 int sta = FALSE;
11636
11637 if (AscHostReqRiscHalt(iop_base)) {
11638 sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
11639 AscStartChip(iop_base);
11640 return (sta);
11641 }
11642 return (sta);
11643}
11644
11645STATIC int
11646AscSetChipSynRegAtID(
11647 PortAddr iop_base,
11648 uchar id,
11649 uchar sdtr_data
11650)
11651{
11652 ASC_SCSI_BIT_ID_TYPE org_id;
11653 int i;
11654 int sta = TRUE;
11655
11656 AscSetBank(iop_base, 1);
11657 org_id = AscReadChipDvcID(iop_base);
11658 for (i = 0; i <= ASC_MAX_TID; i++) {
11659 if (org_id == (0x01 << i))
11660 break;
11661 }
11662 org_id = (ASC_SCSI_BIT_ID_TYPE) i;
11663 AscWriteChipDvcID(iop_base, id);
11664 if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
11665 AscSetBank(iop_base, 0);
11666 AscSetChipSyn(iop_base, sdtr_data);
11667 if (AscGetChipSyn(iop_base) != sdtr_data) {
11668 sta = FALSE;
11669 }
11670 } else {
11671 sta = FALSE;
11672 }
11673 AscSetBank(iop_base, 1);
11674 AscWriteChipDvcID(iop_base, org_id);
11675 AscSetBank(iop_base, 0);
11676 return (sta);
11677}
11678
11679STATIC ushort
11680AscInitLram(
11681 ASC_DVC_VAR *asc_dvc
11682)
11683{
11684 uchar i;
11685 ushort s_addr;
11686 PortAddr iop_base;
11687 ushort warn_code;
11688
11689 iop_base = asc_dvc->iop_base;
11690 warn_code = 0;
11691 AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
11692 (ushort) (((int) (asc_dvc->max_total_qng + 2 + 1) * 64) >> 1)
11693);
11694 i = ASC_MIN_ACTIVE_QNO;
11695 s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
11696 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_FWD),
11697 (uchar) (i + 1));
11698 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_BWD),
11699 (uchar) (asc_dvc->max_total_qng));
11700 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_QNO),
11701 (uchar) i);
11702 i++;
11703 s_addr += ASC_QBLK_SIZE;
11704 for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
11705 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_FWD),
11706 (uchar) (i + 1));
11707 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_BWD),
11708 (uchar) (i - 1));
11709 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_QNO),
11710 (uchar) i);
11711 }
11712 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_FWD),
11713 (uchar) ASC_QLINK_END);
11714 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_BWD),
11715 (uchar) (asc_dvc->max_total_qng - 1));
11716 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_QNO),
11717 (uchar) asc_dvc->max_total_qng);
11718 i++;
11719 s_addr += ASC_QBLK_SIZE;
11720 for (; i <= (uchar) (asc_dvc->max_total_qng + 3);
11721 i++, s_addr += ASC_QBLK_SIZE) {
11722 AscWriteLramByte(iop_base,
11723 (ushort) (s_addr + (ushort) ASC_SCSIQ_B_FWD), i);
11724 AscWriteLramByte(iop_base,
11725 (ushort) (s_addr + (ushort) ASC_SCSIQ_B_BWD), i);
11726 AscWriteLramByte(iop_base,
11727 (ushort) (s_addr + (ushort) ASC_SCSIQ_B_QNO), i);
11728 }
11729 return (warn_code);
11730}
11731
11732STATIC ushort
11733AscInitQLinkVar(
11734 ASC_DVC_VAR *asc_dvc
11735)
11736{
11737 PortAddr iop_base;
11738 int i;
11739 ushort lram_addr;
11740
11741 iop_base = asc_dvc->iop_base;
11742 AscPutRiscVarFreeQHead(iop_base, 1);
11743 AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
11744 AscPutVarFreeQHead(iop_base, 1);
11745 AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
11746 AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
11747 (uchar) ((int) asc_dvc->max_total_qng + 1));
11748 AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
11749 (uchar) ((int) asc_dvc->max_total_qng + 2));
11750 AscWriteLramByte(iop_base, (ushort) ASCV_TOTAL_READY_Q_B,
11751 asc_dvc->max_total_qng);
11752 AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
11753 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
11754 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
11755 AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
11756 AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
11757 AscPutQDoneInProgress(iop_base, 0);
11758 lram_addr = ASC_QADR_BEG;
11759 for (i = 0; i < 32; i++, lram_addr += 2) {
11760 AscWriteLramWord(iop_base, lram_addr, 0);
11761 }
11762 return (0);
11763}
11764
11765STATIC int
11766AscSetLibErrorCode(
11767 ASC_DVC_VAR *asc_dvc,
11768 ushort err_code
11769)
11770{
11771 if (asc_dvc->err_code == 0) {
11772 asc_dvc->err_code = err_code;
11773 AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
11774 err_code);
11775 }
11776 return (err_code);
11777}
11778
11779
11780STATIC uchar
11781AscMsgOutSDTR(
11782 ASC_DVC_VAR *asc_dvc,
11783 uchar sdtr_period,
11784 uchar sdtr_offset
11785)
11786{
11787 EXT_MSG sdtr_buf;
11788 uchar sdtr_period_index;
11789 PortAddr iop_base;
11790
11791 iop_base = asc_dvc->iop_base;
11792 sdtr_buf.msg_type = MS_EXTEND;
11793 sdtr_buf.msg_len = MS_SDTR_LEN;
11794 sdtr_buf.msg_req = MS_SDTR_CODE;
11795 sdtr_buf.xfer_period = sdtr_period;
11796 sdtr_offset &= ASC_SYN_MAX_OFFSET;
11797 sdtr_buf.req_ack_offset = sdtr_offset;
11798 if ((sdtr_period_index =
11799 AscGetSynPeriodIndex(asc_dvc, sdtr_period)) <=
11800 asc_dvc->max_sdtr_index) {
11801 AscMemWordCopyPtrToLram(iop_base,
11802 ASCV_MSGOUT_BEG,
11803 (uchar *) &sdtr_buf,
11804 sizeof (EXT_MSG) >> 1);
11805 return ((sdtr_period_index << 4) | sdtr_offset);
11806 } else {
11807
11808 sdtr_buf.req_ack_offset = 0;
11809 AscMemWordCopyPtrToLram(iop_base,
11810 ASCV_MSGOUT_BEG,
11811 (uchar *) &sdtr_buf,
11812 sizeof (EXT_MSG) >> 1);
11813 return (0);
11814 }
11815}
11816
11817STATIC uchar
11818AscCalSDTRData(
11819 ASC_DVC_VAR *asc_dvc,
11820 uchar sdtr_period,
11821 uchar syn_offset
11822)
11823{
11824 uchar byte;
11825 uchar sdtr_period_ix;
11826
11827 sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
11828 if (
11829 (sdtr_period_ix > asc_dvc->max_sdtr_index)
11830) {
11831 return (0xFF);
11832 }
11833 byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
11834 return (byte);
11835}
11836
11837STATIC void
11838AscSetChipSDTR(
11839 PortAddr iop_base,
11840 uchar sdtr_data,
11841 uchar tid_no
11842)
11843{
11844 AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
11845 AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
11846 return;
11847}
11848
11849STATIC uchar
11850AscGetSynPeriodIndex(
11851 ASC_DVC_VAR *asc_dvc,
11852 uchar syn_time
11853)
11854{
11855 uchar *period_table;
11856 int max_index;
11857 int min_index;
11858 int i;
11859
11860 period_table = asc_dvc->sdtr_period_tbl;
11861 max_index = (int) asc_dvc->max_sdtr_index;
11862 min_index = (int)asc_dvc->host_init_sdtr_index;
11863 if ((syn_time <= period_table[max_index])) {
11864 for (i = min_index; i < (max_index - 1); i++) {
11865 if (syn_time <= period_table[i]) {
11866 return ((uchar) i);
11867 }
11868 }
11869 return ((uchar) max_index);
11870 } else {
11871 return ((uchar) (max_index + 1));
11872 }
11873}
11874
11875STATIC uchar
11876AscAllocFreeQueue(
11877 PortAddr iop_base,
11878 uchar free_q_head
11879)
11880{
11881 ushort q_addr;
11882 uchar next_qp;
11883 uchar q_status;
11884
11885 q_addr = ASC_QNO_TO_QADDR(free_q_head);
11886 q_status = (uchar) AscReadLramByte(iop_base,
11887 (ushort) (q_addr + ASC_SCSIQ_B_STATUS));
11888 next_qp = AscReadLramByte(iop_base,
11889 (ushort) (q_addr + ASC_SCSIQ_B_FWD));
11890 if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END)) {
11891 return (next_qp);
11892 }
11893 return (ASC_QLINK_END);
11894}
11895
11896STATIC uchar
11897AscAllocMultipleFreeQueue(
11898 PortAddr iop_base,
11899 uchar free_q_head,
11900 uchar n_free_q
11901)
11902{
11903 uchar i;
11904
11905 for (i = 0; i < n_free_q; i++) {
11906 if ((free_q_head = AscAllocFreeQueue(iop_base, free_q_head))
11907 == ASC_QLINK_END) {
11908 return (ASC_QLINK_END);
11909 }
11910 }
11911 return (free_q_head);
11912}
11913
11914STATIC int
11915AscHostReqRiscHalt(
11916 PortAddr iop_base
11917)
11918{
11919 int count = 0;
11920 int sta = 0;
11921 uchar saved_stop_code;
11922
11923 if (AscIsChipHalted(iop_base))
11924 return (1);
11925 saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
11926 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
11927 ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP
11928);
11929 do {
11930 if (AscIsChipHalted(iop_base)) {
11931 sta = 1;
11932 break;
11933 }
11934 DvcSleepMilliSecond(100);
11935 } while (count++ < 20);
11936 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
11937 return (sta);
11938}
11939
11940STATIC int
11941AscStopQueueExe(
11942 PortAddr iop_base
11943)
11944{
11945 int count = 0;
11946
11947 if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
11948 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
11949 ASC_STOP_REQ_RISC_STOP);
11950 do {
11951 if (
11952 AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
11953 ASC_STOP_ACK_RISC_STOP) {
11954 return (1);
11955 }
11956 DvcSleepMilliSecond(100);
11957 } while (count++ < 20);
11958 }
11959 return (0);
11960}
11961
11962STATIC void
11963DvcDelayMicroSecond(ADV_DVC_VAR *asc_dvc, ushort micro_sec)
11964{
11965 udelay(micro_sec);
11966}
11967
11968STATIC void
11969DvcDelayNanoSecond(ASC_DVC_VAR *asc_dvc, ASC_DCNT nano_sec)
11970{
11971 udelay((nano_sec + 999)/1000);
11972}
11973
11974#ifdef CONFIG_ISA
11975ASC_INITFUNC(
11976STATIC ASC_DCNT,
11977AscGetEisaProductID(
11978 PortAddr iop_base
11979)
11980)
11981{
11982 PortAddr eisa_iop;
11983 ushort product_id_high, product_id_low;
11984 ASC_DCNT product_id;
11985
11986 eisa_iop = ASC_GET_EISA_SLOT(iop_base) | ASC_EISA_PID_IOP_MASK;
11987 product_id_low = inpw(eisa_iop);
11988 product_id_high = inpw(eisa_iop + 2);
11989 product_id = ((ASC_DCNT) product_id_high << 16) |
11990 (ASC_DCNT) product_id_low;
11991 return (product_id);
11992}
11993
11994ASC_INITFUNC(
11995STATIC PortAddr,
11996AscSearchIOPortAddrEISA(
11997 PortAddr iop_base
11998)
11999)
12000{
12001 ASC_DCNT eisa_product_id;
12002
12003 if (iop_base == 0) {
12004 iop_base = ASC_EISA_MIN_IOP_ADDR;
12005 } else {
12006 if (iop_base == ASC_EISA_MAX_IOP_ADDR)
12007 return (0);
12008 if ((iop_base & 0x0050) == 0x0050) {
12009 iop_base += ASC_EISA_BIG_IOP_GAP;
12010 } else {
12011 iop_base += ASC_EISA_SMALL_IOP_GAP;
12012 }
12013 }
12014 while (iop_base <= ASC_EISA_MAX_IOP_ADDR) {
12015 eisa_product_id = AscGetEisaProductID(iop_base);
12016 if ((eisa_product_id == ASC_EISA_ID_740) ||
12017 (eisa_product_id == ASC_EISA_ID_750)) {
12018 if (AscFindSignature(iop_base)) {
12019 inpw(iop_base + 4);
12020 return (iop_base);
12021 }
12022 }
12023 if (iop_base == ASC_EISA_MAX_IOP_ADDR)
12024 return (0);
12025 if ((iop_base & 0x0050) == 0x0050) {
12026 iop_base += ASC_EISA_BIG_IOP_GAP;
12027 } else {
12028 iop_base += ASC_EISA_SMALL_IOP_GAP;
12029 }
12030 }
12031 return (0);
12032}
12033#endif
12034
12035STATIC int
12036AscStartChip(
12037 PortAddr iop_base
12038)
12039{
12040 AscSetChipControl(iop_base, 0);
12041 if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
12042 return (0);
12043 }
12044 return (1);
12045}
12046
12047STATIC int
12048AscStopChip(
12049 PortAddr iop_base
12050)
12051{
12052 uchar cc_val;
12053
12054 cc_val = AscGetChipControl(iop_base) & (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
12055 AscSetChipControl(iop_base, (uchar) (cc_val | CC_HALT));
12056 AscSetChipIH(iop_base, INS_HALT);
12057 AscSetChipIH(iop_base, INS_RFLAG_WTM);
12058 if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
12059 return (0);
12060 }
12061 return (1);
12062}
12063
12064STATIC int
12065AscIsChipHalted(
12066 PortAddr iop_base
12067)
12068{
12069 if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
12070 if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
12071 return (1);
12072 }
12073 }
12074 return (0);
12075}
12076
12077STATIC void
12078AscSetChipIH(
12079 PortAddr iop_base,
12080 ushort ins_code
12081)
12082{
12083 AscSetBank(iop_base, 1);
12084 AscWriteChipIH(iop_base, ins_code);
12085 AscSetBank(iop_base, 0);
12086 return;
12087}
12088
12089STATIC void
12090AscAckInterrupt(
12091 PortAddr iop_base
12092)
12093{
12094 uchar host_flag;
12095 uchar risc_flag;
12096 ushort loop;
12097
12098 loop = 0;
12099 do {
12100 risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
12101 if (loop++ > 0x7FFF) {
12102 break;
12103 }
12104 } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
12105 host_flag = AscReadLramByte(iop_base, ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
12106 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
12107 (uchar) (host_flag | ASC_HOST_FLAG_ACK_INT));
12108 AscSetChipStatus(iop_base, CIW_INT_ACK);
12109 loop = 0;
12110 while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
12111 AscSetChipStatus(iop_base, CIW_INT_ACK);
12112 if (loop++ > 3) {
12113 break;
12114 }
12115 }
12116 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
12117 return;
12118}
12119
12120STATIC void
12121AscDisableInterrupt(
12122 PortAddr iop_base
12123)
12124{
12125 ushort cfg;
12126
12127 cfg = AscGetChipCfgLsw(iop_base);
12128 AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
12129 return;
12130}
12131
12132STATIC void
12133AscEnableInterrupt(
12134 PortAddr iop_base
12135)
12136{
12137 ushort cfg;
12138
12139 cfg = AscGetChipCfgLsw(iop_base);
12140 AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
12141 return;
12142}
12143
12144
12145
12146STATIC void
12147AscSetBank(
12148 PortAddr iop_base,
12149 uchar bank
12150)
12151{
12152 uchar val;
12153
12154 val = AscGetChipControl(iop_base) &
12155 (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET | CC_CHIP_RESET));
12156 if (bank == 1) {
12157 val |= CC_BANK_ONE;
12158 } else if (bank == 2) {
12159 val |= CC_DIAG | CC_BANK_ONE;
12160 } else {
12161 val &= ~CC_BANK_ONE;
12162 }
12163 AscSetChipControl(iop_base, val);
12164 return;
12165}
12166
12167STATIC int
12168AscResetChipAndScsiBus(
12169 ASC_DVC_VAR *asc_dvc
12170)
12171{
12172 PortAddr iop_base;
12173 int i = 10;
12174
12175 iop_base = asc_dvc->iop_base;
12176 while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE) && (i-- > 0))
12177 {
12178 DvcSleepMilliSecond(100);
12179 }
12180 AscStopChip(iop_base);
12181 AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
12182 DvcDelayNanoSecond(asc_dvc, 60000);
12183 AscSetChipIH(iop_base, INS_RFLAG_WTM);
12184 AscSetChipIH(iop_base, INS_HALT);
12185 AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
12186 AscSetChipControl(iop_base, CC_HALT);
12187 DvcSleepMilliSecond(200);
12188 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
12189 AscSetChipStatus(iop_base, 0);
12190 return (AscIsChipHalted(iop_base));
12191}
12192
12193ASC_INITFUNC(
12194STATIC ASC_DCNT,
12195AscGetMaxDmaCount(
12196 ushort bus_type
12197)
12198)
12199{
12200 if (bus_type & ASC_IS_ISA)
12201 return (ASC_MAX_ISA_DMA_COUNT);
12202 else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
12203 return (ASC_MAX_VL_DMA_COUNT);
12204 return (ASC_MAX_PCI_DMA_COUNT);
12205}
12206
12207#ifdef CONFIG_ISA
12208ASC_INITFUNC(
12209STATIC ushort,
12210AscGetIsaDmaChannel(
12211 PortAddr iop_base
12212)
12213)
12214{
12215 ushort channel;
12216
12217 channel = AscGetChipCfgLsw(iop_base) & 0x0003;
12218 if (channel == 0x03)
12219 return (0);
12220 else if (channel == 0x00)
12221 return (7);
12222 return (channel + 4);
12223}
12224
12225ASC_INITFUNC(
12226STATIC ushort,
12227AscSetIsaDmaChannel(
12228 PortAddr iop_base,
12229 ushort dma_channel
12230)
12231)
12232{
12233 ushort cfg_lsw;
12234 uchar value;
12235
12236 if ((dma_channel >= 5) && (dma_channel <= 7)) {
12237 if (dma_channel == 7)
12238 value = 0x00;
12239 else
12240 value = dma_channel - 4;
12241 cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
12242 cfg_lsw |= value;
12243 AscSetChipCfgLsw(iop_base, cfg_lsw);
12244 return (AscGetIsaDmaChannel(iop_base));
12245 }
12246 return (0);
12247}
12248
12249ASC_INITFUNC(
12250STATIC uchar,
12251AscSetIsaDmaSpeed(
12252 PortAddr iop_base,
12253 uchar speed_value
12254)
12255)
12256{
12257 speed_value &= 0x07;
12258 AscSetBank(iop_base, 1);
12259 AscWriteChipDmaSpeed(iop_base, speed_value);
12260 AscSetBank(iop_base, 0);
12261 return (AscGetIsaDmaSpeed(iop_base));
12262}
12263
12264ASC_INITFUNC(
12265STATIC uchar,
12266AscGetIsaDmaSpeed(
12267 PortAddr iop_base
12268)
12269)
12270{
12271 uchar speed_value;
12272
12273 AscSetBank(iop_base, 1);
12274 speed_value = AscReadChipDmaSpeed(iop_base);
12275 speed_value &= 0x07;
12276 AscSetBank(iop_base, 0);
12277 return (speed_value);
12278}
12279#endif
12280
12281ASC_INITFUNC(
12282STATIC ushort,
12283AscReadPCIConfigWord(
12284 ASC_DVC_VAR *asc_dvc,
12285 ushort pci_config_offset)
12286)
12287{
12288 uchar lsb, msb;
12289
12290 lsb = DvcReadPCIConfigByte(asc_dvc, pci_config_offset);
12291 msb = DvcReadPCIConfigByte(asc_dvc, pci_config_offset + 1);
12292 return ((ushort) ((msb << 8) | lsb));
12293}
12294
12295ASC_INITFUNC(
12296STATIC ushort,
12297AscInitGetConfig(
12298 ASC_DVC_VAR *asc_dvc
12299)
12300)
12301{
12302 ushort warn_code;
12303 PortAddr iop_base;
12304 ushort PCIDeviceID;
12305 ushort PCIVendorID;
12306 uchar PCIRevisionID;
12307 uchar prevCmdRegBits;
12308
12309 warn_code = 0;
12310 iop_base = asc_dvc->iop_base;
12311 asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
12312 if (asc_dvc->err_code != 0) {
12313 return (UW_ERR);
12314 }
12315 if (asc_dvc->bus_type == ASC_IS_PCI) {
12316 PCIVendorID = AscReadPCIConfigWord(asc_dvc,
12317 AscPCIConfigVendorIDRegister);
12318
12319 PCIDeviceID = AscReadPCIConfigWord(asc_dvc,
12320 AscPCIConfigDeviceIDRegister);
12321
12322 PCIRevisionID = DvcReadPCIConfigByte(asc_dvc,
12323 AscPCIConfigRevisionIDRegister);
12324
12325 if (PCIVendorID != ASC_PCI_VENDORID) {
12326 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
12327 }
12328 prevCmdRegBits = DvcReadPCIConfigByte(asc_dvc,
12329 AscPCIConfigCommandRegister);
12330
12331 if ((prevCmdRegBits & AscPCICmdRegBits_IOMemBusMaster) !=
12332 AscPCICmdRegBits_IOMemBusMaster) {
12333 DvcWritePCIConfigByte(asc_dvc,
12334 AscPCIConfigCommandRegister,
12335 (prevCmdRegBits |
12336 AscPCICmdRegBits_IOMemBusMaster));
12337
12338 if ((DvcReadPCIConfigByte(asc_dvc,
12339 AscPCIConfigCommandRegister)
12340 & AscPCICmdRegBits_IOMemBusMaster)
12341 != AscPCICmdRegBits_IOMemBusMaster) {
12342 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
12343 }
12344 }
12345 if ((PCIDeviceID == ASC_PCI_DEVICEID_1200A) ||
12346 (PCIDeviceID == ASC_PCI_DEVICEID_1200B)) {
12347 DvcWritePCIConfigByte(asc_dvc,
12348 AscPCIConfigLatencyTimer, 0x00);
12349 if (DvcReadPCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer)
12350 != 0x00) {
12351 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
12352 }
12353 } else if (PCIDeviceID == ASC_PCI_DEVICEID_ULTRA) {
12354 if (DvcReadPCIConfigByte(asc_dvc,
12355 AscPCIConfigLatencyTimer) < 0x20) {
12356 DvcWritePCIConfigByte(asc_dvc,
12357 AscPCIConfigLatencyTimer, 0x20);
12358
12359 if (DvcReadPCIConfigByte(asc_dvc,
12360 AscPCIConfigLatencyTimer) < 0x20) {
12361 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
12362 }
12363 }
12364 }
12365 }
12366
12367 if (AscFindSignature(iop_base)) {
12368 warn_code |= AscInitAscDvcVar(asc_dvc);
12369 warn_code |= AscInitFromEEP(asc_dvc);
12370 asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
12371 if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT) {
12372 asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
12373 }
12374 } else {
12375 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
12376 }
12377 return(warn_code);
12378}
12379
12380ASC_INITFUNC(
12381STATIC ushort,
12382AscInitSetConfig(
12383 ASC_DVC_VAR *asc_dvc
12384)
12385)
12386{
12387 ushort warn_code = 0;
12388
12389 asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
12390 if (asc_dvc->err_code != 0)
12391 return (UW_ERR);
12392 if (AscFindSignature(asc_dvc->iop_base)) {
12393 warn_code |= AscInitFromAscDvcVar(asc_dvc);
12394 asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
12395 } else {
12396 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
12397 }
12398 return (warn_code);
12399}
12400
12401ASC_INITFUNC(
12402STATIC ushort,
12403AscInitFromAscDvcVar(
12404 ASC_DVC_VAR *asc_dvc
12405)
12406)
12407{
12408 PortAddr iop_base;
12409 ushort cfg_msw;
12410 ushort warn_code;
12411 ushort pci_device_id;
12412
12413 iop_base = asc_dvc->iop_base;
12414 pci_device_id = asc_dvc->cfg->pci_device_id;
12415 warn_code = 0;
12416 cfg_msw = AscGetChipCfgMsw(iop_base);
12417 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
12418 cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
12419 warn_code |= ASC_WARN_CFG_MSW_RECOVER;
12420 AscSetChipCfgMsw(iop_base, cfg_msw);
12421 }
12422 if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
12423 asc_dvc->cfg->cmd_qng_enabled) {
12424 asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
12425 warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
12426 }
12427 if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
12428 warn_code |= ASC_WARN_AUTO_CONFIG;
12429 }
12430 if ((asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL)) != 0) {
12431 if (AscSetChipIRQ(iop_base, asc_dvc->irq_no, asc_dvc->bus_type)
12432 != asc_dvc->irq_no) {
12433 asc_dvc->err_code |= ASC_IERR_SET_IRQ_NO;
12434 }
12435 }
12436 if (asc_dvc->bus_type & ASC_IS_PCI) {
12437 cfg_msw &= 0xFFC0;
12438 AscSetChipCfgMsw(iop_base, cfg_msw);
12439 if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
12440 } else {
12441 if ((pci_device_id == ASC_PCI_DEVICE_ID_REV_A) ||
12442 (pci_device_id == ASC_PCI_DEVICE_ID_REV_B)) {
12443 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
12444 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
12445 }
12446 }
12447 } else if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
12448 if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
12449 == ASC_CHIP_VER_ASYN_BUG) {
12450 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
12451 }
12452 }
12453 if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
12454 asc_dvc->cfg->chip_scsi_id) {
12455 asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
12456 }
12457#ifdef CONFIG_ISA
12458 if (asc_dvc->bus_type & ASC_IS_ISA) {
12459 AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
12460 AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
12461 }
12462#endif
12463 return (warn_code);
12464}
12465
12466STATIC ushort
12467AscInitAsc1000Driver(
12468 ASC_DVC_VAR *asc_dvc
12469)
12470{
12471 ushort warn_code;
12472 PortAddr iop_base;
12473
12474 iop_base = asc_dvc->iop_base;
12475 warn_code = 0;
12476 if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
12477 !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
12478 AscResetChipAndScsiBus(asc_dvc);
12479 DvcSleepMilliSecond((ASC_DCNT)
12480 ((ushort) asc_dvc->scsi_reset_wait * 1000));
12481 }
12482 asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
12483 if (asc_dvc->err_code != 0)
12484 return (UW_ERR);
12485 if (!AscFindSignature(asc_dvc->iop_base)) {
12486 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
12487 return (warn_code);
12488 }
12489 AscDisableInterrupt(iop_base);
12490 warn_code |= AscInitLram(asc_dvc);
12491 if (asc_dvc->err_code != 0)
12492 return (UW_ERR);
12493 ASC_DBG1(1, "AscInitAsc1000Driver: _asc_mcode_chksum 0x%lx\n",
12494 (ulong) _asc_mcode_chksum);
12495 if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
12496 _asc_mcode_size) != _asc_mcode_chksum) {
12497 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
12498 return (warn_code);
12499 }
12500 warn_code |= AscInitMicroCodeVar(asc_dvc);
12501 asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
12502 AscEnableInterrupt(iop_base);
12503 return (warn_code);
12504}
12505
12506ASC_INITFUNC(
12507STATIC ushort,
12508AscInitAscDvcVar(
12509 ASC_DVC_VAR *asc_dvc
12510)
12511)
12512{
12513 int i;
12514 PortAddr iop_base;
12515 ushort warn_code;
12516 uchar chip_version;
12517
12518 iop_base = asc_dvc->iop_base;
12519 warn_code = 0;
12520 asc_dvc->err_code = 0;
12521 if ((asc_dvc->bus_type &
12522 (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
12523 asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
12524 }
12525 AscSetChipControl(iop_base, CC_HALT);
12526 AscSetChipStatus(iop_base, 0);
12527 asc_dvc->bug_fix_cntl = 0;
12528 asc_dvc->pci_fix_asyn_xfer = 0;
12529 asc_dvc->pci_fix_asyn_xfer_always = 0;
12530
12531 asc_dvc->sdtr_done = 0;
12532 asc_dvc->cur_total_qng = 0;
12533 asc_dvc->is_in_int = 0;
12534 asc_dvc->in_critical_cnt = 0;
12535 asc_dvc->last_q_shortage = 0;
12536 asc_dvc->use_tagged_qng = 0;
12537 asc_dvc->no_scam = 0;
12538 asc_dvc->unit_not_ready = 0;
12539 asc_dvc->queue_full_or_busy = 0;
12540 asc_dvc->redo_scam = 0;
12541 asc_dvc->res2 = 0;
12542 asc_dvc->host_init_sdtr_index = 0;
12543 asc_dvc->cfg->can_tagged_qng = 0;
12544 asc_dvc->cfg->cmd_qng_enabled = 0;
12545 asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
12546 asc_dvc->init_sdtr = 0;
12547 asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
12548 asc_dvc->scsi_reset_wait = 3;
12549 asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
12550 asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
12551 asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
12552 asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
12553 asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
12554 asc_dvc->cfg->lib_serial_no = ASC_LIB_SERIAL_NUMBER;
12555 asc_dvc->cfg->lib_version = (ASC_LIB_VERSION_MAJOR << 8) |
12556 ASC_LIB_VERSION_MINOR;
12557 chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
12558 asc_dvc->cfg->chip_version = chip_version;
12559 asc_dvc->sdtr_period_tbl[0] = SYN_XFER_NS_0;
12560 asc_dvc->sdtr_period_tbl[1] = SYN_XFER_NS_1;
12561 asc_dvc->sdtr_period_tbl[2] = SYN_XFER_NS_2;
12562 asc_dvc->sdtr_period_tbl[3] = SYN_XFER_NS_3;
12563 asc_dvc->sdtr_period_tbl[4] = SYN_XFER_NS_4;
12564 asc_dvc->sdtr_period_tbl[5] = SYN_XFER_NS_5;
12565 asc_dvc->sdtr_period_tbl[6] = SYN_XFER_NS_6;
12566 asc_dvc->sdtr_period_tbl[7] = SYN_XFER_NS_7;
12567 asc_dvc->max_sdtr_index = 7;
12568 if ((asc_dvc->bus_type & ASC_IS_PCI) &&
12569 (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
12570 asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
12571 asc_dvc->sdtr_period_tbl[0] = SYN_ULTRA_XFER_NS_0;
12572 asc_dvc->sdtr_period_tbl[1] = SYN_ULTRA_XFER_NS_1;
12573 asc_dvc->sdtr_period_tbl[2] = SYN_ULTRA_XFER_NS_2;
12574 asc_dvc->sdtr_period_tbl[3] = SYN_ULTRA_XFER_NS_3;
12575 asc_dvc->sdtr_period_tbl[4] = SYN_ULTRA_XFER_NS_4;
12576 asc_dvc->sdtr_period_tbl[5] = SYN_ULTRA_XFER_NS_5;
12577 asc_dvc->sdtr_period_tbl[6] = SYN_ULTRA_XFER_NS_6;
12578 asc_dvc->sdtr_period_tbl[7] = SYN_ULTRA_XFER_NS_7;
12579 asc_dvc->sdtr_period_tbl[8] = SYN_ULTRA_XFER_NS_8;
12580 asc_dvc->sdtr_period_tbl[9] = SYN_ULTRA_XFER_NS_9;
12581 asc_dvc->sdtr_period_tbl[10] = SYN_ULTRA_XFER_NS_10;
12582 asc_dvc->sdtr_period_tbl[11] = SYN_ULTRA_XFER_NS_11;
12583 asc_dvc->sdtr_period_tbl[12] = SYN_ULTRA_XFER_NS_12;
12584 asc_dvc->sdtr_period_tbl[13] = SYN_ULTRA_XFER_NS_13;
12585 asc_dvc->sdtr_period_tbl[14] = SYN_ULTRA_XFER_NS_14;
12586 asc_dvc->sdtr_period_tbl[15] = SYN_ULTRA_XFER_NS_15;
12587 asc_dvc->max_sdtr_index = 15;
12588 if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150)
12589 {
12590 AscSetExtraControl(iop_base,
12591 (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
12592 } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
12593 AscSetExtraControl(iop_base,
12594 (SEC_ACTIVE_NEGATE | SEC_ENABLE_FILTER));
12595 }
12596 }
12597 if (asc_dvc->bus_type == ASC_IS_PCI) {
12598 AscSetExtraControl(iop_base, (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
12599 }
12600
12601 asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
12602 if (AscGetChipBusType(iop_base) == ASC_IS_ISAPNP) {
12603 AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
12604 asc_dvc->bus_type = ASC_IS_ISAPNP;
12605 }
12606#ifdef CONFIG_ISA
12607 if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
12608 asc_dvc->cfg->isa_dma_channel = (uchar) AscGetIsaDmaChannel(iop_base);
12609 }
12610#endif
12611 for (i = 0; i <= ASC_MAX_TID; i++) {
12612 asc_dvc->cur_dvc_qng[i] = 0;
12613 asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
12614 asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *) 0L;
12615 asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *) 0L;
12616 asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
12617 }
12618 return (warn_code);
12619}
12620
12621ASC_INITFUNC(
12622STATIC ushort,
12623AscInitFromEEP(
12624 ASC_DVC_VAR *asc_dvc
12625)
12626)
12627{
12628 ASCEEP_CONFIG eep_config_buf;
12629 ASCEEP_CONFIG *eep_config;
12630 PortAddr iop_base;
12631 ushort chksum;
12632 ushort warn_code;
12633 ushort cfg_msw, cfg_lsw;
12634 int i;
12635 int write_eep = 0;
12636
12637 iop_base = asc_dvc->iop_base;
12638 warn_code = 0;
12639 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
12640 AscStopQueueExe(iop_base);
12641 if ((AscStopChip(iop_base) == FALSE) ||
12642 (AscGetChipScsiCtrl(iop_base) != 0)) {
12643 asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
12644 AscResetChipAndScsiBus(asc_dvc);
12645 DvcSleepMilliSecond((ASC_DCNT)
12646 ((ushort) asc_dvc->scsi_reset_wait * 1000));
12647 }
12648 if (AscIsChipHalted(iop_base) == FALSE) {
12649 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
12650 return (warn_code);
12651 }
12652 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
12653 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
12654 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
12655 return (warn_code);
12656 }
12657 eep_config = (ASCEEP_CONFIG *) &eep_config_buf;
12658 cfg_msw = AscGetChipCfgMsw(iop_base);
12659 cfg_lsw = AscGetChipCfgLsw(iop_base);
12660 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
12661 cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
12662 warn_code |= ASC_WARN_CFG_MSW_RECOVER;
12663 AscSetChipCfgMsw(iop_base, cfg_msw);
12664 }
12665 chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
12666 ASC_DBG1(1, "AscInitFromEEP: chksum 0x%x\n", chksum);
12667 if (chksum == 0) {
12668 chksum = 0xaa55;
12669 }
12670 if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
12671 warn_code |= ASC_WARN_AUTO_CONFIG;
12672 if (asc_dvc->cfg->chip_version == 3) {
12673 if (eep_config->cfg_lsw != cfg_lsw) {
12674 warn_code |= ASC_WARN_EEPROM_RECOVER;
12675 eep_config->cfg_lsw = AscGetChipCfgLsw(iop_base);
12676 }
12677 if (eep_config->cfg_msw != cfg_msw) {
12678 warn_code |= ASC_WARN_EEPROM_RECOVER;
12679 eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
12680 }
12681 }
12682 }
12683 eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
12684 eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
12685 ASC_DBG1(1, "AscInitFromEEP: eep_config->chksum 0x%x\n",
12686 eep_config->chksum);
12687 if (chksum != eep_config->chksum) {
12688 if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
12689 ASC_CHIP_VER_PCI_ULTRA_3050 )
12690 {
12691 ASC_DBG(1,
12692"AscInitFromEEP: chksum error ignored; EEPROM-less board\n");
12693 eep_config->init_sdtr = 0xFF;
12694 eep_config->disc_enable = 0xFF;
12695 eep_config->start_motor = 0xFF;
12696 eep_config->use_cmd_qng = 0;
12697 eep_config->max_total_qng = 0xF0;
12698 eep_config->max_tag_qng = 0x20;
12699 eep_config->cntl = 0xBFFF;
12700 ASC_EEP_SET_CHIP_ID(eep_config, 7);
12701 eep_config->no_scam = 0;
12702 eep_config->adapter_info[0] = 0;
12703 eep_config->adapter_info[1] = 0;
12704 eep_config->adapter_info[2] = 0;
12705 eep_config->adapter_info[3] = 0;
12706 eep_config->adapter_info[4] = 0;
12707
12708 eep_config->adapter_info[5] = 0xBB;
12709 } else {
12710 ASC_PRINT(
12711"AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
12712 write_eep = 1;
12713 warn_code |= ASC_WARN_EEPROM_CHKSUM;
12714 }
12715 }
12716 asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
12717 asc_dvc->cfg->disc_enable = eep_config->disc_enable;
12718 asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
12719 asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
12720 asc_dvc->start_motor = eep_config->start_motor;
12721 asc_dvc->dvc_cntl = eep_config->cntl;
12722 asc_dvc->no_scam = eep_config->no_scam;
12723 asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
12724 asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
12725 asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
12726 asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
12727 asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
12728 asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
12729 if (!AscTestExternalLram(asc_dvc)) {
12730 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA)) {
12731 eep_config->max_total_qng = ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
12732 eep_config->max_tag_qng = ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
12733 } else {
12734 eep_config->cfg_msw |= 0x0800;
12735 cfg_msw |= 0x0800;
12736 AscSetChipCfgMsw(iop_base, cfg_msw);
12737 eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
12738 eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
12739 }
12740 } else {
12741 }
12742 if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
12743 eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
12744 }
12745 if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
12746 eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
12747 }
12748 if (eep_config->max_tag_qng > eep_config->max_total_qng) {
12749 eep_config->max_tag_qng = eep_config->max_total_qng;
12750 }
12751 if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
12752 eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
12753 }
12754 asc_dvc->max_total_qng = eep_config->max_total_qng;
12755 if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
12756 eep_config->use_cmd_qng) {
12757 eep_config->disc_enable = eep_config->use_cmd_qng;
12758 warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
12759 }
12760 if (asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL | ASC_IS_EISA)) {
12761 asc_dvc->irq_no = AscGetChipIRQ(iop_base, asc_dvc->bus_type);
12762 }
12763 ASC_EEP_SET_CHIP_ID(eep_config, ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
12764 asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
12765 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
12766 !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
12767 asc_dvc->host_init_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
12768 }
12769
12770 for (i = 0; i <= ASC_MAX_TID; i++) {
12771 asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
12772 asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
12773 asc_dvc->cfg->sdtr_period_offset[i] =
12774 (uchar) (ASC_DEF_SDTR_OFFSET |
12775 (asc_dvc->host_init_sdtr_index << 4));
12776 }
12777 eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
12778 if (write_eep) {
12779 if ((i = AscSetEEPConfig(iop_base, eep_config, asc_dvc->bus_type)) !=
12780 0) {
12781 ASC_PRINT1(
12782"AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n", i);
12783 } else {
12784 ASC_PRINT("AscInitFromEEP: Succesfully re-wrote EEPROM.");
12785 }
12786 }
12787 return (warn_code);
12788}
12789
12790STATIC ushort
12791AscInitMicroCodeVar(
12792 ASC_DVC_VAR *asc_dvc
12793)
12794{
12795 int i;
12796 ushort warn_code;
12797 PortAddr iop_base;
12798 ASC_PADDR phy_addr;
12799 ASC_DCNT phy_size;
12800
12801 iop_base = asc_dvc->iop_base;
12802 warn_code = 0;
12803 for (i = 0; i <= ASC_MAX_TID; i++) {
12804 AscPutMCodeInitSDTRAtID(iop_base, i,
12805 asc_dvc->cfg->sdtr_period_offset[i]
12806);
12807 }
12808
12809 AscInitQLinkVar(asc_dvc);
12810 AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
12811 asc_dvc->cfg->disc_enable);
12812 AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
12813 ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
12814
12815
12816 phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
12817 phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
12818 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
12819 (uchar *) &phy_addr, 1);
12820 phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
12821 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
12822 (uchar *) &phy_size, 1);
12823
12824 asc_dvc->cfg->mcode_date =
12825 AscReadLramWord(iop_base, (ushort) ASCV_MC_DATE_W);
12826 asc_dvc->cfg->mcode_version =
12827 AscReadLramWord(iop_base, (ushort) ASCV_MC_VER_W);
12828
12829 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
12830 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
12831 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
12832 return (warn_code);
12833 }
12834 if (AscStartChip(iop_base) != 1) {
12835 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
12836 return (warn_code);
12837 }
12838
12839 return (warn_code);
12840}
12841
12842ASC_INITFUNC(
12843STATIC int,
12844AscTestExternalLram(
12845 ASC_DVC_VAR *asc_dvc
12846)
12847)
12848{
12849 PortAddr iop_base;
12850 ushort q_addr;
12851 ushort saved_word;
12852 int sta;
12853
12854 iop_base = asc_dvc->iop_base;
12855 sta = 0;
12856 q_addr = ASC_QNO_TO_QADDR(241);
12857 saved_word = AscReadLramWord(iop_base, q_addr);
12858 AscSetChipLramAddr(iop_base, q_addr);
12859 AscSetChipLramData(iop_base, 0x55AA);
12860 DvcSleepMilliSecond(10);
12861 AscSetChipLramAddr(iop_base, q_addr);
12862 if (AscGetChipLramData(iop_base) == 0x55AA) {
12863 sta = 1;
12864 AscWriteLramWord(iop_base, q_addr, saved_word);
12865 }
12866 return (sta);
12867}
12868
12869ASC_INITFUNC(
12870STATIC int,
12871AscWriteEEPCmdReg(
12872 PortAddr iop_base,
12873 uchar cmd_reg
12874)
12875)
12876{
12877 uchar read_back;
12878 int retry;
12879
12880 retry = 0;
12881 while (TRUE) {
12882 AscSetChipEEPCmd(iop_base, cmd_reg);
12883 DvcSleepMilliSecond(1);
12884 read_back = AscGetChipEEPCmd(iop_base);
12885 if (read_back == cmd_reg) {
12886 return (1);
12887 }
12888 if (retry++ > ASC_EEP_MAX_RETRY) {
12889 return (0);
12890 }
12891 }
12892}
12893
12894ASC_INITFUNC(
12895STATIC int,
12896AscWriteEEPDataReg(
12897 PortAddr iop_base,
12898 ushort data_reg
12899)
12900)
12901{
12902 ushort read_back;
12903 int retry;
12904
12905 retry = 0;
12906 while (TRUE) {
12907 AscSetChipEEPData(iop_base, data_reg);
12908 DvcSleepMilliSecond(1);
12909 read_back = AscGetChipEEPData(iop_base);
12910 if (read_back == data_reg) {
12911 return (1);
12912 }
12913 if (retry++ > ASC_EEP_MAX_RETRY) {
12914 return (0);
12915 }
12916 }
12917}
12918
12919ASC_INITFUNC(
12920STATIC void,
12921AscWaitEEPRead(
12922 void
12923)
12924)
12925{
12926 DvcSleepMilliSecond(1);
12927 return;
12928}
12929
12930ASC_INITFUNC(
12931STATIC void,
12932AscWaitEEPWrite(
12933 void
12934)
12935)
12936{
12937 DvcSleepMilliSecond(20);
12938 return;
12939}
12940
12941ASC_INITFUNC(
12942STATIC ushort,
12943AscReadEEPWord(
12944 PortAddr iop_base,
12945 uchar addr
12946)
12947)
12948{
12949 ushort read_wval;
12950 uchar cmd_reg;
12951
12952 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
12953 AscWaitEEPRead();
12954 cmd_reg = addr | ASC_EEP_CMD_READ;
12955 AscWriteEEPCmdReg(iop_base, cmd_reg);
12956 AscWaitEEPRead();
12957 read_wval = AscGetChipEEPData(iop_base);
12958 AscWaitEEPRead();
12959 return (read_wval);
12960}
12961
12962ASC_INITFUNC(
12963STATIC ushort,
12964AscWriteEEPWord(
12965 PortAddr iop_base,
12966 uchar addr,
12967 ushort word_val
12968)
12969)
12970{
12971 ushort read_wval;
12972
12973 read_wval = AscReadEEPWord(iop_base, addr);
12974 if (read_wval != word_val) {
12975 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
12976 AscWaitEEPRead();
12977 AscWriteEEPDataReg(iop_base, word_val);
12978 AscWaitEEPRead();
12979 AscWriteEEPCmdReg(iop_base,
12980 (uchar) ((uchar) ASC_EEP_CMD_WRITE | addr));
12981 AscWaitEEPWrite();
12982 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
12983 AscWaitEEPRead();
12984 return (AscReadEEPWord(iop_base, addr));
12985 }
12986 return (read_wval);
12987}
12988
12989ASC_INITFUNC(
12990STATIC ushort,
12991AscGetEEPConfig(
12992 PortAddr iop_base,
12993 ASCEEP_CONFIG * cfg_buf, ushort bus_type
12994)
12995)
12996{
12997 ushort wval;
12998 ushort sum;
12999 ushort *wbuf;
13000 int cfg_beg;
13001 int cfg_end;
13002 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
13003 int s_addr;
13004
13005 wbuf = (ushort *) cfg_buf;
13006 sum = 0;
13007
13008 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
13009 *wbuf = AscReadEEPWord(iop_base, (uchar) s_addr);
13010 sum += *wbuf;
13011 }
13012 if (bus_type & ASC_IS_VL) {
13013 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
13014 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
13015 } else {
13016 cfg_beg = ASC_EEP_DVC_CFG_BEG;
13017 cfg_end = ASC_EEP_MAX_DVC_ADDR;
13018 }
13019 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
13020 wval = AscReadEEPWord( iop_base, ( uchar )s_addr ) ;
13021 if (s_addr <= uchar_end_in_config) {
13022
13023
13024
13025
13026 *wbuf = le16_to_cpu(wval);
13027 } else {
13028
13029 *wbuf = wval;
13030 }
13031 sum += wval;
13032 }
13033
13034
13035
13036
13037 *wbuf = AscReadEEPWord(iop_base, (uchar) s_addr);
13038 return (sum);
13039}
13040
13041ASC_INITFUNC(
13042STATIC int,
13043AscSetEEPConfigOnce(
13044 PortAddr iop_base,
13045 ASCEEP_CONFIG * cfg_buf, ushort bus_type
13046)
13047)
13048{
13049 int n_error;
13050 ushort *wbuf;
13051 ushort word;
13052 ushort sum;
13053 int s_addr;
13054 int cfg_beg;
13055 int cfg_end;
13056 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
13057
13058
13059 wbuf = (ushort *) cfg_buf;
13060 n_error = 0;
13061 sum = 0;
13062
13063 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
13064 sum += *wbuf;
13065 if (*wbuf != AscWriteEEPWord(iop_base, (uchar) s_addr, *wbuf)) {
13066 n_error++;
13067 }
13068 }
13069 if (bus_type & ASC_IS_VL) {
13070 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
13071 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
13072 } else {
13073 cfg_beg = ASC_EEP_DVC_CFG_BEG;
13074 cfg_end = ASC_EEP_MAX_DVC_ADDR;
13075 }
13076 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
13077 if (s_addr <= uchar_end_in_config) {
13078
13079
13080
13081
13082 word = cpu_to_le16(*wbuf);
13083 if (word != AscWriteEEPWord( iop_base, (uchar) s_addr, word)) {
13084 n_error++;
13085 }
13086 } else {
13087
13088 if (*wbuf != AscWriteEEPWord(iop_base, (uchar) s_addr, *wbuf)) {
13089 n_error++;
13090 }
13091 }
13092 sum += *wbuf;
13093 }
13094
13095 *wbuf = sum;
13096 if (sum != AscWriteEEPWord(iop_base, (uchar) s_addr, sum)) {
13097 n_error++;
13098 }
13099
13100
13101 wbuf = (ushort *) cfg_buf;
13102
13103
13104
13105 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
13106 if (*wbuf != AscReadEEPWord(iop_base, (uchar) s_addr)) {
13107 n_error++;
13108 }
13109 }
13110 if (bus_type & ASC_IS_VL) {
13111 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
13112 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
13113 } else {
13114 cfg_beg = ASC_EEP_DVC_CFG_BEG;
13115 cfg_end = ASC_EEP_MAX_DVC_ADDR;
13116 }
13117 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
13118 if (s_addr <= uchar_end_in_config) {
13119
13120
13121
13122
13123 word = le16_to_cpu(AscReadEEPWord(iop_base, (uchar) s_addr));
13124 } else {
13125
13126 word = AscReadEEPWord(iop_base, (uchar) s_addr);
13127 }
13128 if (*wbuf != word) {
13129 n_error++;
13130 }
13131 }
13132
13133 if (AscReadEEPWord(iop_base, (uchar) s_addr) != sum) {
13134 n_error++;
13135 }
13136 return (n_error);
13137}
13138
13139ASC_INITFUNC(
13140STATIC int,
13141AscSetEEPConfig(
13142 PortAddr iop_base,
13143 ASCEEP_CONFIG * cfg_buf, ushort bus_type
13144)
13145)
13146{
13147 int retry;
13148 int n_error;
13149
13150 retry = 0;
13151 while (TRUE) {
13152 if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
13153 bus_type)) == 0) {
13154 break;
13155 }
13156 if (++retry > ASC_EEP_MAX_RETRY) {
13157 break;
13158 }
13159 }
13160 return (n_error);
13161}
13162
13163STATIC void
13164AscAsyncFix(
13165 ASC_DVC_VAR *asc_dvc,
13166 uchar tid_no,
13167 ASC_SCSI_INQUIRY *inq)
13168{
13169 uchar dvc_type;
13170 ASC_SCSI_BIT_ID_TYPE tid_bits;
13171
13172 dvc_type = ASC_INQ_DVC_TYPE(inq);
13173 tid_bits = ASC_TIX_TO_TARGET_ID(tid_no);
13174
13175 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN)
13176 {
13177 if (!(asc_dvc->init_sdtr & tid_bits))
13178 {
13179 if ((dvc_type == SCSI_TYPE_CDROM) &&
13180 (AscCompareString((uchar *) inq->vendor_id,
13181 (uchar *) "HP ", 3) == 0))
13182 {
13183 asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
13184 }
13185 asc_dvc->pci_fix_asyn_xfer |= tid_bits;
13186 if ((dvc_type == SCSI_TYPE_PROC) ||
13187 (dvc_type == SCSI_TYPE_SCANNER) ||
13188 (dvc_type == SCSI_TYPE_CDROM) ||
13189 (dvc_type == SCSI_TYPE_SASD))
13190 {
13191 asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
13192 }
13193
13194 if (asc_dvc->pci_fix_asyn_xfer & tid_bits)
13195 {
13196 AscSetRunChipSynRegAtID(asc_dvc->iop_base, tid_no,
13197 ASYN_SDTR_DATA_FIX_PCI_REV_AB);
13198 }
13199 }
13200 }
13201 return;
13202}
13203
13204STATIC int
13205AscTagQueuingSafe(ASC_SCSI_INQUIRY *inq)
13206{
13207 if ((inq->add_len >= 32) &&
13208 (AscCompareString((uchar *) inq->vendor_id,
13209 (uchar *) "QUANTUM XP34301", 15) == 0) &&
13210 (AscCompareString((uchar *) inq->product_rev_level,
13211 (uchar *) "1071", 4) == 0))
13212 {
13213 return 0;
13214 }
13215 return 1;
13216}
13217
13218STATIC void
13219AscInquiryHandling(ASC_DVC_VAR *asc_dvc,
13220 uchar tid_no, ASC_SCSI_INQUIRY *inq)
13221{
13222 ASC_SCSI_BIT_ID_TYPE tid_bit = ASC_TIX_TO_TARGET_ID(tid_no);
13223 ASC_SCSI_BIT_ID_TYPE orig_init_sdtr, orig_use_tagged_qng;
13224
13225 orig_init_sdtr = asc_dvc->init_sdtr;
13226 orig_use_tagged_qng = asc_dvc->use_tagged_qng;
13227
13228 asc_dvc->init_sdtr &= ~tid_bit;
13229 asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
13230 asc_dvc->use_tagged_qng &= ~tid_bit;
13231
13232 if (ASC_INQ_RESPONSE_FMT(inq) >= 2 || ASC_INQ_ANSI_VER(inq) >= 2) {
13233 if ((asc_dvc->cfg->sdtr_enable & tid_bit) && ASC_INQ_SYNC(inq)) {
13234 asc_dvc->init_sdtr |= tid_bit;
13235 }
13236 if ((asc_dvc->cfg->cmd_qng_enabled & tid_bit) &&
13237 ASC_INQ_CMD_QUEUE(inq)) {
13238 if (AscTagQueuingSafe(inq)) {
13239 asc_dvc->use_tagged_qng |= tid_bit;
13240 asc_dvc->cfg->can_tagged_qng |= tid_bit;
13241 }
13242 }
13243 }
13244 if (orig_use_tagged_qng != asc_dvc->use_tagged_qng) {
13245 AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
13246 asc_dvc->cfg->disc_enable);
13247 AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
13248 asc_dvc->use_tagged_qng);
13249 AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
13250 asc_dvc->cfg->can_tagged_qng);
13251
13252 asc_dvc->max_dvc_qng[tid_no] =
13253 asc_dvc->cfg->max_tag_qng[tid_no];
13254 AscWriteLramByte(asc_dvc->iop_base,
13255 (ushort) (ASCV_MAX_DVC_QNG_BEG + tid_no),
13256 asc_dvc->max_dvc_qng[tid_no]);
13257 }
13258 if (orig_init_sdtr != asc_dvc->init_sdtr) {
13259 AscAsyncFix(asc_dvc, tid_no, inq);
13260 }
13261 return;
13262}
13263
13264STATIC int
13265AscCompareString(
13266 uchar *str1,
13267 uchar *str2,
13268 int len
13269)
13270{
13271 int i;
13272 int diff;
13273
13274 for (i = 0; i < len; i++) {
13275 diff = (int) (str1[i] - str2[i]);
13276 if (diff != 0)
13277 return (diff);
13278 }
13279 return (0);
13280}
13281
13282STATIC uchar
13283AscReadLramByte(
13284 PortAddr iop_base,
13285 ushort addr
13286)
13287{
13288 uchar byte_data;
13289 ushort word_data;
13290
13291 if (isodd_word(addr)) {
13292 AscSetChipLramAddr(iop_base, addr - 1);
13293 word_data = AscGetChipLramData(iop_base);
13294 byte_data = (uchar) ((word_data >> 8) & 0xFF);
13295 } else {
13296 AscSetChipLramAddr(iop_base, addr);
13297 word_data = AscGetChipLramData(iop_base);
13298 byte_data = (uchar) (word_data & 0xFF);
13299 }
13300 return (byte_data);
13301}
13302STATIC ushort
13303AscReadLramWord(
13304 PortAddr iop_base,
13305 ushort addr
13306)
13307{
13308 ushort word_data;
13309
13310 AscSetChipLramAddr(iop_base, addr);
13311 word_data = AscGetChipLramData(iop_base);
13312 return (word_data);
13313}
13314
13315#if CC_VERY_LONG_SG_LIST
13316STATIC ASC_DCNT
13317AscReadLramDWord(
13318 PortAddr iop_base,
13319 ushort addr
13320)
13321{
13322 ushort val_low, val_high;
13323 ASC_DCNT dword_data;
13324
13325 AscSetChipLramAddr(iop_base, addr);
13326 val_low = AscGetChipLramData(iop_base);
13327 val_high = AscGetChipLramData(iop_base);
13328 dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
13329 return (dword_data);
13330}
13331#endif
13332
13333STATIC void
13334AscWriteLramWord(
13335 PortAddr iop_base,
13336 ushort addr,
13337 ushort word_val
13338)
13339{
13340 AscSetChipLramAddr(iop_base, addr);
13341 AscSetChipLramData(iop_base, word_val);
13342 return;
13343}
13344
13345STATIC void
13346AscWriteLramByte(
13347 PortAddr iop_base,
13348 ushort addr,
13349 uchar byte_val
13350)
13351{
13352 ushort word_data;
13353
13354 if (isodd_word(addr)) {
13355 addr--;
13356 word_data = AscReadLramWord(iop_base, addr);
13357 word_data &= 0x00FF;
13358 word_data |= (((ushort) byte_val << 8) & 0xFF00);
13359 } else {
13360 word_data = AscReadLramWord(iop_base, addr);
13361 word_data &= 0xFF00;
13362 word_data |= ((ushort) byte_val & 0x00FF);
13363 }
13364 AscWriteLramWord(iop_base, addr, word_data);
13365 return;
13366}
13367
13368
13369
13370
13371
13372
13373
13374STATIC void
13375AscMemWordCopyPtrToLram(
13376 PortAddr iop_base,
13377 ushort s_addr,
13378 uchar *s_buffer,
13379 int words
13380)
13381{
13382 int i;
13383
13384 AscSetChipLramAddr(iop_base, s_addr);
13385 for (i = 0; i < 2 * words; i += 2) {
13386
13387
13388
13389
13390
13391
13392
13393
13394 outpw(iop_base + IOP_RAM_DATA,
13395 ((ushort) s_buffer[i + 1] << 8) | s_buffer[i]);
13396 }
13397 return;
13398}
13399
13400
13401
13402
13403
13404
13405
13406STATIC void
13407AscMemDWordCopyPtrToLram(
13408 PortAddr iop_base,
13409 ushort s_addr,
13410 uchar *s_buffer,
13411 int dwords
13412)
13413{
13414 int i;
13415
13416 AscSetChipLramAddr(iop_base, s_addr);
13417 for (i = 0; i < 4 * dwords; i += 4) {
13418 outpw(iop_base + IOP_RAM_DATA,
13419 ((ushort) s_buffer[i + 1] << 8) | s_buffer[i]);
13420 outpw(iop_base + IOP_RAM_DATA,
13421 ((ushort) s_buffer[i + 3] << 8) | s_buffer[i + 2]);
13422 }
13423 return;
13424}
13425
13426
13427
13428
13429
13430
13431
13432STATIC void
13433AscMemWordCopyPtrFromLram(
13434 PortAddr iop_base,
13435 ushort s_addr,
13436 uchar *d_buffer,
13437 int words
13438)
13439{
13440 int i;
13441 ushort word;
13442
13443 AscSetChipLramAddr(iop_base, s_addr);
13444 for (i = 0; i < 2 * words; i += 2) {
13445 word = inpw(iop_base + IOP_RAM_DATA);
13446 d_buffer[i] = word & 0xff;
13447 d_buffer[i + 1] = (word >> 8) & 0xff;
13448 }
13449 return;
13450}
13451
13452STATIC ASC_DCNT
13453AscMemSumLramWord(
13454 PortAddr iop_base,
13455 ushort s_addr,
13456 int words
13457)
13458{
13459 ASC_DCNT sum;
13460 int i;
13461
13462 sum = 0L;
13463 for (i = 0; i < words; i++, s_addr += 2) {
13464 sum += AscReadLramWord(iop_base, s_addr);
13465 }
13466 return (sum);
13467}
13468
13469STATIC void
13470AscMemWordSetLram(
13471 PortAddr iop_base,
13472 ushort s_addr,
13473 ushort set_wval,
13474 int words
13475)
13476{
13477 int i;
13478
13479 AscSetChipLramAddr(iop_base, s_addr);
13480 for (i = 0; i < words; i++) {
13481 AscSetChipLramData(iop_base, set_wval);
13482 }
13483 return;
13484}
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494STATIC unsigned char _adv_asc3550_buf[] = {
13495 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc, 0x01, 0x00, 0x48, 0xe4,
13496 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7,
13497 0xff, 0x00, 0x82, 0xe7, 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6,
13498 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00, 0x00, 0xec, 0x85, 0xf0,
13499 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54, 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00,
13500 0x98, 0x57, 0xd0, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80,
13501 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea,
13502 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12, 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00,
13503 0xc0, 0x00, 0x01, 0x01, 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54,
13504 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00, 0x3e, 0x00, 0x80, 0x00,
13505 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01,
13506 0x78, 0x01, 0x62, 0x0a, 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55,
13507 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
13508 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00, 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15,
13509 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0,
13510 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01,
13511 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10, 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c,
13512 0x00, 0x4e, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0,
13513 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00, 0xb5, 0x00,
13514 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10,
13515 0x04, 0x10, 0x0a, 0x10, 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15,
13516 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45,
13517 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6,
13518 0x0b, 0xf0, 0x0c, 0xf0, 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa,
13519 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00, 0x9e, 0x00, 0xa8, 0x00,
13520 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01,
13521 0xc2, 0x01, 0x7c, 0x02, 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08,
13522 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x06, 0x12,
13523 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13, 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17,
13524 0xd2, 0x17, 0x6b, 0x18, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47,
13525 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55, 0x14, 0x56, 0x77, 0x57,
13526 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90, 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe,
13527 0xb8, 0x0c, 0xff, 0x10, 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff,
13528 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00, 0x00, 0xfe, 0x57, 0x24,
13529 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00, 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08,
13530 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f,
13531 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00, 0xfe, 0x04, 0xf7, 0xcf,
13532 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe, 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe,
13533 0x3d, 0xf0, 0xfe, 0x02, 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe,
13534 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b, 0x02, 0xfe, 0xd4, 0x0c,
13535 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe, 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6,
13536 0x00, 0xfe, 0xd3, 0x12, 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02,
13537 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02, 0xfe, 0x46, 0xf0, 0xfe,
13538 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44,
13539 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18,
13540 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9,
13541 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e,
13542 0x02, 0x29, 0x14, 0x4d, 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd,
13543 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe, 0x58, 0x1c, 0x17, 0x06,
13544 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0, 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe,
13545 0x5a, 0x1c, 0xea, 0xfe, 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f,
13546 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe, 0x69, 0x10, 0x17, 0x06,
13547 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d, 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe,
13548 0x52, 0x16, 0x09, 0x4a, 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40,
13549 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41, 0x58, 0x0a, 0x99, 0x01,
13550 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03, 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02,
13551 0xe8, 0x27, 0xf8, 0xfe, 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b,
13552 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0, 0xfe, 0x56, 0x03, 0xfe,
13553 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0, 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe,
13554 0x64, 0x03, 0xeb, 0x0f, 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04,
13555 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40, 0x01, 0x0e, 0xac, 0x75,
13556 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2, 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe,
13557 0x92, 0x03, 0xec, 0x11, 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4,
13558 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe, 0x0a, 0xf0, 0xfe, 0x7a,
13559 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe, 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe,
13560 0x66, 0x02, 0x02, 0xd1, 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c,
13561 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3, 0x0a, 0xca, 0x01, 0x0e,
13562 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28, 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f,
13563 0xfe, 0x66, 0x02, 0x02, 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f,
13564 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e, 0x12, 0x2b, 0xff, 0x02,
13565 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04, 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5,
13566 0xfe, 0x4c, 0x44, 0xfe, 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
13567 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d, 0xfe, 0x2a, 0x13, 0x2f,
13568 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86,
13569 0x09, 0x04, 0x1d, 0xfe, 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12,
13570 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22,
13571 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90, 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29,
13572 0xfe, 0x42, 0x5b, 0x67, 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4,
13573 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a, 0xfe, 0x70, 0x12, 0x49,
13574 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2, 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31,
13575 0xe4, 0x6a, 0x49, 0x04, 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12,
13576 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05, 0x11, 0xfe, 0xe3, 0x00,
13577 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24,
13578 0xfe, 0x21, 0x00, 0xa1, 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08,
13579 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01, 0x86, 0x24, 0x06, 0x12,
13580 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d, 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92,
13581 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe,
13582 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13, 0x47, 0x01, 0xa7, 0x26,
13583 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19, 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14,
13584 0x1f, 0xfe, 0xfe, 0x05, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c,
13585 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x14,
13586 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48, 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57,
13587 0x48, 0x8b, 0x1c, 0x3d, 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04,
13588 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68, 0x06, 0x11, 0x9a, 0x01,
13589 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4, 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72,
13590 0x70, 0x01, 0x6e, 0x87, 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe,
13591 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07, 0x8d, 0x81, 0x02, 0x22,
13592 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00,
13593 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32,
13594 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15, 0xfe, 0x1b, 0x00, 0x01,
13595 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01,
13596 0x08, 0x15, 0x00, 0x02, 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d,
13597 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12,
13598 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d,
13599 0x81, 0x8c, 0xfe, 0x5c, 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02,
13600 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x77, 0xfe, 0xca,
13601 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a, 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12,
13602 0x74, 0xfe, 0x80, 0x80, 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1,
13603 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f, 0x40, 0x12, 0x58, 0x01,
13604 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe,
13605 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe,
13606 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a, 0xfe, 0x2a, 0x12, 0xfe,
13607 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe,
13608 0x1f, 0x80, 0x12, 0x58, 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe,
13609 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x39, 0x18, 0x3a,
13610 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35, 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48,
13611 0x08, 0xfe, 0x9e, 0xf0, 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80,
13612 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x7a, 0x08, 0x8d,
13613 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10, 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06,
13614 0xfe, 0x10, 0x12, 0x61, 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c,
13615 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe, 0x52, 0x12, 0xfe, 0x2c,
13616 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe, 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10,
13617 0xaa, 0xfe, 0xf3, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe,
13618 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xb5, 0xfe,
13619 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a, 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d,
13620 0xb8, 0x6d, 0xb9, 0x6d, 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33,
13621 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a, 0xfe, 0x74, 0x18, 0x1c,
13622 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01, 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27,
13623 0x74, 0x67, 0x1a, 0x02, 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe,
13624 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc, 0xfe, 0x83, 0x80, 0xfe,
13625 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59,
13626 0xfe, 0xc1, 0x59, 0x77, 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf,
13627 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e, 0x79, 0x56, 0x68, 0x57,
13628 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05, 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b,
13629 0x0c, 0x7c, 0x79, 0x56, 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39,
13630 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x10, 0x58, 0xfe,
13631 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09,
13632 0x04, 0xfe, 0xf7, 0x00, 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe,
13633 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08, 0x11, 0x9b, 0x09, 0x04,
13634 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a, 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe,
13635 0x8d, 0x58, 0x02, 0x6d, 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12,
13636 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9, 0x14, 0x7a, 0x01, 0x33,
13637 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf,
13638 0x3a, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10,
13639 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a, 0x84, 0x05, 0xcb, 0x1c,
13640 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00, 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a,
13641 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca,
13642 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe, 0x22, 0x00, 0x02, 0x5a,
13643 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe, 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe,
13644 0xec, 0x0a, 0x0f, 0x93, 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10,
13645 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00, 0x2a, 0x13, 0xfe, 0x4e,
13646 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0, 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73,
13647 0xdd, 0xb8, 0x22, 0xb9, 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48,
13648 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xdb, 0x10, 0x11, 0xfe,
13649 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd, 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8,
13650 0xbc, 0x7d, 0xbd, 0x7f, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42,
13651 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c, 0x09, 0x04, 0x0b, 0xfe,
13652 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54, 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6,
13653 0x0c, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01,
13654 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x02, 0x29,
13655 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e, 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b,
13656 0xfe, 0xaa, 0x10, 0x01, 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe,
13657 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01, 0xe8, 0x59, 0x11, 0x2d,
13658 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02, 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e,
13659 0x0b, 0x0f, 0x00, 0xfe, 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe,
13660 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d,
13661 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35, 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe,
13662 0x04, 0xe6, 0x0b, 0x5f, 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00,
13663 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa, 0xab, 0x70, 0x05, 0x6b,
13664 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b, 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01,
13665 0xda, 0x02, 0x29, 0xea, 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01,
13666 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e, 0x1d, 0xfe, 0xce, 0x45,
13667 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47, 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe,
13668 0x98, 0x56, 0xfe, 0x38, 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d,
13669 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe,
13670 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe, 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee,
13671 0x3e, 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e,
13672 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12, 0xce, 0x1e, 0x2d, 0x47,
13673 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe, 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe,
13674 0xe2, 0x15, 0x05, 0xfe, 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02,
13675 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
13676 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4, 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea,
13677 0xce, 0x62, 0x7a, 0xfe, 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01,
13678 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01, 0x0c, 0xfe, 0x62, 0x01,
13679 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11, 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e,
13680 0x4d, 0xfe, 0xf7, 0x12, 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24,
13681 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57,
13682 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc, 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe,
13683 0x03, 0x57, 0xb6, 0x23, 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04,
13684 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13, 0xfe, 0x1e, 0x80, 0xe1,
13685 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe, 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c,
13686 0x90, 0xfe, 0x30, 0xf4, 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d,
13687 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01, 0xe8, 0x11, 0xfe, 0xe9,
13688 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01, 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14,
13689 0x90, 0xfe, 0x96, 0x90, 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe,
13690 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80, 0x40, 0x12, 0x20, 0x63,
13691 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac,
13692 0x00, 0xfe, 0x06, 0x58, 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe,
13693 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x24, 0x69, 0x12, 0xc9,
13694 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48, 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91,
13695 0x54, 0x21, 0xfe, 0x08, 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe,
13696 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c, 0x46, 0x1e, 0x20, 0xed,
13697 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c,
13698 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d,
13699 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46, 0xfa, 0xef, 0xfe, 0x42,
13700 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0,
13701 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10,
13702 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e, 0x10, 0x07, 0x7e, 0x45,
13703 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03, 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97,
13704 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe,
13705 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b, 0xfe, 0x48, 0x12, 0x07,
13706 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30, 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07,
13707 0xfe, 0x23, 0x00, 0x16, 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe,
13708 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b, 0x01, 0x08, 0x8c, 0x43,
13709 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01, 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b,
13710 0x2f, 0x07, 0x9b, 0xfe, 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04,
13711 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe, 0xc6, 0x10, 0x1e, 0x58,
13712 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77, 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23,
13713 0x0c, 0x7b, 0x0c, 0x7c, 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1,
13714 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05, 0xfa, 0x4e, 0xfe,
13715 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57,
13716 0x83, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
13717 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e, 0x58, 0xfe, 0x1f, 0x40,
13718 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44,
13719 0x50, 0xfe, 0xc6, 0x50, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39,
13720 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06, 0x12, 0xcd, 0x02, 0x5b,
13721 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5, 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21,
13722 0x5b, 0x01, 0x6e, 0x1c, 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe,
13723 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51,
13724 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19, 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32,
13725 0x1f, 0xa2, 0x30, 0x2e, 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01,
13726 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44, 0x01, 0x08, 0x1f, 0xa2,
13727 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49,
13728 0x04, 0x19, 0x34, 0x9f, 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda,
13729 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1, 0x05, 0xc6, 0x28, 0x84,
13730 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
13731 0x05, 0x50, 0xb4, 0x0c, 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02,
13732 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06, 0x21, 0x44, 0x01, 0xfe,
13733 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14, 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b,
13734 0x16, 0x44, 0xfe, 0x4a, 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05,
13735 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xd8, 0x14, 0x02, 0x5c,
13736 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe, 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72,
13737 0x03, 0x8f, 0xfe, 0xdc, 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01,
13738 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0xfe, 0xff, 0x7f,
13739 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c,
13740 0x3d, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
13741 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58, 0x03, 0x0a, 0x50, 0x01,
13742 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c, 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4,
13743 0x19, 0x48, 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27,
13744 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe,
13745 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01, 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60,
13746 0x89, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14,
13747 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe, 0xcc, 0x12, 0x49, 0x04,
13748 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2, 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13,
13749 0x06, 0x17, 0xc3, 0x78, 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83,
13750 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c, 0x13, 0x06, 0xfe, 0x56,
13751 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00, 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93,
13752 0x13, 0x06, 0xfe, 0x28, 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4,
13753 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90, 0x01, 0xba, 0xfe, 0x4e,
13754 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4, 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe,
13755 0x04, 0xf4, 0x6c, 0xfe, 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c,
13756 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba, 0xfe, 0x9c, 0x14, 0xb7,
13757 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7,
13758 0x19, 0x83, 0x60, 0x23, 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe,
13759 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x0b, 0x01,
13760 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03,
13761 0x15, 0x06, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08,
13762 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89, 0x4a, 0x01, 0x08, 0x03,
13763 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44, 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00,
13764 0x3b, 0x72, 0x9f, 0x5e, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe,
13765 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd, 0x01, 0x43, 0x1e, 0xcd,
13766 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10,
13767 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88,
13768 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3, 0x88, 0x03, 0x0a, 0x42,
13769 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2,
13770 0xfe, 0x49, 0xe4, 0x10, 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17,
13771 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe,
13772 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01, 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe,
13773 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10,
13774 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58, 0x05, 0xfe, 0x66, 0x01,
13775 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66,
13776 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6,
13777 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17, 0x10, 0x71, 0xfe, 0x83,
13778 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe,
13779 0x94, 0x14, 0xfe, 0x10, 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
13780 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71, 0xfe, 0x30, 0xbc, 0xfe,
13781 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a,
13782 0x16, 0xfe, 0x5c, 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02,
13783 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc, 0xfe, 0x1d, 0xf7, 0x4f,
13784 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58,
13785 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63,
13786 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14, 0x06, 0x37, 0x95, 0xa9,
13787 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17, 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d,
13788 0x13, 0x0d, 0x03, 0x71, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c,
13789 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x3c, 0x8a, 0x0a,
13790 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc,
13791 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f,
13792 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xf6, 0xfe, 0xd6, 0xf0,
13793 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c, 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76,
13794 0x27, 0x01, 0xda, 0x17, 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f,
13795 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68, 0xc8, 0xfe, 0x48, 0x55,
13796 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73, 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0,
13797 0x0a, 0x40, 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42,
13798 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01, 0x0e, 0x73, 0x75, 0x03,
13799 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18, 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b,
13800 0xfe, 0x4e, 0xe4, 0xc2, 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b,
13801 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05, 0xfe, 0x94, 0x00, 0xfe,
13802 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e,
13803 0x45, 0xfe, 0x0c, 0x12, 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe,
13804 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1b, 0xfe, 0x5a,
13805 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26, 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07,
13806 0x0b, 0x5d, 0x24, 0x93, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14,
13807 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9, 0x03, 0x25, 0xfe, 0xca,
13808 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6, 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00,
13809};
13810
13811STATIC unsigned short _adv_asc3550_size =
13812 sizeof(_adv_asc3550_buf);
13813STATIC ADV_DCNT _adv_asc3550_chksum =
13814 0x04D52DDDUL;
13815
13816
13817STATIC unsigned char _adv_asc38C0800_buf[] = {
13818 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4, 0x01, 0x00, 0x48, 0xe4,
13819 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19, 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6,
13820 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0,
13821 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0, 0x18, 0xf4, 0x08, 0x00,
13822 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0, 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0,
13823 0x98, 0x57, 0x01, 0xfc, 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00,
13824 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13, 0xba, 0x13, 0x18, 0x40,
13825 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc, 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01,
13826 0x76, 0x01, 0xb9, 0x54, 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
13827 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12, 0x08, 0x12, 0x02, 0x4a,
13828 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa,
13829 0x20, 0x00, 0x32, 0x00, 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
13830 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d, 0x06, 0x13, 0x4c, 0x1c,
13831 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00,
13832 0xbe, 0x00, 0x00, 0x01, 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44,
13833 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa, 0x05, 0x00, 0x34, 0x00,
13834 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f,
13835 0x0c, 0x10, 0x22, 0x11, 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54,
13836 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0,
13837 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc, 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00,
13838 0x9b, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03,
13839 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13, 0x12, 0x13, 0x24, 0x14,
13840 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44,
13841 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55,
13842 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0, 0x04, 0xf8,
13843 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00, 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00,
13844 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01,
13845 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08, 0x68, 0x08, 0x69, 0x08,
13846 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f, 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10,
13847 0x2a, 0x11, 0x06, 0x12, 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14,
13848 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18, 0xca, 0x18, 0xe6, 0x19,
13849 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe,
13850 0xac, 0x0d, 0xff, 0x10, 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff,
13851 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00, 0x00, 0xfe, 0x57, 0x24,
13852 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00, 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08,
13853 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11,
13854 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00, 0xfe, 0x04, 0xf7, 0xd6,
13855 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe, 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe,
13856 0x3d, 0xf0, 0xfe, 0x06, 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe,
13857 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d, 0x02, 0xfe, 0xc8, 0x0d,
13858 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe, 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6,
13859 0x00, 0xfe, 0xd3, 0x12, 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02,
13860 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02, 0xfe, 0x46, 0xf0, 0xfe,
13861 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44,
13862 0xf0, 0xfe, 0x4c, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14,
13863 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9,
13864 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8,
13865 0x02, 0x2b, 0x15, 0x59, 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd,
13866 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe, 0x58, 0x1c, 0x18, 0x06,
13867 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0, 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe,
13868 0x5a, 0x1c, 0xf8, 0xfe, 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10,
13869 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe, 0x69, 0x10, 0x18, 0x06,
13870 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43, 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe,
13871 0x4a, 0x17, 0x08, 0x54, 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
13872 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10, 0xfe, 0x41, 0x58, 0x09,
13873 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe, 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
13874 0x2c, 0x4f, 0xfe, 0x02, 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe,
13875 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x40, 0x1c, 0x1c,
13876 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0,
13877 0xa7, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02,
13878 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13, 0x21, 0x22, 0xa3, 0xb7,
13879 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78, 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9,
13880 0xfe, 0x01, 0xf0, 0xd9, 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27,
13881 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe, 0x06, 0xf0, 0xfe, 0xc8,
13882 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a, 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe,
13883 0xfa, 0x04, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19,
13884 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x74, 0x01, 0xaf, 0x8c,
13885 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda, 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79,
13886 0x2a, 0x03, 0x70, 0x28, 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02,
13887 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d, 0xfe, 0x3c, 0x04, 0x3b,
13888 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e, 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b,
13889 0x1d, 0xfe, 0xe4, 0x04, 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe,
13890 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0x4f, 0x79, 0x2a,
13891 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62, 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32,
13892 0x07, 0x82, 0xfe, 0x52, 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe,
13893 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x08, 0x13, 0x32, 0x07,
13894 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d,
13895 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6,
13896 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36, 0x02, 0x2b, 0xfe, 0x42,
13897 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe,
13898 0x31, 0xe4, 0x5b, 0x08, 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c,
13899 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28, 0x17, 0xfe, 0x90, 0x05,
13900 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe, 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe,
13901 0x4e, 0x12, 0x67, 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48,
13902 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0x12, 0xfe, 0xe3, 0x00,
13903 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25,
13904 0xfe, 0x21, 0x00, 0xab, 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02,
13905 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2, 0x08, 0x53, 0x05, 0xcb,
13906 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39, 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22,
13907 0x12, 0x41, 0x01, 0xb2, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36,
13908 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb, 0x03, 0x5c, 0x28, 0xfe,
13909 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18, 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02,
13910 0x12, 0x50, 0x01, 0xfe, 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe,
13911 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62, 0x12, 0x03, 0x45, 0x28,
13912 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01, 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc,
13913 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2,
13914 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01, 0xfe, 0xcc, 0x15, 0x1d,
13915 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45,
13916 0x18, 0x06, 0x01, 0xb2, 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb,
13917 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07, 0xfe, 0x06, 0xf0, 0xfe,
13918 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05, 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b,
13919 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01,
13920 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38, 0x12, 0x08, 0x05, 0x1a,
13921 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
13922 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe,
13923 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b, 0xfe, 0x09, 0x6f, 0xba,
13924 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d, 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c,
13925 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01,
13926 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
13927 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07,
13928 0x11, 0xfe, 0x0e, 0x12, 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe,
13929 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b, 0x37, 0x01, 0xb3, 0xb8,
13930 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51,
13931 0xfe, 0xc6, 0x51, 0x88, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c,
13932 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d, 0x14, 0x3e, 0xfe, 0x4a,
13933 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14,
13934 0x61, 0x08, 0x05, 0x5b, 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe,
13935 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f,
13936 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d, 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c,
13937 0x49, 0x0c, 0x63, 0x08, 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e,
13938 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe, 0x9a, 0x08, 0xc6, 0xfe,
13939 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24,
13940 0x01, 0x4b, 0xfe, 0xc9, 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12,
13941 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e, 0x1c, 0x02, 0xfe, 0x18,
13942 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a, 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa,
13943 0xf0, 0xfe, 0xd2, 0x09, 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7,
13944 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18, 0xfe, 0xf1, 0x18, 0xfe,
13945 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95,
13946 0x59, 0x1c, 0x85, 0xfe, 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5,
13947 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18, 0x0b, 0xb6, 0xfe, 0xbf,
13948 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2,
13949 0xf0, 0x85, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5,
13950 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15, 0x9d, 0x01, 0x36, 0x10,
13951 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10, 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19,
13952 0xe4, 0x0a, 0xfe, 0x1a, 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe,
13953 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08, 0x02, 0x4a, 0x08, 0x05,
13954 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f, 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c,
13955 0x18, 0xfe, 0xed, 0x18, 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49,
13956 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18, 0x8f, 0xfe, 0xe3, 0x54,
13957 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a, 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b,
13958 0xf0, 0xfe, 0x60, 0x09, 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b,
13959 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00, 0xad, 0xfe, 0x01, 0x59,
13960 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a, 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3,
13961 0x54, 0x57, 0x49, 0x7d, 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b,
13962 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63, 0x02, 0x4a, 0x08, 0x05,
13963 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe, 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1,
13964 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a,
13965 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29, 0x61, 0x0c, 0x7f, 0x14,
13966 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8, 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c,
13967 0x3a, 0x3f, 0x3b, 0x40, 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef,
13968 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40, 0xe4, 0x08, 0x05, 0x1f,
13969 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f,
13970 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05,
13971 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19, 0x81, 0x50, 0xfe, 0x10,
13972 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32, 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6,
13973 0x08, 0x05, 0x0a, 0xfe, 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c,
13974 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7, 0x08, 0x05, 0x0a, 0xfe,
13975 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e,
13976 0x01, 0x36, 0x10, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed,
13977 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe, 0x00, 0xff, 0x35, 0xfe,
13978 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6, 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03,
13979 0xd2, 0x1e, 0x06, 0xfe, 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe,
13980 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0,
13981 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00,
13982 0x02, 0x65, 0xfe, 0xcb, 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0,
13983 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea, 0x0b, 0x10, 0x58, 0xfe,
13984 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05, 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f,
13985 0xfe, 0x4e, 0x11, 0x27, 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34,
13986 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20, 0x0c, 0x1c, 0x34, 0x94,
13987 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6, 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10,
13988 0x12, 0xfe, 0xe8, 0x00, 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33,
13989 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24, 0x33, 0x31, 0xdf, 0xbc,
13990 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c, 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d,
13991 0x08, 0x05, 0x0a, 0xfe, 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28,
13992 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x44, 0xfe, 0x28, 0x00,
13993 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09, 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f,
13994 0x01, 0x73, 0x02, 0x2b, 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10,
13995 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xac,
13996 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96, 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01,
13997 0xf6, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08,
13998 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05, 0x1a, 0xfe, 0x58, 0x12,
13999 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe,
14000 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10,
14001 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10, 0xfe, 0x13, 0x00, 0xfe,
14002 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41, 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5,
14003 0xb6, 0x74, 0x03, 0x70, 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe,
14004 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0, 0xb4, 0x15, 0xfe, 0x31,
14005 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02, 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44,
14006 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75,
14007 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x44, 0x48,
14008 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09, 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09,
14009 0xa4, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d,
14010 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe, 0xce, 0x47, 0xfe, 0xad,
14011 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13,
14012 0xd5, 0x22, 0x2f, 0x41, 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06,
14013 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe, 0x3a, 0x01, 0x56, 0xfe,
14014 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00, 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05,
14015 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe,
14016 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13, 0x15, 0x1a, 0x39, 0xa0,
14017 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01,
14018 0x03, 0xfe, 0x3a, 0x01, 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12,
14019 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12, 0x22, 0x9f, 0xb7, 0x13,
14020 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24, 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9,
14021 0x10, 0xc3, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc,
14022 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21, 0xfe, 0x00, 0xcc, 0x04,
14023 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05, 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07,
14024 0x06, 0xfe, 0x1a, 0x13, 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe,
14025 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4, 0x0a, 0xfe, 0x3c, 0x50,
14026 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f, 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b,
14027 0x4e, 0x01, 0xf5, 0x01, 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01,
14028 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90, 0x0c, 0xfe, 0x64, 0x01,
14029 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe, 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01,
14030 0xec, 0x20, 0xfe, 0x80, 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79,
14031 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00,
14032
14033 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09,
14034 0x58, 0xfe, 0x0a, 0x1c, 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52,
14035 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc, 0x0f, 0x44, 0x11, 0x0f,
14036 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20,
14037 0x7c, 0x6f, 0x4f, 0x22, 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
14038 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x04, 0x42,
14039 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01,
14040 0xb0, 0x7c, 0x6f, 0x4f, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f,
14041 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45,
14042 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09,
14043 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14,
14044 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d, 0xfe, 0x01, 0xec, 0xa2,
14045 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe,
14046 0xdd, 0x10, 0x2c, 0xc7, 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07,
14047 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17, 0xfe, 0x32, 0x12, 0x07,
14048 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17, 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12,
14049 0x07, 0x00, 0x17, 0x24, 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d,
14050 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d, 0x32, 0x07, 0xa6, 0xfe,
14051 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe, 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12,
14052 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03,
14053 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21, 0x0c, 0x7f, 0x0c, 0x80,
14054 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01, 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55,
14055 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f,
14056 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40, 0x88, 0x9b, 0x2e, 0x9c,
14057 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14,
14058 0x5f, 0x08, 0x05, 0x5a, 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61,
14059 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50,
14060 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40,
14061 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d,
14062 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23, 0x72, 0x01, 0xaf, 0x1e,
14063 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a, 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe,
14064 0x8b, 0x55, 0x57, 0x3d, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19,
14065 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31,
14066 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a, 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d,
14067 0xe8, 0x33, 0x31, 0xdf, 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8,
14068 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53, 0x05, 0x1f, 0x35, 0xa9,
14069 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06, 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c,
14070 0xfe, 0x4b, 0x45, 0xee, 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35,
14071 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x03, 0x5c, 0xc1, 0x0c,
14072 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c,
14073 0x34, 0x1d, 0x4c, 0x33, 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1,
14074 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a, 0xf4, 0x06, 0xea, 0x32,
14075 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89,
14076 0x01, 0xfe, 0xcc, 0x15, 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13,
14077 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0, 0x13, 0x1c, 0xfe, 0xd0,
14078 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01, 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02,
14079 0x00, 0x57, 0x52, 0x93, 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f,
14080 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04,
14081 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52,
14082 0x93, 0xfe, 0x0b, 0x58, 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03,
14083 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52, 0xfe, 0x00, 0x7d, 0xfe,
14084 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f,
14085 0x7d, 0x40, 0x04, 0xdd, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01,
14086 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15, 0x33,
14087 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15, 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59,
14088 0x03, 0xcd, 0x28, 0xfe, 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee,
14089 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c, 0x30, 0xfe, 0x78, 0x10,
14090 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83, 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00,
14091 0x96, 0xf2, 0x18, 0x6d, 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00,
14092 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28, 0x10, 0x69, 0x06, 0xfe,
14093 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2, 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06,
14094 0x88, 0x98, 0xfe, 0x90, 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe,
14095 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4, 0x9e, 0xfe, 0xf3, 0x10,
14096 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e, 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
14097 0x6e, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
14098 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d, 0xf4, 0x00, 0xe9, 0x91,
14099 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01,
14100 0x0b, 0x26, 0xf3, 0x16, 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76,
14101 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x19, 0x01, 0x0b,
14102 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1, 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76,
14103 0xfe, 0x89, 0x4a, 0x01, 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8,
14104 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01,
14105 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00,
14106 0xfe, 0x20, 0x13, 0x1d, 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06,
14107 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e, 0x07, 0x11, 0xae, 0x09,
14108 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80,
14109 0xe7, 0x11, 0x07, 0x11, 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e,
14110 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xfe, 0x80, 0x4c,
14111 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87,
14112 0x04, 0x18, 0x11, 0x75, 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24,
14113 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4, 0x17, 0xad, 0x9a, 0x1b,
14114 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04, 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10,
14115 0x18, 0x11, 0x75, 0x03, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe,
14116 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c,
14117 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17,
14118 0xfe, 0xb6, 0x14, 0x35, 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75,
14119 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x2e, 0x97, 0xfe, 0x5a,
14120 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c, 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
14121 0x04, 0xb9, 0x23, 0xfe, 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe,
14122 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0xcb, 0x97, 0xfe, 0x92,
14123 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23, 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02,
14124 0xf6, 0x11, 0x75, 0xfe, 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d,
14125 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0x9a, 0x5b, 0x41, 0xfe,
14126 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd,
14127 0x00, 0x6a, 0x2a, 0x04, 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39,
14128 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04, 0xfe, 0x7e, 0x18, 0x1e,
14129 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2, 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10,
14130 0x7c, 0x6f, 0x4f, 0x32, 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09,
14131 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc,
14132 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c,
14133 0x01, 0x73, 0xfe, 0x16, 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14,
14134 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c, 0xe7, 0x0a, 0x10, 0xfe,
14135 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18, 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37,
14136 0x12, 0x2f, 0x01, 0x73, 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b,
14137 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77, 0x13, 0xa3, 0x04, 0x09,
14138 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46, 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8,
14139 0x18, 0x77, 0x78, 0x04, 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09,
14140 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe, 0x1c, 0x19, 0x03, 0xfe,
14141 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19,
14142 0x03, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b,
14143 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe, 0x08, 0x10, 0x03, 0xfe,
14144 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e, 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7,
14145 0x1e, 0x6e, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00,
14146 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19, 0x04, 0x07, 0x7e, 0xfe,
14147 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a,
14148 0xf0, 0xfe, 0x92, 0x19, 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07,
14149 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59, 0xa9, 0xb8, 0x04, 0x15,
14150 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe, 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c,
14151 0xf7, 0xfe, 0x14, 0xf0, 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0,
14152 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
14153};
14154
14155STATIC unsigned short _adv_asc38C0800_size =
14156 sizeof(_adv_asc38C0800_buf);
14157STATIC ADV_DCNT _adv_asc38C0800_chksum =
14158 0x050D3FD8UL;
14159
14160
14161STATIC unsigned char _adv_asc38C1600_buf[] = {
14162 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0, 0x18, 0xe4, 0x01, 0x00,
14163 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13, 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f,
14164 0x00, 0xfa, 0xff, 0xff, 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0,
14165 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00, 0x98, 0x57, 0x01, 0xe6,
14166 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4, 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0,
14167 0x10, 0x00, 0xc2, 0x0e, 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0,
14168 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01, 0x06, 0x13, 0x0c, 0x1c,
14169 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc, 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80,
14170 0x62, 0x0a, 0x5a, 0x12, 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea,
14171 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12, 0x04, 0x13, 0xbb, 0x55,
14172 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4, 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00,
14173 0x00, 0x01, 0x01, 0x01, 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c,
14174 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01,
14175 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01,
14176 0xc6, 0x0e, 0x0c, 0x10, 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48,
14177 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x06, 0x00,
14178 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12, 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c,
14179 0x10, 0x44, 0x00, 0x4c, 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0,
14180 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00,
14181 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09,
14182 0x68, 0x0d, 0x02, 0x10, 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16,
14183 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
14184 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7, 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00,
14185 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c,
14186 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x42, 0x1d, 0x08, 0x44,
14187 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59,
14188 0x31, 0xe4, 0x02, 0xe6, 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8,
14189 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0xa8, 0x00, 0xaa, 0x00,
14190 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01, 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01,
14191 0xc8, 0x01, 0xca, 0x01, 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d,
14192 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10, 0xf3, 0x10, 0x06, 0x12,
14193 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13, 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe,
14194 0xec, 0x0e, 0xff, 0x10, 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff,
14195 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00, 0x00, 0xfe, 0x57, 0x24,
14196 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00, 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08,
14197 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13,
14198 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00, 0xfe, 0x04, 0xf7, 0xe8,
14199 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe, 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe,
14200 0x3d, 0xf0, 0xfe, 0x0c, 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe,
14201 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d, 0x05, 0xfe, 0x08, 0x0f,
14202 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05, 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe,
14203 0xa6, 0x00, 0xfe, 0xd1, 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90,
14204 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8, 0x02, 0xfe, 0x46, 0xf0,
14205 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60, 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe,
14206 0x44, 0xf0, 0xfe, 0x52, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07,
14207 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02, 0x1c, 0xf5, 0xfe, 0x1e,
14208 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01,
14209 0xa3, 0x05, 0x35, 0x1f, 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe,
14210 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe, 0x58, 0x1c, 0x1c,
14211 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02,
14212 0xfe, 0x5a, 0x1c, 0xfe, 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01,
14213 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09, 0x1a, 0x31, 0xfe, 0x69,
14214 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec, 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c,
14215 0xfe, 0x05, 0xf6, 0xde, 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51,
14216 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00,
14217 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41, 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54,
14218 0x7b, 0xfe, 0x1c, 0x03, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30,
14219 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0, 0xfe, 0xe4, 0x01, 0xfe,
14220 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40, 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66,
14221 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f,
14222 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05, 0x70, 0x37, 0xfe, 0x48,
14223 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20,
14224 0xb9, 0x0a, 0x57, 0x01, 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe,
14225 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32, 0x15, 0xfe, 0xe4, 0x00,
14226 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe, 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe,
14227 0xd6, 0x03, 0xaf, 0xa0, 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b,
14228 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xfe, 0x46, 0x1c,
14229 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75,
14230 0x01, 0xa6, 0x86, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77,
14231 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02,
14232 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29, 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04,
14233 0x7e, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01,
14234 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25, 0xee, 0xfe, 0x4c, 0x44,
14235 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d,
14236 0x30, 0x01, 0xfe, 0x4e, 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe,
14237 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10, 0x13, 0x34, 0xfe, 0x4c,
14238 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06,
14239 0x28, 0xa5, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f,
14240 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f, 0xfe, 0xa4, 0x0e, 0x05,
14241 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe, 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b,
14242 0x0e, 0x8b, 0x02, 0x1f, 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46,
14243 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04, 0xfe, 0x87, 0x83, 0xfe,
14244 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20,
14245 0x80, 0x04, 0xfe, 0xa0, 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06,
14246 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda, 0x05, 0xd0, 0x54, 0x01,
14247 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff,
14248 0x02, 0x00, 0x10, 0x2f, 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe,
14249 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01, 0x38, 0xfe, 0x4a, 0xf0,
14250 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba, 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e,
14251 0xfe, 0x22, 0x00, 0xa2, 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0,
14252 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe, 0x1c, 0x00, 0x4d, 0x01,
14253 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27, 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12,
14254 0x3e, 0x01, 0x84, 0x1f, 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42,
14255 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13, 0x03, 0xb6, 0x1e, 0xfe,
14256 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13, 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a,
14257 0x07, 0x01, 0x38, 0x06, 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68,
14258 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66, 0x03, 0x9a, 0x1e, 0xfe,
14259 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13, 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06,
14260 0x2e, 0x12, 0x01, 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00,
14261 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17, 0xfe, 0xea, 0x06, 0x01,
14262 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01, 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15,
14263 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae,
14264 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a, 0x1e, 0xfe, 0x1a, 0x12,
14265 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80,
14266 0xf0, 0x45, 0x0a, 0x95, 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6,
14267 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x17, 0xfe,
14268 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe, 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01,
14269 0x41, 0x15, 0xe2, 0x21, 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05,
14270 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0x9c, 0x32, 0x5f,
14271 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00, 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe,
14272 0xce, 0x07, 0xae, 0xfe, 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29,
14273 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14,
14274 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe,
14275 0xc6, 0x09, 0x01, 0x76, 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13,
14276 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
14277 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00, 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe,
14278 0x9a, 0x81, 0x04, 0xfe, 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c,
14279 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x53, 0x63, 0x4e,
14280 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0,
14281 0xae, 0xfe, 0x96, 0x08, 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c,
14282 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe, 0x1e, 0xfe, 0x99, 0x58,
14283 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe, 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c,
14284 0x61, 0x54, 0x44, 0x21, 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a,
14285 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40, 0x01, 0x0c, 0x61, 0x65,
14286 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50,
14287 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e,
14288 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e, 0x01, 0xfe, 0xfe, 0x1e,
14289 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b, 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06,
14290 0x54, 0xfe, 0x50, 0x12, 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b,
14291 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04, 0xfe, 0x9f, 0x83, 0x33,
14292 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90, 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6,
14293 0x90, 0x04, 0xfe, 0xc6, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e,
14294 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90, 0x04, 0xfe, 0xc0, 0x93,
14295 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c,
14296 0x10, 0x64, 0x22, 0x34, 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
14297 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
14298 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a, 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a,
14299 0xae, 0xfe, 0x12, 0x0a, 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41,
14300 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07, 0xfe, 0x14, 0x12, 0x01,
14301 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe,
14302 0x1a, 0x0c, 0x01, 0x76, 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe,
14303 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe, 0x92, 0x10, 0xc4, 0xf6,
14304 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe, 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b,
14305 0xf0, 0xbf, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0,
14306 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07, 0x1b, 0xbf, 0xd4, 0x5b,
14307 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5, 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f,
14308 0x01, 0x42, 0x19, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74,
14309 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78, 0x0f, 0x4d, 0x01, 0xfe,
14310 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2,
14311 0x0b, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21,
14312 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe, 0x83, 0x83, 0xfe, 0xc9,
14313 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42, 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84,
14314 0x93, 0xfe, 0xca, 0x57, 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b,
14315 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0x10,
14316 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01, 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64,
14317 0xdc, 0x34, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64,
14318 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97, 0x10, 0x98, 0x91, 0x6c,
14319 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06, 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01,
14320 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58,
14321 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24, 0x1b, 0x40, 0x01, 0x0c,
14322 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe, 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04,
14323 0xfe, 0x90, 0x93, 0x3a, 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe,
14324 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb, 0x01, 0x0c, 0x06, 0x0d,
14325 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e, 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d,
14326 0x58, 0x05, 0x5b, 0x26, 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e,
14327 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41,
14328 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef, 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00,
14329 0xfe, 0x90, 0x10, 0xfe, 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51,
14330 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe, 0x76, 0x10, 0xac, 0xfe,
14331 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe,
14332 0x08, 0x13, 0x19, 0xfe, 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92,
14333 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2, 0x0c, 0xfe, 0x3e, 0x10,
14334 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe, 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe,
14335 0xea, 0x0c, 0x19, 0xfe, 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94,
14336 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3, 0xfe, 0xcc, 0xf0, 0xef,
14337 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12, 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
14338 0x16, 0x0d, 0xfe, 0x9e, 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
14339 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32, 0x2f, 0xfe, 0x3e, 0x0d,
14340 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0, 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f,
14341 0x05, 0x29, 0x01, 0x41, 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99,
14342 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8, 0x9c, 0x2f, 0xfe, 0x8c,
14343 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01, 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70,
14344 0x90, 0x07, 0xfe, 0x81, 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13,
14345 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b, 0xfe, 0xda, 0x0e, 0x0a,
14346 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe, 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4,
14347 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85,
14348 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe, 0xcc, 0x10, 0x01, 0xa7,
14349 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f, 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe,
14350 0xcc, 0x47, 0x0b, 0x0e, 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2,
14351 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x40, 0x15,
14352 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01, 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01,
14353 0x0c, 0x06, 0x0d, 0x5d, 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe,
14354 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe,
14355 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44,
14356 0xfe, 0x9f, 0x10, 0x19, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19,
14357 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19, 0xfe, 0x41, 0x00, 0xa2,
14358 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75, 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04,
14359 0xe6, 0x12, 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c,
14360 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01, 0xfe, 0xd4, 0x11, 0x05,
14361 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51,
14362 0xfe, 0x06, 0xea, 0xe0, 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56,
14363 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01, 0x0c, 0x06, 0x28, 0xfe,
14364 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe, 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe,
14365 0x49, 0x54, 0xb0, 0xfe, 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe,
14366 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x05,
14367 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12, 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c,
14368 0xfe, 0x7c, 0x19, 0xfe, 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b,
14369 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe, 0xf0, 0x1a, 0x03, 0xfe,
14370 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe, 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00,
14371 0x36, 0xfe, 0x04, 0xec, 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b,
14372 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02, 0xea, 0xe7, 0x53, 0x92,
14373 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3, 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23,
14374 0xfe, 0xf0, 0xff, 0x10, 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e,
14375 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02, 0x26, 0x02, 0x21, 0x96,
14376 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13, 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10,
14377 0xcf, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe,
14378 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe, 0x00, 0xcc, 0x02, 0xfe,
14379 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80,
14380 0x04, 0xfe, 0x9c, 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80,
14381 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe, 0x1d, 0x80, 0x04, 0xfe,
14382 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c, 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14,
14383 0x13, 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4,
14384 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09, 0x56, 0xfb, 0x01, 0xfe,
14385 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15,
14386 0xfe, 0xe9, 0x00, 0x01, 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e,
14387 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe, 0x96, 0x90, 0x04, 0xfe,
14388 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64, 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06,
14389 0x65, 0xf9, 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01,
14390 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40, 0x21, 0x2c, 0xfe, 0x00,
14391 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe,
14392 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00,
14393 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10, 0x66, 0x10, 0x55, 0x10,
14394 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88,
14395 0x11, 0x46, 0x1a, 0x13, 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe,
14396 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c,
14397 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe,
14398 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47,
14399 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01, 0xa7, 0x90, 0x34, 0x60,
14400 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34,
14401 0x13, 0x0a, 0x5a, 0x01, 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
14402 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89, 0x09, 0x1a, 0xa5, 0x0a,
14403 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85, 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe,
14404 0xd6, 0xf0, 0xfe, 0xec, 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e,
14405 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01, 0xf4, 0xfe, 0xdd, 0x10,
14406 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee, 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe,
14407 0x56, 0x12, 0x09, 0x1d, 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23,
14408 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09, 0x24, 0xfe, 0x12, 0x12,
14409 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42, 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32,
14410 0xfe, 0x62, 0x08, 0x0a, 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43,
14411 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80, 0x13, 0x01, 0x0c, 0x06,
14412 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe,
14413 0x4a, 0x13, 0x21, 0x6e, 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10,
14414 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49, 0x88, 0x20, 0x6e, 0x01,
14415 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa,
14416 0x64, 0xfe, 0x05, 0xfa, 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe,
14417 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x44, 0x55, 0xfe, 0xe5,
14418 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01,
14419 0x0c, 0x06, 0x54, 0xf9, 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50,
14420 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x68, 0x3b,
14421 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03, 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2,
14422 0x50, 0x05, 0x73, 0x2e, 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25,
14423 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01, 0xa6, 0x23, 0x3f, 0x1b,
14424 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31,
14425 0xfe, 0x8b, 0x55, 0xd9, 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01,
14426 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0xc0,
14427 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d, 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05,
14428 0x3d, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08,
14429 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03, 0xb6, 0x1e, 0x83, 0x01,
14430 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45, 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01,
14431 0xfe, 0xf8, 0x15, 0x01, 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82,
14432 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e, 0x05, 0x72, 0xfe, 0xc0,
14433 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66, 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17,
14434 0x73, 0x01, 0xfe, 0x56, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd,
14435 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe, 0xe8, 0x14, 0x01, 0xa6,
14436 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe, 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43,
14437 0x09, 0x82, 0x4e, 0x05, 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73,
14438 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd, 0x09,
14439 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b, 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8,
14440 0xb2, 0x0d, 0x1b, 0x3d, 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72,
14441 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0xc0, 0x19, 0x05,
14442 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17, 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26,
14443 0x5f, 0x02, 0x8f, 0xfe, 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32,
14444 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0xfe, 0xff,
14445 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad,
14446 0x23, 0x3f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
14447 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e, 0x02, 0x13, 0x58, 0xff,
14448 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58, 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01,
14449 0x5c, 0x0a, 0x6f, 0x01, 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54,
14450 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07, 0x7c, 0x3a, 0x0b, 0x0e,
14451 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a, 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00,
14452 0xfe, 0x1b, 0xf7, 0x00, 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe,
14453 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77, 0x02, 0x01, 0xc6, 0xfe,
14454 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08,
14455 0x16, 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe,
14456 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12, 0x48, 0xfe, 0x08, 0x17,
14457 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d, 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07,
14458 0x1c, 0xb4, 0x90, 0x04, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55,
14459 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x1c, 0x63, 0x13,
14460 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16, 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80,
14461 0x17, 0x0a, 0xfe, 0x64, 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60,
14462 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8, 0x00, 0x1c, 0x95, 0x13,
14463 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96,
14464 0xfe, 0x56, 0xf0, 0xfe, 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b,
14465 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe, 0xda, 0x17, 0x62, 0x49,
14466 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe, 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe,
14467 0x4d, 0xf4, 0x00, 0xf7, 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13,
14468 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xbe, 0xfe, 0x03,
14469 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16,
14470 0xa9, 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9,
14471 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01, 0x08, 0x16, 0xa9, 0x27,
14472 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01, 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24,
14473 0x31, 0xa2, 0x78, 0xf2, 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e,
14474 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10, 0xfe, 0x40, 0x5a, 0x23,
14475 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa,
14476 0x18, 0x62, 0x80, 0xfe, 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
14477 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe, 0x43, 0x48, 0x2d, 0x93,
14478 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe, 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4,
14479 0x04, 0xfe, 0x34, 0x10, 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0,
14480 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa, 0x18, 0x45, 0xfe, 0x1c,
14481 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4,
14482 0x58, 0xfe, 0x40, 0xf4, 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01,
14483 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe, 0x7e, 0x01, 0xfe, 0xc8,
14484 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01, 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01,
14485 0xfe, 0xc8, 0x44, 0x4e, 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14,
14486 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14,
14487 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07,
14488 0x01, 0x08, 0x17, 0xc1, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
14489 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01, 0x08, 0x02, 0x50, 0x02,
14490 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f, 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08,
14491 0x17, 0x74, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe,
14492 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17, 0x74, 0x5f, 0xcc, 0x01,
14493 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c, 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00,
14494 0x4d, 0x5f, 0xa1, 0x5e, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f,
14495 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13, 0x16, 0xfe, 0x64, 0x1a,
14496 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09, 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02,
14497 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01,
14498 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa, 0xfe, 0x80, 0xe7, 0x1a,
14499 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe, 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18,
14500 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80,
14501 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x0a,
14502 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c, 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
14503 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3,
14504 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe, 0xf4, 0x1a, 0xfe, 0xfa,
14505 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03,
14506 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07,
14507 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x24, 0xb1, 0xfe,
14508 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c,
14509 0x1a, 0x87, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1,
14510 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe, 0xaf, 0x19, 0xfe, 0x98,
14511 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b, 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f,
14512 0xfe, 0x30, 0x90, 0x04, 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04,
14513 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a, 0x7c, 0x12, 0xfe, 0x0f,
14514 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6, 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b,
14515 0xfe, 0x96, 0x1b, 0x5c, 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe,
14516 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee, 0x1b, 0xfe, 0x36, 0x14,
14517 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a,
14518 0xfe, 0x81, 0xe7, 0x1a, 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45,
14519 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe, 0x39, 0xf0, 0x75, 0x26,
14520 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13, 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe,
14521 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13,
14522 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a, 0x01, 0x18, 0xcb, 0xfe,
14523 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb,
14524 0xfe, 0xf3, 0x13, 0x3f, 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01,
14525 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14, 0x56,
14526 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d, 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15,
14527 0x00, 0x40, 0x8d, 0x30, 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80,
14528 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90,
14529 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31, 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20,
14530 0xb9, 0x02, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44,
14531 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09, 0x1a, 0xa4, 0x0a, 0x67,
14532 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89, 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52,
14533 0x1d, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b,
14534 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10, 0xfe, 0x4e, 0xe4, 0xfe,
14535 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe, 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03,
14536 0xfe, 0x96, 0x00, 0xd1, 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1,
14537 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe,
14538 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa, 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a,
14539 0xf0, 0xfe, 0xba, 0x1d, 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8,
14540 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe, 0x1a, 0x10, 0x09, 0x0d,
14541 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e, 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42,
14542 0xfe, 0x04, 0xfe, 0x99, 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08,
14543 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e, 0xfe, 0x82, 0xf0, 0xfe,
14544 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18,
14545 0x80, 0x04, 0xfe, 0x98, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82,
14546 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86, 0x83, 0x33, 0x0b, 0x0e,
14547 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04,
14548 0x80, 0x04, 0xfe, 0x84, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80,
14549 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04, 0xfe, 0x99, 0x83, 0xfe,
14550 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47,
14551 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
14552 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x08, 0x90, 0x04,
14553 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79,
14554 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
14555 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x3c, 0x90, 0x04,
14556 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b, 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83,
14557 0x33, 0x0b, 0x77, 0x0e, 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
14558};
14559
14560STATIC unsigned short _adv_asc38C1600_size =
14561 sizeof(_adv_asc38C1600_buf);
14562STATIC ADV_DCNT _adv_asc38C1600_chksum =
14563 0x0604EF77UL;
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582STATIC ADVEEP_3550_CONFIG
14583Default_3550_EEPROM_Config ASC_INITDATA = {
14584 ADV_EEPROM_BIOS_ENABLE,
14585 0x0000,
14586 0xFFFF,
14587 0xFFFF,
14588 0xFFFF,
14589 0xFFFF,
14590 0xFFFF,
14591 0xFFFF,
14592 0,
14593 7,
14594 0,
14595 3,
14596 0,
14597 0,
14598 0,
14599 0xFFE7,
14600 0xFFFF,
14601 0,
14602 ASC_DEF_MAX_HOST_QNG,
14603 ASC_DEF_MAX_DVC_QNG,
14604 0,
14605 0,
14606 0,
14607 0,
14608 0,
14609 0,
14610 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
14611 0,
14612 0,
14613 0,
14614 0,
14615 0,
14616 0,
14617 0
14618};
14619
14620STATIC ADVEEP_3550_CONFIG
14621ADVEEP_3550_Config_Field_IsChar ASC_INITDATA = {
14622 0,
14623 0,
14624 0,
14625 0,
14626 0,
14627 0,
14628 0,
14629 0,
14630 0,
14631 1,
14632 1,
14633 1,
14634 1,
14635 1,
14636 1,
14637 0,
14638 0,
14639 0,
14640 1,
14641 1,
14642 0,
14643 0,
14644 0,
14645 0,
14646 0,
14647 0,
14648 { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
14649 0,
14650 0,
14651 0,
14652 0,
14653 0,
14654 0,
14655 0
14656};
14657
14658STATIC ADVEEP_38C0800_CONFIG
14659Default_38C0800_EEPROM_Config ASC_INITDATA = {
14660 ADV_EEPROM_BIOS_ENABLE,
14661 0x0000,
14662 0xFFFF,
14663 0xFFFF,
14664 0x4444,
14665 0xFFFF,
14666 0xFFFF,
14667 0xFFFF,
14668 0,
14669 7,
14670 0,
14671 3,
14672 0,
14673 0,
14674 0,
14675 0xFFE7,
14676 0x4444,
14677 0x4444,
14678 ASC_DEF_MAX_HOST_QNG,
14679 ASC_DEF_MAX_DVC_QNG,
14680 0,
14681 0x4444,
14682 0,
14683 0,
14684 0,
14685 0,
14686 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
14687 0,
14688 0,
14689 0,
14690 0,
14691 0,
14692 0,
14693 0,
14694 0,
14695 0,
14696 0,
14697 0,
14698 0,
14699 0,
14700 0,
14701 0,
14702 0,
14703 0,
14704 0,
14705 0,
14706 0,
14707 0,
14708 0,
14709 0,
14710 0,
14711 0,
14712 0,
14713 0,
14714 0,
14715 ADV_PCI_VENDOR_ID,
14716 ADV_PCI_DEVID_38C0800_REV1,
14717 0,
14718 0,
14719 0,
14720 0
14721};
14722
14723STATIC ADVEEP_38C0800_CONFIG
14724ADVEEP_38C0800_Config_Field_IsChar ASC_INITDATA = {
14725 0,
14726 0,
14727 0,
14728 0,
14729 0,
14730 0,
14731 0,
14732 0,
14733 0,
14734 1,
14735 1,
14736 1,
14737 1,
14738 1,
14739 1,
14740 0,
14741 0,
14742 0,
14743 1,
14744 1,
14745 0,
14746 0,
14747 0,
14748 0,
14749 0,
14750 0,
14751 { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
14752 0,
14753 0,
14754 0,
14755 0,
14756 0,
14757 0,
14758 0,
14759 0,
14760 0,
14761 0,
14762 0,
14763 0,
14764 0,
14765 0,
14766 0,
14767 0,
14768 0,
14769 0,
14770 0,
14771 0,
14772 0,
14773 0,
14774 0,
14775 0,
14776 0,
14777 0,
14778 0,
14779 0,
14780 0,
14781 0,
14782 0,
14783 0,
14784 0,
14785 0
14786};
14787
14788STATIC ADVEEP_38C1600_CONFIG
14789Default_38C1600_EEPROM_Config ASC_INITDATA = {
14790 ADV_EEPROM_BIOS_ENABLE,
14791 0x0000,
14792 0xFFFF,
14793 0xFFFF,
14794 0x5555,
14795 0xFFFF,
14796 0xFFFF,
14797 0xFFFF,
14798 0,
14799 7,
14800 0,
14801 3,
14802 0,
14803 0,
14804 0,
14805 0xFFE7,
14806 0x5555,
14807 0x5555,
14808 ASC_DEF_MAX_HOST_QNG,
14809 ASC_DEF_MAX_DVC_QNG,
14810 0,
14811 0x5555,
14812 0,
14813 0,
14814 0,
14815 0,
14816 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
14817 0,
14818 0,
14819 0,
14820 0,
14821 0,
14822 0,
14823 0,
14824 0,
14825 0,
14826 0,
14827 0,
14828 0,
14829 0,
14830 0,
14831 0,
14832 0,
14833 0,
14834 0,
14835 0,
14836 0,
14837 0,
14838 0,
14839 0,
14840 0,
14841 0,
14842 0,
14843 0,
14844 0,
14845 ADV_PCI_VENDOR_ID,
14846 ADV_PCI_DEVID_38C1600_REV1,
14847 0,
14848 0,
14849 0,
14850 0
14851};
14852
14853STATIC ADVEEP_38C1600_CONFIG
14854ADVEEP_38C1600_Config_Field_IsChar ASC_INITDATA = {
14855 0,
14856 0,
14857 0,
14858 0,
14859 0,
14860 0,
14861 0,
14862 0,
14863 0,
14864 1,
14865 1,
14866 1,
14867 1,
14868 1,
14869 1,
14870 0,
14871 0,
14872 0,
14873 1,
14874 1,
14875 0,
14876 0,
14877 0,
14878 0,
14879 0,
14880 0,
14881 { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
14882 0,
14883 0,
14884 0,
14885 0,
14886 0,
14887 0,
14888 0,
14889 0,
14890 0,
14891 0,
14892 0,
14893 0,
14894 0,
14895 0,
14896 0,
14897 0,
14898 0,
14899 0,
14900 0,
14901 0,
14902 0,
14903 0,
14904 0,
14905 0,
14906 0,
14907 0,
14908 0,
14909 0,
14910 0,
14911 0,
14912 0,
14913 0,
14914 0,
14915 0
14916};
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926ASC_INITFUNC(
14927STATIC int,
14928AdvInitGetConfig(ADV_DVC_VAR *asc_dvc)
14929)
14930{
14931 ushort warn_code;
14932 AdvPortAddr iop_base;
14933 uchar pci_cmd_reg;
14934 int status;
14935
14936 warn_code = 0;
14937 asc_dvc->err_code = 0;
14938 iop_base = asc_dvc->iop_base;
14939
14940
14941
14942
14943
14944
14945
14946
14947 if (((pci_cmd_reg = DvcAdvReadPCIConfigByte(asc_dvc,
14948 AscPCIConfigCommandRegister))
14949 & AscPCICmdRegBits_BusMastering)
14950 != AscPCICmdRegBits_BusMastering)
14951 {
14952 pci_cmd_reg |= AscPCICmdRegBits_BusMastering;
14953
14954 DvcAdvWritePCIConfigByte(asc_dvc,
14955 AscPCIConfigCommandRegister, pci_cmd_reg);
14956
14957 if (((DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigCommandRegister))
14958 & AscPCICmdRegBits_BusMastering)
14959 != AscPCICmdRegBits_BusMastering)
14960 {
14961 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
14962 }
14963 }
14964
14965
14966
14967
14968
14969
14970
14971
14972 if (DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer) < 0x20) {
14973 DvcAdvWritePCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer, 0x20);
14974 if (DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer) < 0x20)
14975 {
14976 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
14977 }
14978 }
14979
14980
14981
14982
14983
14984
14985
14986 asc_dvc->cfg->control_flag = 0;
14987 if (((DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigCommandRegister)
14988 & AscPCICmdRegBits_ParErrRespCtrl)) == 0)
14989 {
14990 asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
14991 }
14992
14993 asc_dvc->cfg->lib_version = (ADV_LIB_VERSION_MAJOR << 8) |
14994 ADV_LIB_VERSION_MINOR;
14995 asc_dvc->cfg->chip_version =
14996 AdvGetChipVersion(iop_base, asc_dvc->bus_type);
14997
14998 ASC_DBG2(1, "AdvInitGetConfig: iopb_chip_id_1: 0x%x 0x%x\n",
14999 (ushort) AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
15000 (ushort) ADV_CHIP_ID_BYTE);
15001
15002 ASC_DBG2(1, "AdvInitGetConfig: iopw_chip_id_0: 0x%x 0x%x\n",
15003 (ushort) AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
15004 (ushort) ADV_CHIP_ID_WORD);
15005
15006
15007
15008
15009 if (AdvFindSignature(iop_base) == 0)
15010 {
15011 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
15012 return ADV_ERROR;
15013 }
15014 else {
15015
15016
15017
15018 if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
15019 asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
15020 asc_dvc->chip_type != ADV_CHIP_ASC38C1600)
15021 {
15022 asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
15023 return ADV_ERROR;
15024 }
15025
15026
15027
15028
15029 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
15030 ADV_CTRL_REG_CMD_RESET);
15031 DvcSleepMilliSecond(100);
15032 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
15033 ADV_CTRL_REG_CMD_WR_IO_REG);
15034
15035 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
15036 {
15037 if ((status = AdvInitFrom38C1600EEP(asc_dvc)) == ADV_ERROR)
15038 {
15039 return ADV_ERROR;
15040 }
15041 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800)
15042 {
15043 if ((status = AdvInitFrom38C0800EEP(asc_dvc)) == ADV_ERROR)
15044 {
15045 return ADV_ERROR;
15046 }
15047 } else
15048 {
15049 if ((status = AdvInitFrom3550EEP(asc_dvc)) == ADV_ERROR)
15050 {
15051 return ADV_ERROR;
15052 }
15053 }
15054 warn_code |= status;
15055 }
15056
15057 return warn_code;
15058}
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070STATIC int
15071AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
15072{
15073 AdvPortAddr iop_base;
15074 ushort warn_code;
15075 ADV_DCNT sum;
15076 int begin_addr;
15077 int end_addr;
15078 ushort code_sum;
15079 int word;
15080 int j;
15081 int adv_asc3550_expanded_size;
15082 ADV_CARR_T *carrp;
15083 ADV_DCNT contig_len;
15084 ADV_SDCNT buf_size;
15085 ADV_PADDR carr_paddr;
15086 int i;
15087 ushort scsi_cfg1;
15088 uchar tid;
15089 ushort bios_mem[ASC_MC_BIOSLEN/2];
15090 ushort wdtr_able = 0, sdtr_able, tagqng_able;
15091 uchar max_cmd[ADV_MAX_TID + 1];
15092
15093
15094 if (asc_dvc->err_code != 0)
15095 {
15096 return ADV_ERROR;
15097 }
15098
15099
15100
15101
15102 if (asc_dvc->chip_type != ADV_CHIP_ASC3550)
15103 {
15104 asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
15105 return ADV_ERROR;
15106 }
15107
15108 warn_code = 0;
15109 iop_base = asc_dvc->iop_base;
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119 for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
15120 {
15121 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
15122 }
15123
15124
15125
15126
15127 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA)
15128 {
15129 ushort bios_version, major, minor;
15130
15131 bios_version = bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM)/2];
15132 major = (bios_version >> 12) & 0xF;
15133 minor = (bios_version >> 8) & 0xF;
15134 if (major < 3 || (major == 3 && minor == 1))
15135 {
15136
15137 AdvReadWordLram(iop_base, 0x120, wdtr_able);
15138 } else
15139 {
15140 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
15141 }
15142 }
15143 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
15144 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
15145 for (tid = 0; tid <= ADV_MAX_TID; tid++)
15146 {
15147 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
15148 max_cmd[tid]);
15149 }
15150
15151
15152
15153
15154
15155
15156 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
15157
15158
15159
15160
15161
15162
15163
15164
15165
15166
15167
15168
15169
15170
15171
15172 word = 0;
15173 for (i = 253 * 2; i < _adv_asc3550_size; i++)
15174 {
15175 if (_adv_asc3550_buf[i] == 0xff)
15176 {
15177 for (j = 0; j < _adv_asc3550_buf[i + 1]; j++)
15178 {
15179 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15180 _adv_asc3550_buf[i + 3] << 8) |
15181 _adv_asc3550_buf[i + 2]));
15182 word++;
15183 }
15184 i += 3;
15185 } else if (_adv_asc3550_buf[i] == 0xfe)
15186 {
15187 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15188 _adv_asc3550_buf[i + 2] << 8) |
15189 _adv_asc3550_buf[i + 1]));
15190 i += 2;
15191 word++;
15192 } else
15193 {
15194 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15195 _adv_asc3550_buf[(_adv_asc3550_buf[i] * 2) + 1] << 8) |
15196 _adv_asc3550_buf[_adv_asc3550_buf[i] * 2]));
15197 word++;
15198 }
15199 }
15200
15201
15202
15203
15204
15205 word *= 2;
15206 adv_asc3550_expanded_size = word;
15207
15208
15209
15210
15211 for (; word < ADV_3550_MEMSIZE; word += 2)
15212 {
15213 AdvWriteWordAutoIncLram(iop_base, 0);
15214 }
15215
15216
15217
15218
15219 sum = 0;
15220 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
15221
15222 for (word = 0; word < adv_asc3550_expanded_size; word += 2)
15223 {
15224 sum += AdvReadWordAutoIncLram(iop_base);
15225 }
15226
15227 if (sum != _adv_asc3550_chksum)
15228 {
15229 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
15230 return ADV_ERROR;
15231 }
15232
15233
15234
15235
15236 for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
15237 {
15238 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
15239 }
15240
15241
15242
15243
15244
15245 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
15246 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
15247 code_sum = 0;
15248 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
15249 for (word = begin_addr; word < end_addr; word += 2)
15250 {
15251 code_sum += AdvReadWordAutoIncLram(iop_base);
15252 }
15253 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
15254
15255
15256
15257
15258 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE, asc_dvc->cfg->mcode_date);
15259 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM, asc_dvc->cfg->mcode_version);
15260
15261
15262
15263
15264 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
15265
15266
15267
15268
15269
15270
15271
15272 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR)
15273 {
15274 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
15275 word |= CONTROL_FLAG_IGNORE_PERR;
15276 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
15277 }
15278
15279
15280
15281
15282
15283 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
15284 START_CTL_EMFU | READ_CMD_MRM);
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0)
15299 {
15300 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, asc_dvc->wdtr_able);
15301 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, asc_dvc->sdtr_able);
15302 }
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326 word = 0;
15327 for (tid = 0; tid <= ADV_MAX_TID; tid++)
15328 {
15329 if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able)
15330 {
15331
15332 word |= (0x3 << (4 * (tid % 4)));
15333 } else
15334 {
15335
15336 word |= (0x2 << (4 * (tid % 4)));
15337 }
15338 if (tid == 3)
15339 {
15340 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
15341 word = 0;
15342 } else if (tid == 7)
15343 {
15344 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
15345 word = 0;
15346 } else if (tid == 11)
15347 {
15348 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
15349 word = 0;
15350 } else if (tid == 15)
15351 {
15352 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
15353
15354 }
15355 }
15356
15357
15358
15359
15360 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE, asc_dvc->cfg->disc_enable);
15361
15362
15363
15364
15365
15366
15367
15368 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
15369 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
15370 asc_dvc->chip_scsi_id);
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
15381
15382
15383
15384
15385 if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
15386 (scsi_cfg1 & CABLE_ILLEGAL_B) == 0)
15387 {
15388 asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
15389 return ADV_ERROR;
15390 }
15391
15392
15393
15394
15395
15396
15397 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07)
15398 {
15399 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
15400 return ADV_ERROR;
15401 }
15402
15403
15404
15405
15406
15407 if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0)
15408 {
15409 asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
15410 return ADV_ERROR;
15411 }
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421 if (asc_dvc->cfg->termination == 0)
15422 {
15423
15424
15425
15426
15427 asc_dvc->cfg->termination |= TERM_CTL_SEL;
15428
15429 switch(scsi_cfg1 & CABLE_DETECT)
15430 {
15431
15432 case 0x3: case 0x7: case 0xB: case 0xD: case 0xE: case 0xF:
15433 asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
15434 break;
15435
15436
15437 case 0x1: case 0x5: case 0x9: case 0xA: case 0xC:
15438 asc_dvc->cfg->termination |= TERM_CTL_H;
15439 break;
15440
15441
15442 case 0x2: case 0x6:
15443 break;
15444 }
15445 }
15446
15447
15448
15449
15450 scsi_cfg1 &= ~TERM_CTL;
15451
15452
15453
15454
15455
15456
15457
15458 scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
15470 FLTR_DISABLE | scsi_cfg1);
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
15484 BIOS_EN | RAM_SZ_8KB);
15485
15486
15487
15488
15489
15490
15491
15492 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
15493 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
15494
15495
15496
15497
15498
15499
15500 ASC_ASSERT(asc_dvc->carrier_buf != NULL);
15501
15502 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
15503 asc_dvc->carr_freelist = NULL;
15504 if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf)
15505 {
15506 buf_size = ADV_CARRIER_BUFSIZE;
15507 } else
15508 {
15509 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
15510 }
15511
15512 do {
15513
15514
15515
15516 contig_len = sizeof(ADV_CARR_T);
15517 carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL, (uchar *) carrp,
15518 (ADV_SDCNT *) &contig_len, ADV_IS_CARRIER_FLAG));
15519
15520 buf_size -= sizeof(ADV_CARR_T);
15521
15522
15523
15524
15525
15526
15527 if (contig_len < sizeof(ADV_CARR_T))
15528 {
15529 carrp++;
15530 continue;
15531 }
15532
15533 carrp->carr_pa = carr_paddr;
15534 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
15535
15536
15537
15538
15539 carrp->next_vpa = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
15540 asc_dvc->carr_freelist = carrp;
15541
15542 carrp++;
15543 }
15544 while (buf_size > 0);
15545
15546
15547
15548
15549
15550 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL)
15551 {
15552 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
15553 return ADV_ERROR;
15554 }
15555 asc_dvc->carr_freelist = (ADV_CARR_T *)
15556 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
15557
15558
15559
15560
15561 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
15562
15563
15564
15565
15566 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
15567
15568
15569
15570
15571 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL)
15572 {
15573 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
15574 return ADV_ERROR;
15575 }
15576 asc_dvc->carr_freelist = (ADV_CARR_T *)
15577 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
15578
15579
15580
15581
15582
15583
15584
15585
15586 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
15587
15588
15589
15590
15591 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
15592 asc_dvc->carr_pending_cnt = 0;
15593
15594 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
15595 (ADV_INTR_ENABLE_HOST_INTR | ADV_INTR_ENABLE_GLOBAL_INTR));
15596
15597 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
15598 AdvWriteWordRegister(iop_base, IOPW_PC, word);
15599
15600
15601 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
15602
15603
15604
15605
15606
15607
15608 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS)
15609 {
15610
15611
15612
15613
15614
15615 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA)
15616 {
15617
15618
15619
15620 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
15621 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
15622 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
15623 for (tid = 0; tid <= ADV_MAX_TID; tid++)
15624 {
15625 AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
15626 max_cmd[tid]);
15627 }
15628 } else
15629 {
15630 if (AdvResetSB(asc_dvc) != ADV_TRUE)
15631 {
15632 warn_code = ASC_WARN_BUSRESET_ERROR;
15633 }
15634 }
15635 }
15636
15637 return warn_code;
15638}
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650STATIC int
15651AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
15652{
15653 AdvPortAddr iop_base;
15654 ushort warn_code;
15655 ADV_DCNT sum;
15656 int begin_addr;
15657 int end_addr;
15658 ushort code_sum;
15659 int word;
15660 int j;
15661 int adv_asc38C0800_expanded_size;
15662 ADV_CARR_T *carrp;
15663 ADV_DCNT contig_len;
15664 ADV_SDCNT buf_size;
15665 ADV_PADDR carr_paddr;
15666 int i;
15667 ushort scsi_cfg1;
15668 uchar byte;
15669 uchar tid;
15670 ushort bios_mem[ASC_MC_BIOSLEN/2];
15671 ushort wdtr_able, sdtr_able, tagqng_able;
15672 uchar max_cmd[ADV_MAX_TID + 1];
15673
15674
15675 if (asc_dvc->err_code != 0)
15676 {
15677 return ADV_ERROR;
15678 }
15679
15680
15681
15682
15683 if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800)
15684 {
15685 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
15686 return ADV_ERROR;
15687 }
15688
15689 warn_code = 0;
15690 iop_base = asc_dvc->iop_base;
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700 for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
15701 {
15702 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
15703 }
15704
15705
15706
15707
15708 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
15709 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
15710 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
15711 for (tid = 0; tid <= ADV_MAX_TID; tid++)
15712 {
15713 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
15714 max_cmd[tid]);
15715 }
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746 for (i = 0; i < 2; i++)
15747 {
15748 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
15749 DvcSleepMilliSecond(10);
15750 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
15751 if ((byte & RAM_TEST_DONE) == 0 || (byte & 0x0F) != PRE_TEST_VALUE)
15752 {
15753 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
15754 return ADV_ERROR;
15755 }
15756
15757 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
15758 DvcSleepMilliSecond(10);
15759 if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
15760 != NORMAL_VALUE)
15761 {
15762 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
15763 return ADV_ERROR;
15764 }
15765 }
15766
15767
15768
15769
15770
15771
15772
15773
15774 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
15775 DvcSleepMilliSecond(10);
15776
15777 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
15778 if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0)
15779 {
15780
15781 asc_dvc->bist_err_code = byte;
15782 asc_dvc->err_code |= ASC_IERR_BIST_RAM_TEST;
15783 return ADV_ERROR;
15784 }
15785
15786
15787 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
15788
15789
15790
15791
15792
15793
15794
15795 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812 word = 0;
15813 for (i = 253 * 2; i < _adv_asc38C0800_size; i++)
15814 {
15815 if (_adv_asc38C0800_buf[i] == 0xff)
15816 {
15817 for (j = 0; j < _adv_asc38C0800_buf[i + 1]; j++)
15818 {
15819 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15820 _adv_asc38C0800_buf[i + 3] << 8) |
15821 _adv_asc38C0800_buf[i + 2]));
15822 word++;
15823 }
15824 i += 3;
15825 } else if (_adv_asc38C0800_buf[i] == 0xfe)
15826 {
15827 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15828 _adv_asc38C0800_buf[i + 2] << 8) |
15829 _adv_asc38C0800_buf[i + 1]));
15830 i += 2;
15831 word++;
15832 } else
15833 {
15834 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15835 _adv_asc38C0800_buf[(_adv_asc38C0800_buf[i] * 2) + 1] << 8) |
15836 _adv_asc38C0800_buf[_adv_asc38C0800_buf[i] * 2]));
15837 word++;
15838 }
15839 }
15840
15841
15842
15843
15844
15845 word *= 2;
15846 adv_asc38C0800_expanded_size = word;
15847
15848
15849
15850
15851 for (; word < ADV_38C0800_MEMSIZE; word += 2)
15852 {
15853 AdvWriteWordAutoIncLram(iop_base, 0);
15854 }
15855
15856
15857
15858
15859 sum = 0;
15860 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
15861
15862 for (word = 0; word < adv_asc38C0800_expanded_size; word += 2)
15863 {
15864 sum += AdvReadWordAutoIncLram(iop_base);
15865 }
15866 ASC_DBG2(1, "AdvInitAsc38C0800Driver: word %d, i %d\n", word, i);
15867
15868 ASC_DBG2(1,
15869 "AdvInitAsc38C0800Driver: sum 0x%lx, _adv_asc38C0800_chksum 0x%lx\n",
15870 (ulong) sum, (ulong) _adv_asc38C0800_chksum);
15871
15872 if (sum != _adv_asc38C0800_chksum)
15873 {
15874 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
15875 return ADV_ERROR;
15876 }
15877
15878
15879
15880
15881 for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
15882 {
15883 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
15884 }
15885
15886
15887
15888
15889
15890 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
15891 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
15892 code_sum = 0;
15893 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
15894 for (word = begin_addr; word < end_addr; word += 2)
15895 {
15896 code_sum += AdvReadWordAutoIncLram(iop_base);
15897 }
15898 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
15899
15900
15901
15902
15903 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE, asc_dvc->cfg->mcode_date);
15904 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM, asc_dvc->cfg->mcode_version);
15905
15906
15907
15908
15909 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
15920 AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1, scsi_cfg1 | DIS_TERM_DRV);
15921
15922
15923
15924
15925
15926
15927
15928 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR)
15929 {
15930 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
15931 word |= CONTROL_FLAG_IGNORE_PERR;
15932 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
15933 }
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
15944 BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0)
15959 {
15960 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, asc_dvc->wdtr_able);
15961 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, asc_dvc->sdtr_able);
15962 }
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE, asc_dvc->cfg->disc_enable);
15974 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
15975 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
15976 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
15977 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
15978
15979
15980
15981
15982
15983
15984
15985 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
15986 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
15987 asc_dvc->chip_scsi_id);
15988
15989
15990
15991
15992
15993
15994
15995
15996
15997 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
15998
15999
16000
16001
16002
16003
16004 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07)
16005 {
16006 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
16007 return ADV_ERROR;
16008 }
16009
16010
16011
16012
16013
16014
16015
16016
16017
16018
16019 if (scsi_cfg1 & HVD)
16020 {
16021 asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
16022 return ADV_ERROR;
16023 }
16024
16025
16026
16027
16028
16029
16030
16031
16032
16033 if ((asc_dvc->cfg->termination & TERM_SE) == 0)
16034 {
16035
16036 switch(scsi_cfg1 & C_DET_SE)
16037 {
16038
16039 case 0x1: case 0x2: case 0x3:
16040 asc_dvc->cfg->termination |= TERM_SE;
16041 break;
16042
16043
16044 case 0x0:
16045 asc_dvc->cfg->termination |= TERM_SE_HI;
16046 break;
16047 }
16048 }
16049
16050 if ((asc_dvc->cfg->termination & TERM_LVD) == 0)
16051 {
16052
16053 switch(scsi_cfg1 & C_DET_LVD)
16054 {
16055
16056 case 0x4: case 0x8: case 0xC:
16057 asc_dvc->cfg->termination |= TERM_LVD;
16058 break;
16059
16060
16061 case 0x0:
16062 break;
16063 }
16064 }
16065
16066
16067
16068
16069 scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
16070
16071
16072
16073
16074 scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
16075
16076
16077
16078
16079
16080
16081 scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
16093
16094
16095
16096
16097
16098
16099
16100
16101
16102
16103
16104
16105 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
16106 BIOS_EN | RAM_SZ_16KB);
16107
16108
16109
16110
16111
16112
16113
16114 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
16115 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
16116
16117
16118
16119
16120
16121
16122 ASC_ASSERT(asc_dvc->carrier_buf != NULL);
16123
16124 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
16125 asc_dvc->carr_freelist = NULL;
16126 if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf)
16127 {
16128 buf_size = ADV_CARRIER_BUFSIZE;
16129 } else
16130 {
16131 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
16132 }
16133
16134 do {
16135
16136
16137
16138 contig_len = sizeof(ADV_CARR_T);
16139 carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL, (uchar *) carrp,
16140 (ADV_SDCNT *) &contig_len, ADV_IS_CARRIER_FLAG));
16141
16142 buf_size -= sizeof(ADV_CARR_T);
16143
16144
16145
16146
16147
16148
16149 if (contig_len < sizeof(ADV_CARR_T))
16150 {
16151 carrp++;
16152 continue;
16153 }
16154
16155 carrp->carr_pa = carr_paddr;
16156 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
16157
16158
16159
16160
16161 carrp->next_vpa = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
16162 asc_dvc->carr_freelist = carrp;
16163
16164 carrp++;
16165 }
16166 while (buf_size > 0);
16167
16168
16169
16170
16171
16172 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL)
16173 {
16174 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
16175 return ADV_ERROR;
16176 }
16177 asc_dvc->carr_freelist = (ADV_CARR_T *)
16178 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
16179
16180
16181
16182
16183 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
16184
16185
16186
16187
16188
16189 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
16190
16191
16192
16193
16194 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL)
16195 {
16196 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
16197 return ADV_ERROR;
16198 }
16199 asc_dvc->carr_freelist = (ADV_CARR_T *)
16200 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
16201
16202
16203
16204
16205
16206
16207
16208
16209 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
16210
16211
16212
16213
16214
16215
16216 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
16217 asc_dvc->carr_pending_cnt = 0;
16218
16219 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
16220 (ADV_INTR_ENABLE_HOST_INTR | ADV_INTR_ENABLE_GLOBAL_INTR));
16221
16222 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
16223 AdvWriteWordRegister(iop_base, IOPW_PC, word);
16224
16225
16226 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
16227
16228
16229
16230
16231
16232
16233 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS)
16234 {
16235
16236
16237
16238
16239
16240 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA)
16241 {
16242
16243
16244
16245 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
16246 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
16247 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
16248 for (tid = 0; tid <= ADV_MAX_TID; tid++)
16249 {
16250 AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
16251 max_cmd[tid]);
16252 }
16253 } else
16254 {
16255 if (AdvResetSB(asc_dvc) != ADV_TRUE)
16256 {
16257 warn_code = ASC_WARN_BUSRESET_ERROR;
16258 }
16259 }
16260 }
16261
16262 return warn_code;
16263}
16264
16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275STATIC int
16276AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
16277{
16278 AdvPortAddr iop_base;
16279 ushort warn_code;
16280 ADV_DCNT sum;
16281 int begin_addr;
16282 int end_addr;
16283 ushort code_sum;
16284 long word;
16285 int j;
16286 int adv_asc38C1600_expanded_size;
16287 ADV_CARR_T *carrp;
16288 ADV_DCNT contig_len;
16289 ADV_SDCNT buf_size;
16290 ADV_PADDR carr_paddr;
16291 int i;
16292 ushort scsi_cfg1;
16293 uchar byte;
16294 uchar tid;
16295 ushort bios_mem[ASC_MC_BIOSLEN/2];
16296 ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
16297 uchar max_cmd[ASC_MAX_TID + 1];
16298
16299
16300 if (asc_dvc->err_code != 0)
16301 {
16302 return ADV_ERROR;
16303 }
16304
16305
16306
16307
16308 if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600)
16309 {
16310 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
16311 return ADV_ERROR;
16312 }
16313
16314 warn_code = 0;
16315 iop_base = asc_dvc->iop_base;
16316
16317
16318
16319
16320
16321
16322
16323
16324
16325 for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
16326 {
16327 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
16328 }
16329
16330
16331
16332
16333 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
16334 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
16335 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
16336 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
16337 for (tid = 0; tid <= ASC_MAX_TID; tid++)
16338 {
16339 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
16340 max_cmd[tid]);
16341 }
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16362
16363
16364
16365
16366
16367
16368
16369
16370
16371
16372 for (i = 0; i < 2; i++)
16373 {
16374 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
16375 DvcSleepMilliSecond(10);
16376 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
16377 if ((byte & RAM_TEST_DONE) == 0 || (byte & 0x0F) != PRE_TEST_VALUE)
16378 {
16379 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
16380 return ADV_ERROR;
16381 }
16382
16383 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
16384 DvcSleepMilliSecond(10);
16385 if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
16386 != NORMAL_VALUE)
16387 {
16388 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
16389 return ADV_ERROR;
16390 }
16391 }
16392
16393
16394
16395
16396
16397
16398
16399
16400 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
16401 DvcSleepMilliSecond(10);
16402
16403 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
16404 if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0)
16405 {
16406
16407 asc_dvc->bist_err_code = byte;
16408 asc_dvc->err_code |= ASC_IERR_BIST_RAM_TEST;
16409 return ADV_ERROR;
16410 }
16411
16412
16413 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
16414
16415
16416
16417
16418
16419
16420
16421 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
16422
16423
16424
16425
16426
16427
16428
16429
16430
16431
16432
16433
16434
16435
16436
16437
16438
16439 word = 0;
16440 for (i = 253 * 2; i < _adv_asc38C1600_size; i++)
16441 {
16442 if (_adv_asc38C1600_buf[i] == 0xff)
16443 {
16444 for (j = 0; j < _adv_asc38C1600_buf[i + 1]; j++)
16445 {
16446 AdvWriteWordAutoIncLram(iop_base, (((ushort)
16447 _adv_asc38C1600_buf[i + 3] << 8) |
16448 _adv_asc38C1600_buf[i + 2]));
16449 word++;
16450 }
16451 i += 3;
16452 } else if (_adv_asc38C1600_buf[i] == 0xfe)
16453 {
16454 AdvWriteWordAutoIncLram(iop_base, (((ushort)
16455 _adv_asc38C1600_buf[i + 2] << 8) |
16456 _adv_asc38C1600_buf[i + 1]));
16457 i += 2;
16458 word++;
16459 } else
16460 {
16461 AdvWriteWordAutoIncLram(iop_base, (((ushort)
16462 _adv_asc38C1600_buf[(_adv_asc38C1600_buf[i] * 2) + 1] << 8) |
16463 _adv_asc38C1600_buf[_adv_asc38C1600_buf[i] * 2]));
16464 word++;
16465 }
16466 }
16467
16468
16469
16470
16471
16472 word *= 2;
16473 adv_asc38C1600_expanded_size = word;
16474
16475
16476
16477
16478 for (; word < ADV_38C1600_MEMSIZE; word += 2)
16479 {
16480 AdvWriteWordAutoIncLram(iop_base, 0);
16481 }
16482
16483
16484
16485
16486 sum = 0;
16487 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
16488
16489 for (word = 0; word < adv_asc38C1600_expanded_size; word += 2)
16490 {
16491 sum += AdvReadWordAutoIncLram(iop_base);
16492 }
16493
16494 if (sum != _adv_asc38C1600_chksum)
16495 {
16496 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
16497 return ADV_ERROR;
16498 }
16499
16500
16501
16502
16503 for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
16504 {
16505 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
16506 }
16507
16508
16509
16510
16511
16512 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
16513 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
16514 code_sum = 0;
16515 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
16516 for (word = begin_addr; word < end_addr; word += 2)
16517 {
16518 code_sum += AdvReadWordAutoIncLram(iop_base);
16519 }
16520 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
16521
16522
16523
16524
16525 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE, asc_dvc->cfg->mcode_date);
16526 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM, asc_dvc->cfg->mcode_version);
16527
16528
16529
16530
16531 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
16532
16533
16534
16535
16536
16537
16538
16539
16540
16541 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
16542 AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1, scsi_cfg1 | DIS_TERM_DRV);
16543
16544
16545
16546
16547
16548
16549
16550 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR)
16551 {
16552 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
16553 word |= CONTROL_FLAG_IGNORE_PERR;
16554 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
16555 }
16556
16557
16558
16559
16560
16561
16562
16563 if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0)
16564 {
16565 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
16566 word |= CONTROL_FLAG_ENABLE_AIPP;
16567 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
16568 }
16569
16570
16571
16572
16573
16574 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
16575 FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0)
16590 {
16591 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, asc_dvc->wdtr_able);
16592 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, asc_dvc->sdtr_able);
16593 }
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE, asc_dvc->cfg->disc_enable);
16605 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
16606 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
16607 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
16608 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
16609
16610
16611
16612
16613
16614
16615
16616 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
16617 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
16618 asc_dvc->chip_scsi_id);
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
16630
16631
16632
16633
16634
16635
16636 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07)
16637 {
16638 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
16639 return ADV_ERROR;
16640 }
16641
16642
16643
16644
16645
16646
16647
16648
16649
16650 if (scsi_cfg1 & HVD)
16651 {
16652 asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
16653 return ADV_ERROR;
16654 }
16655
16656
16657
16658
16659
16660
16661
16662
16663
16664
16665
16666
16667
16668
16669 if ((asc_dvc->cfg->termination & TERM_SE) == 0)
16670 {
16671
16672 switch(scsi_cfg1 & C_DET_SE)
16673 {
16674
16675 case 0x1: case 0x2: case 0x3:
16676 asc_dvc->cfg->termination |= TERM_SE;
16677 break;
16678
16679 case 0x0:
16680 if (ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) == 0)
16681 {
16682
16683 }
16684 else
16685 {
16686
16687 asc_dvc->cfg->termination |= TERM_SE_HI;
16688 }
16689 break;
16690 }
16691 }
16692
16693
16694
16695
16696 scsi_cfg1 &= ~TERM_SE;
16697
16698
16699
16700
16701 scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
16702
16703
16704
16705
16706
16707
16708
16709
16710 scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
16711
16712
16713
16714
16715
16716
16717
16718
16719
16720
16721 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733
16734
16735
16736
16737
16738
16739
16740
16741
16742 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG, BIOS_EN | RAM_SZ_16KB);
16743
16744
16745
16746
16747
16748
16749
16750 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
16751 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
16752
16753
16754
16755
16756
16757
16758
16759 ASC_ASSERT(asc_dvc->carrier_buf != NULL);
16760
16761 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
16762 asc_dvc->carr_freelist = NULL;
16763 if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf)
16764 {
16765 buf_size = ADV_CARRIER_BUFSIZE;
16766 } else
16767 {
16768 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
16769 }
16770
16771 do {
16772
16773
16774
16775 contig_len = sizeof(ADV_CARR_T);
16776 carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL, (uchar *) carrp,
16777 (ADV_SDCNT *) &contig_len, ADV_IS_CARRIER_FLAG));
16778
16779 buf_size -= sizeof(ADV_CARR_T);
16780
16781
16782
16783
16784
16785
16786 if (contig_len < sizeof(ADV_CARR_T))
16787 {
16788 carrp++;
16789 continue;
16790 }
16791
16792 carrp->carr_pa = carr_paddr;
16793 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
16794
16795
16796
16797
16798 carrp->next_vpa = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
16799 asc_dvc->carr_freelist = carrp;
16800
16801 carrp++;
16802 }
16803 while (buf_size > 0);
16804
16805
16806
16807
16808 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL)
16809 {
16810 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
16811 return ADV_ERROR;
16812 }
16813 asc_dvc->carr_freelist = (ADV_CARR_T *)
16814 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
16815
16816
16817
16818
16819 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
16820
16821
16822
16823
16824
16825
16826 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
16827 AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
16828 le32_to_cpu(asc_dvc->icq_sp->carr_pa));
16829
16830
16831
16832
16833 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL)
16834 {
16835 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
16836 return ADV_ERROR;
16837 }
16838 asc_dvc->carr_freelist = (ADV_CARR_T *)
16839 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
16840
16841
16842
16843
16844
16845
16846
16847
16848 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
16849
16850
16851
16852
16853 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
16854 asc_dvc->carr_pending_cnt = 0;
16855
16856 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
16857 (ADV_INTR_ENABLE_HOST_INTR | ADV_INTR_ENABLE_GLOBAL_INTR));
16858 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
16859 AdvWriteWordRegister(iop_base, IOPW_PC, word);
16860
16861
16862 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
16863
16864
16865
16866
16867
16868
16869 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS)
16870 {
16871
16872
16873
16874
16875 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA)
16876 {
16877
16878
16879
16880 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
16881 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
16882 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
16883 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
16884 for (tid = 0; tid <= ASC_MAX_TID; tid++)
16885 {
16886 AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
16887 max_cmd[tid]);
16888 }
16889 } else
16890 {
16891 if (AdvResetSB(asc_dvc) != ADV_TRUE)
16892 {
16893 warn_code = ASC_WARN_BUSRESET_ERROR;
16894 }
16895 }
16896 }
16897
16898 return warn_code;
16899}
16900
16901
16902
16903
16904
16905
16906
16907
16908
16909
16910
16911
16912
16913ASC_INITFUNC(
16914STATIC int,
16915AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
16916)
16917{
16918 AdvPortAddr iop_base;
16919 ushort warn_code;
16920 ADVEEP_3550_CONFIG eep_config;
16921 int i;
16922
16923 iop_base = asc_dvc->iop_base;
16924
16925 warn_code = 0;
16926
16927
16928
16929
16930
16931
16932 if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum)
16933 {
16934 warn_code |= ASC_WARN_EEPROM_CHKSUM;
16935
16936
16937
16938
16939 for (i = 0; i < sizeof(ADVEEP_3550_CONFIG); i++)
16940 {
16941 *((uchar *) &eep_config + i) =
16942 *((uchar *) &Default_3550_EEPROM_Config + i);
16943 }
16944
16945
16946
16947
16948
16949
16950 eep_config.serial_number_word3 =
16951 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
16952
16953 eep_config.serial_number_word2 =
16954 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
16955
16956 eep_config.serial_number_word1 =
16957 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
16958
16959 AdvSet3550EEPConfig(iop_base, &eep_config);
16960 }
16961
16962
16963
16964
16965
16966
16967 asc_dvc->wdtr_able = eep_config.wdtr_able;
16968 asc_dvc->sdtr_able = eep_config.sdtr_able;
16969 asc_dvc->ultra_able = eep_config.ultra_able;
16970 asc_dvc->tagqng_able = eep_config.tagqng_able;
16971 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
16972 asc_dvc->max_host_qng = eep_config.max_host_qng;
16973 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
16974 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
16975 asc_dvc->start_motor = eep_config.start_motor;
16976 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
16977 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
16978 asc_dvc->no_scam = eep_config.scam_tolerant;
16979 asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
16980 asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
16981 asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
16982
16983
16984
16985
16986
16987 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG)
16988 {
16989 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
16990 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG)
16991 {
16992
16993 if (eep_config.max_host_qng == 0)
16994 {
16995 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
16996 } else
16997 {
16998 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
16999 }
17000 }
17001
17002 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG)
17003 {
17004 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
17005 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG)
17006 {
17007
17008 if (eep_config.max_dvc_qng == 0)
17009 {
17010 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
17011 } else
17012 {
17013 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
17014 }
17015 }
17016
17017
17018
17019
17020
17021 if (eep_config.max_dvc_qng > eep_config.max_host_qng)
17022 {
17023 eep_config.max_dvc_qng = eep_config.max_host_qng;
17024 }
17025
17026
17027
17028
17029
17030 asc_dvc->max_host_qng = eep_config.max_host_qng;
17031 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042 if (eep_config.termination == 0)
17043 {
17044 asc_dvc->cfg->termination = 0;
17045 } else
17046 {
17047
17048 if (eep_config.termination == 1)
17049 {
17050 asc_dvc->cfg->termination = TERM_CTL_SEL;
17051
17052
17053 } else if (eep_config.termination == 2)
17054 {
17055 asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
17056
17057
17058 } else if (eep_config.termination == 3)
17059 {
17060 asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
17061 } else
17062 {
17063
17064
17065
17066
17067 asc_dvc->cfg->termination = 0;
17068 warn_code |= ASC_WARN_EEPROM_TERMINATION;
17069 }
17070 }
17071
17072 return warn_code;
17073}
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087ASC_INITFUNC(
17088STATIC int,
17089AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
17090)
17091{
17092 AdvPortAddr iop_base;
17093 ushort warn_code;
17094 ADVEEP_38C0800_CONFIG eep_config;
17095 int i;
17096 uchar tid, termination;
17097 ushort sdtr_speed = 0;
17098
17099 iop_base = asc_dvc->iop_base;
17100
17101 warn_code = 0;
17102
17103
17104
17105
17106
17107
17108 if (AdvGet38C0800EEPConfig(iop_base, &eep_config) != eep_config.check_sum)
17109 {
17110 warn_code |= ASC_WARN_EEPROM_CHKSUM;
17111
17112
17113
17114
17115 for (i = 0; i < sizeof(ADVEEP_38C0800_CONFIG); i++)
17116 {
17117 *((uchar *) &eep_config + i) =
17118 *((uchar *) &Default_38C0800_EEPROM_Config + i);
17119 }
17120
17121
17122
17123
17124
17125
17126 eep_config.serial_number_word3 =
17127 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
17128
17129 eep_config.serial_number_word2 =
17130 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
17131
17132 eep_config.serial_number_word1 =
17133 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
17134
17135 AdvSet38C0800EEPConfig(iop_base, &eep_config);
17136 }
17137
17138
17139
17140
17141
17142
17143 asc_dvc->wdtr_able = eep_config.wdtr_able;
17144 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
17145 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
17146 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
17147 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
17148 asc_dvc->tagqng_able = eep_config.tagqng_able;
17149 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
17150 asc_dvc->max_host_qng = eep_config.max_host_qng;
17151 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
17152 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
17153 asc_dvc->start_motor = eep_config.start_motor;
17154 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
17155 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
17156 asc_dvc->no_scam = eep_config.scam_tolerant;
17157 asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
17158 asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
17159 asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
17160
17161
17162
17163
17164
17165 asc_dvc->sdtr_able = 0;
17166 for (tid = 0; tid <= ADV_MAX_TID; tid++)
17167 {
17168 if (tid == 0)
17169 {
17170 sdtr_speed = asc_dvc->sdtr_speed1;
17171 } else if (tid == 4)
17172 {
17173 sdtr_speed = asc_dvc->sdtr_speed2;
17174 } else if (tid == 8)
17175 {
17176 sdtr_speed = asc_dvc->sdtr_speed3;
17177 } else if (tid == 12)
17178 {
17179 sdtr_speed = asc_dvc->sdtr_speed4;
17180 }
17181 if (sdtr_speed & ADV_MAX_TID)
17182 {
17183 asc_dvc->sdtr_able |= (1 << tid);
17184 }
17185 sdtr_speed >>= 4;
17186 }
17187
17188
17189
17190
17191
17192 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG)
17193 {
17194 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
17195 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG)
17196 {
17197
17198 if (eep_config.max_host_qng == 0)
17199 {
17200 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
17201 } else
17202 {
17203 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
17204 }
17205 }
17206
17207 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG)
17208 {
17209 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
17210 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG)
17211 {
17212
17213 if (eep_config.max_dvc_qng == 0)
17214 {
17215 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
17216 } else
17217 {
17218 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
17219 }
17220 }
17221
17222
17223
17224
17225
17226 if (eep_config.max_dvc_qng > eep_config.max_host_qng)
17227 {
17228 eep_config.max_dvc_qng = eep_config.max_host_qng;
17229 }
17230
17231
17232
17233
17234
17235 asc_dvc->max_host_qng = eep_config.max_host_qng;
17236 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246 if (eep_config.termination_se == 0)
17247 {
17248 termination = 0;
17249 } else
17250 {
17251
17252 if (eep_config.termination_se == 1)
17253 {
17254 termination = 0;
17255
17256
17257 } else if (eep_config.termination_se == 2)
17258 {
17259 termination = TERM_SE_HI;
17260
17261
17262 } else if (eep_config.termination_se == 3)
17263 {
17264 termination = TERM_SE;
17265 } else
17266 {
17267
17268
17269
17270
17271 termination = 0;
17272 warn_code |= ASC_WARN_EEPROM_TERMINATION;
17273 }
17274 }
17275
17276 if (eep_config.termination_lvd == 0)
17277 {
17278 asc_dvc->cfg->termination = termination;
17279 } else
17280 {
17281
17282 if (eep_config.termination_lvd == 1)
17283 {
17284 asc_dvc->cfg->termination = termination;
17285
17286
17287 } else if (eep_config.termination_lvd == 2)
17288 {
17289 asc_dvc->cfg->termination = termination | TERM_LVD_HI;
17290
17291
17292 } else if (eep_config.termination_lvd == 3)
17293 {
17294 asc_dvc->cfg->termination =
17295 termination | TERM_LVD;
17296 } else
17297 {
17298
17299
17300
17301
17302 asc_dvc->cfg->termination = termination;
17303 warn_code |= ASC_WARN_EEPROM_TERMINATION;
17304 }
17305 }
17306
17307 return warn_code;
17308}
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322ASC_INITFUNC(
17323STATIC int,
17324AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
17325)
17326{
17327 AdvPortAddr iop_base;
17328 ushort warn_code;
17329 ADVEEP_38C1600_CONFIG eep_config;
17330 int i;
17331 uchar tid, termination;
17332 ushort sdtr_speed = 0;
17333
17334 iop_base = asc_dvc->iop_base;
17335
17336 warn_code = 0;
17337
17338
17339
17340
17341
17342
17343 if (AdvGet38C1600EEPConfig(iop_base, &eep_config) != eep_config.check_sum)
17344 {
17345 warn_code |= ASC_WARN_EEPROM_CHKSUM;
17346
17347
17348
17349
17350 for (i = 0; i < sizeof(ADVEEP_38C1600_CONFIG); i++)
17351 {
17352 if (i == 1 && ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) != 0)
17353 {
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365 *((uchar *) &eep_config + i) =
17366 ((*((uchar *) &Default_38C1600_EEPROM_Config + i)) &
17367 (~(((ADV_EEPROM_BIOS_ENABLE | ADV_EEPROM_INTAB) >> 8) &
17368 0xFF)));
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382 AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
17383 if (AdvReadByteRegister(iop_base, IOPB_GPIO_DATA) & 0x01)
17384 {
17385
17386 *((uchar *) &eep_config + i) |=
17387 ((ADV_EEPROM_INTAB >> 8) & 0xFF);
17388 }
17389 }
17390 else
17391 {
17392 *((uchar *) &eep_config + i) =
17393 *((uchar *) &Default_38C1600_EEPROM_Config + i);
17394 }
17395 }
17396
17397
17398
17399
17400
17401
17402 eep_config.serial_number_word3 =
17403 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
17404
17405 eep_config.serial_number_word2 =
17406 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
17407
17408 eep_config.serial_number_word1 =
17409 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
17410
17411 AdvSet38C1600EEPConfig(iop_base, &eep_config);
17412 }
17413
17414
17415
17416
17417
17418
17419
17420 asc_dvc->wdtr_able = eep_config.wdtr_able;
17421 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
17422 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
17423 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
17424 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
17425 asc_dvc->ppr_able = 0;
17426 asc_dvc->tagqng_able = eep_config.tagqng_able;
17427 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
17428 asc_dvc->max_host_qng = eep_config.max_host_qng;
17429 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
17430 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
17431 asc_dvc->start_motor = eep_config.start_motor;
17432 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
17433 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
17434 asc_dvc->no_scam = eep_config.scam_tolerant;
17435
17436
17437
17438
17439
17440 asc_dvc->sdtr_able = 0;
17441 for (tid = 0; tid <= ASC_MAX_TID; tid++)
17442 {
17443 if (tid == 0)
17444 {
17445 sdtr_speed = asc_dvc->sdtr_speed1;
17446 } else if (tid == 4)
17447 {
17448 sdtr_speed = asc_dvc->sdtr_speed2;
17449 } else if (tid == 8)
17450 {
17451 sdtr_speed = asc_dvc->sdtr_speed3;
17452 } else if (tid == 12)
17453 {
17454 sdtr_speed = asc_dvc->sdtr_speed4;
17455 }
17456 if (sdtr_speed & ASC_MAX_TID)
17457 {
17458 asc_dvc->sdtr_able |= (1 << tid);
17459 }
17460 sdtr_speed >>= 4;
17461 }
17462
17463
17464
17465
17466
17467 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG)
17468 {
17469 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
17470 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG)
17471 {
17472
17473 if (eep_config.max_host_qng == 0)
17474 {
17475 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
17476 } else
17477 {
17478 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
17479 }
17480 }
17481
17482 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG)
17483 {
17484 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
17485 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG)
17486 {
17487
17488 if (eep_config.max_dvc_qng == 0)
17489 {
17490 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
17491 } else
17492 {
17493 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
17494 }
17495 }
17496
17497
17498
17499
17500
17501 if (eep_config.max_dvc_qng > eep_config.max_host_qng)
17502 {
17503 eep_config.max_dvc_qng = eep_config.max_host_qng;
17504 }
17505
17506
17507
17508
17509
17510 asc_dvc->max_host_qng = eep_config.max_host_qng;
17511 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521 if (eep_config.termination_se == 0)
17522 {
17523 termination = 0;
17524 } else
17525 {
17526
17527 if (eep_config.termination_se == 1)
17528 {
17529 termination = 0;
17530
17531
17532 } else if (eep_config.termination_se == 2)
17533 {
17534 termination = TERM_SE_HI;
17535
17536
17537 } else if (eep_config.termination_se == 3)
17538 {
17539 termination = TERM_SE;
17540 } else
17541 {
17542
17543
17544
17545
17546 termination = 0;
17547 warn_code |= ASC_WARN_EEPROM_TERMINATION;
17548 }
17549 }
17550
17551 if (eep_config.termination_lvd == 0)
17552 {
17553 asc_dvc->cfg->termination = termination;
17554 } else
17555 {
17556
17557 if (eep_config.termination_lvd == 1)
17558 {
17559 asc_dvc->cfg->termination = termination;
17560
17561
17562 } else if (eep_config.termination_lvd == 2)
17563 {
17564 asc_dvc->cfg->termination = termination | TERM_LVD_HI;
17565
17566
17567 } else if (eep_config.termination_lvd == 3)
17568 {
17569 asc_dvc->cfg->termination =
17570 termination | TERM_LVD;
17571 } else
17572 {
17573
17574
17575
17576
17577 asc_dvc->cfg->termination = termination;
17578 warn_code |= ASC_WARN_EEPROM_TERMINATION;
17579 }
17580 }
17581
17582 return warn_code;
17583}
17584
17585
17586
17587
17588
17589
17590ASC_INITFUNC(
17591STATIC ushort,
17592AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
17593)
17594{
17595 ushort wval, chksum;
17596 ushort *wbuf;
17597 int eep_addr;
17598 ushort *charfields;
17599
17600 charfields = (ushort *) &ADVEEP_3550_Config_Field_IsChar;
17601 wbuf = (ushort *) cfg_buf;
17602 chksum = 0;
17603
17604 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
17605 eep_addr < ADV_EEP_DVC_CFG_END;
17606 eep_addr++, wbuf++)
17607 {
17608 wval = AdvReadEEPWord(iop_base, eep_addr);
17609 chksum += wval;
17610 if (*charfields++) {
17611 *wbuf = le16_to_cpu(wval);
17612 } else {
17613 *wbuf = wval;
17614 }
17615 }
17616
17617 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
17618 wbuf++; charfields++;
17619
17620
17621 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
17622 eep_addr < ADV_EEP_MAX_WORD_ADDR;
17623 eep_addr++, wbuf++)
17624 {
17625 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
17626 if (*charfields++) {
17627 *wbuf = le16_to_cpu(*wbuf);
17628 }
17629 }
17630 return chksum;
17631}
17632
17633
17634
17635
17636
17637
17638ASC_INITFUNC(
17639STATIC ushort,
17640AdvGet38C0800EEPConfig(AdvPortAddr iop_base,
17641 ADVEEP_38C0800_CONFIG *cfg_buf)
17642)
17643{
17644 ushort wval, chksum;
17645 ushort *wbuf;
17646 int eep_addr;
17647 ushort *charfields;
17648
17649 charfields = (ushort *) &ADVEEP_38C0800_Config_Field_IsChar;
17650 wbuf = (ushort *) cfg_buf;
17651 chksum = 0;
17652
17653 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
17654 eep_addr < ADV_EEP_DVC_CFG_END;
17655 eep_addr++, wbuf++)
17656 {
17657 wval = AdvReadEEPWord(iop_base, eep_addr);
17658 chksum += wval;
17659 if (*charfields++) {
17660 *wbuf = le16_to_cpu(wval);
17661 } else {
17662 *wbuf = wval;
17663 }
17664 }
17665
17666 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
17667 wbuf++; charfields++;
17668
17669
17670 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
17671 eep_addr < ADV_EEP_MAX_WORD_ADDR;
17672 eep_addr++, wbuf++)
17673 {
17674 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
17675 if (*charfields++) {
17676 *wbuf = le16_to_cpu(*wbuf);
17677 }
17678 }
17679 return chksum;
17680}
17681
17682
17683
17684
17685
17686
17687ASC_INITFUNC(
17688STATIC ushort,
17689AdvGet38C1600EEPConfig(AdvPortAddr iop_base,
17690 ADVEEP_38C1600_CONFIG *cfg_buf)
17691)
17692{
17693 ushort wval, chksum;
17694 ushort *wbuf;
17695 int eep_addr;
17696 ushort *charfields;
17697
17698 charfields = (ushort*) &ADVEEP_38C1600_Config_Field_IsChar;
17699 wbuf = (ushort *) cfg_buf;
17700 chksum = 0;
17701
17702 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
17703 eep_addr < ADV_EEP_DVC_CFG_END;
17704 eep_addr++, wbuf++)
17705 {
17706 wval = AdvReadEEPWord(iop_base, eep_addr);
17707 chksum += wval;
17708 if (*charfields++) {
17709 *wbuf = le16_to_cpu(wval);
17710 } else {
17711 *wbuf = wval;
17712 }
17713 }
17714
17715 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
17716 wbuf++; charfields++;
17717
17718
17719 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
17720 eep_addr < ADV_EEP_MAX_WORD_ADDR;
17721 eep_addr++, wbuf++)
17722 {
17723 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
17724 if (*charfields++) {
17725 *wbuf = le16_to_cpu(*wbuf);
17726 }
17727 }
17728 return chksum;
17729}
17730
17731
17732
17733
17734ASC_INITFUNC(
17735STATIC ushort,
17736AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
17737)
17738{
17739 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
17740 ASC_EEP_CMD_READ | eep_word_addr);
17741 AdvWaitEEPCmd(iop_base);
17742 return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
17743}
17744
17745
17746
17747
17748ASC_INITFUNC(
17749STATIC void,
17750AdvWaitEEPCmd(AdvPortAddr iop_base)
17751)
17752{
17753 int eep_delay_ms;
17754
17755 for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++)
17756 {
17757 if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE)
17758 {
17759 break;
17760 }
17761 DvcSleepMilliSecond(1);
17762 }
17763 if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) == 0)
17764 {
17765 ASC_ASSERT(0);
17766 }
17767 return;
17768}
17769
17770
17771
17772
17773void
17774AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
17775{
17776 ushort *wbuf;
17777 ushort addr, chksum;
17778 ushort *charfields;
17779
17780 wbuf = (ushort *) cfg_buf;
17781 charfields = (ushort *) &ADVEEP_3550_Config_Field_IsChar;
17782 chksum = 0;
17783
17784 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
17785 AdvWaitEEPCmd(iop_base);
17786
17787
17788
17789
17790 for (addr = ADV_EEP_DVC_CFG_BEGIN;
17791 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++)
17792 {
17793 ushort word;
17794
17795 if (*charfields++) {
17796 word = cpu_to_le16(*wbuf);
17797 } else {
17798 word = *wbuf;
17799 }
17800 chksum += *wbuf;
17801 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
17802 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
17803 AdvWaitEEPCmd(iop_base);
17804 DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
17805 }
17806
17807
17808
17809
17810 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
17811 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
17812 AdvWaitEEPCmd(iop_base);
17813 wbuf++; charfields++;
17814
17815
17816
17817
17818 for (addr = ADV_EEP_DVC_CTL_BEGIN;
17819 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++)
17820 {
17821 ushort word;
17822
17823 if (*charfields++) {
17824 word = cpu_to_le16(*wbuf);
17825 } else {
17826 word = *wbuf;
17827 }
17828 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
17829 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
17830 AdvWaitEEPCmd(iop_base);
17831 }
17832 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
17833 AdvWaitEEPCmd(iop_base);
17834 return;
17835}
17836
17837
17838
17839
17840void
17841AdvSet38C0800EEPConfig(AdvPortAddr iop_base,
17842 ADVEEP_38C0800_CONFIG *cfg_buf)
17843{
17844 ushort *wbuf;
17845 ushort *charfields;
17846 ushort addr, chksum;
17847
17848 wbuf = (ushort *) cfg_buf;
17849 charfields = (ushort *) &ADVEEP_38C0800_Config_Field_IsChar;
17850 chksum = 0;
17851
17852 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
17853 AdvWaitEEPCmd(iop_base);
17854
17855
17856
17857
17858 for (addr = ADV_EEP_DVC_CFG_BEGIN;
17859 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++)
17860 {
17861 ushort word;
17862
17863 if (*charfields++) {
17864 word = cpu_to_le16(*wbuf);
17865 } else {
17866 word = *wbuf;
17867 }
17868 chksum += *wbuf;
17869 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
17870 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
17871 AdvWaitEEPCmd(iop_base);
17872 DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
17873 }
17874
17875
17876
17877
17878 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
17879 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
17880 AdvWaitEEPCmd(iop_base);
17881 wbuf++; charfields++;
17882
17883
17884
17885
17886 for (addr = ADV_EEP_DVC_CTL_BEGIN;
17887 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++)
17888 {
17889 ushort word;
17890
17891 if (*charfields++) {
17892 word = cpu_to_le16(*wbuf);
17893 } else {
17894 word = *wbuf;
17895 }
17896 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
17897 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
17898 AdvWaitEEPCmd(iop_base);
17899 }
17900 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
17901 AdvWaitEEPCmd(iop_base);
17902 return;
17903}
17904
17905
17906
17907
17908void
17909AdvSet38C1600EEPConfig(AdvPortAddr iop_base,
17910 ADVEEP_38C1600_CONFIG *cfg_buf)
17911{
17912 ushort *wbuf;
17913 ushort *charfields;
17914 ushort addr, chksum;
17915
17916 wbuf = (ushort *) cfg_buf;
17917 charfields = (ushort *) &ADVEEP_38C1600_Config_Field_IsChar;
17918 chksum = 0;
17919
17920 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
17921 AdvWaitEEPCmd(iop_base);
17922
17923
17924
17925
17926 for (addr = ADV_EEP_DVC_CFG_BEGIN;
17927 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++)
17928 {
17929 ushort word;
17930
17931 if (*charfields++) {
17932 word = cpu_to_le16(*wbuf);
17933 } else {
17934 word = *wbuf;
17935 }
17936 chksum += *wbuf;
17937 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
17938 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
17939 AdvWaitEEPCmd(iop_base);
17940 DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
17941 }
17942
17943
17944
17945
17946 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
17947 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
17948 AdvWaitEEPCmd(iop_base);
17949 wbuf++; charfields++;
17950
17951
17952
17953
17954 for (addr = ADV_EEP_DVC_CTL_BEGIN;
17955 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++)
17956 {
17957 ushort word;
17958
17959 if (*charfields++) {
17960 word = cpu_to_le16(*wbuf);
17961 } else {
17962 word = *wbuf;
17963 }
17964 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
17965 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
17966 AdvWaitEEPCmd(iop_base);
17967 }
17968 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
17969 AdvWaitEEPCmd(iop_base);
17970 return;
17971}
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995STATIC int
17996AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc,
17997 ADV_SCSI_REQ_Q *scsiq)
17998{
17999 ulong last_int_level;
18000 AdvPortAddr iop_base;
18001 ADV_DCNT req_size;
18002 ADV_PADDR req_paddr;
18003 ADV_CARR_T *new_carrp;
18004
18005 ASC_ASSERT(scsiq != NULL);
18006
18007
18008
18009
18010 if (scsiq->target_id > ADV_MAX_TID)
18011 {
18012 scsiq->host_status = QHSTA_M_INVALID_DEVICE;
18013 scsiq->done_status = QD_WITH_ERROR;
18014 return ADV_ERROR;
18015 }
18016
18017 iop_base = asc_dvc->iop_base;
18018
18019 last_int_level = DvcEnterCritical();
18020
18021
18022
18023
18024
18025 if ((new_carrp = asc_dvc->carr_freelist) == NULL)
18026 {
18027 DvcLeaveCritical(last_int_level);
18028 return ADV_BUSY;
18029 }
18030 asc_dvc->carr_freelist = (ADV_CARR_T *)
18031 ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
18032 asc_dvc->carr_pending_cnt++;
18033
18034
18035
18036
18037
18038
18039 new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
18040
18041
18042
18043
18044 scsiq->a_flag &= ~ADV_SCSIQ_DONE;
18045
18046 req_size = sizeof(ADV_SCSI_REQ_Q);
18047 req_paddr = DvcGetPhyAddr(asc_dvc, scsiq, (uchar *) scsiq,
18048 (ADV_SDCNT *) &req_size, ADV_IS_SCSIQ_FLAG);
18049
18050 ASC_ASSERT(ADV_32BALIGN(req_paddr) == req_paddr);
18051 ASC_ASSERT(req_size >= sizeof(ADV_SCSI_REQ_Q));
18052
18053
18054 req_paddr = cpu_to_le32(req_paddr);
18055
18056
18057 scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
18058 scsiq->scsiq_rptr = req_paddr;
18059
18060 scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
18061
18062
18063
18064
18065 scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
18066
18067
18068
18069
18070
18071
18072 asc_dvc->icq_sp->areq_vpa = req_paddr;
18073
18074
18075
18076
18077
18078
18079 asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
18080
18081
18082
18083
18084 asc_dvc->icq_sp = new_carrp;
18085
18086 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
18087 asc_dvc->chip_type == ADV_CHIP_ASC38C0800)
18088 {
18089
18090
18091
18092 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
18093 if (asc_dvc->chip_type == ADV_CHIP_ASC3550)
18094 {
18095
18096
18097
18098
18099
18100 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
18101 }
18102 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
18103 {
18104
18105
18106
18107
18108 AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
18109 le32_to_cpu(new_carrp->carr_pa));
18110 }
18111
18112 DvcLeaveCritical(last_int_level);
18113
18114 return ADV_SUCCESS;
18115}
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126STATIC int
18127AdvResetSB(ADV_DVC_VAR *asc_dvc)
18128{
18129 int status;
18130
18131
18132
18133
18134
18135 status = AdvSendIdleCmd(asc_dvc, (ushort) IDLE_CMD_SCSI_RESET_START, 0L);
18136 if (status != ADV_TRUE)
18137 {
18138 return status;
18139 }
18140
18141
18142
18143
18144
18145
18146
18147 DvcDelayMicroSecond(asc_dvc, (ushort) ASC_SCSI_RESET_HOLD_TIME_US);
18148
18149
18150
18151
18152
18153 status = AdvSendIdleCmd(asc_dvc, (ushort) IDLE_CMD_SCSI_RESET_END, 0L);
18154 if (status != ADV_TRUE)
18155 {
18156 return status;
18157 }
18158
18159 DvcSleepMilliSecond((ADV_DCNT) asc_dvc->scsi_reset_wait * 1000);
18160
18161 return status;
18162}
18163
18164
18165
18166
18167
18168
18169
18170
18171STATIC int
18172AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
18173{
18174 int status;
18175 ushort wdtr_able, sdtr_able, tagqng_able;
18176 ushort ppr_able = 0;
18177 uchar tid, max_cmd[ADV_MAX_TID + 1];
18178 AdvPortAddr iop_base;
18179 ushort bios_sig;
18180
18181 iop_base = asc_dvc->iop_base;
18182
18183
18184
18185
18186 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
18187 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
18188 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
18189 {
18190 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
18191 }
18192 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
18193 for (tid = 0; tid <= ADV_MAX_TID; tid++)
18194 {
18195 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
18196 max_cmd[tid]);
18197 }
18198
18199
18200
18201
18202
18203
18204
18205 AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
18206 AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
18207
18208
18209
18210
18211 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
18212 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
18213 DvcSleepMilliSecond(100);
18214 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_WR_IO_REG);
18215
18216
18217
18218
18219
18220 asc_dvc->err_code = 0;
18221 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
18222 {
18223 status = AdvInitAsc38C1600Driver(asc_dvc);
18224 }
18225 else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800)
18226 {
18227 status = AdvInitAsc38C0800Driver(asc_dvc);
18228 } else
18229 {
18230 status = AdvInitAsc3550Driver(asc_dvc);
18231 }
18232
18233
18234 if (status == 0)
18235 {
18236 status = ADV_TRUE;
18237 } else
18238 {
18239 status = ADV_FALSE;
18240 }
18241
18242
18243
18244
18245 AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
18246
18247
18248
18249
18250 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
18251 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
18252 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
18253 {
18254 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
18255 }
18256 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
18257 for (tid = 0; tid <= ADV_MAX_TID; tid++)
18258 {
18259 AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
18260 max_cmd[tid]);
18261 }
18262
18263 return status;
18264}
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285STATIC int
18286AdvISR(ADV_DVC_VAR *asc_dvc)
18287{
18288 AdvPortAddr iop_base;
18289 uchar int_stat;
18290 ushort target_bit;
18291 ADV_CARR_T *free_carrp;
18292 ADV_VADDR irq_next_vpa;
18293 int flags;
18294 ADV_SCSI_REQ_Q *scsiq;
18295
18296 flags = DvcEnterCritical();
18297
18298 iop_base = asc_dvc->iop_base;
18299
18300
18301 int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
18302
18303 if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
18304 ADV_INTR_STATUS_INTRC)) == 0)
18305 {
18306 DvcLeaveCritical(flags);
18307 return ADV_FALSE;
18308 }
18309
18310
18311
18312
18313
18314
18315 if (int_stat & ADV_INTR_STATUS_INTRB)
18316 {
18317 uchar intrb_code;
18318
18319 AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
18320
18321 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
18322 asc_dvc->chip_type == ADV_CHIP_ASC38C0800)
18323 {
18324 if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
18325 asc_dvc->carr_pending_cnt != 0)
18326 {
18327 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
18328 if (asc_dvc->chip_type == ADV_CHIP_ASC3550)
18329 {
18330 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
18331 }
18332 }
18333 }
18334
18335 if (asc_dvc->async_callback != 0)
18336 {
18337 (*asc_dvc->async_callback)(asc_dvc, intrb_code);
18338 }
18339 }
18340
18341
18342
18343
18344 while (((irq_next_vpa =
18345 le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0)
18346 {
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356 scsiq = (ADV_SCSI_REQ_Q *)
18357 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
18358
18359
18360
18361
18362
18363
18364 if ((irq_next_vpa & ASC_RQ_GOOD) != 0)
18365 {
18366 scsiq->done_status = QD_NO_ERROR;
18367 scsiq->host_status = scsiq->scsi_status = 0;
18368 scsiq->data_cnt = 0L;
18369 }
18370
18371
18372
18373
18374
18375
18376 free_carrp = asc_dvc->irq_sp;
18377 asc_dvc->irq_sp = (ADV_CARR_T *)
18378 ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
18379
18380 free_carrp->next_vpa =
18381 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
18382 asc_dvc->carr_freelist = free_carrp;
18383 asc_dvc->carr_pending_cnt--;
18384
18385 ASC_ASSERT(scsiq != NULL);
18386 target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
18387
18388
18389
18390
18391 scsiq->cntl = 0;
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402 if (scsiq->done_status == QD_NO_ERROR &&
18403 scsiq->cdb[0] == SCSICMD_Inquiry &&
18404 scsiq->target_lun == 0 &&
18405 (scsiq->cdb[1] & ADV_INQ_RTN_VPD_AND_CMDDT)
18406 == ADV_INQ_RTN_STD_INQUIRY_DATA)
18407 {
18408 AdvInquiryHandling(asc_dvc, scsiq);
18409 }
18410
18411
18412
18413
18414
18415 scsiq->a_flag |= ADV_SCSIQ_DONE;
18416 (*asc_dvc->isr_callback)(asc_dvc, scsiq);
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433 (void) DvcEnterCritical();
18434 }
18435 DvcLeaveCritical(flags);
18436 return ADV_TRUE;
18437}
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453STATIC int
18454AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
18455 ushort idle_cmd,
18456 ADV_DCNT idle_cmd_parameter)
18457{
18458 ulong last_int_level;
18459 int result;
18460 ADV_DCNT i, j;
18461 AdvPortAddr iop_base;
18462
18463 last_int_level = DvcEnterCritical();
18464
18465 iop_base = asc_dvc->iop_base;
18466
18467
18468
18469
18470
18471
18472
18473 AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort) 0);
18474
18475
18476
18477
18478
18479
18480
18481 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
18482 cpu_to_le32(idle_cmd_parameter));
18483 AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
18484
18485
18486
18487
18488 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
18489 if (asc_dvc->chip_type == ADV_CHIP_ASC3550)
18490 {
18491
18492
18493
18494
18495
18496 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
18497 }
18498
18499
18500 for (i = 0; i < SCSI_WAIT_100_MSEC; i++)
18501 {
18502
18503 for (j = 0; j < SCSI_US_PER_MSEC; j++)
18504 {
18505 AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, result);
18506 if (result != 0)
18507 {
18508 DvcLeaveCritical(last_int_level);
18509 return result;
18510 }
18511 DvcDelayMicroSecond(asc_dvc, (ushort) 1);
18512 }
18513 }
18514
18515 ASC_ASSERT(0);
18516 DvcLeaveCritical(last_int_level);
18517 return ADV_ERROR;
18518}
18519
18520
18521
18522
18523
18524
18525
18526
18527STATIC void
18528AdvInquiryHandling(
18529 ADV_DVC_VAR *asc_dvc,
18530 ADV_SCSI_REQ_Q *scsiq)
18531{
18532 AdvPortAddr iop_base;
18533 uchar tid;
18534 ADV_SCSI_INQUIRY *inq;
18535 ushort tidmask;
18536 ushort cfg_word;
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548 if (scsiq->cdb[4] < 8 ||
18549 (scsiq->cdb[4] - le32_to_cpu(scsiq->data_cnt)) < 8)
18550 {
18551 return;
18552 }
18553
18554 iop_base = asc_dvc->iop_base;
18555 tid = scsiq->target_id;
18556
18557 inq = (ADV_SCSI_INQUIRY *) scsiq->vdata_addr;
18558
18559
18560
18561
18562 if (ADV_INQ_RESPONSE_FMT(inq) < 2 && ADV_INQ_ANSI_VER(inq) < 2)
18563 {
18564 return;
18565 } else
18566 {
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576 tidmask = ADV_TID_TO_TIDMASK(tid);
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586 if ((asc_dvc->wdtr_able & tidmask) && ADV_INQ_WIDE16(inq))
18587 {
18588 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
18589 if ((cfg_word & tidmask) == 0)
18590 {
18591 cfg_word |= tidmask;
18592 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
18593
18594
18595
18596
18597
18598
18599
18600
18601 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
18602 cfg_word &= ~tidmask;
18603 AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
18604 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
18605 cfg_word &= ~tidmask;
18606 AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
18607 }
18608 }
18609
18610
18611
18612
18613
18614
18615
18616
18617 if ((asc_dvc->sdtr_able & tidmask) && ADV_INQ_SYNC(inq))
18618 {
18619 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
18620 if ((cfg_word & tidmask) == 0)
18621 {
18622 cfg_word |= tidmask;
18623 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
18624
18625
18626
18627
18628
18629
18630 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
18631 cfg_word &= ~tidmask;
18632 AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
18633 }
18634 }
18635
18636
18637
18638
18639 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600 &&
18640 (scsiq->cdb[4] >= 57 ||
18641 (scsiq->cdb[4] - le32_to_cpu(scsiq->data_cnt)) >= 57))
18642 {
18643
18644
18645
18646
18647
18648
18649
18650
18651 if (ADV_INQ_CLOCKING(inq) & ADV_INQ_CLOCKING_DT_ONLY)
18652 {
18653 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, asc_dvc->ppr_able);
18654 asc_dvc->ppr_able |= tidmask;
18655 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, asc_dvc->ppr_able);
18656 }
18657 }
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671 if ((asc_dvc->tagqng_able & tidmask) && ADV_INQ_CMD_QUEUE(inq))
18672 {
18673 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
18674 cfg_word |= tidmask;
18675 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
18676
18677 AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
18678 asc_dvc->max_dvc_qng);
18679 }
18680 }
18681}
18682MODULE_LICENSE("Dual BSD/GPL");
18683