-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmt669.c
2830 lines (2501 loc) · 78.8 KB
/
mt669.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
/*--------------------------------------------------------------------------
**
** Copyright (c) 2003-2011, Tom Hunter
**
** Name: mt669.c
**
** Description:
** Perform emulation of CDC 6600 669 tape drives attached to a
** 7021-21 magnetic tape controller.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License version 3 as
** published by the Free Software Foundation.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License version 3 for more details.
**
** You should have received a copy of the GNU General Public License
** version 3 along with this program in file "license-gpl-3.0.txt".
** If not, see <http://www.gnu.org/licenses/gpl-3.0.txt>.
**
**--------------------------------------------------------------------------
*/
#define DEBUG 0
/*
** -------------
** Include Files
** -------------
*/
#include <stdio.h>
#include <stdlib.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include <string.h>
#include "const.h"
#include "types.h"
#include "proto.h"
/*
** -----------------
** Private Constants
** -----------------
*/
/*
** MTS tape function codes:
** ========================
*/
/*
** Setup functions.
*/
#define Fc669FormatUnit 00030
#define Fc669LoadConversion1 00131
#define Fc669LoadConversion2 00231
#define Fc669LoadConversion3 00331
/*
** Unit reserve functions.
*/
#define Fc669Connect 00020
#define Fc669Release 00001
#define Fc669ClearReserve 00002
#define Fc669ClearOppositeReserve 00003
/*
** Unit manipulation functions.
*/
#define Fc669Rewind 00010
#define Fc669RewindUnload 00110
#define Fc669SearchTapeMarkF 00015
#define Fc669SearchTapeMarkB 00115
#define Fc669CtrlForespaceFindGap 00214
#define Fc669CtrlBackspaceFindGap 00314
#define Fc669Forespace 00013
#define Fc669Backspace 00113
#define Fc669WriteTapeMark 00051
#define Fc669EraseToEOT 00152
#define Fc669CtrledForespace 00014
#define Fc669CtrledBackspace 00114
#define Fc669StopMotion 00011
/*
** Read functions.
*/
#define Fc669ReadFwd 00040
#define Fc669ReadBkw 00140
/*
** Write functions.
*/
#define Fc669Write 00050
#define Fc669WriteOdd12 00150
#define Fc669WriteOdd 00250
/*
** Status functions.
*/
#define Fc669GeneralStatus 00012
#define Fc669DetailedStatus 00112
#define Fc669CumulativeStatus 00212
#define Fc669UnitReadyStatus 00312
/*
** Non-motion read recovery functions.
*/
#define Fc669SetReadClipNorm 00006
#define Fc669SetReadClipHigh 00106
#define Fc669SetReadClipLow 00206
#define Fc669SetReadClipHyper 00306
#define Fc669ReadSprktDlyNorm 00007
#define Fc669ReadSprktDlyIncr 00107
#define Fc669ReadSprktDlyDecr 00207
#define Fc669OppParity 00005
#define Fc669OppDensity 00105
/*
** Read error recovery functions.
*/
#define Fc669LongForespace 00213
#define Fc669LongBackspace 00313
#define Fc669RereadFwd 00041
#define Fc669RereadBkw 00141
#define Fc669ReadBkwOddLenParity 00340
#define Fc669RereadBkwOddLenParity 00341
#define Fc669RepeatRead 00042
/*
** Write error recovery functions.
*/
#define Fc669Erase 00052
#define Fc669WriteRepos 00017
#define Fc669WriteEraseRepos 00117
#define Fc669WriteReposiCtrl 00217
#define Fc669WriteEraseReposCtrl 00317
#define Fc669EraseRepos 00016
#define Fc669EraseEraseRepos 00116
/*
** Diagnostic functions.
*/
#define Fc669LoadReadRam 00132
#define Fc669LoadWriteRam 00232
#define Fc669LoadReadWriteRam 00332
#define Fc669CopyReadRam 00133
#define Fc669CopyWriteRam 00233
#define Fc669FormatTcuUnitStatus 00034
#define Fc669CopyTcuStatus 00035
#define Fc669SendTcuCmd 00036
#define Fc669SetQuartReadSprktDly 00037
/*
** Undocumented functions.
*/
#define Fc669ConnectRewindRead 00260
#define Fc669MasterClear 00414
#define Fc669ClearUnit 00000
/*
** General status reply:
** =====================
*/
#define St669Alert 04000
#define St669NoUnit 01000
#define St669WriteEnabled 00200
#define St669NineTrack 00100
#define St669OddCount 00040
#define St669TapeMark 00020
#define St669EOT 00010
#define St669BOT 00004
#define St669Busy 00002
#define St669Ready 00001
/*
** Detailed status error codes:
** ============================
*/
#define EcIllegalUnit 001
#define EcUnitNotReady 004
#define EcMissingRing 006
#define EcBlankTape 010
#define EcStopMotion 011 // alert bit not set
#define EcBackPastLoadpoint 030
#define EcIllegalFunction 050
#define EcNoFuncParams 052
#define EcMiscUnitError 047
/*
** Misc constants.
*/
#define MaxPpBuf 40000
#define MaxByteBuf 60000
#define MaxPackedConvBuf (((256 * 8) + 11) / 12)
#define MaxTapeSize 1250000000 // this may need adjusting for shorter real tapes
/*
** -----------------------
** Private Macro Functions
** -----------------------
*/
/*
** -----------------------------------------
** Private Typedef and Structure Definitions
** -----------------------------------------
*/
/*
** MTS controller.
*/
typedef struct ctrlParam
{
FILE *convFileHandle;
u8 readConv[3][256];
u8 writeConv[3][256];
PpWord deviceStatus[9]; // first element not used
PpWord excludedUnits;
bool writing;
} CtrlParam;
/*
** MTS tape unit.
*/
typedef struct tapeParam
{
/*
** Info for show_tape operator command.
*/
struct tapeParam * nextTape;
u8 channelNo;
u8 eqNo;
u8 unitNo;
char fileName[_MAX_PATH + 1];
/*
** Format parameters.
*/
u8 selectedConversion;
bool packedMode;
u8 assemblyMode;
u8 density;
u8 minBlockLength;
/*
** Tape status variables.
*/
bool alert;
bool endOfTape;
bool fileMark;
bool unitReady;
bool ringIn;
bool oddCount;
bool flagBitDetected;
bool rewinding;
bool suppressBot;
u32 rewindStart;
u16 blockCrc;
u8 errorCode;
u32 blockNo;
/*
** I/O buffer.
*/
PpWord frameCount;
PpWord recordLength;
PpWord ioBuffer[MaxPpBuf];
PpWord *bp;
} TapeParam;
/*
** ---------------------------
** Private Function Prototypes
** ---------------------------
*/
static void mt669ResetStatus(TapeParam *tp);
static void mt669SetupGeneralStatus(TapeParam *tp);
static void mt669SetupDetailedStatus(TapeParam *tp);
static void mt669SetupCumulativeStatus(TapeParam *tp);
static void mt669SetupUnitReadyStatus(void);
static FcStatus mt669Func(PpWord funcCode);
static void mt669Io(void);
static void mt669Activate(void);
static void mt669Disconnect(void);
static void mt669PackAndConvert(u32 recLen);
static void mt669FuncRead(void);
static void mt669FuncForespace(void);
static void mt669FuncBackspace(void);
static void mt669FuncReadBkw(void);
static char *mt669Func2String(PpWord funcCode);
/*
** ----------------
** Public Variables
** ----------------
*/
/*
** -----------------
** Private Variables
** -----------------
*/
static TapeParam *firstTape = NULL;
static TapeParam *lastTape = NULL;
static u8 rawBuffer[MaxByteBuf];
#if DEBUG
static FILE *mt669Log = NULL;
#endif
/*
**--------------------------------------------------------------------------
**
** Public Functions
**
**--------------------------------------------------------------------------
*/
/*--------------------------------------------------------------------------
** Purpose: Initialise 669 tape drives.
**
** Parameters: Name Description.
** eqNo equipment number
** unitNo number of the unit to initialise
** channelNo channel number the device is attached to
** deviceName optional device file name
**
** Returns: Nothing.
**
**------------------------------------------------------------------------*/
void mt669Init(u8 eqNo, u8 unitNo, u8 channelNo, char *deviceName)
{
DevSlot *dp;
FILE *fcb;
TapeParam *tp;
(void)eqNo;
#if DEBUG
if (mt669Log == NULL)
{
mt669Log = fopen("mt669log.txt", "wt");
}
#endif
/*
** Attach device to channel.
*/
dp = channelAttach(channelNo, eqNo, DtMt669);
/*
** Setup channel functions.
*/
dp->activate = mt669Activate;
dp->disconnect = mt669Disconnect;
dp->func = mt669Func;
dp->io = mt669Io;
dp->selectedUnit = -1;
/*
** Setup controller context.
*/
if (dp->controllerContext == NULL)
{
dp->controllerContext = calloc(1, sizeof(CtrlParam));
/*
** Optionally read in persistent conversion tables.
*/
if (*persistDir != '\0')
{
CtrlParam *cp = dp->controllerContext;
char fileName[256];
/*
** Try to open existing backing file.
*/
sprintf(fileName, "%s/mt669StoreC%02oE%02o", persistDir, channelNo, eqNo);
cp->convFileHandle = fopen(fileName, "r+b");
if (cp->convFileHandle != NULL)
{
/*
** Read conversion table contents.
*/
if ( fread(cp->writeConv, 1, sizeof(cp->writeConv), cp->convFileHandle) != sizeof(cp->writeConv)
|| fread(cp->readConv, 1, sizeof(cp->readConv), cp->convFileHandle) != sizeof(cp->readConv))
{
printf("Unexpected length of MT669 backing file, clearing tables\n");
memset(cp->writeConv, 0, sizeof(cp->writeConv));
memset(cp->readConv, 0, sizeof(cp->readConv));
}
}
else
{
/*
** Create a new file.
*/
cp->convFileHandle = fopen(fileName, "w+b");
if (cp->convFileHandle == NULL)
{
fprintf(stderr, "Failed to create MT669 backing file\n");
exit(1);
}
}
}
}
/*
** Setup tape unit parameter block.
*/
tp = calloc(1, sizeof(TapeParam));
if (tp == NULL)
{
fprintf(stderr, "Failed to allocate MT669 context block\n");
exit(1);
}
dp->context[unitNo] = tp;
/*
** Link into list of tape units.
*/
if (lastTape == NULL)
{
firstTape = tp;
}
else
{
lastTape->nextTape = tp;
}
lastTape = tp;
/*
** Open TAP container if file name was specified.
*/
if (deviceName != NULL)
{
strncpy(tp->fileName, deviceName, _MAX_PATH);
fcb = fopen(deviceName, "rb");
if (fcb == NULL)
{
fprintf(stderr, "Failed to open %s\n", deviceName);
exit(1);
}
dp->fcb[unitNo] = fcb;
tp->blockNo = 0;
tp->unitReady = TRUE;
}
else
{
dp->fcb[unitNo] = NULL;
tp->unitReady = FALSE;
}
/*
** Setup show_tape values.
*/
tp->channelNo = channelNo;
tp->eqNo = eqNo;
tp->unitNo = unitNo;
/*
** All initially mounted tapes are read only.
*/
tp->ringIn = FALSE;
/*
** Print a friendly message.
*/
printf("MT669 initialised on channel %o equipment %o unit %o\n", channelNo, eqNo, unitNo);
}
/*--------------------------------------------------------------------------
** Purpose: Optionally persist conversion tables.
**
** Parameters: Name Description.
** dp Device pointer.
**
** Returns: Nothing.
**
**------------------------------------------------------------------------*/
void mt669Terminate(DevSlot *dp)
{
CtrlParam *cp = dp->controllerContext;
/*
** Optionally save conversion tables.
*/
if (cp->convFileHandle != NULL)
{
fseek(cp->convFileHandle, 0, SEEK_SET);
if ( fwrite(cp->writeConv, 1, sizeof(cp->writeConv), cp->convFileHandle) != sizeof(cp->writeConv)
|| fwrite(cp->readConv, 1, sizeof(cp->readConv), cp->convFileHandle) != sizeof(cp->readConv))
{
fprintf(stderr, "Error writing MT669 backing file\n");
}
fclose(cp->convFileHandle);
cp->convFileHandle = NULL;
}
}
/*--------------------------------------------------------------------------
** Purpose: Load a new tape (operator interface).
**
** Parameters: Name Description.
** params parameters
**
** Returns: Nothing.
**
**------------------------------------------------------------------------*/
void mt669LoadTape(char *params)
{
static char str[200];
DevSlot *dp;
int numParam;
int channelNo;
int equipmentNo;
int unitNo;
TapeParam *tp;
FILE *fcb;
u8 unitMode;
/*
** Operator inserted a new tape.
*/
numParam = sscanf(params,"%o,%o,%o,%c,%s",&channelNo, &equipmentNo, &unitNo, &unitMode, str);
/*
** Check parameters.
*/
if (numParam != 5)
{
printf("Not enough or invalid parameters\n");
return;
}
if (channelNo < 0 || channelNo >= MaxChannels)
{
printf("Invalid channel no\n");
return;
}
if (unitNo < 0 || unitNo >= MaxUnits)
{
printf("Invalid unit no\n");
return;
}
if (unitMode != 'w' && unitMode != 'r')
{
printf("Invalid ring mode (r/w)\n");
return;
}
if (str[0] == 0)
{
printf("Invalid file name\n");
return;
}
/*
** Locate the device control block.
*/
dp = channelFindDevice((u8)channelNo, DtMt669);
if (dp == NULL)
{
return;
}
/*
** Check if the unit is even configured.
*/
tp = (TapeParam *)dp->context[unitNo];
if (tp == NULL)
{
printf("Unit %d not allocated\n", unitNo);
return;
}
/*
** Check if the unit has been unloaded.
*/
if (dp->fcb[unitNo] != NULL)
{
printf("Unit %d not unloaded\n", unitNo);
return;
}
/*
** Open the file in the requested mode.
*/
if (unitMode == 'w')
{
fcb = fopen(str, "r+b");
if (fcb == NULL)
{
fcb = fopen(str, "w+b");
}
}
else
{
fcb = fopen(str, "rb");
}
dp->fcb[unitNo] = fcb;
/*
** Check if the open succeeded.
*/
if (fcb == NULL)
{
printf("Failed to open %s\n", str);
return;
}
/*
** Setup show_tape path name.
*/
strncpy(tp->fileName, str, _MAX_PATH);
/*
** Setup status.
*/
mt669ResetStatus(tp);
tp->ringIn = unitMode == 'w';
tp->blockNo = 0;
tp->unitReady = TRUE;
printf("Successfully loaded %s\n", str);
}
/*--------------------------------------------------------------------------
** Purpose: Unload a mounted tape (operator interface).
**
** Parameters: Name Description.
** params parameters
**
** Returns: Nothing.
**
**------------------------------------------------------------------------*/
void mt669UnloadTape(char *params)
{
DevSlot *dp;
int numParam;
int channelNo;
int equipmentNo;
int unitNo;
TapeParam *tp;
/*
** Operator inserted a new tape.
*/
numParam = sscanf(params,"%o,%o,%o",&channelNo, &equipmentNo, &unitNo);
/*
** Check parameters.
*/
if (numParam != 3)
{
printf("Not enough or invalid parameters\n");
return;
}
if (channelNo < 0 || channelNo >= MaxChannels)
{
printf("Invalid channel no\n");
return;
}
if (unitNo < 0 || unitNo >= MaxUnits2)
{
printf("Invalid unit no\n");
return;
}
/*
** Locate the device control block.
*/
dp = channelFindDevice((u8)channelNo, DtMt669);
if (dp == NULL)
{
return;
}
/*
** Check if the unit is even configured.
*/
tp = (TapeParam *)dp->context[unitNo];
if (tp == NULL)
{
printf("Unit %d not allocated\n", unitNo);
return;
}
/*
** Check if the unit has been unloaded.
*/
if (dp->fcb[unitNo] == NULL)
{
printf("Unit %d not loaded\n", unitNo);
return;
}
/*
** Close the file.
*/
fclose(dp->fcb[unitNo]);
dp->fcb[unitNo] = NULL;
/*
** Clear show_tape path name.
*/
memset(tp->fileName, '0', _MAX_PATH);
/*
** Setup status.
*/
mt669ResetStatus(tp);
tp->unitReady = FALSE;
tp->ringIn = FALSE;
tp->rewinding = FALSE;
tp->rewindStart = 0;
tp->blockCrc = 0;
tp->blockNo = 0;
printf("Successfully unloaded MT669 on channel %o equipment %o unit %o\n", channelNo, equipmentNo, unitNo);
}
/*--------------------------------------------------------------------------
** Purpose: Show tape status (operator interface).
**
** Parameters: Name Description.
**
**
** Returns: Nothing.
**
**------------------------------------------------------------------------*/
void mt669ShowTapeStatus(void)
{
TapeParam *tp = firstTape;
while (tp)
{
printf("MT669 on %o,%o,%o", tp->channelNo, tp->eqNo, tp->unitNo);
if (tp->unitReady)
{
printf(",%c,%s\n", tp->ringIn ? 'w' : 'r', tp->fileName);
}
else
{
printf(" (idle)\n");
}
tp = tp->nextTape;
}
}
/*
**--------------------------------------------------------------------------
**
** Private Functions
**
**--------------------------------------------------------------------------
*/
/*--------------------------------------------------------------------------
** Purpose: Reset device status at start of new function.
**
** Parameters: Name Description.
** tp pointer to tape parameters
**
** Returns: Nothing
**
**------------------------------------------------------------------------*/
static void mt669ResetStatus(TapeParam *tp)
{
if (tp != NULL)
{
tp->alert = FALSE;
tp->endOfTape = FALSE;
tp->fileMark = FALSE;
tp->oddCount = FALSE;
tp->flagBitDetected = FALSE;
tp->suppressBot = FALSE;
tp->errorCode = 0;
}
}
/*--------------------------------------------------------------------------
** Purpose: Setup general status based on current tape parameters.
**
** Parameters: Name Description.
** tp pointer to tape parameters
**
** Returns: Nothing
**
**------------------------------------------------------------------------*/
static void mt669SetupGeneralStatus(TapeParam *tp)
{
CtrlParam *cp = activeDevice->controllerContext;
if (tp == NULL)
{
cp->deviceStatus[1] = St669NineTrack;
cp->deviceStatus[2] = 0;
return;
}
cp->deviceStatus[1] = St669NineTrack;
if (tp->alert)
{
cp->deviceStatus[1] |= St669Alert;
}
if (tp->ringIn)
{
cp->deviceStatus[1] |= St669WriteEnabled;
}
if (tp->oddCount)
{
cp->deviceStatus[1] |= St669OddCount;
}
if (tp->fileMark)
{
cp->deviceStatus[1] |= St669TapeMark;
}
if (tp->endOfTape)
{
cp->deviceStatus[1] |= St669EOT;
}
if (tp->rewinding)
{
cp->deviceStatus[1] |= St669Busy;
if (labs(cycles - tp->rewindStart) > 1000)
{
tp->rewinding = FALSE;
tp->blockNo = 0;
}
}
else
{
if (tp->blockNo == 0 && !tp->suppressBot)
{
cp->deviceStatus[1] |= St669BOT;
}
if (tp->unitReady)
{
cp->deviceStatus[1] |= St669Ready;
if (ftell(activeDevice->fcb[activeDevice->selectedUnit]) > MaxTapeSize)
{
cp->deviceStatus[1] |= St669EOT;
}
}
}
cp->deviceStatus[2] = (tp->blockCrc & Mask9) << 3;
}
/*--------------------------------------------------------------------------
** Purpose: Setup detailed status based on current tape parameters.
**
** Parameters: Name Description.
** tp pointer to tape parameters
**
** Returns: Nothing
**
**------------------------------------------------------------------------*/
static void mt669SetupDetailedStatus(TapeParam *tp)
{
CtrlParam *cp = activeDevice->controllerContext;
if (tp == NULL)
{
cp->deviceStatus[1] = 0;
cp->deviceStatus[2] = 0;
cp->deviceStatus[3] = 0;
cp->deviceStatus[4] = 0;
cp->deviceStatus[5] = 0;
cp->deviceStatus[6] = 0;
cp->deviceStatus[7] = 0;
cp->deviceStatus[8] = 0;
return;
}
cp->deviceStatus[1] = tp->errorCode;
cp->deviceStatus[2] = 0;
cp->deviceStatus[3] = 0;
if (tp->flagBitDetected)
{
cp->deviceStatus[3] |= 1 << 5;
}
if (tp->oddCount)
{
cp->deviceStatus[3] |= 1 << 10;
}
cp->deviceStatus[4] = 0;
/*
** Report: forward tape motion, speed=100 ips, density=1600 cpi
** and configured unit number.
*/
cp->deviceStatus[5] = 00600 + activeDevice->selectedUnit;
cp->deviceStatus[6] = 0;
/*
** 24 bit last read frame count or zero if last operation was a
** successful write.
*/
cp->deviceStatus[7] = (tp->frameCount >> 12) & Mask12;
cp->deviceStatus[8] = (tp->frameCount >> 0) & Mask12;
}
/*--------------------------------------------------------------------------
** Purpose: Setup cumulative status based on current tape parameters.
**
** Parameters: Name Description.
** tp pointer to tape parameters
**
** Returns: Nothing
**
**------------------------------------------------------------------------*/
static void mt669SetupCumulativeStatus(TapeParam *tp)
{
CtrlParam *cp = activeDevice->controllerContext;
if (tp == NULL)
{
cp->deviceStatus[1] = 0;
cp->deviceStatus[2] = 0;
cp->deviceStatus[3] = 0;
cp->deviceStatus[4] = 0;
cp->deviceStatus[5] = 0;
cp->deviceStatus[6] = 0;
cp->deviceStatus[7] = 0;
cp->deviceStatus[8] = 0;
return;
}
/*
** Report: forward tape motion, speed=100 ips, density=1600 cpi
** and configured unit number.
*/
cp->deviceStatus[1] = 00600 + activeDevice->selectedUnit;
cp->deviceStatus[2] = activeDevice->selectedUnit << 8;
cp->deviceStatus[3] = 0;
cp->deviceStatus[4] = 0;
cp->deviceStatus[5] = 0;
cp->deviceStatus[6] = 0;
cp->deviceStatus[7] = 0;
cp->deviceStatus[8] = 0;
}
/*--------------------------------------------------------------------------
** Purpose: Setup all tape unit's ready status.
**
** Parameters: Name Description.
**
** Returns: Nothing
**
**------------------------------------------------------------------------*/
static void mt669SetupUnitReadyStatus(void)
{
CtrlParam *cp = activeDevice->controllerContext;
TapeParam *tp;
PpWord s = 0;
u8 unitNo;
for (unitNo = 0; unitNo < 8; unitNo++)
{
tp = (TapeParam *)activeDevice->context[unitNo];
if (tp != NULL && tp->unitReady)
{
if (tp->rewinding)
{
/*
** Unit is not ready while rewinding.
*/
if (labs(cycles - tp->rewindStart) > 1000)
{
tp->rewinding = FALSE;
tp->blockNo = 0;
}