forked from qmor/elcus-1553-usb-linux-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmknllusb.c
5584 lines (5212 loc) · 132 KB
/
tmknllusb.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
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
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//;***************************************************************************;
//;* Based onTMKNLL v7.02 *;
//;* ELCUS, 1995, 2008. *;
//;***************************************************************************;
//6.00
// - ASM->C
// - TA minimal support
//6.01
// - added __ for internal vars
// - bits = 0 for TA in rtgetanswbits
//6.02
// - TA timer support (w/o user timer interrupts)
// - QNX4 support (w/o MRTX)
// - LINUX support
// - shared irq processing fixed (DOS/QNX4)
// - SMP support for TMKX, MRTX, TA serves:
// TMKX writes in irq TMK_CtrlPort (RT mode)
// MRTX writes in irq TMK_CtrlPort, TMK_AddrPort, TMK_DataPort
// TA writes in irq TA_ADDR, TA_TIMCR, TA_MODE1
// - TA1-PCI4 support
//6.03
// - 80186/80188 support (DOS)
// - QNX4 support with MRTX (used tmkisr.c)
//6.04
// - QNX4 support for VME cards
// - commented __tmkDrvType[num] = 0xFFFF; (in tmkconfig on irq error)
// - TA timeout control support (tmktimeout function)
// - TA mt def/get mode functions
// - tmk def/get dac functions for TH6-PCI
// - rtsetanswbits bug for xTMK400 cards fixed
// - bcdeflink with CX_NOSIG fixed
// - GET_DIS_IRQ_SMP/REST_IRQ_SMP put out of ...PokeTA/...PeekTA
// - added Virtual RTs reset in bcreset (mrtreset)
//7.00
// - MRTA, MRTAI support
//7.01
// - QNX6 support
// - mbcinit, mbcpreparex, mbcstartx, mbcalloc, mbcfree functions
// - MRTA bcreset fixed (possible fake tester interrupt)
// - wrong type bug fixed (in __RT_DIS_MASK, __RT_BRC_MASK)
//7.02
// - updated tmkisr.c for MRTA and QNX6
// - bcstop for TA cards fixed
// - tmktimer single loop fixed
#include "config.h"
#define WRITE_RG 0
#define READ_RG 1
#define WRITE_MEM 2
#define READ_MEM 3
#define MOD_RG_AND 4
#define MOD_RG_OR 5
#define MOD_MEM_AND 6
#define MOD_MEM_OR 7
#define WRITE_PARAM 10
#define READ_PARAM 11
#define PARAM_MODE 1
#define PARAM_BCBASEBUS 2
#define PARAM_BCXSTART 4
#define PARAM_MTCW 5
#define PARAM_BCAW1 6
#define PARAM_BCAW2 7
#define PARAM_BCAW1POS 8
#define PARAM_BCAW2POS 9
#define PARAM_BCLINKBASEN 10
#define PARAM_BCLINKCCN 11
#ifndef NOT_INCLUDE_DEFS
#include "tmkndefs.h"
#endif
#define VOID void
#define BOOL char
#ifdef __cplusplus
#define __CPPARGS ...
#define __INLINE inline
#else
#define __CPPARGS
#define __INLINE
#endif
#ifdef LINUX
#ifndef TMK1553B_NOCONFIGH
#include <linux/config.h>
#endif
#ifdef CONFIG_SMP
#define __SMP__
#endif
#include <asm/io.h>
#endif //def LINUX
#define CFG_SUB_VID 0x2C
#define CFG_SUB_DID 0x2E
#define CFG_ADDR1 0x14
#define CFG_IRQ 0x3C
#define PLX_VID 0x10B5
#define PLX_DID 0x9030
#define ELCUS_VID 0xE1C5
#define TX1PCI_ID 0x0001
#define TX6PCI_ID 0x0002
#define TX1PCI2_ID 0x0003
#define TX6PCI2_ID 0x0004
#define TA1PCI_ID 0x0005
#define TA1PCI4_ID 0x0006
#define TA1PCI32RT_ID 0x0007
#define IN_DELAY 1
#define OUT_DELAY 1
#define TMK_MIN_TYPE 2
#define TMK_MAX_TYPE 12
#define TMK400 2
#define TMKMPC 3
#define RTMK400 4
#define TMKX 5
#define TMKXI 6
#define MRTX 7
#define MRTXI 8
#define TA 9
#define TAI 10
#define MRTA 11
#define MRTAI 12
#ifndef NTMK
#define NTMK 8
#endif
#ifndef NRT
#define NRT 32
#endif
#ifndef DRV_MAX_BASE
#define DRV_MAX_BASE 1023
#endif
#define TMKXV_VectPort 0x2
#define TAV_VectPort 0x22
#define TMKH_DacPort 0x2
#define TMKX_StopPort 0x4
#define TMK_BasePort 0x2
#define TMK_StartPort 0x4
#define TMK_ResetPort 0x6
#define TMK_ModePort 0x8
#define TMK_AddrPort 0xA
#define TMK_CtrlPort 0xC
#define TMK_StatePort 0xC
#define TMK_DataPort 0xE
#define TMKMPC_BasePort 0xC
#define TMKMPC_StartPort 0xA
#define TMKMPC_ResetPort 0x8
#define TMKMPC_ModePort 0x6
#define TMKMPC_AddrHPort 0x4
#define TMKMPC_AddrLPort 0xE
#define TMKMPC_CtrlHPort 0x3
#define TMKMPC_CtrlLPort 0x2
#define TMKMPC_StateHPort 0x3
#define TMKMPC_StateLPort 0x2
#define TMKMPC_DataHPort 0x1
#define TMKMPC_DataLPort 0x0
#define TA_BASE(i) (__tmkPortsAddr1_usb[i])
#define TA_IRQ(i) (__tmkPortsAddr1_usb[i]+2)
#define AdrRCod_Dec(i) (__tmkPortsAddr1_usb[i]+4)
#define TA_RESET(i) (__tmkPortsAddr1_usb[i]+6)
#define TA_MODE1(i) (__tmkPortsAddr1_usb[i]+8)
#define TA_ADDR(i) (__tmkPortsAddr1_usb[i]+0xA)
#define TA_MODE2(i) (__tmkPortsAddr1_usb[i]+0xC)
#define TA_DATA(i) (__tmkPortsAddr1_usb[i]+0xE)
#define TA_TIMER1(i) (__tmkPortsAddr1_usb[i]+0x10)
#define TA_TIMER2(i) (__tmkPortsAddr1_usb[i]+0x12)
#define TA_RTA(i) (__tmkPortsAddr1_usb[i]+0x14)
#define TA_TIMCR(i) (__tmkPortsAddr1_usb[i]+0x18)
#define TA_LCW(i) (__tmkPortsAddr1_usb[i]+0x1A)
#define TA_MSGA(i) (__tmkPortsAddr1_usb[i]+0x1C)
#define MRTA_ADDR2(i) (__tmkPortsAddr1_usb[i]+4)
#define MRTA_SW(i) (__tmkPortsAddr1_usb[i]+0x16)
#define MRTA_RT_ON 0x0020
#define MRTA_BRC_PAGE 0x003F
#define TA_RT_DATA_INT_BLK 0x0010
#define TA_IRQ_EN 0x0400
#define TA_TXRX_EN 0x03C0
#define TA_BS_MODE_DATA_EN 0x0002
#define TA_FIFO_RESET 0x0004
#define TA_RTMT_START 0x0008
#define TA_BC_START 0x8000
#define TA_BC_STOP 0x2000
#define TA_STOP_ON_EXC 0x000C
#define __TA_14US 0x0000
#define __TA_18US 0x1000
#define __TA_26US 0x2000
#define __TA_63US 0x3000
//Mask RRG1
#define RRG1_WORK_Reset 0xC000
#define RRG1_WORK_RT 0x4000
#define RRG1_WORK_MCO 0x8000
#define RRG1_WORK_MCL 0xC000
#define RRG1_PAUSE_Reset 0x3000
#define RRG1_PAUSE_18 0x1000
#define RRG1_PAUSE_26 0x2000
#define RRG1_PAUSE_63 0x3000
#define RRG1_Dis_MCO 0x0800
#define RRG1_En_IRQ 0x0400
#define RRG1_Dis_BUS_A_td 0x0200
#define RRG1_Dis_BUS_B_td 0x0100
#define RRG1_Dis_BUS_A_rd 0x0080
#define RRG1_Dis_BUS_B_rd 0x0040
#define RRG1_Dis_BS 0x0020
#define RRG1_Dis_IRQ_CW 0x0010
#define RRG1_Start_RT 0x0008
#define RRG1_Reset_FIFO 0x0004
#define RRG1_Dis_tr_BS 0x0002
#define RRG1_Dis_tr_LCW_BS 0x0001
//Mask RRG2
//BC
#define RRG2_BC_Start 0x8000
#define RRG2_BC_En_IRQ_er 0x4000
#define RRG2_BC_END_Stop_IRQ 0x2000
#define RRG2_BC_En_Restart 0x1000
#define RRG2_BC_En_2_Restart 0x0800
#define RRG2_BC_1Res_Activ_Bus 0x0400
#define RRG2_BC_2Res_Activ_Bus 0x0200
#define RRG2_BC_Dis_Flag_Gen 0x0100
#define RRG2_BC_Goto_Rezerv 0x0040
#define RRG2_BC_Dis_Answ_Bit 0x0020
#define RRG2_BC_Mask_Rez_Bit 0x0010
#define RRG2_BC_Stop_IRQ_AnswBit 0x8
#define RRG2_BC_Stop_IRQ_Error 0x4
#define RRG2_BC_Mode_Mask_BC 0x0001
//RT MCO MCL
#define RRG2_RT_ADR 0xF800
#define RRG2_RT_EN_GRUP 0x0010
#define RRG2_RT_DIS_IRQ_ERR 0x0400
#define RRG2_RT_SET_BIT_SR 0x0100
#define RRG2_RT_RESET_BIT_SR_TR_VECTOR_WORD 0x0080
#define RRG2_RT_SET_BIT_BS 0x8
#define RRG2_RT_SET_BIT_SF 0x4
#define RRG2_RT_SET_BIT_TF 0x1
#define RRG2_RT_EN_BUS_CTRL 0x2
#define RRG2_RT_SET_INSTR_BIT 0x0200
#define RRG2_MTW_TEST_BUS 0x40
#define RRG2_MTW_TEST_SYNC 0x20
#define BCMT_MODE_L 0x0000
#define TMK400_INT1_MASK 0x40
#define TMK400_INT2_MASK 0x80
#define TMKMPC_INT1_MASK 0x8000
#define RTMK400_INT1_MASK 0x02
#define RTMK400_INT2_MASK 0x01
#define TMK400CWBitsMask 0x0060
#define RT_CLEAR_INT 0x03E0
#define RTAnswBitsMask 0x001F
#define DRV_HBIT_MODE 0x0001
#define DRV_FLAG_MODE 0x0002
#define DRV_BRCST_MODE 0x0004
#define RTMK400_HBIT_MODE 0x0020
#define RTMK400_FLAG_MODE 0x0040
#define RTMK400_BRCST_MODE 0x0080
//;TMKX_HBIT_MODE 0000001000000000b
#define TMKX_HBIT_MODE 0x0000
#define TMKX_FLAG_MODE 0x0400
#define TMKX_BRCST_MODE 0x0100
//;MRTX_HBIT_MODE 0000001000000000b
#define MRTX_HBIT_MODE 0x0000
#define MRTX_FLAG_MODE 0x0400
#define MRTX_BRCST_MODE 0x0100
#define TA_HBIT_MODE 0x0200
#define TA_BRCST_MODE 0x0010
#define TX_RT_DATA_INT_BLK 0x2000
#define GENER1_BLK 0x0004
#define GENER2_BLK 0x4000
#if NRT == 0
#ifdef MRTX
#undef MRTX
#endif
#ifdef MRTXI
#undef MRTXI
#endif
#ifdef MRTA
#undef MRTA
#endif
#ifdef MRTAI
#undef MRTAI
#endif
#endif
BOOL __tmkIsUserType_usb[TMK_MAX_TYPE+1+1] =
{
0, 0,
#ifdef TMK400
1, 1, 1, //TMK400, TMKMPC, RTMK000
#else
0, 0, 0,
#endif
#ifdef TMKX
1, 1, //TMKX, TMKXI
#else
0, 0,
#endif
#ifdef MRTX
1, 1, //MRTX, MRTXI
#else
0, 0,
#endif
#ifdef TA
1, 1, //TA, TAI
#else
0, 0,
#endif
#ifdef MRTA
1, 1, //MRTA, MRTAI
#else
0, 0,
#endif
0
};
#define __TMK400 0
#define __TMKMPC 1
#define __RTMK400 2
#define __TMKX 3
#define __TA 4
#if !defined(MRTX) && !defined(MRTA)
#define DRV_MAX_TYPE 4
#endif
#if defined(MRTX) && !defined(MRTA)
#define __MRTX 5
#define DRV_MAX_TYPE 5
#endif
#if !defined(MRTX) && defined(MRTA)
#define __MRTA 5
#define DRV_MAX_TYPE 5
#endif
#if defined(MRTX) && defined(MRTA)
#define __MRTX 5
#define __MRTA 6
#define DRV_MAX_TYPE 6
#endif
U16 __tmkUser2DrvType_usb[TMK_MAX_TYPE+1] =
{
0xFFFF,
0xFFFF,
__TMK400, //TMK400
__TMKMPC, //TMKMPC
__RTMK400, //RTMK400
__TMKX, //TMKX
__TMKX, //TMKXI
#ifdef MRTX
__MRTX, //MRTX
__MRTX, //MRTXI
#else
0xFFFF,
0xFFFF,
#endif
__TA, //TA
__TA, //TAI
#ifdef MRTA
__MRTA, //MRTA
__MRTA //MRTAI
#else
0xFFFF,
0xFFFF,
#endif
};
BOOL __tmkFirstTime_usb = 1;
U16 __tmkTimerCtrl_usb[NTMK]; // DUP(0)
U16 __tmkTimeOut_usb[NTMK]; //DUP(0)
U16 __tmkHWVer_usb[NTMK]; // DUP(0)
#define AdrTab 1023
BOOL __FLAG_MODE_ON_usb[NTMK+NRT]; // DUP(0)
U16 __BC_RT_FLAG_usb[NTMK+NRT][32];
U16 __RT_BC_FLAG_usb[NTMK+NRT][32];
U16 __wInDelay_usb[NTMK]; // DUP(1)
U16 __wOutDelay_usb[NTMK]; // DUP(1)
int __tmkMaxNumber_usb = NTMK-1;
#ifdef STATIC_TMKNUM
int tmkError_usb = 0;
#else
int tmkError_usb[NTMK+NRT]; // DUP(0)
#endif
#ifdef STATIC_TMKNUM
int volatile __tmkNumber_usb = 0;
#endif
int __amrtNumber_usb[NTMK+NRT]; // DUP(0)
U16 __tmkPortsAddr1_usb[NTMK];
U16 __tmkPortsAddr2_usb[NTMK];
U16 __tmkDrvType_usb[NTMK+NRT]; // DUP(0xFFFF)
U16 __tmkUserType_usb[NTMK+NRT];
U16 __tmkMode_usb[NTMK+NRT]; // DUP(0xFFFF)
U16 __tmkRAMSize_usb[NTMK];
#if NRT > 0
int __mrtMinRT_usb[NTMK]; // DUP(0)
int __mrtNRT_usb[NTMK]; // DUP(1)
U16 __mrtCtrl0_usb[NTMK+NRT];
U16 __mrtCtrl1_usb[NTMK+NRT];
U16 __mrtMask0_usb[NTMK+NRT];
U16 __mrtMask1_usb[NTMK+NRT];
U32 __dmrtRT_usb[NTMK]; //DUP(0L)
U32 __dmrtBrc_usb[NTMK]; //DUP(0L)
U08 __mrtA2RT_usb[NTMK][32];
U16 __mrtLastBrcTxRT_usb[NTMK]; //DUP(0xFF)
#endif //NRT
BOOL __tmkRAMInWork_usb[NTMK]; // DUP(0)
unsigned __tmkRAMAddr_usb[NTMK]; // DUP(0)
BOOL __tmkStarted_usb[NTMK]; // DUP(0)
U16 __bcControls1_usb[NTMK];
U16 __bcControls_usb[NTMK];
U16 __bcBus_usb[NTMK]; // DUP(0)
U16 __bcMaxBase_usb[NTMK]; // DUP(0)
U16 __mtMaxBase_usb[NTMK]; // DUP(0)
U16 __bcBaseBus_usb[NTMK];
U16 __bcBasePC_usb[NTMK];
U16 __bcAW1Pos_usb[NTMK];
U16 __bcAW2Pos_usb[NTMK];
//U16 bcAW1[NTMK];
//U16 bcAW2[NTMK];
BOOL __bcXStart_usb[NTMK];
U08 __bcExt2StdResult_usb[] =
{
0x00, 0x02, 0x08, 0x08,
0x80, 0x01, 0x02, 0x20,
0x04, 0x06, 0x0C, 0x0C,
0x84, 0x05, 0x06, 0x24
};
void FARIR retfLabel_usb(void);
U16 __rtControls_usb[NTMK+NRT]; // DUP(0)
//MRTA(realnum) - MODE1
U16 __rtControls1_usb[NTMK+NRT]; // DUP(0)
//MRTA(realnum) - MODE2
//MRTA(num) - SW
U16 __rtPagePC_usb[NTMK+NRT];
U16 __rtPageBus_usb[NTMK+NRT];
U16 __rtAddress_usb[NTMK+NRT]; //DUP(00FFh)
//;rtMaskAddr U16 [NTMK+NRT]; DUP(001Fh)
//;rtMaskBrc U16 [NTMK+NRT]; //!!! DUP(0)
U16 __rtMaxPage_usb[NTMK+NRT]; // DUP(0)
U16 __rtMode_usb[NTMK+NRT]; // DUP(0)
U16 __rtSubAddr_usb[NTMK+NRT]; // DUP(0)
U16 __hm400Page_usb[NTMK+NRT]; // DUP(0)
#if NRT > 0
#ifdef MRTA
U16 __hm400Page2_usb[NTMK+NRT]; // DUP(0) current ADDR2
U16 __hm400Page0_usb[NTMK+NRT]; // DUP(0) starting page
#endif //def MRTA
#endif
U16 __rtDisableMask_usb[NTMK+NRT];
U16 __rtBRCMask_usb[NTMK+NRT];
BOOL __rtEnableOnAddr_usb[NTMK+NRT]; // DUP(1)
U16 __RT_DIS_MASK0_usb[TMK_MAX_TYPE+1] =
{
0, //; none
0, //; none
0x001F, //; TMK400
0x001F, //; RTMK400
0x001F, //; TMKMPC
0xF800, //; TMKX
0xF800, //; TMKXI
0x001F, //; MRTX
0x001F, //; MRTXI
0xF800, //; TA
0xF800, //; TAI
0x001F, //; MRTA
0x001F //; MRTAI
};
U16 __RT_BRC_MASK0_usb[TMK_MAX_TYPE+1] =
{
0, //; none
0, //; none
0xFFFF, //; TMK400
0xFF7F, //; RTMK400
0xFFFF, //; TMKMPC
0xFEFF, //; TMKX
0xFEFF, //; TMKXI
0xFEFF, //; MRTX
0xFEFF, //; MRTXI
0xFFEF, //; TA
0xFFEF, //; TAI
0x7FFF, //; MRTA
0x7FFF //; MRTAI
};
U16 __RT_DIS_MASK_usb[DRV_MAX_TYPE+1];
U16 __RT_BRC_MASK_usb[DRV_MAX_TYPE+1];
U16 __mtCW_usb[NTMK];
U16 __rtGap_usb[NTMK];
U16 __bcLinkBaseN_usb[NTMK][DRV_MAX_BASE+1];
U16 __bcLinkCCN_usb[NTMK][DRV_MAX_BASE+1];
////U32 bcLinkWPtr[NTMK];
//// DD bcLinkW0
//// IRPC N, 1234567
//// DD bcLinkW&N&
//// ENDM
U16 __bcCmdWN_usb[NTMK][DRV_MAX_BASE+1];
////U32 bcCmdWPtr[NTMK];
//// DD bcCmdW0
//// IRPC N, 1234567
//// DD bcCmdW&N&
//// ENDM
#ifdef NMBCID
int __mbcAlloc_usb[NMBCID];
int __mbci_usb[NMBCID];
U16 __mbcBase_usb[NMBCID][NTMK];
U16 __mbcTmkN_usb[NMBCID][NTMK];
U16 __mbcPort_usb[NMBCID][NTMK];
U16 __mbcData_usb[NMBCID][NTMK];
U16 __mbcPort0_usb[NMBCID][NTMK];
U16 __mbcData0_usb[NMBCID][NTMK];
#endif //NMBCID
char __TMKLL_Ver_usb[] = "TMKNLL v7.02";
#ifdef CPU188
char __ch186_usb[] = "-188";
#endif
#ifdef RAMwoCLI
char __chRAMwoCLI_usb[] = ".a";
#else
char __chRAMwoCLI_usb[] = ".b";
#endif
#ifdef MASKTMKS
char __chMASKTMKS_usb[] = ".a";
#else
char __chMASKTMKS_usb[] = ".b";
#endif
//;_DATA ENDS
//;VXD_LOCKED_DATA_ENDS
#ifdef LINUX
#define IRQ_FLAGS
#define GET_DIS_IRQ() { /*spin_lock_irq(&tmkIrqSpinLock);*/ }
#define REST_IRQ() { /*spin_unlock_irq(&tmkIrqSpinLock);*/ }
#define GET_MUTEX
#define REST_MUTEX
#ifdef __SMP__
#define GET_DIS_IRQ_SMP() { /*spin_lock_irq(&tmkIrqSpinLock);*/ }
#define REST_IRQ_SMP() { /*spin_unlock_irq(&tmkIrqSpinLock);*/ }
#else
#define GET_DIS_IRQ_SMP()
#define REST_IRQ_SMP()
#endif //def __SMP__
#endif
#ifdef LINUX
#define outpw(port, data) Error//fakeout(port, data)
#define inpw(port) Error//fakein(port)
#define outpb(port, data) Error//fakeout(data, port)
#define inpb(port) Error//fakein(port)
#endif //def LINUX
/*#ifdef LINUX
#define outpw(port, data) outw(data, port)
#define inpw(port) inw(port)
#define outpb(port, data) outb(data, port)
#define inpb(port) inb(port)
#endif //def LINUX*/
#define DrvBcDefBaseTA(realnum, base) { \
__bcBasePC_usb[realnum] = base; \
}
/*__INLINE
void DrvBcPokeTA(int realnum, unsigned pos, unsigned data)
{
outpw(TA_ADDR(realnum), (__bcBasePC[realnum] << 6) + pos);
outpw(TA_DATA(realnum), data);
} */
void DrvBcDefBase_usb(int realnum, unsigned type, unsigned base);
void DrvBcPoke_usb(int realnum, unsigned type, unsigned pos, unsigned data);
unsigned DrvBcPeek_usb(int realnum, unsigned type, unsigned pos);
/*__INLINE
unsigned DrvBcPeekTA(int realnum, unsigned pos)
{
unsigned data;
outpw(TA_ADDR(realnum), (__bcBasePC[realnum] << 6) + pos);
data = inpw(TA_DATA(realnum));
return data;
} */
void DrvRtPoke_usb(int __tmkNumber, unsigned type, unsigned pos, unsigned data);
unsigned DrvRtPeek_usb(int __tmkNumber, unsigned type, unsigned pos);
/*__INLINE
void DrvRtPokeTA(int realnum, unsigned base, unsigned pos, unsigned data)
{
outpw(TA_ADDR(realnum), (base << 6) + pos);
outpw(TA_DATA(realnum), data);
}
__INLINE
unsigned DrvRtPeekTA(int realnum, unsigned base, unsigned pos)
{
unsigned data;
outpw(TA_ADDR(realnum), (base << 6) + pos);
data = inpw(TA_DATA(realnum));
return data;
} */
void DrvRtWMode_usb(int num, unsigned type, unsigned mode);
void DrvFlagMode_usb(int num, int m);
void (FARIR *tmkUserErrors_usb)(void) = retfLabel_usb;
#define DEF_VAR(type, var) type var
#define GET_VAR(varloc, varpar) varloc = varpar
#define GET_RealNum (__amrtNumber_usb[__tmkNumber_usb])
#define PUT_RealNum(num) {}
#define PUSH_RealNum {}
#define POP_RealNum {}
#define INT3 { asm db 0cch; }
#ifdef STATIC_TMKNUM
#define CLRtmkError { \
tmkError_usb = 0; \
}
#else
#ifdef NTMKLL_CLR_TMK_ERROR
#define CLRtmkError { \
tmkError_usb[__tmkNumber_usb] = 0; \
}
#else
#define CLRtmkError {}
#endif
#endif
#define CONVERT_TMKX_SW_BITS(bits, bitst) { \
bits = bitst & 0x04; \
if (bitst & 0x01) \
bits |= 0x02; \
if (bitst & 0x02) \
bits |= 0x01; \
if (bitst & 0x08) \
bits |= 0x10; \
if (bitst & 0x10) \
bits |= 0x08; \
}
#define CONVERT_TA_SW_BITS(bits, bitst) { \
bits = 0; \
if (bitst & SREQ) \
bits |= SREQ_MASK; \
if (bitst & BUSY) \
bits |= BUSY_MASK; \
if (bitst & SSFL) \
bits |= SSFL_MASK; \
if (bitst & RTFL) \
bits |= RTFL_MASK; \
if (bitst & DNBA) \
bits |= DNBA_MASK; \
}
#ifdef STATIC_TMKNUM
#define USER_ERROR(err) (tmkError_usb = err)
#define USER_ERROR_R USER_ERROR
#else
#define USER_ERROR(err) (tmkError_usb[__tmkNumber_usb] = err)
#define USER_ERROR_R(err) (err)
#endif
#ifndef NOCHECK
#define CHECK_TMK_DEVICE(num) { \
if (minor_table[num] == NULL) \
return USER_ERROR(TMK_BAD_NUMBER); \
}
#define CHECK_TMK_DEVICEN(num) { \
if (minor_table[num] == NULL) \
{ \
USER_ERROR(TMK_BAD_NUMBER); \
return 0;\
} \
}
#define CHECK_TMK_DEVICEV(num) { \
if (minor_table[num] == NULL) \
{ \
USER_ERROR(TMK_BAD_NUMBER); \
return;\
} \
}
#else
#define CHECK_TMK_DEVICE(num)
#define CHECK_TMK_DEVICEN(num)
#define CHECK_TMK_DEVICEV(num)
#endif
#ifndef NOCHECK
#define CHECK_TMK_REAL_NUMBER(num) { \
if (num >= NTMK) \
return USER_ERROR_R(TMK_BAD_NUMBER); \
}
#else
#define CHECK_TMK_REAL_NUMBER(num)
#endif
#ifndef NOCHECK
#define CHECK_TMK_NUMBER(num) { \
if ((unsigned)num > __tmkMaxNumber_usb) \
return USER_ERROR_R(TMK_BAD_NUMBER); \
}
#else
#define CHECK_TMK_NUMBER(num)
#endif
#ifndef NOCHECK
#define CHECK_TMK_MODE(num, ReqMode) { \
if (__tmkMode_usb[realnum] != ReqMode) \
return USER_ERROR(TMK_BAD_FUNC); \
}
#else
#define CHECK_TMK_MODE(num, ReqMode)
#endif
#ifndef NOCHECK
#define CHECK_TMK_MODE_L(num, ReqMode) { \
if ((__tmkMode_usb[realnum] & 0x00FF) != ReqMode) \
return USER_ERROR(TMK_BAD_FUNC); \
}
#else
#define CHECK_TMK_MODE_L(num, ReqMode)
#endif
#ifndef NOCHECK
#define CHECK_TMK_MODE_LN(num, ReqMode) { \
if ((__tmkMode_usb[realnum] & 0x00FF) != ReqMode) \
{ \
USER_ERROR(TMK_BAD_FUNC); \
return; \
} \
}
#else
#define CHECK_TMK_MODE_LN(num, ReqMode)
#endif
#ifndef NOCHECK
#define CHECK_IRQ(irq)
#else
#define CHECK_IRQ(irq)
#endif
#ifndef NOCHECK
#define CHECK_TMK_TYPE_1(type) { \
if ((unsigned)(type) < TMK_MIN_TYPE || (unsigned)(type) > TMK_MAX_TYPE) \
return USER_ERROR_R(TMK_BAD_TYPE); \
}
#else
#define CHECK_TMK_TYPE_1(type)
#endif
#ifndef NOCHECK
#define CHECK_TMK_TYPE_2(type) { \
if ((unsigned)(type) > DRV_MAX_TYPE) \
return USER_ERROR_R(TMK_BAD_TYPE); \
}
#else
#define CHECK_TMK_TYPE_2(type)
#endif
#define CHECK_TMK_TYPE(type)
#define CHECK_BC_BASE_BX(num, base) { \
if (base > __bcMaxBase_usb[num]) \
return USER_ERROR(BC_BAD_BASE); \
}
#define CHECK_BCMT_BASE_BX(num, base) { \
if ((__tmkMode_usb[num] == BC_MODE && base > __bcMaxBase_usb[num]) || \
(__tmkMode_usb[num] != BC_MODE && base > __mtMaxBase_usb[num])) \
return USER_ERROR(BC_BAD_BASE); \
}
#define CHECK_BC_ADDR(addr) { addr &= 0x3F; }
#define CHECK_BC_LEN(len) { \
if (len > 64) \
{ \
USER_ERROR(BC_BAD_LEN); \
return; \
} \
}
#define CHECK_BC_BUS(bus) { bus &= 1; }
#define CHECK_BC_CTRL(ctrl) { ctrl &= 0xF; }
#define CHECK_BC_CTRLX(ctrlx) { ctrlx &= 0x803F; }
#define CHECK_MT_CTRLX(ctrlx) { ctrlx &= 0x8030; }
#define CHECK_RT_DIR(dir) { dir &= 0x0400; }
#define CHECK_RT_SUBADDR(sa) { sa &= 0x1F; }
#define CHECK_RT_SUBPOS(pos) { pos &= 0x1F; }
#define CHECK_RT_LEN(len) { \
if (len > 32) \
{ \
USER_ERROR(RT_BAD_LEN); \
return; \
} \
}
#define CHECK_RT_PAGE_BX(num, page) { \
if (page > __rtMaxPage_usb[num]) \
return USER_ERROR(RT_BAD_PAGE); \
}
#define CHECK_RT_ADDRESS(addr) { \
if (addr > 0x1E) \
return USER_ERROR(RT_BAD_ADDRESS); \
}
#define CHECK_RT_CMD(cmd) { cmd &= 0x041F; }
void MyUserErrors_usb(unsigned err)
{
#ifdef STATIC_TMKNUM
tmkError_usb = err;
tmkUserErrors_usb();
#endif
}
/*unsigned inpb_d(int num, unsigned port)
{
unsigned t;
unsigned data;
data = inpb(port);
t = __wInDelay[num];
while (--t);
return data;
}
unsigned inpw_d(int num, unsigned port)
{
unsigned t;
unsigned data;
data = inpw(port);
t = __wInDelay[num];
while (--t);
return data;
}
void outpb_d(int num, unsigned port, unsigned data)
{
unsigned t;
outpb(port, data);
t = __wOutDelay[num];
while (--t);
return;
}
void outpw_d(int num, unsigned port, unsigned data)
{
unsigned t;
outpw(port, data);
t = __wOutDelay[num];
while (--t);
return;
}
#define REP_OUTSWB_D { \
do \
{ \
unsigned data; \
data = *(buf++); \
++port; \
GET_DIS_IRQ(); \
outpb(port, data >> 8);\
--port; \
outpb_d(realnum, port, data); \
++__tmkRAMAddr[realnum]; \
REST_IRQ(); \
} \
while (--len != 0); \
}
#define REP_INSW { \
do \
{ \
GET_DIS_IRQ(); \
*(buf++) = inpw(port); \
++__tmkRAMAddr[realnum]; \
REST_IRQ(); \
} \
while (--len != 0); \
}
#define REP_OUTSW { \
do \
{ \
GET_DIS_IRQ(); \
outpw(port, *(buf++)); \
++__tmkRAMAddr[realnum]; \
REST_IRQ(); \
} \
while (--len != 0); \
}
// can be macro only because of --port !
#define outpwb_d(num, port, data) { \
GET_DIS_IRQ(); \
outpb(port, (data) >> 8); \
--port; \
outpb_d(num, port, data); \
REST_IRQ(); \
}
//the function always works as ifndef RAMwoCLI
#define REP_INSW_D { \
do \
{ \
int t; \
GET_DIS_IRQ(); \
*(buf++) = inpw(port); \
++__tmkRAMAddr[realnum]; \
REST_IRQ(); \
t = __wInDelay[realnum]; \
while (--t); \
} \
while (--len != 0); \
}
//the function always works as ifndef RAMwoCLI
#define REP_OUTSW_D { \
do \
{ \
int t; \
GET_DIS_IRQ(); \
outpw(port, *(buf++)); \
++__tmkRAMAddr[realnum]; \
REST_IRQ(); \
t = __wOutDelay[realnum]; \
while (--t); \
} \
while (--len != 0); \
}*/
void FARIR retfLabel_usb()
{
}
int FARFN tmkdefdac_usb(
#ifndef STATIC_TMKNUM
int __tmkNumber_usb,
#endif
U16 tmkDacValue)
{
int realnum;