root/src/dps8/doAppendCycleOperandStore.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. doAppendCycleOperandStore_

   1 /*
   2  * vim: filetype=c:tabstop=4:ai:expandtab
   3  * SPDX-License-Identifier: ICU
   4  * scspell-id: 2b0da7ec-171d-11ee-a633-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 doAppendCycleOperandStore_ (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 ("doAppendCycleOperandStore(Entry) thisCycle=OPERAND_STORE\r\n");
  22   DBGAPP ("doAppendCycleOperandStore(Entry) lastCycle=%s\r\n", str_pct (cpu.apu.lastCycle));
  23   DBGAPP ("doAppendCycleOperandStore(Entry) CA %06o\r\n", cpu.TPR.CA);
  24   DBGAPP ("doAppendCycleOperandStore(Entry) n=%2u\r\n", nWords);
  25   DBGAPP ("doAppendCycleOperandStore(Entry) PPR.PRR=%o PPR.PSR=%05o\r\n", cpu.PPR.PRR, cpu.PPR.PSR);
  26   DBGAPP ("doAppendCycleOperandStore(Entry) TPR.TRR=%o TPR.TSR=%05o\r\n", cpu.TPR.TRR, cpu.TPR.TSR);
  27 
  28   if (i->b29) {
  29     DBGAPP ("doAppendCycleOperandStore(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 = OPERAND_STORE;
  48 
  49   DBGAPP ("doAppendCycleOperandStore(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 = address;)
  74   PNL (cpu.APUMemAddr = cpu.TPR.CA;)
  75 
  76   DBGAPP ("doAppendCycleOperandStore(A)\r\n");
  77 
  78   // is SDW for C(TPR.TSR) in SDWAM?
  79   if (nomatch || ! fetch_sdw_from_sdwam (cpup, cpu.TPR.TSR)) {
  80     // No
  81     DBGAPP ("doAppendCycleOperandStore(A):SDW for segment %05o not in SDWAM\r\n", cpu.TPR.TSR);
  82 
  83     DBGAPP ("doAppendCycleOperandStore(A):DSBR.U=%o\r\n", cpu.DSBR.U);
  84 
  85     if (cpu.DSBR.U == 0) {
  86       fetch_dsptw (cpup, cpu.TPR.TSR);
  87 
  88       if (! cpu.PTW0.DF)
  89         doFault (FAULT_DF0 + cpu.PTW0.FC, fst_zero, "doAppendCycleOperandStore(A): PTW0.F == 0");
  90 
  91       if (! cpu.PTW0.U)
  92         modify_dsptw (cpup, cpu.TPR.TSR);
  93 
  94       fetch_psdw (cpup, cpu.TPR.TSR);
  95     } else
  96       fetch_nsdw (cpup, cpu.TPR.TSR); // load SDW0 from descriptor segment table.
  97 
  98     if (cpu.SDW0.DF == 0) {
  99       DBGAPP ("doAppendCycleOperandStore(A): SDW0.F == 0! " "Initiating directed fault\r\n");
 100       // initiate a directed fault ...
 101       doFault (FAULT_DF0 + cpu.SDW0.FC, fst_zero, "SDW0.F == 0");
 102     }
 103     // load SDWAM .....
 104     load_sdwam (cpup, cpu.TPR.TSR, nomatch);
 105   }
 106   DBGAPP ("doAppendCycleOperandStore(A) R1 %o R2 %o R3 %o E %o\r\n", cpu.SDW->R1, cpu.SDW->R2, cpu.SDW->R3, cpu.SDW->E);
 107 
 108   // Yes...
 109   cpu.RSDWH_R1 = cpu.SDW->R1;
 110 
 111 ////////////////////////////////////////
 112 //
 113 // Sheet 3: "B"
 114 //
 115 ////////////////////////////////////////
 116 
 117 //
 118 // B: Check the ring
 119 //
 120 
 121   DBGAPP ("doAppendCycleOperandStore(B)\r\n");
 122 
 123   // check ring bracket consistency
 124 
 125   //C(SDW.R1) <= C(SDW.R2) <= C(SDW .R3)?
 126   if (! (cpu.SDW->R1 <= cpu.SDW->R2 && cpu.SDW->R2 <= cpu.SDW->R3)) {
 127     // Set fault ACV0 = IRO
 128     cpu.acvFaults |= ACV0;
 129     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 130     FMSG (acvFaultsMsg = "acvFaults(B) C(SDW.R1) <= C(SDW.R2) <= " "C(SDW .R3)";)
 131   }
 132 
 133   if (lastCycle == RTCD_OPERAND_FETCH)
 134     sim_warn ("%s: lastCycle == RTCD_OPERAND_FETCH opcode %0#o\r\n", __func__, i->opcode);
 135 
 136   //
 137   // B1: The operand is one of: an instruction, data to be read or data to be
 138   //     written
 139   //
 140 
 141   //
 142   // check write bracket for write access
 143   //
 144   DBGAPP ("doAppendCycleOperandStore(B):STR-OP\r\n");
 145 
 146   // isolts 870
 147   if (cpu.TPR.TSR == cpu.PPR.PSR)
 148     cpu.TPR.TRR = cpu.PPR.PRR;
 149 
 150   // C(TPR.TRR) > C(SDW .R1)? Note typo in AL39, R2 should be R1
 151   if (cpu.TPR.TRR > cpu.SDW->R1) {
 152     DBGAPP ("ACV5 TRR %o R1 %o\r\n", cpu.TPR.TRR, cpu.SDW->R1);
 153     //Set fault ACV5 = OWB
 154     cpu.acvFaults |= ACV5;
 155     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 156     FMSG (acvFaultsMsg = "acvFaults(B) C(TPR.TRR) > C(SDW .R1)";)
 157   }
 158 
 159   if (! cpu.SDW->W) {
 160     // isolts 870
 161     cpu.TPR.TRR = cpu.PPR.PRR;
 162 
 163     DBGAPP ("ACV6\r\n");
 164     // Set fault ACV6 = W-OFF
 165     cpu.acvFaults |= ACV6;
 166     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 167     FMSG (acvFaultsMsg = "acvFaults(B) ACV6 = W-OFF";)
 168   }
 169 
 170   goto G;
 171 
 172 ////////////////////////////////////////
 173 //
 174 // Sheet 7: "G"
 175 //
 176 ////////////////////////////////////////
 177 
 178 G:;
 179 
 180   DBGAPP ("doAppendCycleOperandStore(G)\r\n");
 181 
 182   //C(TPR.CA)0,13 > SDW.BOUND?
 183   if (((cpu.TPR.CA >> 4) & 037777) > cpu.SDW->BOUND) {
 184     DBGAPP ("ACV15\r\n");
 185     DBGAPP ("doAppendCycleOperandStore(G) ACV15\r\n");
 186     cpu.acvFaults |= ACV15;
 187     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 188     FMSG (acvFaultsMsg = "acvFaults(G) C(TPR.CA)0,13 > SDW.BOUND";)
 189     DBGAPP ("acvFaults(G) C(TPR.CA)0,13 > SDW.BOUND\r\n" "   CA %06o CA>>4 & 037777 %06o SDW->BOUND %06o",
 190             cpu.TPR.CA, ((cpu.TPR.CA >> 4) & 037777), cpu.SDW->BOUND);
 191   }
 192 
 193   if (cpu.acvFaults) {
 194     DBGAPP ("doAppendCycleOperandStore(G) acvFaults\r\n");
 195     PNL (L68_ (cpu.apu.state |= apu_FLT;))
 196     // Initiate an access violation fault
 197     doFault (FAULT_ACV, (_fault_subtype) {.fault_acv_subtype=cpu.acvFaults}, "ACV fault");
 198   }
 199 
 200   // is segment C(TPR.TSR) paged?
 201   if (cpu.SDW->U)
 202     goto H; // Not paged
 203 
 204   // Yes. segment is paged ...
 205   // is PTW for C(TPR.CA) in PTWAM?
 206 
 207   DBGAPP ("doAppendCycleOperandStore(G) CA %06o\r\n", cpu.TPR.CA);
 208   if (nomatch || ! fetch_ptw_from_ptwam (cpup, cpu.SDW->POINTER, cpu.TPR.CA)) {
 209     fetch_ptw (cpup, cpu.SDW, cpu.TPR.CA);
 210     if (! cpu.PTW0.DF) {
 211       // initiate a directed fault
 212       doFault (FAULT_DF0 + cpu.PTW0.FC, (_fault_subtype) {.bits=0}, "PTW0.F == 0");
 213     }
 214     loadPTWAM (cpup, cpu.SDW->POINTER, cpu.TPR.CA, nomatch); // load PTW0 to PTWAM
 215   }
 216 
 217   // Prepage mode?
 218   // check for "uninterruptible" EIS instruction
 219   // ISOLTS-878 02: mvn,cmpn,mvne,ad3d; obviously also
 220   // ad2/3d,sb2/3d,mp2/3d,dv2/3d
 221   // DH03 p.8-13: probably also mve,btd,dtb
 222   if (i->opcodeX && ((i->opcode & 0770)== 0200|| (i->opcode & 0770) == 0220
 223       || (i->opcode & 0770)== 020|| (i->opcode & 0770) == 0300)) {
 224     do_ptw2 (cpup, cpu.SDW, cpu.TPR.CA);
 225   }
 226   goto I;
 227 
 228 ////////////////////////////////////////
 229 //
 230 // Sheet 8: "H", "I"
 231 //
 232 ////////////////////////////////////////
 233 
 234 H:;
 235   DBGAPP ("doAppendCycleOperandStore(H): FANP\r\n");
 236 
 237   PNL (L68_ (cpu.apu.state |= apu_FANP;))
 238 
 239 
 240 
 241 
 242 
 243 
 244 
 245   set_apu_status (cpup, apuStatus_FANP);
 246 
 247   DBGAPP ("doAppendCycleOperandStore(H): SDW->ADDR=%08o CA=%06o\r\n", cpu.SDW->ADDR, cpu.TPR.CA);
 248 
 249   finalAddress = (cpu.SDW->ADDR & 077777760) + cpu.TPR.CA;
 250   finalAddress &= 0xffffff;
 251   PNL (cpu.APUMemAddr = finalAddress;)
 252 
 253   DBGAPP ("doAppendCycleOperandStore(H:FANP): (%05o:%06o) finalAddress=%08o\r\n", cpu.TPR.TSR, cpu.TPR.CA, finalAddress);
 254 
 255   goto HI;
 256 
 257 I:;
 258 
 259 // Set PTW.M
 260 
 261   DBGAPP ("doAppendCycleOperandStore(I): FAP\r\n");
 262   if (cpu.PTW->M == 0)  // is this the right way to do this?
 263    modify_ptw (cpup, cpu.SDW, cpu.TPR.CA);
 264 
 265   // final address paged
 266   set_apu_status (cpup, apuStatus_FAP);
 267   PNL (L68_ (cpu.apu.state |= apu_FAP;))
 268 
 269   word24 y2 = cpu.TPR.CA % 1024;
 270 
 271   // AL39: The hardware ignores low order bits of the main memory page
 272   // address according to page size
 273   finalAddress = (((word24)cpu.PTW->ADDR & 0777760) << 6) + y2;
 274   finalAddress &= 0xffffff;
 275   PNL (cpu.APUMemAddr = finalAddress;)
 276 
 277   L68_ (
 278     if (cpu.MR_cache.emr && cpu.MR_cache.ihr)
 279       add_l68_APU_history (cpup, APUH_FAP);
 280   )
 281 
 282   DBGAPP ("doAppendCycleOperandStore(H:FAP): (%05o:%06o) finalAddress=%08o\r\n", cpu.TPR.TSR, cpu.TPR.CA, finalAddress);
 283 
 284   goto HI;
 285 
 286 HI:
 287   DBGAPP ("doAppendCycleOperandStore(HI)\r\n");
 288 
 289   // isolts 870
 290   cpu.cu.XSF = 1;
 291   if (full && cpu.currentInstruction.b29)   // (1), see FULL_MODEL_ON
 292     cpu.xsfScu = true;
 293   sim_debug (DBG_TRACEEXT, & cpu_dev, "loading of cpu.TPR.TSR sets XSF to 1\r\n");
 294 
 295   if (full && sdpap_store (cpup, finalAddress, data, nWords))
 296     ;
 297   else if (cpu.useZone)
 298     cache_write_zone (cpup, finalAddress, * data, "OPERAND_STORE");
 299   else if (full)
 300     cache_writeN (cpup, finalAddress, data, nWords, "OPERAND_STORE");
 301   else
 302     core_writeN_fast (cpup, finalAddress, data, nWords, "OPERAND_STORE");
 303 
 304 //Exit:;
 305 
 306   PNL (cpu.APUDataBusOffset = cpu.TPR.CA;)
 307   PNL (cpu.APUDataBusAddr = finalAddress;)
 308 
 309   PNL (L68_ (cpu.apu.state |= apu_FA;))
 310 
 311   DBGAPP ("doAppendCycleOperandStore (Exit) PRR %o PSR %05o P %o IC %06o\r\n", cpu.PPR.PRR, cpu.PPR.PSR, cpu.PPR.P, cpu.PPR.IC);
 312   DBGAPP ("doAppendCycleOperandStore (Exit) TRR %o TSR %05o TBR %02o CA %06o\r\n", cpu.TPR.TRR, cpu.TPR.TSR, cpu.TPR.TBR, cpu.TPR.CA);
 313 
 314   return finalAddress;
 315 }

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