-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdd8xx.c
More file actions
1936 lines (1755 loc) · 55 KB
/
dd8xx.c
File metadata and controls
1936 lines (1755 loc) · 55 KB
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-2007, Tom Hunter, Gerard van der Grinten,
** and Paul Koning.
** (see license.txt)
**
** Name: dd8xx.c
**
** Description:
** Perform emulation of CDC 844 and 885 disk drives.
**
**--------------------------------------------------------------------------
*/
#define DEBUG 0
/*
** -------------
** Include Files
** -------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
//#include <unistd.h>
#include <errno.h>
#include "const.h"
#include "types.h"
#include "proto.h"
/*
** -----------------
** Private Constants
** -----------------
*/
#define MAXDDUNITS 64
/*
** CDC 844 and 885 disk drive function and status codes.
*/
#define Fc8xxConnect 00000
#define Fc8xxSeekFull 00001
#define Fc8xxSeekHalf 00002
#define Fc8xxIoLength 00003
#define Fc8xxRead 00004
#define Fc8xxWrite 00005
#define Fc8xxWriteVerify 00006
#define Fc8xxReadCheckword 00007
#define Fc8xxOpComplete 00010
#define Fc8xxDisableReserve 00011
#define Fc8xxGeneralStatus 00012
#define Fc8xxDetailedStatus 00013
#define Fc8xxContinue 00014
#define Fc8xxDropSeeks 00015
#define Fc8xxFormatPack 00016
#define Fc8xxOnSectorStatus 00017
#define Fc8xxDriveRelease 00020
#define Fc8xxReturnCylAddr 00021
#define Fc8xxSetClearFlaw 00022
#define Fc8xxDetailedStatus2 00023
#define Fc8xxGapRead 00024
#define Fc8xxGapWrite 00025
#define Fc8xxGapWriteVerify 00026
#define Fc8xxGapReadCheckword 00027
#define Fc8xxReadFactoryData 00030
#define Fc8xxReadUtilityMap 00031
#define Fc8xxReadFlawedSector 00034
#define Fc8xxWriteLastSector 00035
#define Fc8xxWriteVerifyLastSector 00036
#define Fc8xxWriteFlawedSector 00037
#define Fc8xxManipulateProcessor 00062
#define Fc8xxDeadstart 00300
#define Fc8xxStartMemLoad 00414
/*
**
** General status bits.
**
** 4000 Abnormal termination
** 2000 Dual access coupler reserved
** 1000 Nonrecoverable error
** 0400 Recovery in progress
** 0200 Checkword error
** 0100 Correctable address error
** 0040 Correctable data error
** 0020 DSU malfunction
** 0010 DSU reserved
** 0004 Miscellaneous error
** 0002 Busy
** 0001 Noncorrectable data error
*/
#define St8xxAbnormal 04000
#define St8xxOppositeReserved 02000
#define St8xxNonRecoverable 01000
#define St8xxRecovering 00400
#define St8xxCheckwordError 00200
#define St8xxCorrectableAddress 00100
#define St8xxCorrectableData 00040
#define St8xxDSUmalfunction 00020
#define St8xxDSUreserved 00010
#define St8xxMiscError 00004
#define St8xxBusy 00002
#define St8xxDataError 00001
/*
** Detailed status.
*/
/*
** Physical dimensions of 844 disks.
** 322 12-bit bytes per sector (64 cm wds + 2 bytes). 1st
** byte is unused. 2nd byte contains byte count of data.
** 24 sectors/track
** 19 tracks/cylinder
** 411 cylinders/unit on 844-2 and 844-21
** 823 cylinders/unit on 844-41 and 844-44
*/
#define MaxCylinders844_2 411
#define MaxCylinders844_4 823
#define MaxTracks844 19
#define MaxSectors844 24
#define SectorSize 322
/*
** Address of 844 deadstart sector.
*/
#define DsCylinder844_2 410
#define DsCylinder844_4 822
#define DsTrack844 0
#define DsSector844 3
/*
** Physical dimensions of 885 disk.
** 322 12-bit bytes per sector (64 cm wds + 2 bytes). 1st
** byte is unused. 2nd byte contains byte count of data.
** 32 sectors/track
** 40 tracks/cylinder
** 843 cylinders/unit on 885-11 and 885-12
*/
#define MaxCylinders885_1 843
#define MaxTracks885 40
#define MaxSectors885 32
/*
** Address of 885 deadstart sector.
*/
#define DsCylinder885 841
#define DsTrack885 1
#define DsSector885 30
/*
** Disk drive types.
*/
#define DiskType844 1
#define DiskType885 2
/*
** Disk container types.
*/
#define CtUndefined 0
#define CtClassic 1
#define CtPacked 2
/*
** -----------------------
** Private Macro Functions
** -----------------------
*/
/*
** -----------------------------------------
** Private Typedef and Structure Definitions
** -----------------------------------------
*/
typedef struct diskSize
{
i32 maxCylinders;
i32 maxTracks;
i32 maxSectors;
} DiskSize;
typedef struct diskParam
{
PpWord (*read)(struct diskParam *);
void (*write)(struct diskParam *, PpWord);
DiskIO ioDesc;
i32 sector;
i32 track;
i32 cylinder;
i32 sectorSize;
DiskSize size;
PpWord *bufPtr;
void *statusBuf;
u16 detailedStatus[20];
u8 diskNo;
u8 unitNo;
u8 diskType;
i8 interlace;
bool readonly;
PpWord buffer[SectorSize];
} DiskParam;
/*
** ---------------------------
** Private Function Prototypes
** ---------------------------
*/
static void dd8xxInit(u8 eqNo, u8 unitNo, u8 channelNo, char *deviceName, DiskSize *size, u8 diskType);
static FcStatus dd8xxFunc(PpWord funcCode);
static void dd8xxIo(void);
static void dd8xxActivate(void);
static void dd8xxDisconnect(void);
static void dd8xxSeek(DiskParam *dp);
static void dd8xxSeekNextSector(DiskParam *dp, bool gap);
static PpWord dd8xxReadClassic(DiskParam *dp);
static PpWord dd8xxReadPacked(DiskParam *dp);
static void dd8xxWriteClassic(DiskParam *dp, PpWord data);
static void dd8xxWritePacked(DiskParam *dp, PpWord data);
static void dd8xxSectorWrite(DiskParam *dp, PpWord *sector);
static void dd844SetClearFlaw(DiskParam *dp, PpWord flawState);
#if DEBUG
static char *dd8xxFunc2String(PpWord funcCode);
#endif
static void dd8xxLoad(DevSlot *dp, int unitNo, char *fn);
/*
** ----------------
** Public Variables
** ----------------
*/
/*
** -----------------
** Private Variables
** -----------------
*/
static int diskCount = 0;
static PpWord mySector[SectorSize];
static DiskSize sizeDd844_2 = {MaxCylinders844_2, MaxTracks844, MaxSectors844};
static DiskSize sizeDd844_4 = {MaxCylinders844_4, MaxTracks844, MaxSectors844};
static DiskSize sizeDd885_1 = {MaxCylinders885_1, MaxTracks885, MaxSectors885};
#if DEBUG
static FILE *dd8xxLog = NULL;
static int waitcount = 0;
#endif
/*
**--------------------------------------------------------------------------
**
** Public Functions
**
**--------------------------------------------------------------------------
*/
/*--------------------------------------------------------------------------
** Purpose: Initialise disk drive types (844-2, 844-21, 844-41 ,
** 844-42, 885-2 and 885-4).
**
** Parameters: Name Description.
** eqNo equipment number
** unitNo unit number
** channelNo channel number the device is attached to
** deviceName optional device file name
**
** Returns: Nothing.
**
**------------------------------------------------------------------------*/
void dd844Init_2(u8 eqNo, u8 unitNo, u8 channelNo, char *deviceName)
{
dd8xxInit(eqNo, unitNo, channelNo, deviceName, &sizeDd844_2, DiskType844);
}
void dd844Init_4(u8 eqNo, u8 unitNo, u8 channelNo, char *deviceName)
{
dd8xxInit(eqNo, unitNo, channelNo, deviceName, &sizeDd844_4, DiskType844);
}
void dd885Init_1(u8 eqNo, u8 unitNo, u8 channelNo, char *deviceName)
{
dd8xxInit(eqNo, unitNo, channelNo, deviceName, &sizeDd885_1, DiskType885);
}
/*
**--------------------------------------------------------------------------
**
** Private Functions
**
**--------------------------------------------------------------------------
*/
/*--------------------------------------------------------------------------
** Purpose: Initialise specified disk drive.
**
** Parameters: Name Description.
** eqNo equipment number
** unitNo unit number
** channelNo channel number the device is attached to
** deviceName optional device file name
** size pointer to disk size structure
**
** Returns: Nothing.
**
**------------------------------------------------------------------------*/
static void dd8xxInit(u8 eqNo, u8 unitNo, u8 channelNo, char *deviceName, DiskSize *size, u8 diskType)
{
DevSlot *ds;
DiskParam *dp;
DiskParam **dpvec;
time_t mTime;
struct tm tmbuf;
struct tm *lTime;
u8 yy, mm, dd;
u8 containerType = CtPacked;
char *opt = NULL;
(void)eqNo;
#if DEBUG
if (dd8xxLog == NULL)
{
dd8xxLog = fopen("dd8xxlog.txt", "wt");
}
#endif
/*
** Setup channel functions.
*/
ds = channelAttach(channelNo, eqNo, DtDd8xx);
activeDevice = ds;
ds->activate = dd8xxActivate;
ds->disconnect = dd8xxDisconnect;
ds->func = dd8xxFunc;
ds->io = dd8xxIo;
ds->load = dd8xxLoad;
/*
** Save disk parameters.
*/
ds->selectedUnit = unitNo;
dp = (DiskParam *)calloc(1, sizeof(DiskParam));
if (dp == NULL)
{
fprintf(stderr, "Failed to allocate dd8xx context block\n");
exit(1);
}
dp->size = *size;
dp->diskNo = diskCount++;
dp->diskType = diskType;
dp->unitNo = unitNo;
dp->readonly = FALSE;
/*
** Allocate the operator status buffer
*/
dp->statusBuf = opInitStatus ((diskType == DiskType885) ? "DD885" : "DD844",
channelNo, unitNo);
/*
** Determine if any options have been specified.
*/
if (deviceName != NULL)
{
opt = strchr (deviceName, ',');
}
if (opt != NULL)
{
/*
** Process options.
*/
*opt++ = '\0';
if ( strcmp (opt, "old") == 0
|| strcmp (opt, "classic") == 0)
{
containerType = CtClassic;
}
else if ( strcmp (opt, "new") == 0
|| strcmp (opt, "packed") == 0)
{
containerType = CtPacked;
}
else
{
fprintf (stderr, "Unrecognized option name %s\n", opt);
exit (1);
}
}
else
{
/*
** No options specified - use default values.
*/
switch (diskType)
{
case DiskType885:
containerType = CtPacked;
break;
case DiskType844:
containerType = CtClassic;
break;
}
}
opSetStatus (dp->statusBuf, deviceName);
/*
** Setup environment for disk container type.
*/
switch (containerType)
{
case CtClassic:
dp->read = dd8xxReadClassic;
dp->write = dd8xxWriteClassic;
dp->sectorSize = SectorSize * 2;
break;
case CtPacked:
dp->read = dd8xxReadPacked;
dp->write = dd8xxWritePacked;
dp->sectorSize = 512;
break;
}
/*
** Initialize detailed status.
*/
switch (diskType)
{
case DiskType885:
dp->detailedStatus[ 0] = 0; // strobe offset & address error status
dp->detailedStatus[ 1] = 0340; // checkword error status & sector count
dp->detailedStatus[ 2] = 0; // command code & error bits
dp->detailedStatus[ 3] = 07440 + unitNo; // dsu number
dp->detailedStatus[ 4] = 0; // address 1 of failing sector
dp->detailedStatus[ 5] = 0; // address 2 of failing sector
dp->detailedStatus[ 6] = 010; // non recoverable error status
dp->detailedStatus[ 7] = 037; // 11 bit correction factor
dp->detailedStatus[ 8] = 01640; // DSU status
dp->detailedStatus[ 9] = 07201; // DSU fault status
dp->detailedStatus[10] = 0; // DSU interlock status
dp->detailedStatus[11] = 0; // bit address of correctable read error
dp->detailedStatus[12] = 02000; // PP address of correctable read error
dp->detailedStatus[13] = 0; // first word of correction vector
dp->detailedStatus[14] = 0; // second word of correction vector
dp->detailedStatus[15] = 0; // DSC operating status word
dp->detailedStatus[16] = 0; // coupler buffer status
dp->detailedStatus[17] = 0400; // access A is connected & last command
dp->detailedStatus[18] = 0; // last command 2 and 3
dp->detailedStatus[19] = 0; // last command 4
break;
case DiskType844:
dp->detailedStatus[ 0] = 0; // strobe offset & address error status
dp->detailedStatus[ 1] = 0; // checkword error status & sector count
dp->detailedStatus[ 2] = 0; // command code & error bits
dp->detailedStatus[ 3] = 04440 + unitNo; // dsu number
dp->detailedStatus[ 4] = 0; // address 1 of failing sector
dp->detailedStatus[ 5] = 0; // address 2 of failing sector
dp->detailedStatus[ 6] = 010; // non recoverable error status
dp->detailedStatus[ 7] = 0; // 11 bit correction factor
if (size == &sizeDd844_4)
{
dp->detailedStatus[ 8] = 00740; // DSU status, double density
}
else
{
dp->detailedStatus[ 8] = 00700; // DSU status, single density
}
dp->detailedStatus[ 9] = 04001; // DSU fault status
dp->detailedStatus[10] = 07520; // DSU interlock status
dp->detailedStatus[11] = 0; // bit address of correctable read error
dp->detailedStatus[12] = 0; // PP address of correctable read error
dp->detailedStatus[13] = 0; // first word of correction vector
dp->detailedStatus[14] = 0; // second word of correction vector
dp->detailedStatus[15] = 00020; // DSC operating status word
dp->detailedStatus[16] = 0; // coupler buffer status
dp->detailedStatus[17] = 0400; // access A is connected & last command
dp->detailedStatus[18] = 0; // last command 2 and 3
dp->detailedStatus[19] = 0; // last command 4
break;
}
/*
** Link device parameters.
*/
dpvec = (DiskParam **) (ds->context[0]);
if (dpvec == NULL)
{
dpvec = (DiskParam **) malloc (sizeof (DiskParam *) * MAXDDUNITS);
if (dpvec == NULL)
{
fprintf (stderr, "Failed to allocate DiskParam vector");
exit (1);
}
ds->context[0] = dpvec;
}
dpvec[unitNo] = dp;
/*
** Open disk image, if a name is given. Otherwise leave unit unloaded.
*/
if (deviceName != NULL)
{
/*
** Try to open existing disk image.
*/
if (!ddOpen (&dp->ioDesc, deviceName, TRUE))
{
/*
** Disk does not yet exist - manufacture one.
*/
if (!ddCreate (&dp->ioDesc, deviceName))
{
fprintf(stderr, "Failed to open %s\n", deviceName);
exit(1);
}
if (!ddLock (&dp->ioDesc))
{
fprintf (stderr, "Failed to lock %s\n", deviceName);
exit (1);
}
/*
** Write last disk sector to reserve the space.
*/
memset(mySector, 0, SectorSize * 2);
dp->cylinder = size->maxCylinders - 1;
dp->track = size->maxTracks - 1;
dp->sector = size->maxSectors - 1;
dd8xxSeek(dp);
dd8xxSectorWrite(dp, mySector);
/*
** Position to cylinder with the disk's factory and utility
** data areas.
*/
switch (diskType)
{
case DiskType885:
dp->cylinder = size->maxCylinders - 2;
break;
case DiskType844:
dp->cylinder = size->maxCylinders - 1;
break;
}
/*
** Zero entire cylinder containing factory and utility data areas.
*/
memset(mySector, 0, SectorSize * 2);
for (dp->track = 0; dp->track < size->maxTracks; dp->track++)
{
for (dp->sector = 0; dp->sector < size->maxSectors; dp->sector++)
{
dd8xxSeek(dp);
dd8xxSectorWrite(dp, mySector);
}
}
/*
** Write serial number and date of manufacture.
*/
mySector[0] = (channelNo & 070) << (8 - 3);
mySector[0] |= (channelNo & 007) << (4 - 0);
mySector[0] |= (unitNo & 070) >> (3 - 0);
mySector[1] = (unitNo & 007) << (8 - 0);
mySector[1] |= (diskType & 070) << (4 - 3);
mySector[1] |= (diskType & 007) << (0 - 0);
time(&mTime);
lTime = localtime_r(&mTime, &tmbuf);
yy = lTime->tm_year % 100;
mm = lTime->tm_mon + 1;
dd = lTime->tm_mday;
mySector[2] = (dd / 10) << 8 | (dd % 10) << 4 | mm / 10;
mySector[3] = (mm % 10) << 8 | (yy / 10) << 4 | yy % 10;
dp->track = 0;
dp->sector = 0;
dd8xxSeek(dp);
dd8xxSectorWrite(dp, mySector);
}
else
{
if (!ddLock (&dp->ioDesc))
{
fprintf (stderr, "Failed to lock %s\n", deviceName);
exit (1);
}
}
/*
** Reset disk seek position.
*/
dp->cylinder = 0;
dp->track = 0;
dp->sector = 0;
dp->interlace = 1;
dd8xxSeek(dp);
}
/*
** Print a friendly message.
*/
printf("Disk with %d cylinders initialised on channel %o unit %o\n",
dp->size.maxCylinders, channelNo, unitNo);
}
/*--------------------------------------------------------------------------
** Purpose: Execute function code on 8xx disk drive.
**
** Parameters: Name Description.
** funcCode function code
**
** Returns: FcStatus
**
**------------------------------------------------------------------------*/
static FcStatus dd8xxFunc(PpWord funcCode)
{
i8 unitNo;
DiskParam *dp;
bool opened;
unitNo = activeDevice->selectedUnit;
if (unitNo != -1)
{
dp = ((DiskParam **) (activeDevice->context[0]))[unitNo];
opened = ddOpened (&dp->ioDesc);
}
else
{
dp = NULL;
opened = FALSE;
}
/*
** Decline functions for units which are not configured.
*/
if (!opened)
{
//// return(FcDeclined); <<<< fix this properly as in mt679.c
}
/*
** Deal with deadstart function.
*/
if ((funcCode & 0700) == Fc8xxDeadstart )
{
funcCode = Fc8xxDeadstart;
activeDevice->selectedUnit = funcCode & 077;
unitNo = activeDevice->selectedUnit;
dp = ((DiskParam **) (activeDevice->context[0]))[unitNo];
opened = ddOpened (&dp->ioDesc);
}
#if DEBUG
if (dp != NULL)
{
fprintf(dd8xxLog, "\n%06d PP:%02o CH:%02o DSK:%o f:%04o T:%-25s c:%3d t:%2d s:%2d > ",
traceSequenceNo,
activePpu->id,
activeDevice->channel->id,
dp->diskNo,
funcCode,
dd8xxFunc2String(funcCode),
dp->cylinder,
dp->track,
dp->sector);
}
else
{
fprintf(dd8xxLog, "\n%06d PP:%02o CH:%02o DSK:? f:%04o T:%-25s > ",
traceSequenceNo,
activePpu->id,
activeDevice->channel->id,
funcCode,
dd8xxFunc2String(funcCode));
}
fflush(dd8xxLog);
#endif
/*
** Process function request.
*/
switch (funcCode)
{
default:
#if DEBUG
fprintf(dd8xxLog, " !!!!!FUNC not implemented & declined!!!!!! ");
#endif
return(FcDeclined);
case Fc8xxConnect:
/*
** Expect drive number.
*/
activeDevice->recordLength = 1;
break;
case Fc8xxSeekFull:
if (dp == NULL)
{
return(FcDeclined);
}
/*
** Expect drive number, cylinder, track and sector.
*/
dp->interlace = 1;
activeDevice->recordLength = 4;
break;
case Fc8xxSeekHalf:
if (dp == NULL)
{
return(FcDeclined);
}
/*
** Expect drive number, cylinder, track and sector.
*/
dp->interlace = 2;
activeDevice->recordLength = 4;
break;
case Fc8xxRead:
case Fc8xxReadFlawedSector:
activeDevice->recordLength = SectorSize;
dp->bufPtr = dp->buffer;
ddQueueRead (&dp->ioDesc, dp->buffer, dp->sectorSize);
break;
case Fc8xxWrite:
case Fc8xxWriteFlawedSector:
case Fc8xxWriteLastSector:
case Fc8xxWriteVerify:
activeDevice->recordLength = SectorSize;
break;
case Fc8xxReadCheckword:
activeDevice->recordLength = 2;
break;
case Fc8xxOpComplete:
case Fc8xxDropSeeks:
return(FcProcessed);
case Fc8xxGeneralStatus:
activeDevice->recordLength = 1;
break;
case Fc8xxDetailedStatus:
case Fc8xxDetailedStatus2:
dp->detailedStatus[2] = (funcCode << 4) & 07760;
switch (dp->diskType)
{
case DiskType885:
dp->detailedStatus[4] = (dp->cylinder >> 4) & 077;
dp->detailedStatus[5] = ((dp->cylinder << 8) | dp->track) & 07777;
dp->detailedStatus[6] = (dp->sector << 4) | 010;
if ((dp->track & 1) != 0)
{
dp->detailedStatus[9] |= 2; /* odd track */
}
else
{
dp->detailedStatus[9] &= ~2;
}
break;
case DiskType844:
dp->detailedStatus[4] = ((dp->cylinder & 0777) << 3) | ((dp->track >> 2) & 07);
dp->detailedStatus[5] = ((dp->track & 03) << 10) | ((dp->sector & 017) << 5) | ((dp->cylinder >> 9) & 01);
dp->detailedStatus[6] = (dp->sector << 4) | 010;
break;
}
if (funcCode == Fc8xxDetailedStatus)
{
activeDevice->recordLength = 12;
}
else
{
activeDevice->recordLength = 20;
}
break;
case Fc8xxStartMemLoad:
break;
case Fc8xxReadUtilityMap:
case Fc8xxReadFactoryData:
activeDevice->recordLength = SectorSize;
break;
case Fc8xxDriveRelease:
return(FcProcessed);
case Fc8xxDeadstart:
switch (dp->diskType)
{
case DiskType844:
if (dp->size.maxCylinders == MaxCylinders844_2)
{
dp->cylinder = DsCylinder844_2;
}
else
{
dp->cylinder = DsCylinder844_4;
}
dp->track = DsTrack844;
dp->sector = DsSector844;
break;
case DiskType885:
dp->cylinder = DsCylinder885;
dp->track = DsTrack885;
dp->sector = DsSector885;
break;
}
dd8xxSeek(dp);
activeDevice->recordLength = SectorSize;
break;
case Fc8xxSetClearFlaw:
if (dp->diskType != DiskType844)
{
return(FcDeclined);
}
activeDevice->recordLength = 1;
break;
case Fc8xxFormatPack:
if (dp->size.maxTracks == MaxTracks844) // use diskType instead?
{
activeDevice->recordLength = 7;
}
else
{
activeDevice->recordLength = 18;
}
break;
case Fc8xxManipulateProcessor:
activeDevice->recordLength = 5;
break;
case Fc8xxIoLength:
case Fc8xxDisableReserve:
case Fc8xxContinue:
case Fc8xxOnSectorStatus:
case Fc8xxReturnCylAddr:
case Fc8xxGapRead:
case Fc8xxGapWrite:
case Fc8xxGapWriteVerify:
case Fc8xxGapReadCheckword:
#if DEBUG
fprintf(dd8xxLog, " !!!!!FUNC not implemented but accepted!!!!!! ");
#endif
logError(LogErrorLocation, "ch %o, function %04o not implemented\n", activeChannel->id, funcCode);
break;
}
activeDevice->fcode = funcCode;
#if DEBUG
fflush(dd8xxLog);
#endif
return(FcAccepted);
}
/*--------------------------------------------------------------------------
** Purpose: Perform I/O on 8xx disk drive.
**
** Parameters: Name Description.
**
** Returns: Nothing.
**
**------------------------------------------------------------------------*/
static void dd8xxIo(void)
{
i8 unitNo;
DiskParam *dp;
unitNo = activeDevice->selectedUnit;
if (unitNo != -1)
{
dp = ((DiskParam **) (activeDevice->context[0]))[unitNo];
}
else
{
dp = NULL;
}
switch (activeDevice->fcode)
{
case Fc8xxConnect:
if (activeChannel->full)
{
unitNo = activeChannel->data & 077;
if (unitNo != activeDevice->selectedUnit)
{
dp = ((DiskParam **) (activeDevice->context[0]))[unitNo];
if (dp != NULL && ddOpened (&dp->ioDesc))
{
activeDevice->selectedUnit = unitNo;
activeDevice->status = 0;
dp->detailedStatus[12] &= ~01000;
}
else
{
activeDevice->selectedUnit = -1;
activeDevice->status = 05020;
}
}
else
{
dp->detailedStatus[12] |= 01000;
}
activeChannel->full = FALSE;
}
break;
case Fc8xxSeekFull:
case Fc8xxSeekHalf:
if (activeChannel->full)
{
switch (activeDevice->recordLength--)
{
case 4:
unitNo = activeChannel->data & 077;
if (unitNo != activeDevice->selectedUnit)
{
dp = ((DiskParam **) (activeDevice->context[0]))[unitNo];
if (dp != NULL && ddOpened (&dp->ioDesc))
{
activeDevice->selectedUnit = unitNo;
dp->detailedStatus[12] &= ~01000;
}
else
{
activeDevice->selectedUnit = -1;
}
}
else
{
dp->detailedStatus[12] |= 01000;
}
break;
case 3:
if (dp != NULL)
{
dp->cylinder = activeChannel->data;
}
break;
case 2:
if (dp != NULL)
{
dp->track = activeChannel->data;
}
break;
case 1:
if (dp != NULL)
{
dp->sector = activeChannel->data;
dd8xxSeek(dp);
}
else
{
activeDevice->status = 05020;
}
break;
default:
activeDevice->recordLength = 0;
break;
}
#if DEBUG
fprintf(dd8xxLog, " %04o[%d]", activeChannel->data, activeChannel->data);