root/src/dps8/doAppendCycleAPUDataStore.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. doAppendCycleAPUDataStore_

   1 /*
   2  * vim: filetype=c:tabstop=4:ai:expandtab
   3  * SPDX-License-Identifier: ICU
   4  * scspell-id: 83d28596-171d-11ee-88df-80ee73e9b8e7
   5  *
   6  * ---------------------------------------------------------------------------
   7  *
   8  * Copyright (c) 2022-2023 Charles Anthony
   9  * Copyright (c) 2022-2023 Jeffrey H. Johnson
  10  * Copyright (c) 2022-2025 The DPS8M Development Team
  11  *
  12  * This software is made available under the terms of the ICU License.
  13  * See the LICENSE.md file at the top-level directory of this distribution.
  14  *
  15  * ---------------------------------------------------------------------------
  16  */
  17 
  18 // Compiled twice (see FULL_MODEL_ON and dps8_append.c)
  19 static ALWAYS_INLINE word24 doAppendCycleAPUDataStore_ (cpu_state_t * cpup, word36 * data, uint nWords, const bool full) {
     /* [previous][next][first][last][top][bottom][index][help] */
  20   DCDstruct * i = & cpu.currentInstruction;
  21   DBGAPP ("doAppendCycleAPUDataStore(Entry) thisCycle=APU_DATA_STORE\r\n");
  22   DBGAPP ("doAppendCycleAPUDataStore(Entry) lastCycle=%s\r\n", str_pct (cpu.apu.lastCycle));
  23   DBGAPP ("doAppendCycleAPUDataStore(Entry) CA %06o\r\n", cpu.TPR.CA);
  24   DBGAPP ("doAppendCycleAPUDataStore(Entry) n=%2u\r\n", nWords);
  25   DBGAPP ("doAppendCycleAPUDataStore(Entry) PPR.PRR=%o PPR.PSR=%05o\r\n", cpu.PPR.PRR, cpu.PPR.PSR);
  26   DBGAPP ("doAppendCycleAPUDataStore(Entry) TPR.TRR=%o TPR.TSR=%05o\r\n", cpu.TPR.TRR, cpu.TPR.TSR);
  27 
  28   if (i->b29) {
  29     DBGAPP ("doAppendCycleAPUDataStore(Entry) isb29 PRNO %o\r\n", GET_PRN (IWB_IRODD));
  30   }
  31 
  32   bool nomatch = true;
  33   if (cpu.tweaks.enable_wam) {
  34     // AL39: The associative memory is ignored (forced to "no match") during
  35     // address preparation.
  36     // lptp,lptr,lsdp,lsdr,sptp,sptr,ssdp,ssdr
  37     // Unfortunately, ISOLTS doesn't try to execute any of these in append mode.
  38     // XXX should this be only for OPERAND_READ and OPERAND_STORE?
  39     nomatch = ((i->opcode == 0232 || i->opcode == 0254 ||
  40                 i->opcode == 0154 || i->opcode == 0173) &&
  41                 i->opcodeX ) ||
  42                ((i->opcode == 0557 || i->opcode == 0257) &&
  43                 ! i->opcodeX);
  44   }
  45 
  46   processor_cycle_type lastCycle = cpu.apu.lastCycle;
  47   cpu.apu.lastCycle = APU_DATA_STORE;
  48 
  49   DBGAPP ("doAppendCycleAPUDataStore(Entry) XSF %o\r\n", cpu.cu.XSF);
  50 
  51   PNL (L68_ (cpu.apu.state = 0;))
  52 
  53   cpu.RSDWH_R1 = 0;
  54 
  55   cpu.acvFaults = 0;
  56 
  57 //#define FMSG(x) x
  58 #define FMSG(x)
  59   FMSG (char * acvFaultsMsg = "<unknown>";)
  60 
  61   word24 finalAddress = (word24) -1;  // not everything requires a final address
  62 
  63 ////////////////////////////////////////
  64 //
  65 // Sheet 2: "A"
  66 //
  67 ////////////////////////////////////////
  68 
  69 //
  70 //  A:
  71 //    Get SDW
  72 
  73   PNL (cpu.APUMemAddr = cpu.TPR.CA;)
  74 
  75   DBGAPP ("doAppendCycleAPUDataStore(A)\r\n");
  76 
  77   // is SDW for C(TPR.TSR) in SDWAM?
  78   if (nomatch || ! fetch_sdw_from_sdwam (cpup, cpu.TPR.TSR)) {
  79     // No
  80     DBGAPP ("doAppendCycleAPUDataStore(A):SDW for segment %05o not in SDWAM\r\n", cpu.TPR.TSR);
  81 
  82     DBGAPP ("doAppendCycleAPUDataStore(A):DSBR.U=%o\r\n", cpu.DSBR.U);
  83 
  84     if (cpu.DSBR.U == 0) {
  85       fetch_dsptw (cpup, cpu.TPR.TSR);
  86 
  87       if (! cpu.PTW0.DF)
  88         doFault (FAULT_DF0 + cpu.PTW0.FC, fst_zero, "doAppendCycleAPUDataStore(A): PTW0.F == 0");
  89 
  90       if (! cpu.PTW0.U)
  91           modify_dsptw (cpup, cpu.TPR.TSR);
  92 
  93       fetch_psdw (cpup, cpu.TPR.TSR);
  94     } else
  95       fetch_nsdw (cpup, cpu.TPR.TSR); // load SDW0 from descriptor segment table.
  96 
  97     if (cpu.SDW0.DF == 0) {
  98       DBGAPP ("doAppendCycleAPUDataStore(A): SDW0.F == 0! " "Initiating directed fault\r\n");
  99       // initiate a directed fault ...
 100       doFault (FAULT_DF0 + cpu.SDW0.FC, fst_zero, "SDW0.F == 0");
 101     }
 102     // load SDWAM .....
 103     load_sdwam (cpup, cpu.TPR.TSR, nomatch);
 104   }
 105   DBGAPP ("doAppendCycleAPUDataStore(A) R1 %o R2 %o R3 %o E %o\r\n", cpu.SDW->R1, cpu.SDW->R2, cpu.SDW->R3, cpu.SDW->E);
 106 
 107   // Yes...
 108   cpu.RSDWH_R1 = cpu.SDW->R1;
 109 
 110 ////////////////////////////////////////
 111 //
 112 // Sheet 3: "B"
 113 //
 114 ////////////////////////////////////////
 115 
 116 //
 117 // B: Check the ring
 118 //
 119 
 120   DBGAPP ("doAppendCycleAPUDataStore(B)\r\n");
 121 
 122   // check ring bracket consistency
 123 
 124   //C(SDW.R1) <= C(SDW.R2) <= C(SDW .R3)?
 125   if (! (cpu.SDW->R1 <= cpu.SDW->R2 && cpu.SDW->R2 <= cpu.SDW->R3)) {
 126     // Set fault ACV0 = IRO
 127     cpu.acvFaults |= ACV0;
 128     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 129     FMSG (acvFaultsMsg = "acvFaults(B) C(SDW.R1) <= C(SDW.R2) <= " "C(SDW .R3)";)
 130   }
 131 
 132   // lastCycle == RTCD_OPERAND_FETCH
 133   // if a fault happens between the RTCD_OPERAND_FETCH and the INSTRUCTION_FETCH
 134   // of the next instruction - this happens about 35 time for just booting  and
 135   // shutting down multics -- a stored lastCycle is useless.
 136   // the opcode is preserved across faults and only replaced as the
 137   // INSTRUCTION_FETCH succeeds.
 138   if (lastCycle == RTCD_OPERAND_FETCH)
 139     sim_warn ("%s: lastCycle == RTCD_OPERAND_FETCH opcode %0#o\r\n", __func__, i->opcode);
 140 
 141   //
 142   // B1: The operand is one of: an instruction, data to be read or data to be
 143   //     written
 144   //
 145 
 146   //
 147   // check write bracket for write access
 148   //
 149   DBGAPP ("doAppendCycleAPUDataStore(B):STR-OP\r\n");
 150 
 151   // isolts 870
 152   if (cpu.TPR.TSR == cpu.PPR.PSR)
 153     cpu.TPR.TRR = cpu.PPR.PRR;
 154 
 155   // C(TPR.TRR) > C(SDW .R1)? Note typo in AL39, R2 should be R1
 156   if (cpu.TPR.TRR > cpu.SDW->R1) {
 157     DBGAPP ("ACV5 TRR %o R1 %o\r\n", cpu.TPR.TRR, cpu.SDW->R1);
 158     //Set fault ACV5 = OWB
 159     cpu.acvFaults |= ACV5;
 160     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 161     FMSG (acvFaultsMsg = "acvFaults(B) C(TPR.TRR) > C(SDW .R1)";)
 162   }
 163 
 164   if (! cpu.SDW->W) {
 165     // isolts 870
 166     cpu.TPR.TRR = cpu.PPR.PRR;
 167 
 168     DBGAPP ("ACV6\r\n");
 169     // Set fault ACV6 = W-OFF
 170     cpu.acvFaults |= ACV6;
 171     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 172     FMSG (acvFaultsMsg = "acvFaults(B) ACV6 = W-OFF";)
 173   }
 174 
 175 ////////////////////////////////////////
 176 //
 177 // Sheet 7: "G"
 178 //
 179 ////////////////////////////////////////
 180 
 181   DBGAPP ("doAppendCycleAPUDataStore(G)\r\n");
 182 
 183   //C(TPR.CA)0,13 > SDW.BOUND?
 184   if (((cpu.TPR.CA >> 4) & 037777) > cpu.SDW->BOUND) {
 185     DBGAPP ("ACV15\r\n");
 186     DBGAPP ("doAppendCycleAPUDataStore(G) ACV15\r\n");
 187     cpu.acvFaults |= ACV15;
 188     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 189     FMSG (acvFaultsMsg = "acvFaults(G) C(TPR.CA)0,13 > SDW.BOUND";)
 190     DBGAPP ("acvFaults(G) C(TPR.CA)0,13 > SDW.BOUND\r\n" "   CA %06o CA>>4 & 037777 %06o SDW->BOUND %06o",
 191             cpu.TPR.CA, ((cpu.TPR.CA >> 4) & 037777), cpu.SDW->BOUND);
 192   }
 193 
 194   if (cpu.acvFaults) {
 195     DBGAPP ("doAppendCycleAPUDataStore(G) acvFaults\r\n");
 196     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 197     // Initiate an access violation fault
 198     doFault (FAULT_ACV, (_fault_subtype) {.fault_acv_subtype=cpu.acvFaults}, "ACV fault");
 199   }
 200 
 201   // is segment C(TPR.TSR) paged?
 202   if (cpu.SDW->U)
 203     goto H; // Not paged
 204 
 205   // Yes. segment is paged ...
 206   // is PTW for C(TPR.CA) in PTWAM?
 207 
 208   DBGAPP ("doAppendCycleAPUDataStore(G) CA %06o\r\n", cpu.TPR.CA);
 209   if (nomatch || ! fetch_ptw_from_ptwam (cpup, cpu.SDW->POINTER, cpu.TPR.CA)) {
 210     fetch_ptw (cpup, cpu.SDW, cpu.TPR.CA);
 211     if (! cpu.PTW0.DF) {
 212       // initiate a directed fault
 213       doFault (FAULT_DF0 + cpu.PTW0.FC, (_fault_subtype) {.bits=0}, "PTW0.F == 0");
 214     }
 215     loadPTWAM (cpup, cpu.SDW->POINTER, cpu.TPR.CA, nomatch); // load PTW0 to PTWAM
 216   }
 217 
 218   // Prepage mode?
 219   // check for "uninterruptible" EIS instruction
 220   // ISOLTS-878 02: mvn,cmpn,mvne,ad3d; obviously also
 221   // ad2/3d,sb2/3d,mp2/3d,dv2/3d
 222   // DH03 p.8-13: probably also mve,btd,dtb
 223   if (i->opcodeX && ((i->opcode & 0770)== 0200|| (i->opcode & 0770) == 0220
 224       || (i->opcode & 0770)== 020|| (i->opcode & 0770) == 0300)) {
 225     do_ptw2 (cpup, cpu.SDW, cpu.TPR.CA);
 226   }
 227   goto I;
 228 
 229 ////////////////////////////////////////
 230 //
 231 // Sheet 8: "H", "I"
 232 //
 233 ////////////////////////////////////////
 234 
 235 H:;
 236   DBGAPP ("doAppendCycleAPUDataStore(H): FANP\r\n");
 237 
 238   PNL (L68_ (cpu.apu.state |= apu_FANP;))
 239 
 240 
 241 
 242 
 243 
 244 
 245 
 246 
 247   set_apu_status (cpup, apuStatus_FANP);
 248 
 249   DBGAPP ("doAppendCycleAPUDataStore(H): SDW->ADDR=%08o CA=%06o\r\n", cpu.SDW->ADDR, cpu.TPR.CA);
 250 
 251   finalAddress = (cpu.SDW->ADDR & 077777760) + cpu.TPR.CA;
 252   finalAddress &= 0xffffff;
 253   PNL (cpu.APUMemAddr = finalAddress;)
 254 
 255   DBGAPP ("doAppendCycleAPUDataStore(H:FANP): (%05o:%06o) finalAddress=%08o\r\n", cpu.TPR.TSR, cpu.TPR.CA, finalAddress);
 256 
 257   goto HI;
 258 
 259 I:;
 260 
 261 // Set PTW.M
 262 
 263   DBGAPP ("doAppendCycleAPUDataStore(I): FAP\r\n");
 264   if (cpu.PTW->M == 0)  // is this the right way to do this?
 265      modify_ptw (cpup, cpu.SDW, cpu.TPR.CA);
 266 
 267     // final address paged
 268   set_apu_status (cpup, apuStatus_FAP);
 269   PNL (L68_ (cpu.apu.state |= apu_FAP;))
 270 
 271   word24 y2 = cpu.TPR.CA % 1024;
 272 
 273   // AL39: The hardware ignores low order bits of the main memory page
 274   // address according to page size
 275   finalAddress = (((word24)cpu.PTW->ADDR & 0777760) << 6) + y2;
 276   finalAddress &= 0xffffff;
 277   PNL (cpu.APUMemAddr = finalAddress;)
 278 
 279   L68_ (
 280     if (cpu.MR_cache.emr && cpu.MR_cache.ihr)
 281       add_l68_APU_history (cpup, APUH_FAP);
 282   )
 283 
 284   DBGAPP ("doAppendCycleAPUDataStore(H:FAP): (%05o:%06o) finalAddress=%08o\r\n", cpu.TPR.TSR, cpu.TPR.CA, finalAddress);
 285 
 286   goto HI;
 287 
 288 HI:
 289   DBGAPP ("doAppendCycleAPUDataStore(HI)\r\n");
 290 
 291   // isolts 870
 292   cpu.cu.XSF = 1;
 293   if (full)   // (1), see FULL_MODEL_ON
 294     cpu.xsfScu = true;   // IT modifier (tally) words
 295   sim_debug (DBG_TRACEEXT, & cpu_dev, "loading of cpu.TPR.TSR sets XSF to 1\r\n");
 296 
 297   if (full && sdpap_store (cpup, finalAddress, data, nWords))
 298     ;
 299   else if (full)
 300     cache_writeN (cpup, finalAddress, data, nWords, "APU_DATA_STORE");
 301   else
 302     core_writeN_fast (cpup, finalAddress, data, nWords, "APU_DATA_STORE");
 303 
 304   PNL (cpu.APUDataBusOffset = cpu.TPR.CA;)
 305   PNL (cpu.APUDataBusAddr = finalAddress;)
 306 
 307   PNL (L68_ (cpu.apu.state |= apu_FA;))
 308 
 309   DBGAPP ("doAppendCycleAPUDataStore (Exit) PRR %o PSR %05o P %o IC %06o\r\n", cpu.PPR.PRR, cpu.PPR.PSR, cpu.PPR.P, cpu.PPR.IC);
 310   DBGAPP ("doAppendCycleAPUDataStore (Exit) TRR %o TSR %05o TBR %02o CA %06o\r\n", cpu.TPR.TRR, cpu.TPR.TSR, cpu.TPR.TBR, cpu.TPR.CA);
 311 
 312   return finalAddress;    // or 0 or -1???
 313 }

/* [previous][next][first][last][top][bottom][index][help] */