This source file includes following definitions.
- selftest_ptwaw
- do_ldbr
- fetch_dsptw
- modify_dsptw
- calc_hit_am
- fetch_sdw_from_sdwam
- fetch_psdw
- fetch_nsdw
- str_sdw
- dump_sdwam
- to_be_discarded_am
- load_sdwam
- fetch_ptw_from_ptwam
- fetch_ptw
- loadPTWAM
- modify_ptw
- do_ptw2
- str_access_type
- str_acv
- str_pct
- do_append_cycle
- APPEND_CYCLE_COPIES
- dbgLookupAddress
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 #include <stdio.h>
31 #include "dps8.h"
32 #include "dps8_sys.h"
33 #include "dps8_iom.h"
34 #include "dps8_cable.h"
35 #include "dps8_cpu.h"
36 #include "dps8_addrmods.h"
37 #include "dps8_faults.h"
38 #include "dps8_scu.h"
39 #include "dps8_append.h"
40 #include "dps8_utils.h"
41 #include "dps8_cache.h"
42 #if defined(THREADZ) || defined(LOCKLESS)
43 # include "threadz.h"
44 #endif
45
46 #define DBG_CTR cpu.cycleCnt
47
48
49
50
51
52 #if defined(TESTING)
53 # define DBG_CTR cpu.cycleCnt
54 # define DBGAPP(...) sim_debug (DBG_APPENDING, & cpu_dev, __VA_ARGS__)
55 #else
56 # define DBGAPP(...)
57 #endif
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 #if defined(TESTING)
116 static char *str_sdw (char * buf, sdw_s *SDW);
117 #endif
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139 #if defined(do_selftestPTWAM)
140 static void selftest_ptwaw (void)
141 {
142 int usages[N_NAX_WAM_ENTRIES];
143 for (int i = 0; i < N_MODEL_WAM_ENTRIES; i ++)
144 usages[i] = -1;
145
146 for (int i = 0; i < N_MODEL_WAM_ENTRIES; i ++)
147 {
148 ptw_s * p = cpu.PTWAM + i;
149 if (p->USE > N_MODEL_WAM_ENTRIES - 1)
150 sim_printf ("PTWAM[%d].USE is %d; > %d!\r\n",
151 i, p->USE, N_MODEL_WAM_ENTRIES - 1);
152 if (usages[p->USE] != -1)
153 sim_printf ("PTWAM[%d].USE is equal to PTWAM[%d].USE; %d\r\n",
154 i, usages[p->USE], p->USE);
155 usages[p->USE] = i;
156 }
157 for (int i = 0; i < N_MODEL_WAM_ENTRIES; i ++)
158 {
159 if (usages[i] == -1)
160 sim_printf ("No PTWAM had a USE of %d\r\n", i);
161 }
162 }
163 #endif
164
165
166
167
168
169 void do_ldbr (cpu_state_t * cpup, word36 * Ypair)
170 {
171 CPTUR (cptUseDSBR);
172 if (cpu.tweaks.enable_wam)
173 {
174 if (cpu.cu.SD_ON)
175 {
176
177
178
179 for (uint i = 0; i < N_MODEL_WAM_ENTRIES; i ++)
180 {
181 cpu.SDWAM[i].FE = 0;
182 L68_ (cpu.SDWAM[i].USE = (word4) i;)
183 DPS8M_ (cpu.SDWAM[i].USE = 0;)
184 }
185 }
186
187 if (cpu.cu.PT_ON)
188 {
189
190
191
192 for (uint i = 0; i < N_MODEL_WAM_ENTRIES; i ++)
193 {
194 cpu.PTWAM[i].FE = 0;
195 L68_ (cpu.PTWAM[i].USE = (word4) i;)
196 DPS8M_ (cpu.PTWAM[i].USE = 0;)
197 }
198 #if defined(do_selftestPTWAM)
199 selftest_ptwaw ();
200 #endif
201 }
202 }
203 else
204 {
205 cpu.SDW0.FE = 0;
206 cpu.SDW0.USE = 0;
207 cpu.PTW0.FE = 0;
208 cpu.PTW0.USE = 0;
209 }
210
211
212 if (cpu.switches.enable_cache && cpu.tweaks.enable_wam) {
213 cacheReset (cpup);
214 }
215
216
217 cpu.DSBR.ADDR = (Ypair[0] >> (35 - 23)) & PAMASK;
218
219
220 cpu.DSBR.BND = (Ypair[1] >> (71 - 50)) & 037777;
221
222
223 cpu.DSBR.U = (Ypair[1] >> (71 - 55)) & 01;
224
225
226 cpu.DSBR.STACK = (Ypair[1] >> (71 - 71)) & 07777;
227 DBGAPP ("ldbr 0 -> SDWAM/PTWAM[*].F, i -> SDWAM/PTWAM[i].USE, "
228 "DSBR.ADDR 0%o, DSBR.BND 0%o, DSBR.U 0%o, DSBR.STACK 0%o\r\n",
229 cpu.DSBR.ADDR, cpu.DSBR.BND, cpu.DSBR.U, cpu.DSBR.STACK);
230 }
231
232
233
234
235
236
237
238 static void fetch_dsptw (cpu_state_t * cpup, word15 segno)
239 {
240 DBGAPP ("%s segno 0%o\r\n", __func__, segno);
241 PNL (L68_ (cpu.apu.state |= apu_FDPT;))
242
243 if (2 * segno >= 16 * (cpu.DSBR.BND + 1))
244 {
245 DBGAPP ("%s ACV15\r\n", __func__);
246
247 PNL (cpu.acvFaults |= ACV15;)
248 PNL (L68_ (cpu.apu.state |= apu_FLT;))
249 doFault (FAULT_ACV, fst_acv15,
250 "acvFault: fetch_dsptw out of segment bounds fault");
251 }
252 set_apu_status (cpup, apuStatus_DSPTW);
253
254
255 word24 x1 = (2u * segno) / 1024u;
256
257 PNL (cpu.lastPTWOffset = segno;)
258 PNL (cpu.lastPTWIsDS = true;)
259
260 word36 PTWx1;
261 core_read (cpup, (cpu.DSBR.ADDR + x1) & PAMASK, & PTWx1, __func__);
262
263 cpu.PTW0.ADDR = GETHI (PTWx1);
264 cpu.PTW0.U = TSTBIT (PTWx1, 9);
265 cpu.PTW0.M = TSTBIT (PTWx1, 6);
266 cpu.PTW0.DF = TSTBIT (PTWx1, 2);
267 cpu.PTW0.FC = PTWx1 & 3;
268
269 L68_ (if (cpu.MR_cache.emr && cpu.MR_cache.ihr)
270 add_l68_APU_history (cpup, APUH_FDSPTW);)
271
272 DBGAPP ("%s x1 0%o DSBR.ADDR 0%o PTWx1 0%012"PRIo64" "
273 "PTW0: ADDR 0%o U %o M %o F %o FC %o\r\n",
274 __func__, x1, cpu.DSBR.ADDR, PTWx1, cpu.PTW0.ADDR, cpu.PTW0.U,
275 cpu.PTW0.M, cpu.PTW0.DF, cpu.PTW0.FC);
276 }
277
278
279
280
281
282
283
284 static void modify_dsptw (cpu_state_t * cpup, word15 segno)
285 {
286 PNL (L68_ (cpu.apu.state |= apu_MDPT;))
287
288 set_apu_status (cpup, apuStatus_MDSPTW);
289
290 word24 x1 = (2u * segno) / 1024u;
291
292 #if defined(THREADZ)
293 bool lck = get_rmw_lock ();
294 if (! lck)
295 lock_rmw ();
296 #endif
297
298 word36 PTWx1;
299 #if defined(LOCKLESS)
300 core_read_lock (cpup, (cpu.DSBR.ADDR + x1) & PAMASK, & PTWx1, __func__);
301 PTWx1 = SETBIT (PTWx1, 9);
302 core_write_unlock (cpup, (cpu.DSBR.ADDR + x1) & PAMASK, PTWx1, __func__);
303 cacheInvalidate (cpup, (cpu.DSBR.ADDR + x1) & PAMASK);
304 #else
305 core_read (cpup, (cpu.DSBR.ADDR + x1) & PAMASK, & PTWx1, __func__);
306 PTWx1 = SETBIT (PTWx1, 9);
307 core_write (cpup, (cpu.DSBR.ADDR + x1) & PAMASK, PTWx1, __func__);
308 cacheInvalidate (cpup, (cpu.DSBR.ADDR + x1) & PAMASK);
309 #endif
310
311 #if defined(THREADZ)
312 if (! lck)
313 unlock_rmw ();
314 #endif
315
316 cpu.PTW0.U = 1;
317 L68_ (if (cpu.MR_cache.emr && cpu.MR_cache.ihr)
318 add_l68_APU_history (cpup, APUH_MDSPTW);)
319 }
320
321
322
323
324 static word6 calc_hit_am (word6 LRU, uint hit_level)
325 {
326 #if defined(TESTING)
327 cpu_state_t * cpup = _cpup;
328 #endif
329 switch (hit_level)
330 {
331 case 0:
332 return (LRU | 070);
333 case 1:
334 return ((LRU & 037) | 06);
335 case 2:
336 return ((LRU & 053) | 01);
337 case 3:
338 return (LRU & 064);
339 default:
340 DBGAPP ("%s: Invalid AM level\r\n", __func__);
341 return 0;
342 }
343 }
344
345 static sdw_s * fetch_sdw_from_sdwam (cpu_state_t * cpup, word15 segno) {
346 DBGAPP ("%s(0):segno=%05o\r\n", __func__, segno);
347
348
349
350 cpu.cu.SDWAMM = 0;
351 cpu.cu.PTWAMM = 0;
352
353 if ((! cpu.tweaks.enable_wam || ! cpu.cu.SD_ON)) {
354 DBGAPP ("%s(0): SDWAM disabled\r\n", __func__);
355 return NULL;
356 }
357
358 if (cpu.tweaks.l68_mode) {
359 int nwam = N_L68_WAM_ENTRIES;
360 for (int _n = 0; _n < nwam; _n++) {
361
362 if (cpu.SDWAM[_n].FE && segno == cpu.SDWAM[_n].POINTER) {
363 DBGAPP ("%s(1):found match for segno %05o " "at _n=%d\r\n", __func__, segno, _n);
364
365 cpu.cu.SDWAMM = 1;
366 cpu.SDWAMR = (word4) _n;
367 cpu.SDW = & cpu.SDWAM[_n];
368
369
370
371
372
373
374
375 for (int _h = 0; _h < nwam; _h++) {
376 if (cpu.SDWAM[_h].USE > cpu.SDW->USE)
377 cpu.SDWAM[_h].USE -= 1;
378 }
379 cpu.SDW->USE = N_L68_WAM_ENTRIES - 1;
380
381 char buf[256];
382 (void)buf;
383 #if defined(TESTING)
384 DBGAPP ("%s(2):SDWAM[%d]=%s\r\n", __func__, _n, str_sdw (buf, cpu.SDW));
385 #endif
386 return cpu.SDW;
387 }
388 }
389 }
390
391 if (! cpu.tweaks.l68_mode) {
392 uint setno = segno & 017;
393 uint toffset;
394 sdw_s *p;
395 for (toffset = 0; toffset < 64; toffset += 16) {
396 p = & cpu.SDWAM[toffset + setno];
397 if (p->FE && segno == p->POINTER) {
398 DBGAPP ("%s(1):found match for segno %05o " "at _n=%d\r\n", __func__, segno, toffset + setno);
399
400 cpu.cu.SDWAMM = 1;
401 cpu.SDWAMR = (word6) (toffset + setno);
402 cpu.SDW = p;
403
404 word6 u = calc_hit_am (p->USE, toffset >> 4);
405 for (toffset = 0; toffset < 64; toffset += 16) {
406 p = & cpu.SDWAM[toffset + setno];
407 p->USE = u;
408 }
409
410 char buf[256];
411 (void)buf;
412 #if defined(TESTING)
413 DBGAPP ("%s(2):SDWAM[%d]=%s\r\n", __func__, toffset + setno, str_sdw (buf, cpu.SDW));
414 #endif
415 return cpu.SDW;
416 }
417 }
418 }
419 #if defined(TESTING)
420 DBGAPP ("%s(3):SDW for segment %05o not found in SDWAM\r\n", __func__, segno);
421 #endif
422 cpu.cu.SDWAMM = 0;
423 return NULL;
424 }
425
426
427
428
429
430
431 static void fetch_psdw (cpu_state_t * cpup, word15 segno)
432 {
433 DBGAPP ("%s(0):segno=%05o\r\n",
434 __func__, segno);
435
436 PNL (L68_ (cpu.apu.state |= apu_FSDP;))
437
438 cpu.cu.SDWAMM = 0;
439 cpu.cu.PTWAMM = 0;
440 set_apu_status (cpup, apuStatus_SDWP);
441 word24 y1 = (2 * segno) % 1024;
442
443 word36 SDWeven, SDWodd;
444
445 core_read2 (cpup, ((((word24) cpu.PTW0.ADDR & 0777760) << 6) + y1) & PAMASK,
446 & SDWeven, & SDWodd, __func__);
447
448
449 cpu.SDW0.ADDR = (SDWeven >> 12) & 077777777;
450 cpu.SDW0.R1 = (SDWeven >> 9) & 7;
451 cpu.SDW0.R2 = (SDWeven >> 6) & 7;
452 cpu.SDW0.R3 = (SDWeven >> 3) & 7;
453 cpu.SDW0.DF = TSTBIT (SDWeven, 2);
454 cpu.SDW0.FC = SDWeven & 3;
455
456
457 cpu.SDW0.BOUND = (SDWodd >> 21) & 037777;
458 cpu.SDW0.R = TSTBIT (SDWodd, 20);
459 cpu.SDW0.E = TSTBIT (SDWodd, 19);
460 cpu.SDW0.W = TSTBIT (SDWodd, 18);
461 cpu.SDW0.P = TSTBIT (SDWodd, 17);
462 cpu.SDW0.U = TSTBIT (SDWodd, 16);
463 cpu.SDW0.G = TSTBIT (SDWodd, 15);
464 cpu.SDW0.C = TSTBIT (SDWodd, 14);
465 cpu.SDW0.EB = SDWodd & 037777;
466
467 L68_ (
468 if (cpu.MR_cache.emr && cpu.MR_cache.ihr)
469 add_l68_APU_history (cpup, APUH_FSDWP);
470 )
471 DBGAPP ("%s y1 0%o p->ADDR 0%o SDW 0%012"PRIo64" 0%012"PRIo64" "
472 "ADDR %o R %o%o%o BOUND 0%o REWPUGC %o%o%o%o%o%o%o "
473 "F %o FC %o FE %o USE %o\r\n",
474 __func__, y1, cpu.PTW0.ADDR, SDWeven, SDWodd, cpu.SDW0.ADDR,
475 cpu.SDW0.R1, cpu.SDW0.R2, cpu.SDW0.R3, cpu.SDW0.BOUND,
476 cpu.SDW0.R, cpu.SDW0.E, cpu.SDW0.W, cpu.SDW0.P, cpu.SDW0.U,
477 cpu.SDW0.G, cpu.SDW0.C, cpu.SDW0.DF, cpu.SDW0.FC, cpu.SDW0.FE,
478 cpu.SDW0.USE);
479 }
480
481
482
483
484
485 static void fetch_nsdw (cpu_state_t * cpup, word15 segno)
486 {
487 DBGAPP ("%s (0):segno=%05o\r\n", __func__, segno);
488
489 PNL (L68_ (cpu.apu.state |= apu_FSDN;))
490
491 cpu.cu.SDWAMM = 0;
492 cpu.cu.PTWAMM = 0;
493 set_apu_status (cpup, apuStatus_SDWNP);
494
495 if (2 * segno >= 16 * (cpu.DSBR.BND + 1))
496 {
497 DBGAPP ("%s (1):Access Violation, out of segment bounds for "
498 "segno=%05o DSBR.BND=%d\r\n",
499 __func__, segno, cpu.DSBR.BND);
500
501 PNL (cpu.acvFaults |= ACV15;)
502 PNL (L68_ (cpu.apu.state |= apu_FLT;))
503 doFault (FAULT_ACV, fst_acv15,
504 "acvFault fetch_dsptw: out of segment bounds fault");
505 }
506 DBGAPP ("%s (2):fetching SDW from %05o\r\n",
507 __func__, cpu.DSBR.ADDR + 2u * segno);
508
509 word36 SDWeven, SDWodd;
510 core_read2 (cpup, (cpu.DSBR.ADDR + 2u * segno) & PAMASK,
511 & SDWeven, & SDWodd, __func__);
512
513
514 cpu.SDW0.ADDR = (SDWeven >> 12) & 077777777;
515 cpu.SDW0.R1 = (SDWeven >> 9) & 7;
516 cpu.SDW0.R2 = (SDWeven >> 6) & 7;
517 cpu.SDW0.R3 = (SDWeven >> 3) & 7;
518 cpu.SDW0.DF = TSTBIT (SDWeven, 2);
519 cpu.SDW0.FC = SDWeven & 3;
520
521
522 cpu.SDW0.BOUND = (SDWodd >> 21) & 037777;
523 cpu.SDW0.R = TSTBIT (SDWodd, 20);
524 cpu.SDW0.E = TSTBIT (SDWodd, 19);
525 cpu.SDW0.W = TSTBIT (SDWodd, 18);
526 cpu.SDW0.P = TSTBIT (SDWodd, 17);
527 cpu.SDW0.U = TSTBIT (SDWodd, 16);
528 cpu.SDW0.G = TSTBIT (SDWodd, 15);
529 cpu.SDW0.C = TSTBIT (SDWodd, 14);
530 cpu.SDW0.EB = SDWodd & 037777;
531
532 L68_ (
533 if (cpu.MR_cache.emr && cpu.MR_cache.ihr)
534 add_l68_APU_history (cpup, 0 );
535 )
536 #if !defined(SPEED)
537 char buf[256];
538 (void)buf;
539 DBGAPP ("%s (2):SDW0=%s\r\n", __func__, str_SDW0 (buf, & cpu.SDW0));
540 #endif
541 }
542
543 #if defined(TESTING)
544 static char *str_sdw (char * buf, sdw_s *SDW)
545 {
546 if (! SDW->FE)
547 (void)sprintf (buf, "*** SDW Uninitialized ***");
548 else
549 (void)sprintf (buf,
550 "ADDR:%06o R1:%o R2:%o R3:%o BOUND:%o R:%o E:%o W:%o P:%o "
551 "U:%o G:%o C:%o CL:%o DF:%o FC:%o POINTER=%o USE=%d",
552 SDW->ADDR, SDW->R1, SDW->R2, SDW->R3, SDW->BOUND,
553 SDW->R, SDW->E, SDW->W, SDW->P, SDW->U,
554 SDW->G, SDW->C, SDW->EB, SDW->DF, SDW->FC,
555 SDW->POINTER, SDW->USE);
556 return buf;
557 }
558
559
560
561
562
563 t_stat dump_sdwam (cpu_state_t * cpup)
564 {
565 char buf[256];
566 (void)buf;
567 for (int _n = 0; _n < N_MODEL_WAM_ENTRIES; _n++)
568 {
569 sdw_s *p = & cpu.SDWAM[_n];
570
571 if (p->FE)
572 sim_printf ("SDWAM n:%d %s\r\n", _n, str_sdw (buf, p));
573 }
574 return SCPE_OK;
575 }
576 #endif
577
578 static uint to_be_discarded_am (word6 LRU)
579 {
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596 if ((LRU & 070) == 0) return 0;
597 if ((LRU & 046) == 040) return 1;
598 if ((LRU & 025) == 024) return 2;
599 return 3;
600 }
601
602
603
604
605
606 static void load_sdwam (cpu_state_t * cpup, word15 segno, bool nomatch)
607 {
608 cpu.SDW0.POINTER = segno;
609 cpu.SDW0.USE = 0;
610
611 cpu.SDW0.FE = true;
612
613 cpu.SDW = & cpu.SDW0;
614
615 if (nomatch || (! cpu.tweaks.enable_wam) || (! cpu.cu.SD_ON))
616 {
617 DBGAPP ("%s: SDWAM disabled\r\n", __func__);
618 return;
619 }
620
621 if (cpu.tweaks.l68_mode) {
622
623
624
625
626
627
628
629 for (int _n = 0; _n < N_L68_WAM_ENTRIES; _n++) {
630 sdw_s * p = & cpu.SDWAM[_n];
631 if (! p->FE || p->USE == 0) {
632 DBGAPP ("%s(1):SDWAM[%d] FE=0 || USE=0\r\n", __func__, _n);
633
634 * p = cpu.SDW0;
635 p->POINTER = segno;
636 p->USE = 0;
637 p->FE = true;
638
639 for (int _h = 0; _h < N_L68_WAM_ENTRIES; _h++) {
640 sdw_s * q = & cpu.SDWAM[_h];
641 q->USE -= 1;
642 q->USE &= N_L68_WAM_MASK;
643 }
644
645 cpu.SDW = p;
646
647 char buf[256];
648 (void) buf;
649 #if defined(TESTING)
650 DBGAPP ("%s(2):SDWAM[%d]=%s\r\n", __func__, _n, str_sdw (buf, p));
651 #endif
652 return;
653 }
654 }
655
656 #if defined(TESTING)
657 DBGAPP ("%s(3) no USE=0 found for segment=%d\r\n", __func__, segno);
658 sim_printf ("%s(%05o): no USE=0 found!\r\n", __func__, segno);
659 dump_sdwam (cpup);
660 #endif
661 }
662
663 if (! cpu.tweaks.l68_mode) {
664 uint setno = segno & 017;
665 uint toffset;
666 sdw_s *p;
667 for (toffset = 0; toffset < 64; toffset += 16) {
668 p = & cpu.SDWAM[toffset + setno];
669 if (!p->FE)
670 break;
671 }
672 if (toffset == 64) {
673 toffset = to_be_discarded_am (p->USE) << 4;
674 p = & cpu.SDWAM[toffset + setno];
675 }
676 DBGAPP ("%s(1):SDWAM[%d] FE=0 || LRU\r\n", __func__, toffset + setno);
677
678 word6 u = calc_hit_am (p->USE, toffset >> 4);
679 * p = cpu.SDW0;
680 p->POINTER = segno;
681 p->FE = true;
682 p->loaded = true;
683 cpu.SDW = p;
684
685 for (uint toffset1 = 0; toffset1 < 64; toffset1 += 16) {
686 p = & cpu.SDWAM[toffset1 + setno];
687 p->USE = u;
688 }
689
690 char buf[256];
691 (void) buf;
692 #if defined(TESTING)
693 DBGAPP ("%s(2):SDWAM[%d]=%s\r\n", __func__, toffset + setno, str_sdw (buf, cpu.SDW));
694 #endif
695 }
696 }
697
698 static ptw_s * fetch_ptw_from_ptwam (cpu_state_t * cpup, word15 segno, word18 CA)
699 {
700 if ((! cpu.tweaks.enable_wam) || (! cpu.cu.PT_ON))
701 {
702 DBGAPP ("%s: PTWAM disabled\r\n", __func__);
703 return NULL;
704 }
705
706 if (cpu.tweaks.l68_mode) {
707 int nwam = N_L68_WAM_ENTRIES;
708 for (int _n = 0; _n < nwam; _n++)
709 {
710 if (cpu.PTWAM[_n].FE && ((CA >> 6) & 07760) == cpu.PTWAM[_n].PAGENO &&
711 cpu.PTWAM[_n].POINTER == segno)
712 {
713 DBGAPP ("%s: found match for segno=%o pageno=%o "
714 "at _n=%d\r\n",
715 __func__, segno, cpu.PTWAM[_n].PAGENO, _n);
716 cpu.cu.PTWAMM = 1;
717 cpu.PTWAMR = (word4) _n;
718 cpu.PTW = & cpu.PTWAM[_n];
719
720
721
722
723
724
725
726 for (int _h = 0; _h < nwam; _h++)
727 {
728 if (cpu.PTWAM[_h].USE > cpu.PTW->USE)
729 cpu.PTWAM[_h].USE -= 1;
730 }
731 cpu.PTW->USE = N_L68_WAM_ENTRIES - 1;
732 #if defined(do_selftestPTWAM)
733 selftest_ptwaw ();
734 #endif
735 DBGAPP ("%s: ADDR 0%o U %o M %o F %o FC %o\r\n",
736 __func__, cpu.PTW->ADDR, cpu.PTW->U, cpu.PTW->M,
737 cpu.PTW->DF, cpu.PTW->FC);
738 return cpu.PTW;
739 }
740 }
741 }
742
743 DPS8M_ (
744 uint setno = (CA >> 10) & 017;
745 uint toffset;
746 ptw_s *p;
747 for (toffset = 0; toffset < 64; toffset += 16)
748 {
749 p = & cpu.PTWAM[toffset + setno];
750
751 if (p->FE && ((CA >> 6) & 07760) == p->PAGENO && p->POINTER == segno)
752 {
753 DBGAPP ("%s: found match for segno=%o pageno=%o "
754 "at _n=%d\r\n",
755 __func__, segno, p->PAGENO, toffset + setno);
756 cpu.cu.PTWAMM = 1;
757 cpu.PTWAMR = (word6) (toffset + setno);
758 cpu.PTW = p;
759
760 word6 u = calc_hit_am (p->USE, toffset >> 4);
761 for (toffset = 0; toffset < 64; toffset += 16)
762 {
763 p = & cpu.PTWAM[toffset + setno];
764 p->USE = u;
765 }
766
767 DBGAPP ("%s: ADDR 0%o U %o M %o F %o FC %o\r\n",
768 __func__, cpu.PTW->ADDR, cpu.PTW->U, cpu.PTW->M,
769 cpu.PTW->DF, cpu.PTW->FC);
770 return cpu.PTW;
771 }
772 }
773 )
774 cpu.cu.PTWAMM = 0;
775 return NULL;
776 }
777
778 static void fetch_ptw (cpu_state_t * cpup, sdw_s *sdw, word18 offset)
779 {
780
781
782
783 PNL (L68_ (cpu.apu.state |= apu_FPTW;))
784 set_apu_status (cpup, apuStatus_PTW);
785
786
787 word24 x2 = (offset) / 1024;
788
789 word36 PTWx2;
790
791 DBGAPP ("%s address %08o\r\n", __func__, sdw->ADDR + x2);
792
793 PNL (cpu.lastPTWOffset = offset;)
794 PNL (cpu.lastPTWIsDS = false;)
795
796 #if defined(THREADZ)
797 bool lck = get_rmw_lock ();
798 if (! lck)
799 lock_rmw ();
800 #endif
801 #if defined(LOCKLESS)
802 core_read_lock (cpup, (sdw->ADDR + x2) & PAMASK, & PTWx2, __func__);
803 #else
804 core_read (cpup, (sdw->ADDR + x2) & PAMASK, & PTWx2, __func__);
805 #endif
806
807 cpu.PTW0.ADDR = GETHI (PTWx2);
808 cpu.PTW0.U = TSTBIT (PTWx2, 9);
809 cpu.PTW0.M = TSTBIT (PTWx2, 6);
810 cpu.PTW0.DF = TSTBIT (PTWx2, 2);
811 cpu.PTW0.FC = PTWx2 & 3;
812
813
814 #if !defined(LOCKLESS)
815 if (! cpu.PTW0.U)
816 #endif
817 {
818 PTWx2 = SETBIT (PTWx2, 9);
819 #if defined(LOCKLESS)
820 core_write_unlock (cpup, (sdw->ADDR + x2) & PAMASK, PTWx2, __func__);
821 cacheInvalidate (cpup, (sdw->ADDR + x2) & PAMASK);
822 #else
823 core_write (cpup, (sdw->ADDR + x2) & PAMASK, PTWx2, __func__);
824 cacheInvalidate (cpup, (sdw->ADDR + x2) & PAMASK);
825 #endif
826 cpu.PTW0.U = 1;
827 }
828
829 #if defined(THREADZ)
830 if (! lck)
831 unlock_rmw ();
832 #endif
833
834 L68_ (if (cpu.MR_cache.emr && cpu.MR_cache.ihr)
835 add_l68_APU_history (cpup, APUH_FPTW);)
836
837 DBGAPP ("%s x2 0%o sdw->ADDR 0%o PTWx2 0%012"PRIo64" "
838 "PTW0: ADDR 0%o U %o M %o F %o FC %o\r\n",
839 __func__, x2, sdw->ADDR, PTWx2, cpu.PTW0.ADDR, cpu.PTW0.U,
840 cpu.PTW0.M, cpu.PTW0.DF, cpu.PTW0.FC);
841 }
842
843 static void loadPTWAM (cpu_state_t * cpup, word15 segno, word18 offset, UNUSED bool nomatch)
844 {
845 cpu.PTW0.PAGENO = (offset >> 6) & 07760;
846 cpu.PTW0.POINTER = segno;
847 cpu.PTW0.USE = 0;
848 cpu.PTW0.FE = true;
849
850 cpu.PTW = & cpu.PTW0;
851 if (nomatch || (! cpu.tweaks.enable_wam) || (! cpu.cu.PT_ON))
852 {
853 DBGAPP ("loadPTWAM: PTWAM disabled\r\n");
854 return;
855 }
856
857 if (cpu.tweaks.l68_mode) {
858
859
860
861
862
863
864 for (int _n = 0; _n < N_L68_WAM_ENTRIES; _n++)
865 {
866 ptw_s * p = & cpu.PTWAM[_n];
867 if (! p->FE || p->USE == 0)
868 {
869 DBGAPP ("loadPTWAM(1):PTWAM[%d] FE=0 || USE=0\r\n", _n);
870 *p = cpu.PTW0;
871 p->PAGENO = (offset >> 6) & 07760;
872 p->POINTER = segno;
873 p->USE = 0;
874 p->FE = true;
875
876 for (int _h = 0; _h < N_L68_WAM_ENTRIES; _h++)
877 {
878 ptw_s * q = & cpu.PTWAM[_h];
879 q->USE -= 1;
880 q->USE &= N_L68_WAM_MASK;
881 }
882
883 cpu.PTW = p;
884 DBGAPP ("loadPTWAM(2): ADDR 0%o U %o M %o F %o FC %o "
885 "POINTER=%o PAGENO=%o USE=%d\r\n",
886 cpu.PTW->ADDR, cpu.PTW->U, cpu.PTW->M, cpu.PTW->DF,
887 cpu.PTW->FC, cpu.PTW->POINTER, cpu.PTW->PAGENO,
888 cpu.PTW->USE);
889 #if defined(do_selftestPTWAM)
890 selftest_ptwaw ();
891 #endif
892 return;
893 }
894 }
895
896 sim_printf ("loadPTWAM(segno=%05o, offset=%012o): no USE=0 found!\r\n",
897 segno, offset);
898 }
899
900 DPS8M_ (
901 uint setno = (offset >> 10) & 017;
902 uint toffset;
903 ptw_s *p;
904 for (toffset = 0; toffset < 64; toffset += 16)
905 {
906 p = & cpu.PTWAM[toffset + setno];
907 if (! p->FE)
908 break;
909 }
910 if (toffset == 64)
911 {
912 toffset = to_be_discarded_am (p->USE) << 4;
913 p = & cpu.PTWAM[toffset + setno];
914 }
915
916 DBGAPP ("loadPTWAM(1):PTWAM[%d] FE=0 || LRU\r\n",
917 toffset + setno);
918
919 word6 u = calc_hit_am (p->USE, toffset >> 4);
920 * p = cpu.PTW0;
921 p->PAGENO = (offset >> 6) & 07760;
922 p->POINTER = segno;
923 p->FE = true;
924 p->loaded = true;
925 cpu.PTW = p;
926
927 for (uint toffset1 = 0; toffset1 < 64; toffset1 += 16)
928 {
929 p = & cpu.PTWAM[toffset1 + setno];
930 p->USE = u;
931 }
932
933 DBGAPP ("loadPTWAM(2): ADDR 0%o U %o M %o F %o FC %o POINTER=%o "
934 "PAGENO=%o USE=%d\r\n",
935 cpu.PTW->ADDR, cpu.PTW->U, cpu.PTW->M, cpu.PTW->DF,
936 cpu.PTW->FC, cpu.PTW->POINTER, cpu.PTW->PAGENO, cpu.PTW->USE);
937 )
938 }
939
940
941
942
943
944 static void modify_ptw (cpu_state_t * cpup, sdw_s *sdw, word18 offset)
945 {
946 PNL (L68_ (cpu.apu.state |= apu_MPTW;))
947
948 word24 x2 = offset / 1024;
949
950 word36 PTWx2;
951
952 set_apu_status (cpup, apuStatus_MPTW);
953
954 #if defined(THREADZ)
955 bool lck = get_rmw_lock ();
956 if (! lck)
957 lock_rmw ();
958 #endif
959 #if defined(LOCKLESS)
960 core_read_lock (cpup, (sdw->ADDR + x2) & PAMASK, & PTWx2, __func__);
961 PTWx2 = SETBIT (PTWx2, 6);
962 core_write_unlock (cpup, (sdw->ADDR + x2) & PAMASK, PTWx2, __func__);
963 cacheInvalidate (cpup, (sdw->ADDR + x2) & PAMASK);
964 #else
965 core_read (cpup, (sdw->ADDR + x2) & PAMASK, & PTWx2, __func__);
966 PTWx2 = SETBIT (PTWx2, 6);
967 core_write (cpup, (sdw->ADDR + x2) & PAMASK, PTWx2, __func__);
968 cacheInvalidate (cpup, (sdw->ADDR + x2) & PAMASK);
969 #endif
970 #if defined(THREADZ)
971 if (! lck)
972 unlock_rmw ();
973 #endif
974 cpu.PTW->M = 1;
975 L68_ (if (cpu.MR_cache.emr && cpu.MR_cache.ihr)
976 add_l68_APU_history (cpup, APUH_MPTW);)
977 }
978
979 static void do_ptw2 (cpu_state_t * cpup, sdw_s *sdw, word18 offset)
980 {
981 PNL (L68_ (cpu.apu.state |= apu_FPTW2;))
982 set_apu_status (cpup, apuStatus_PTW2);
983
984
985 word24 x2 = (offset) / 1024;
986
987 word36 PTWx2n;
988
989 DBGAPP ("%s address %08o\r\n", __func__, sdw->ADDR + x2 + 1);
990
991 core_read (cpup, (sdw->ADDR + x2 + 1) & PAMASK, & PTWx2n, __func__);
992
993 ptw_s PTW2;
994 PTW2.ADDR = GETHI (PTWx2n);
995 PTW2.U = TSTBIT (PTWx2n, 9);
996 PTW2.M = TSTBIT (PTWx2n, 6);
997 PTW2.DF = TSTBIT (PTWx2n, 2);
998 PTW2.FC = PTWx2n & 3;
999
1000 L68_ (if (cpu.MR_cache.emr && cpu.MR_cache.ihr)
1001 add_l68_APU_history (cpup, APUH_FPTW2);)
1002
1003 DBGAPP ("%s x2 0%o sdw->ADDR 0%o PTW2 0%012"PRIo64" "
1004 "PTW2: ADDR 0%o U %o M %o F %o FC %o\r\n",
1005 __func__, x2, sdw->ADDR, PTWx2n, PTW2.ADDR, PTW2.U, PTW2.M,
1006 PTW2.DF, PTW2.FC);
1007
1008
1009
1010 if ((PTW2.ADDR & 0777760) == (cpu.PTW->ADDR & 0777760) + 16)
1011
1012 if (! PTW2.DF)
1013
1014 doFault (FAULT_DF0 + PTW2.FC, fst_zero, "PTW2.F == 0");
1015 }
1016
1017
1018
1019
1020
1021 #if !defined(QUIET_UNUSED)
1022 static char *str_access_type (MemoryAccessType accessType)
1023 {
1024 switch (accessType)
1025 {
1026 case UnknownMAT: return "Unknown";
1027 case OperandRead: return "OperandRead";
1028 case OperandWrite: return "OperandWrite";
1029 default: return "???";
1030 }
1031 }
1032
1033 static char *str_acv (_fault_subtype acv)
1034 {
1035 switch (acv)
1036 {
1037 case ACV0: return "Illegal ring order (ACV0=IRO)";
1038 case ACV1: return "Not in execute bracket (ACV1=OEB)";
1039 case ACV2: return "No execute permission (ACV2=E-OFF)";
1040 case ACV3: return "Not in read bracket (ACV3=ORB)";
1041 case ACV4: return "No read permission (ACV4=R-OFF)";
1042 case ACV5: return "Not in write bracket (ACV5=OWB)";
1043 case ACV6: return "No write permission (ACV6=W-OFF)";
1044 case ACV7: return "Call limiter fault (ACV7=NO GA)";
1045 case ACV8: return "Out of call brackets (ACV8=OCB)";
1046 case ACV9: return "Outward call (ACV9=OCALL)";
1047 case ACV10: return "Bad outward call (ACV10=BOC)";
1048 case ACV11: return "Inward return (ACV11=INRET) XXX ??";
1049 case ACV12: return "Invalid ring crossing (ACV12=CRT)";
1050 case ACV13: return "Ring alarm (ACV13=RALR)";
1051 case ACV14: return "Associative memory error XXX ??";
1052 case ACV15: return "Out of segment bounds (ACV15=OOSB)";
1053
1054
1055
1056
1057 default:
1058 break;
1059 }
1060 return "unhandled acv in str_acv";
1061 }
1062 #endif
1063
1064 #if defined (TESTING) || defined (OLDAPP)
1065 static char *str_pct (processor_cycle_type t)
1066 {
1067 switch (t)
1068 {
1069 case UNKNOWN_CYCLE: return "UNKNOWN_CYCLE";
1070 case OPERAND_STORE: return "OPERAND_STORE";
1071 case OPERAND_READ: return "OPERAND_READ";
1072 case INDIRECT_WORD_FETCH: return "INDIRECT_WORD_FETCH";
1073 # if defined(LOCKLESS)
1074 case OPERAND_RMW: return "OPERAND_RMW";
1075 case APU_DATA_RMW: return "APU_DATA_RMW";
1076 # endif
1077 default:
1078 return "Unhandled processor_cycle_type";
1079 }
1080 }
1081 #endif
1082
1083 #if !defined(OLDAPP)
1084 word24 do_append_cycle (cpu_state_t * cpup, processor_cycle_type thisCycle, word36 * data, uint nWords) {
1085 switch (thisCycle) {
1086 case OPERAND_STORE:
1087 return doAppendCycleOperandStore (cpup, data, nWords);
1088 case OPERAND_READ:
1089 return doAppendCycleOperandRead (cpup, data, nWords);
1090 case INDIRECT_WORD_FETCH:
1091 return doAppendCycleIndirectWordFetch (cpup, data, nWords);
1092 case RTCD_OPERAND_FETCH:
1093 return doAppendCycleRTCDOperandFetch (cpup, data, nWords);
1094 case INSTRUCTION_FETCH:
1095 return doAppendCycleInstructionFetch (cpup, data, nWords);
1096 case APU_DATA_READ:
1097 return doAppendCycleAPUDataRead (cpup, data, nWords);
1098 case APU_DATA_STORE:
1099 return doAppendCycleAPUDataStore (cpup, data, nWords);
1100 case ABSA_CYCLE:
1101 return doAppendCycleABSA (cpup, data, nWords);
1102 # if defined(LOCKLESS)
1103 case OPERAND_RMW:
1104 return doAppendCycleOperandRMW (cpup, data, nWords);
1105 case APU_DATA_RMW:
1106 return doAppendCycleAPUDataRMW (cpup, data, nWords);
1107 # endif
1108 case UNKNOWN_CYCLE:
1109 default:
1110 (void)fprintf (stderr, "\rFATAL: APU unknown cycle %llu! Aborting at %s[%s:%d]\r\n",
1111 (long long unsigned)thisCycle, __func__, __FILE__, __LINE__);
1112 # if defined(USE_BACKTRACE)
1113 # if defined(SIGUSR2)
1114 (void)raise(SIGUSR2);
1115
1116 # endif
1117 # endif
1118 abort();
1119 }
1120 }
1121 #endif
1122
1123 #if !defined(OLDAPP)
1124 # include "doAppendCycleOperandStore.h"
1125 # include "doAppendCycleOperandRead.h"
1126 # include "doAppendCycleIndirectWordFetch.h"
1127 # include "doAppendCycleRTCDOperandFetch.h"
1128 # include "doAppendCycleInstructionFetch.h"
1129 # include "doAppendCycleAPUDataRead.h"
1130 # include "doAppendCycleAPUDataStore.h"
1131 # include "doAppendCycleABSA.h"
1132 # if defined(LOCKLESS)
1133 # include "doAppendCycleOperandRMW.h"
1134 # include "doAppendCycleAPUDataRMW.h"
1135 # endif
1136
1137
1138
1139
1140
1141
1142 # define APPEND_CYCLE_COPIES(name) \
1143 static NO_INLINE word24 name##Full (cpu_state_t * cpup, word36 * data, \
1144 uint nWords) \
1145 { \
1146 return name##_ (cpup, data, nWords, true); \
1147 } \
1148 word24 name (cpu_state_t * cpup, word36 * data, uint nWords) \
1149 { \
1150 if (UNLIKELY (cpup->fullCopy)) \
1151 return name##Full (cpup, data, nWords); \
1152 return name##_ (cpup, data, nWords, false); \
1153 }
1154
1155 APPEND_CYCLE_COPIES (doAppendCycleOperandStore)
1156 APPEND_CYCLE_COPIES (doAppendCycleOperandRead)
1157 APPEND_CYCLE_COPIES (doAppendCycleIndirectWordFetch)
1158 APPEND_CYCLE_COPIES (doAppendCycleRTCDOperandFetch)
1159 APPEND_CYCLE_COPIES (doAppendCycleInstructionFetch)
1160 APPEND_CYCLE_COPIES (doAppendCycleAPUDataRead)
1161 APPEND_CYCLE_COPIES (doAppendCycleAPUDataStore)
1162 # if defined(LOCKLESS)
1163 APPEND_CYCLE_COPIES (doAppendCycleOperandRMW)
1164 APPEND_CYCLE_COPIES (doAppendCycleAPUDataRMW)
1165 # endif
1166 #endif
1167
1168 #if defined(OLDAPP)
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244 word24 do_append_cycle (processor_cycle_type thisCycle, word36 * data,
1245 uint nWords)
1246 {
1247 DCDstruct * i = & cpu.currentInstruction;
1248 DBGAPP ("do_append_cycle(Entry) thisCycle=%s\r\n",
1249 str_pct (thisCycle));
1250 DBGAPP ("do_append_cycle(Entry) lastCycle=%s\r\n",
1251 str_pct (cpu.apu.lastCycle));
1252 DBGAPP ("do_append_cycle(Entry) CA %06o\r\n",
1253 cpu.TPR.CA);
1254 DBGAPP ("do_append_cycle(Entry) n=%2u\r\n",
1255 nWords);
1256 DBGAPP ("do_append_cycle(Entry) PPR.PRR=%o PPR.PSR=%05o\r\n",
1257 cpu.PPR.PRR, cpu.PPR.PSR);
1258 DBGAPP ("do_append_cycle(Entry) TPR.TRR=%o TPR.TSR=%05o\r\n",
1259 cpu.TPR.TRR, cpu.TPR.TSR);
1260
1261 if (i->b29)
1262 {
1263 DBGAPP ("do_append_cycle(Entry) isb29 PRNO %o\r\n",
1264 GET_PRN (IWB_IRODD));
1265 }
1266
1267 bool StrOp = (thisCycle == OPERAND_STORE ||
1268 thisCycle == APU_DATA_STORE);
1269
1270 bool nomatch = true;
1271 if (cpu.tweaks.enable_wam)
1272 {
1273
1274
1275
1276
1277
1278 nomatch = ((i->opcode == 0232 || i->opcode == 0254 ||
1279 i->opcode == 0154 || i->opcode == 0173) && i->opcodeX) ||
1280 ((i->opcode == 0557 || i->opcode == 0257) && ! i->opcodeX);
1281 }
1282
1283 processor_cycle_type lastCycle = cpu.apu.lastCycle;
1284 cpu.apu.lastCycle = thisCycle;
1285
1286 DBGAPP ("do_append_cycle(Entry) XSF %o\r\n", cpu.cu.XSF);
1287
1288 PNL (L68_ (cpu.apu.state = 0;))
1289
1290 cpu.RSDWH_R1 = 0;
1291
1292 cpu.acvFaults = 0;
1293
1294
1295 # define FMSG(x)
1296 FMSG (char * acvFaultsMsg = "<unknown>";)
1297
1298 word24 finalAddress = (word24) -1;
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308 word3 n = 0;
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323 if (thisCycle == RTCD_OPERAND_FETCH &&
1324 get_addr_mode() == ABSOLUTE_mode &&
1325 ! (cpu.cu.XSF || cpu.currentInstruction.b29) )
1326 {
1327 cpu.TPR.TSR = 0;
1328 DBGAPP ("RTCD_OPERAND_FETCH ABSOLUTE mode set TSR %05o TRR %o\r\n",
1329 cpu.TPR.TSR, cpu.TPR.TRR);
1330 }
1331
1332 goto A;
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344 A:;
1345
1346
1347 PNL (cpu.APUMemAddr = cpu.TPR.CA;)
1348
1349 DBGAPP ("do_append_cycle(A)\r\n");
1350
1351
1352 if (nomatch || ! fetch_sdw_from_sdwam (cpu.TPR.TSR))
1353 {
1354
1355 DBGAPP ("do_append_cycle(A):SDW for segment %05o not in SDWAM\r\n",
1356 cpu.TPR.TSR);
1357
1358 DBGAPP ("do_append_cycle(A):DSBR.U=%o\r\n",
1359 cpu.DSBR.U);
1360
1361 if (cpu.DSBR.U == 0)
1362 {
1363 fetch_dsptw (cpu.TPR.TSR);
1364
1365 if (! cpu.PTW0.DF)
1366 doFault (FAULT_DF0 + cpu.PTW0.FC, fst_zero,
1367 "do_append_cycle(A): PTW0.F == 0");
1368
1369 if (! cpu.PTW0.U)
1370 modify_dsptw (cpu.TPR.TSR);
1371
1372 fetch_psdw (cpu.TPR.TSR);
1373 }
1374 else
1375 fetch_nsdw (cpu.TPR.TSR);
1376
1377 if (cpu.SDW0.DF == 0)
1378 {
1379 if (thisCycle != ABSA_CYCLE)
1380 {
1381 DBGAPP ("do_append_cycle(A): SDW0.F == 0! "
1382 "Initiating directed fault\r\n");
1383
1384 doFault (FAULT_DF0 + cpu.SDW0.FC, fst_zero, "SDW0.F == 0");
1385 }
1386 }
1387
1388 load_sdwam (cpu.TPR.TSR, nomatch);
1389 }
1390 DBGAPP ("do_append_cycle(A) R1 %o R2 %o R3 %o E %o\r\n",
1391 cpu.SDW->R1, cpu.SDW->R2, cpu.SDW->R3, cpu.SDW->E);
1392
1393
1394 cpu.RSDWH_R1 = cpu.SDW->R1;
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406 DBGAPP ("do_append_cycle(B)\r\n");
1407
1408
1409
1410
1411 if (! (cpu.SDW->R1 <= cpu.SDW->R2 && cpu.SDW->R2 <= cpu.SDW->R3))
1412 {
1413
1414 cpu.acvFaults |= ACV0;
1415 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1416 FMSG (acvFaultsMsg = "acvFaults(B) C(SDW.R1) <= C(SDW.R2) <= "
1417 "C(SDW .R3)";)
1418 }
1419
1420
1421
1422
1423
1424
1425
1426 if (thisCycle == INSTRUCTION_FETCH &&
1427 i->opcode == 0610 && ! i->opcodeX)
1428 goto C;
1429 else if (lastCycle == RTCD_OPERAND_FETCH)
1430 sim_warn ("%s: lastCycle == RTCD_OPERAND_FETCH opcode %0#o\r\n", __func__, i->opcode);
1431
1432
1433
1434
1435
1436
1437
1438 if (thisCycle == OPERAND_READ && (i->info->flags & CALL6_INS))
1439 goto E;
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463 if (thisCycle == INSTRUCTION_FETCH ||
1464 (thisCycle == OPERAND_READ && (i->info->flags & TRANSFER_INS)))
1465 goto F;
1466
1467
1468
1469
1470
1471 # if defined(LOCKLESS)
1472 if (!StrOp || thisCycle == OPERAND_RMW || thisCycle == APU_DATA_RMW)
1473 # else
1474 if (!StrOp)
1475 # endif
1476 {
1477 DBGAPP ("do_append_cycle(B):!STR-OP\r\n");
1478
1479
1480
1481 if (cpu.TPR.TRR > cpu.SDW->R2)
1482 {
1483 DBGAPP ("ACV3\r\n");
1484 DBGAPP ("do_append_cycle(B) ACV3\r\n");
1485
1486 cpu.acvFaults |= ACV3;
1487 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1488 FMSG (acvFaultsMsg = "acvFaults(B) C(TPR.TRR) > C(SDW .R2)";)
1489 }
1490
1491 if (cpu.SDW->R == 0)
1492 {
1493
1494 cpu.TPR.TRR = cpu.PPR.PRR;
1495
1496
1497 if (cpu.PPR.PSR != cpu.TPR.TSR)
1498 {
1499 DBGAPP ("ACV4\r\n");
1500 DBGAPP ("do_append_cycle(B) ACV4\r\n");
1501
1502 cpu.acvFaults |= ACV4;
1503 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1504 FMSG (acvFaultsMsg = "acvFaults(B) C(PPR.PSR) = C(TPR.TSR)";)
1505 }
1506
1507
1508
1509
1510
1511
1512 }
1513 }
1514
1515
1516
1517
1518 # if defined(LOCKLESS)
1519 if (StrOp || thisCycle == OPERAND_RMW || thisCycle == APU_DATA_RMW)
1520 # else
1521 if (StrOp)
1522 # endif
1523 {
1524 DBGAPP ("do_append_cycle(B):STR-OP\r\n");
1525
1526
1527 if (cpu.TPR.TSR == cpu.PPR.PSR)
1528 cpu.TPR.TRR = cpu.PPR.PRR;
1529
1530
1531 if (cpu.TPR.TRR > cpu.SDW->R1)
1532 {
1533 DBGAPP ("ACV5 TRR %o R1 %o\r\n",
1534 cpu.TPR.TRR, cpu.SDW->R1);
1535
1536 cpu.acvFaults |= ACV5;
1537 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1538 FMSG (acvFaultsMsg = "acvFaults(B) C(TPR.TRR) > C(SDW .R1)";)
1539 }
1540
1541 if (! cpu.SDW->W)
1542 {
1543
1544 cpu.TPR.TRR = cpu.PPR.PRR;
1545
1546 DBGAPP ("ACV6\r\n");
1547
1548 cpu.acvFaults |= ACV6;
1549 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1550 FMSG (acvFaultsMsg = "acvFaults(B) ACV6 = W-OFF";)
1551 }
1552
1553 }
1554 goto G;
1555
1556
1557
1558
1559
1560
1561
1562 C:;
1563 DBGAPP ("do_append_cycle(C)\r\n");
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573 if (cpu.TPR.TRR < cpu.SDW->R1 ||
1574 cpu.TPR.TRR > cpu.SDW->R2)
1575 {
1576 DBGAPP ("ACV1 c\r\n");
1577 DBGAPP ("acvFaults(C) ACV1 ! ( C(SDW .R1) %o <= C(TPR.TRR) %o <= C(SDW .R2) %o )\r\n",
1578 cpu.SDW->R1, cpu.TPR.TRR, cpu.SDW->R2);
1579
1580 cpu.acvFaults |= ACV1;
1581 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1582 FMSG (acvFaultsMsg = "acvFaults(C) C(SDW.R1 > C(TPR.TRR) > C(SDW.R2)";)
1583 }
1584
1585 if (! cpu.SDW->E)
1586 {
1587 DBGAPP ("ACV2 a\r\n");
1588 DBGAPP ("do_append_cycle(C) ACV2\r\n");
1589
1590 cpu.acvFaults |= ACV2;
1591 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1592 FMSG (acvFaultsMsg = "acvFaults(C) SDW.E";)
1593 }
1594 if (cpu.TPR.TRR > cpu.PPR.PRR)
1595 sim_warn ("rtcd: outbound call cpu.TPR.TRR %d cpu.PPR.PRR %d\r\n",
1596 cpu.TPR.TRR, cpu.PPR.PRR);
1597
1598 if (cpu.TPR.TRR < cpu.PPR.PRR)
1599 {
1600 DBGAPP ("ACV11\r\n");
1601 DBGAPP ("do_append_cycle(C) ACV11\r\n");
1602
1603 cpu.acvFaults |= ACV11;
1604 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1605 FMSG (acvFaultsMsg = "acvFaults(C) TRR>=PRR";)
1606 }
1607
1608 D:;
1609 DBGAPP ("do_append_cycle(D)\r\n");
1610
1611
1612
1613
1614
1615 if (cpu.rRALR == 0)
1616 goto G;
1617
1618
1619 if (! (cpu.PPR.PRR < cpu.rRALR))
1620 {
1621 DBGAPP ("ACV13\r\n");
1622 DBGAPP ("acvFaults(D) C(PPR.PRR) %o < RALR %o\r\n",
1623 cpu.PPR.PRR, cpu.rRALR);
1624 cpu.acvFaults |= ACV13;
1625 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1626 FMSG (acvFaultsMsg = "acvFaults(D) C(PPR.PRR) < RALR";)
1627 }
1628
1629 goto G;
1630
1631
1632
1633
1634
1635
1636
1637 E:;
1638
1639
1640
1641
1642
1643
1644 DBGAPP ("do_append_cycle(E): CALL6\r\n");
1645 DBGAPP ("do_append_cycle(E): E %o G %o PSR %05o TSR %05o CA %06o "
1646 "EB %06o R %o%o%o TRR %o PRR %o\r\n",
1647 cpu.SDW->E, cpu.SDW->G, cpu.PPR.PSR, cpu.TPR.TSR, cpu.TPR.CA,
1648 cpu.SDW->EB, cpu.SDW->R1, cpu.SDW->R2, cpu.SDW->R3,
1649 cpu.TPR.TRR, cpu.PPR.PRR);
1650
1651
1652 if (! cpu.SDW->E)
1653 {
1654 DBGAPP ("ACV2 b\r\n");
1655 DBGAPP ("do_append_cycle(E) ACV2\r\n");
1656
1657 cpu.acvFaults |= ACV2;
1658 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1659 FMSG (acvFaultsMsg = "acvFaults(E) SDW .E set OFF";)
1660 }
1661
1662
1663 if (cpu.SDW->G)
1664 goto E1;
1665
1666
1667 if (cpu.PPR.PSR == cpu.TPR.TSR && ! TST_I_ABS)
1668 goto E1;
1669
1670
1671
1672
1673 if (cpu.TPR.CA >= (word18) cpu.SDW->EB)
1674 {
1675 DBGAPP ("ACV7\r\n");
1676 DBGAPP ("do_append_cycle(E) ACV7\r\n");
1677
1678 cpu.acvFaults |= ACV7;
1679 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1680 FMSG (acvFaultsMsg = "acvFaults(E) TPR.CA4-17 >= SDW.CL";)
1681 }
1682
1683 E1:
1684 DBGAPP ("do_append_cycle(E1): CALL6 (cont'd)\r\n");
1685
1686
1687 if (cpu.TPR.TRR > cpu.SDW->R3)
1688 {
1689 DBGAPP ("ACV8\r\n");
1690 DBGAPP ("do_append_cycle(E) ACV8\r\n");
1691
1692 cpu.acvFaults |= ACV8;
1693 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1694 FMSG (acvFaultsMsg = "acvFaults(E1) C(TPR.TRR) > SDW.R3";)
1695 }
1696
1697
1698 if (cpu.TPR.TRR < cpu.SDW->R1)
1699 {
1700 DBGAPP ("ACV9\r\n");
1701 DBGAPP ("do_append_cycle(E) ACV9\r\n");
1702
1703 cpu.acvFaults |= ACV9;
1704 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1705 FMSG (acvFaultsMsg = "acvFaults(E1) C(TPR.TRR) < SDW.R1";)
1706 }
1707
1708
1709 if (cpu.TPR.TRR > cpu.PPR.PRR)
1710 {
1711
1712 if (cpu.PPR.PRR < cpu.SDW->R2)
1713 {
1714 DBGAPP ("ACV10\r\n");
1715 DBGAPP ("do_append_cycle(E) ACV10\r\n");
1716
1717 cpu.acvFaults |= ACV10;
1718 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1719 FMSG (acvFaultsMsg = "acvFaults(E1) C(TPR.TRR) > C(PPR.PRR) && "
1720 "C(PPR.PRR) < SDW.R2";)
1721 }
1722 }
1723
1724 DBGAPP ("do_append_cycle(E1): CALL6 TPR.TRR %o SDW->R2 %o\r\n",
1725 cpu.TPR.TRR, cpu.SDW->R2);
1726
1727
1728 if (cpu.TPR.TRR > cpu.SDW->R2)
1729 {
1730
1731 cpu.TPR.TRR = cpu.SDW->R2;
1732 }
1733
1734 DBGAPP ("do_append_cycle(E1): CALL6 TPR.TRR %o\r\n", cpu.TPR.TRR);
1735
1736 goto G;
1737
1738
1739
1740
1741
1742
1743
1744 F:;
1745 PNL (L68_ (cpu.apu.state |= apu_PIAU;))
1746 DBGAPP ("do_append_cycle(F): transfer or instruction fetch\r\n");
1747
1748
1749
1750
1751
1752
1753
1754 if (cpu.TPR.TRR < cpu.SDW->R1 ||
1755 cpu.TPR.TRR > cpu.SDW->R2)
1756 {
1757 DBGAPP ("ACV1 a/b\r\n");
1758 DBGAPP ("acvFaults(F) ACV1 !( C(SDW .R1) %o <= C(TPR.TRR) %o <= C(SDW .R2) %o )\r\n",
1759 cpu.SDW->R1, cpu.TPR.TRR, cpu.SDW->R2);
1760 cpu.acvFaults |= ACV1;
1761 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1762 FMSG (acvFaultsMsg = "acvFaults(F) C(TPR.TRR) < C(SDW .R1)";)
1763 }
1764
1765 if (! cpu.SDW->E)
1766 {
1767 DBGAPP ("ACV2 c\r\n");
1768 DBGAPP ("do_append_cycle(F) ACV2\r\n");
1769 cpu.acvFaults |= ACV2;
1770 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1771 FMSG (acvFaultsMsg = "acvFaults(F) SDW .E set OFF";)
1772 }
1773
1774
1775 if (cpu.PPR.PRR != cpu.TPR.TRR)
1776 {
1777 DBGAPP ("ACV12\r\n");
1778 DBGAPP ("do_append_cycle(F) ACV12\r\n");
1779
1780 cpu.acvFaults |= ACV12;
1781 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1782 FMSG (acvFaultsMsg = "acvFaults(F) C(PPR.PRR) != C(TPR.TRR)";)
1783 }
1784
1785 goto D;
1786
1787
1788
1789
1790
1791
1792
1793 G:;
1794
1795 DBGAPP ("do_append_cycle(G)\r\n");
1796
1797
1798 if (((cpu.TPR.CA >> 4) & 037777) > cpu.SDW->BOUND)
1799 {
1800 DBGAPP ("ACV15\r\n");
1801 DBGAPP ("do_append_cycle(G) ACV15\r\n");
1802 cpu.acvFaults |= ACV15;
1803 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1804 FMSG (acvFaultsMsg = "acvFaults(G) C(TPR.CA)0,13 > SDW.BOUND";)
1805 DBGAPP ("acvFaults(G) C(TPR.CA)0,13 > SDW.BOUND\r\n"
1806 " CA %06o CA>>4 & 037777 %06o SDW->BOUND %06o",
1807 cpu.TPR.CA, ((cpu.TPR.CA >> 4) & 037777), cpu.SDW->BOUND);
1808 }
1809
1810 if (cpu.acvFaults)
1811 {
1812 DBGAPP ("do_append_cycle(G) acvFaults\r\n");
1813 PNL (L68_ (cpu.apu.state |= apu_FLT;))
1814
1815 doFault (FAULT_ACV, (_fault_subtype) {.fault_acv_subtype=cpu.acvFaults},
1816 "ACV fault");
1817 }
1818
1819
1820 if (cpu.SDW->U)
1821 goto H;
1822
1823
1824
1825
1826 DBGAPP ("do_append_cycle(G) CA %06o\r\n", cpu.TPR.CA);
1827 if (nomatch ||
1828 ! fetch_ptw_from_ptwam (cpu.SDW->POINTER, cpu.TPR.CA))
1829 {
1830 fetch_ptw (cpu.SDW, cpu.TPR.CA);
1831 if (! cpu.PTW0.DF)
1832 {
1833 if (thisCycle != ABSA_CYCLE)
1834 {
1835
1836 doFault (FAULT_DF0 + cpu.PTW0.FC, (_fault_subtype) {.bits=0},
1837 "PTW0.F == 0");
1838 }
1839 }
1840 loadPTWAM (cpu.SDW->POINTER, cpu.TPR.CA, nomatch);
1841 }
1842
1843
1844
1845
1846
1847
1848 if (i->opcodeX && ((i->opcode & 0770)== 0200|| (i->opcode & 0770) == 0220
1849 || (i->opcode & 0770)== 020|| (i->opcode & 0770) == 0300))
1850 {
1851 do_ptw2 (cpu.SDW, cpu.TPR.CA);
1852 }
1853 goto I;
1854
1855
1856
1857
1858
1859
1860
1861 H:;
1862 DBGAPP ("do_append_cycle(H): FANP\r\n");
1863
1864 PNL (L68_ (cpu.apu.state |= apu_FANP;))
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874 set_apu_status (apuStatus_FANP);
1875
1876 DBGAPP ("do_append_cycle(H): SDW->ADDR=%08o CA=%06o\r\n",
1877 cpu.SDW->ADDR, cpu.TPR.CA);
1878
1879 if (thisCycle == RTCD_OPERAND_FETCH &&
1880 get_addr_mode () == ABSOLUTE_mode &&
1881 ! (cpu.cu.XSF || cpu.currentInstruction.b29) )
1882 {
1883 finalAddress = cpu.TPR.CA;
1884 }
1885 else
1886 {
1887 finalAddress = (cpu.SDW->ADDR & 077777760) + cpu.TPR.CA;
1888 finalAddress &= 0xffffff;
1889 }
1890 PNL (cpu.APUMemAddr = finalAddress;)
1891
1892 DBGAPP ("do_append_cycle(H:FANP): (%05o:%06o) finalAddress=%08o\r\n",
1893 cpu.TPR.TSR, cpu.TPR.CA, finalAddress);
1894
1895
1896
1897 goto HI;
1898
1899 I:;
1900
1901
1902
1903 DBGAPP ("do_append_cycle(I): FAP\r\n");
1904 # if defined(LOCKLESS)
1905 if ((StrOp ||
1906 thisCycle == OPERAND_RMW ||
1907 thisCycle == APU_DATA_RMW) && cpu.PTW->M == 0)
1908 # else
1909 if (StrOp && cpu.PTW->M == 0)
1910 # endif
1911 {
1912 modify_ptw (cpu.SDW, cpu.TPR.CA);
1913 }
1914
1915
1916 set_apu_status (apuStatus_FAP);
1917 PNL (L68_ (cpu.apu.state |= apu_FAP;))
1918
1919 word24 y2 = cpu.TPR.CA % 1024;
1920
1921
1922
1923 finalAddress = (((word24)cpu.PTW->ADDR & 0777760) << 6) + y2;
1924 finalAddress &= 0xffffff;
1925 PNL (cpu.APUMemAddr = finalAddress;)
1926
1927 L68_ (if (cpu.MR_cache.emr && cpu.MR_cache.ihr)
1928 add_l68_APU_history (APUH_FAP);)
1929
1930 DBGAPP ("do_append_cycle(H:FAP): (%05o:%06o) finalAddress=%08o\r\n",
1931 cpu.TPR.TSR, cpu.TPR.CA, finalAddress);
1932
1933
1934
1935 goto HI;
1936
1937 HI:
1938 DBGAPP ("do_append_cycle(HI)\r\n");
1939
1940
1941 if (thisCycle != ABSA_CYCLE)
1942 {
1943 cpu.cu.XSF = 1;
1944 if (cpu.currentInstruction.b29)
1945 cpu.xsfScu = true;
1946 sim_debug (DBG_TRACEEXT, & cpu_dev, "loading of cpu.TPR.TSR sets XSF to 1\r\n");
1947 }
1948
1949 if (thisCycle == OPERAND_STORE && cpu.useZone)
1950 {
1951 cache_write_zone (finalAddress, * data, str_pct (thisCycle));
1952 }
1953 else if (StrOp)
1954 {
1955 cache_writeN (finalAddress, data, nWords, str_pct (thisCycle));
1956 }
1957 else
1958 {
1959 # if defined(LOCKLESS)
1960 if ((thisCycle == OPERAND_RMW || thisCycle == APU_DATA_RMW) && nWords == 1)
1961 {
1962 cache_read_lock (finalAddress, data, str_pct (thisCycle));
1963 }
1964 else
1965 {
1966 if (thisCycle == OPERAND_RMW || thisCycle == APU_DATA_RMW)
1967 sim_warn("do_append_cycle: RMW nWords %d != 1\r\n", nWords);
1968 cache_readN (finalAddress, data, nWords, str_pct (thisCycle));
1969 }
1970 # else
1971 if (thisCycle != ABSA_CYCLE)
1972 cache_readN (finalAddress, data, nWords, str_pct (thisCycle));
1973 # endif
1974 }
1975
1976
1977 if (thisCycle == INDIRECT_WORD_FETCH)
1978 goto J;
1979
1980
1981 if (thisCycle == RTCD_OPERAND_FETCH)
1982 goto K;
1983
1984
1985 if (thisCycle == OPERAND_READ && (i->info->flags & CALL6_INS))
1986 goto N;
1987
1988
1989 if (thisCycle == INSTRUCTION_FETCH ||
1990 (thisCycle == OPERAND_READ && (i->info->flags & TRANSFER_INS)))
1991 goto L;
1992
1993
1994
1995 goto Exit;
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005 J:;
2006 DBGAPP ("do_append_cycle(J)\r\n");
2007
2008
2009 word6 tag = GET_TAG (IWB_IRODD);
2010 if ((GET_TM (tag) == TM_IR || GET_TM (tag) == TM_RI) &&
2011 (cpu.TPR.CA & 1) == 0)
2012 {
2013 if (ISITS (* data))
2014 goto O;
2015 if (ISITP (* data))
2016 goto P;
2017 }
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052 if ((* data) & 060)
2053
2054 {
2055
2056
2057
2058
2059
2060
2061
2062 }
2063
2064 goto Exit;
2065
2066
2067
2068
2069
2070
2071
2072 K:;
2073 DBGAPP ("do_append_cycle(K)\r\n");
2074
2075 word3 y = GET_ITS_RN (data);
2076
2077
2078
2079 cpu.TPR.TSR = GET_ITS_SEGNO (data);
2080
2081
2082
2083
2084 cpu.PPR.PRR = cpu.TPR.TRR = max3 (y, cpu.TPR.TRR, cpu.RSDWH_R1);
2085
2086
2087
2088 cpu.TPR.CA = GET_ITS_WORDNO (data);
2089
2090
2091
2092
2093
2094 goto KL;
2095
2096 L:;
2097
2098 DBGAPP ("do_append_cycle(L)\r\n");
2099
2100
2101 if (thisCycle == OPERAND_READ && (i->info->flags & TSPN_INS))
2102 {
2103
2104 if (i->opcode <= 0273)
2105 n = (i->opcode & 3);
2106 else
2107 n = (i->opcode & 3) + 4;
2108
2109
2110
2111
2112
2113 cpu.PR[n].RNR = cpu.PPR.PRR;
2114
2115
2116 if (get_addr_mode () == APPEND_mode)
2117 cpu.PR[n].SNR = cpu.PPR.PSR;
2118 cpu.PR[n].WORDNO = (cpu.PPR.IC + 1) & MASK18;
2119 SET_PR_BITNO (n, 0);
2120 # if defined(TESTING)
2121 HDBGRegPRW (n, "app tspn");
2122 # endif
2123 }
2124
2125
2126
2127 if (thisCycle == INSTRUCTION_FETCH &&
2128 i->opcode == 0610 && ! i->opcodeX)
2129 {
2130
2131
2132 CPTUR (cptUsePRn + 0);
2133 CPTUR (cptUsePRn + 1);
2134 CPTUR (cptUsePRn + 2);
2135 CPTUR (cptUsePRn + 3);
2136 CPTUR (cptUsePRn + 4);
2137 CPTUR (cptUsePRn + 5);
2138 CPTUR (cptUsePRn + 6);
2139 CPTUR (cptUsePRn + 7);
2140 cpu.PR[0].RNR =
2141 cpu.PR[1].RNR =
2142 cpu.PR[2].RNR =
2143 cpu.PR[3].RNR =
2144 cpu.PR[4].RNR =
2145 cpu.PR[5].RNR =
2146 cpu.PR[6].RNR =
2147 cpu.PR[7].RNR = cpu.TPR.TRR;
2148 # if defined(TESTING)
2149 HDBGRegPRW (0, "app rtcd");
2150 HDBGRegPRW (1, "app rtcd");
2151 HDBGRegPRW (2, "app rtcd");
2152 HDBGRegPRW (3, "app rtcd");
2153 HDBGRegPRW (4, "app rtcd");
2154 HDBGRegPRW (5, "app rtcd");
2155 HDBGRegPRW (6, "app rtcd");
2156 HDBGRegPRW (7, "app rtcd");
2157 # endif
2158 }
2159 goto KL;
2160
2161 KL:
2162 DBGAPP ("do_append_cycle(KL)\r\n");
2163
2164
2165 cpu.PPR.PSR = cpu.TPR.TSR;
2166
2167 cpu.PPR.IC = cpu.TPR.CA;
2168
2169 goto M;
2170
2171 M:
2172 DBGAPP ("do_append_cycle(M)\r\n");
2173
2174
2175 if (cpu.TPR.TRR == 0)
2176 {
2177
2178 cpu.PPR.P = cpu.SDW->P;
2179 }
2180 else
2181 {
2182
2183 cpu.PPR.P = 0;
2184 }
2185
2186 goto Exit;
2187
2188 N:
2189 DBGAPP ("do_append_cycle(N)\r\n");
2190
2191
2192 if (cpu.TPR.TRR == cpu.PPR.PRR)
2193 {
2194
2195 cpu.PR[7].SNR = cpu.PR[6].SNR;
2196 DBGAPP ("do_append_cycle(N) PR7.SNR = PR6.SNR %05o\r\n", cpu.PR[7].SNR);
2197 }
2198 else
2199 {
2200
2201 cpu.PR[7].SNR = ((word15) (cpu.DSBR.STACK << 3)) | cpu.TPR.TRR;
2202 DBGAPP ("do_append_cycle(N) STACK %05o TRR %o\r\n",
2203 cpu.DSBR.STACK, cpu.TPR.TRR);
2204 DBGAPP ("do_append_cycle(N) PR7.SNR = STACK||TRR %05o\r\n", cpu.PR[7].SNR);
2205 }
2206
2207
2208 cpu.PR[7].RNR = cpu.TPR.TRR;
2209
2210 cpu.PR[7].WORDNO = 0;
2211
2212 SET_PR_BITNO (7, 0);
2213 # if defined(TESTING)
2214 HDBGRegPRW (7, "app call6");
2215 # endif
2216
2217 cpu.PPR.PRR = cpu.TPR.TRR;
2218
2219 cpu.PPR.PSR = cpu.TPR.TSR;
2220
2221 cpu.PPR.IC = cpu.TPR.CA;
2222
2223 goto M;
2224
2225
2226
2227
2228
2229
2230
2231 O:;
2232 DBGAPP ("do_append_cycle(O)\r\n");
2233 word3 its_RNR = GET_ITS_RN (data);
2234 DBGAPP ("do_append_cycle(O) TRR %o RSDWH.R1 %o ITS.RNR %o\r\n",
2235 cpu.TPR.TRR, cpu.RSDWH_R1, its_RNR);
2236
2237
2238
2239 cpu.TPR.TRR = max3 (its_RNR, cpu.TPR.TRR, cpu.RSDWH_R1);
2240 DBGAPP ("do_append_cycle(O) Set TRR to %o\r\n", cpu.TPR.TRR);
2241
2242 goto Exit;
2243
2244 P:;
2245
2246 DBGAPP ("do_append_cycle(P)\r\n");
2247
2248 n = GET_ITP_PRNUM (data);
2249 DBGAPP ("do_append_cycle(P) TRR %o RSDWH.R1 %o PR[n].RNR %o\r\n",
2250 cpu.TPR.TRR, cpu.RSDWH_R1, cpu.PR[n].RNR);
2251
2252
2253
2254 cpu.TPR.TRR = max3 (cpu.PR[n].RNR, cpu.TPR.TRR, cpu.RSDWH_R1);
2255 DBGAPP ("do_append_cycle(P) Set TRR to %o\r\n", cpu.TPR.TRR);
2256
2257 goto Exit;
2258
2259 Exit:;
2260
2261 PNL (cpu.APUDataBusOffset = cpu.TPR.CA;)
2262 PNL (cpu.APUDataBusAddr = finalAddress;)
2263
2264 PNL (L68_ (cpu.apu.state |= apu_FA;))
2265
2266 DBGAPP ("do_append_cycle (Exit) PRR %o PSR %05o P %o IC %06o\r\n",
2267 cpu.PPR.PRR, cpu.PPR.PSR, cpu.PPR.P, cpu.PPR.IC);
2268 DBGAPP ("do_append_cycle (Exit) TRR %o TSR %05o TBR %02o CA %06o\r\n",
2269 cpu.TPR.TRR, cpu.TPR.TSR, cpu.TPR.TBR, cpu.TPR.CA);
2270
2271 return finalAddress;
2272 }
2273 #endif
2274
2275
2276
2277
2278 #if defined(TESTING)
2279 int dbgLookupAddress (word18 segno, word18 offset, word24 * finalAddress,
2280 char * * msg)
2281 {
2282 cpu_state_t * cpup = _cpup;
2283
2284
2285 ptw_s PTW1;
2286 sdw_s SDW1;
2287
2288 if (2u * segno >= 16u * (cpu.DSBR.BND + 1u))
2289 {
2290 if (msg)
2291 * msg = "DSBR boundary violation.";
2292 return 1;
2293 }
2294
2295 if (cpu.DSBR.U == 0)
2296 {
2297
2298
2299 word24 y1 = (2 * segno) % 1024;
2300 word24 x1 = (2 * segno) / 1024;
2301
2302 word36 PTWx1;
2303 core_read (cpup, (cpu.DSBR.ADDR + x1) & PAMASK, & PTWx1, __func__);
2304
2305 PTW1.ADDR = GETHI (PTWx1);
2306 PTW1.U = TSTBIT (PTWx1, 9);
2307 PTW1.M = TSTBIT (PTWx1, 6);
2308 PTW1.DF = TSTBIT (PTWx1, 2);
2309 PTW1.FC = PTWx1 & 3;
2310
2311 if (! PTW1.DF)
2312 {
2313 if (msg)
2314 * msg = "!PTW0.F";
2315 return 2;
2316 }
2317
2318
2319
2320 y1 = (2 * segno) % 1024;
2321
2322 word36 SDWeven, SDWodd;
2323
2324 core_read2 (cpup, ((((word24)PTW1. ADDR & 0777760) << 6) + y1) & PAMASK,
2325 & SDWeven, & SDWodd, __func__);
2326
2327
2328 SDW1.ADDR = (SDWeven >> 12) & 077777777;
2329 SDW1.R1 = (SDWeven >> 9) & 7;
2330 SDW1.R2 = (SDWeven >> 6) & 7;
2331 SDW1.R3 = (SDWeven >> 3) & 7;
2332 SDW1.DF = TSTBIT (SDWeven, 2);
2333 SDW1.FC = SDWeven & 3;
2334
2335
2336 SDW1.BOUND = (SDWodd >> 21) & 037777;
2337 SDW1.R = TSTBIT (SDWodd, 20);
2338 SDW1.E = TSTBIT (SDWodd, 19);
2339 SDW1.W = TSTBIT (SDWodd, 18);
2340 SDW1.P = TSTBIT (SDWodd, 17);
2341 SDW1.U = TSTBIT (SDWodd, 16);
2342 SDW1.G = TSTBIT (SDWodd, 15);
2343 SDW1.C = TSTBIT (SDWodd, 14);
2344 SDW1.EB = SDWodd & 037777;
2345 }
2346 else
2347 {
2348
2349
2350 word36 SDWeven, SDWodd;
2351
2352 core_read2 (cpup, (cpu.DSBR.ADDR + 2 * segno) & PAMASK,
2353 & SDWeven, & SDWodd, __func__);
2354
2355
2356 SDW1.ADDR = (SDWeven >> 12) & 077777777;
2357 SDW1.R1 = (SDWeven >> 9) & 7;
2358 SDW1.R2 = (SDWeven >> 6) & 7;
2359 SDW1.R3 = (SDWeven >> 3) & 7;
2360 SDW1.DF = TSTBIT (SDWeven, 2);
2361 SDW1.FC = SDWeven & 3;
2362
2363
2364 SDW1.BOUND = (SDWodd >> 21) & 037777;
2365 SDW1.R = TSTBIT (SDWodd, 20);
2366 SDW1.E = TSTBIT (SDWodd, 19);
2367 SDW1.W = TSTBIT (SDWodd, 18);
2368 SDW1.P = TSTBIT (SDWodd, 17);
2369 SDW1.U = TSTBIT (SDWodd, 16);
2370 SDW1.G = TSTBIT (SDWodd, 15);
2371 SDW1.C = TSTBIT (SDWodd, 14);
2372 SDW1.EB = SDWodd & 037777;
2373
2374 }
2375
2376 if (SDW1.DF == 0)
2377 {
2378 if (msg)
2379 * msg = "!SDW0.F != 0";
2380 return 3;
2381 }
2382
2383 if (((offset >> 4) & 037777) > SDW1.BOUND)
2384 {
2385 if (msg)
2386 * msg = "C(TPR.CA)0,13 > SDW.BOUND";
2387 return 4;
2388 }
2389
2390
2391 if (SDW1.U)
2392 {
2393 * finalAddress = (SDW1.ADDR + offset) & PAMASK;
2394 }
2395 else
2396 {
2397
2398 word24 y2 = offset % 1024;
2399 word24 x2 = (offset) / 1024;
2400
2401 word36 PTWx2;
2402
2403 core_read (cpup, (SDW1.ADDR + x2) & PAMASK, & PTWx2, __func__);
2404
2405 PTW1.ADDR = GETHI (PTWx2);
2406 PTW1.U = TSTBIT (PTWx2, 9);
2407 PTW1.M = TSTBIT (PTWx2, 6);
2408 PTW1.DF = TSTBIT (PTWx2, 2);
2409 PTW1.FC = PTWx2 & 3;
2410
2411 if (! PTW1.DF)
2412 {
2413 if (msg)
2414 * msg = "!PTW0.F";
2415 return 5;
2416 }
2417
2418 y2 = offset % 1024;
2419
2420 * finalAddress = ((((word24)PTW1.ADDR & 0777760) << 6) + y2) & PAMASK;
2421 }
2422 if (msg)
2423 * msg = "";
2424 return 0;
2425 }
2426 #endif