Implement segmented memory by M[][] rather than M[], start executing at specified...
authorNick Downing <nick@ndcode.org>
Wed, 16 Oct 2019 13:15:33 +0000 (00:15 +1100)
committerNick Downing <nick@ndcode.org>
Wed, 16 Oct 2019 13:15:45 +0000 (00:15 +1100)
Makefile
dps8/dps8_cpu.c
dps8/dps8_cpu.h
dps8/dps8_ins.c
dps8/dps8_simh.h
dps8/dps8_sys.c
dps8/dps8_sys.h
dps8/errs [deleted file]
dps8/scp.h
multics_sim.c

index 27aa771..5e47ec8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
-CFLAGS=-g -O3 -std=c99 -U__STRICT_ANSI__ -IdecNumber -Idps8 -D_GNU_SOURCE -DUSE_READER_THREAD -DUSE_INT64 -Wno-unused-result
+CFLAGS=-g -std=c99 -U__STRICT_ANSI__ -IdecNumber -Idps8 -D_GNU_SOURCE -DUSE_READER_THREAD -DUSE_INT64 -DTESTING -Wno-unused-result
+#-O3
 
 multics_sim: \
 multics_sim.o \
index 0e5f540..581270d 100644 (file)
@@ -624,30 +624,30 @@ uint set_cpu_idx (UNUSED uint cpu_idx)
 void cpu_reset_unit_idx (UNUSED uint cpun, bool clear_mem)
   {
     uint save = set_cpu_idx (cpun);
-    if (clear_mem)
-      {
-#ifdef SCUMEM
-        for (int cpu_port_num = 0; cpu_port_num < N_CPU_PORTS; cpu_port_num ++)
-          {
-            if (get_scu_in_use (current_running_cpu_idx, cpu_port_num))
-              {
-                uint sci_unit_idx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
-                // Clear lock bits
-                for (uint i = 0; i < SCU_MEM_SIZE; i ++)
-                  {
-                    //scu [sci_unit_idx].M[i] = MEM_UNINITIALIZED;
-                    scu [sci_unit_idx].M[i] &= (MASK36 | MEM_UNINITIALIZED);
-                  }
-              }
-          }
-#else
-        for (uint i = 0; i < MEMSIZE; i ++)
-          {
-            //M [i] = MEM_UNINITIALIZED;
-            M[i] &= (MASK36 | MEM_UNINITIALIZED);
-          }
-#endif
-      }
+//    if (clear_mem)
+//      {
+//#ifdef SCUMEM
+//        for (int cpu_port_num = 0; cpu_port_num < N_CPU_PORTS; cpu_port_num ++)
+//          {
+//            if (get_scu_in_use (current_running_cpu_idx, cpu_port_num))
+//              {
+//                uint sci_unit_idx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
+//                // Clear lock bits
+//                for (uint i = 0; i < SCU_MEM_SIZE; i ++)
+//                  {
+//                    //scu [sci_unit_idx].M[i] = MEM_UNINITIALIZED;
+//                    scu [sci_unit_idx].M[i] &= (MASK36 | MEM_UNINITIALIZED);
+//                  }
+//              }
+//          }
+//#else
+//        for (uint i = 0; i < MEMSIZE; i ++)
+//          {
+//            //M [i] = MEM_UNINITIALIZED;
+//            M[i] &= (MASK36 | MEM_UNINITIALIZED);
+//          }
+//#endif
+//      }
     cpu.rA = 0;
     cpu.rQ = 0;
     
@@ -1305,7 +1305,7 @@ static t_stat cpu_ex (t_value *vptr, t_addr addr, UNUSED UNIT * uptr,
         core_read (addr, & w, __func__);
         *vptr = w;
 #else
-        *vptr = M[addr] & DMASK;
+        *vptr = M[(addr >> 18) & 077777][addr & 0777777] & DMASK;
 #endif
       }
     return SCPE_OK;
@@ -1321,7 +1321,7 @@ static t_stat cpu_dep (t_value val, t_addr addr, UNUSED UNIT * uptr,
     word36 w = val & DMASK;
     core_write (addr, w, __func__);
 #else
-    M[addr] = val & DMASK;
+    M[(addr >> 18) & 077777][addr & 0777777] = val & DMASK;
 #endif
     return SCPE_OK;
   }
@@ -3166,7 +3166,7 @@ int32 core_read (word24 addr, word36 *data, const char * ctx)
       }
 #else
 #ifndef LOCKLESS
-    if (M[addr] & MEM_UNINITIALIZED)
+    if (M[(addr >> 18) & 077777][addr & 0777777] & MEM_UNINITIALIZED)
       {
         sim_debug (DBG_WARN, & cpu_dev,
                    "Unitialized memory accessed at address %08o; "
@@ -3179,7 +3179,7 @@ int32 core_read (word24 addr, word36 *data, const char * ctx)
       {
         sim_msg ("WATCH [%"PRId64"] %05o:%06o read   %08o %012"PRIo64" "
                     "(%s)\n",
-                    cpu.cycleCnt, cpu.PPR.PSR, cpu.PPR.IC, addr, M [addr],
+                    cpu.cycleCnt, cpu.PPR.PSR, cpu.PPR.IC, addr, M[(addr >> 18) & 077777][addr & 0777777],
                     ctx);
         traceInstruction (0);
       }
@@ -3190,7 +3190,7 @@ int32 core_read (word24 addr, word36 *data, const char * ctx)
     *data = v & DMASK;
 #else
     LOCK_MEM_RD;
-    *data = M[addr] & DMASK;
+    *data = M[(addr >> 18) & 077777][addr & 0777777] & DMASK;
     UNLOCK_MEM;
 #endif
 
@@ -3290,7 +3290,7 @@ int core_write (word24 addr, word36 data, const char * ctx)
     STORE_REL_CORE_WORD(addr, data);
 #else
     LOCK_MEM_WR;
-    M[addr] = data & DMASK;
+    M[(addr >> 18) & 077777][addr & 0777777] = data & DMASK;
     UNLOCK_MEM;
 #endif
 #ifndef SPEED
@@ -3298,7 +3298,7 @@ int core_write (word24 addr, word36 data, const char * ctx)
       {
         sim_msg ("WATCH [%"PRId64"] %05o:%06o write  %08o %012"PRIo64" "
                     "(%s)\n", cpu.cycleCnt, cpu.PPR.PSR, cpu.PPR.IC, addr, 
-                    M [addr], ctx);
+                    M[(addr >> 18) & 077777][addr & 0777777], ctx);
         traceInstruction (0);
       }
 #endif
@@ -3352,7 +3352,7 @@ int core_unlock_all ()
       sim_warn ("core_unlock_all: locked %08o %c %05o:%06o\n",
                 cpu.locked_addr, current_running_cpu_idx + 'A',
                 cpu.PPR.PSR, cpu.PPR.IC);
-      STORE_REL_CORE_WORD(cpu.locked_addr, M[cpu.locked_addr]);
+      STORE_REL_CORE_WORD(cpu.locked_addr, M[(cpu.locked_addr >> 18) & 077777][cpu.locked_addr & 0777777]);
       cpu.locked_addr = 0;
   }
   return 0;
@@ -3413,7 +3413,7 @@ int core_write_zone (word24 addr, word36 data, const char * ctx)
       nem_check (addr,  "core_read nem");
 #endif
     LOCK_MEM_WR;
-    M[addr] = (M[addr] & ~cpu.zone) | (data & cpu.zone);
+    M[(addr >> 18) & 077777][addr & 0777777] = (M[(addr >> 18) & 077777][addr & 0777777] & ~cpu.zone) | (data & cpu.zone);
     UNLOCK_MEM;
 #endif
     cpu.useZone = false; // Safety
@@ -3422,7 +3422,7 @@ int core_write_zone (word24 addr, word36 data, const char * ctx)
       {
         sim_msg ("WATCH [%"PRId64"] %05o:%06o writez %08o %012"PRIo64" "
                     "(%s)\n", cpu.cycleCnt, cpu.PPR.PSR, cpu.PPR.IC, addr, 
-                    M [addr], ctx);
+                    M[(addr >> 18) & 077777][addr & 0777777], ctx);
         traceInstruction (0);
       }
 #endif
@@ -3515,7 +3515,7 @@ int core_read2 (word24 addr, word36 *even, word36 *odd, const char * ctx)
                 addr+1, * odd, ctx);
 #else
 #ifndef LOCKLESS
-    if (M[addr] & MEM_UNINITIALIZED)
+    if (M[(addr >> 18) & 077777][addr & 0777777] & MEM_UNINITIALIZED)
       {
         sim_debug (DBG_WARN, & cpu_dev,
                    "Unitialized memory accessed at address %08o; "
@@ -3528,7 +3528,7 @@ int core_read2 (word24 addr, word36 *even, word36 *odd, const char * ctx)
       {
         sim_msg ("WATCH [%"PRId64"] %05o:%06o read2  %08o %012"PRIo64" "
                     "(%s)\n", cpu.cycleCnt, cpu.PPR.PSR, cpu.PPR.IC, addr, 
-                    M [addr], ctx);
+                    M[(addr >> 18) & 077777][addr & 0777777], ctx);
         traceInstruction (0);
       }
 #endif
@@ -3543,7 +3543,8 @@ int core_read2 (word24 addr, word36 *even, word36 *odd, const char * ctx)
     addr++;
 #else
     LOCK_MEM_RD;
-    *even = M[addr++] & DMASK;
+    *even = M[(addr >> 18) & 077777][addr & 0777777] & DMASK;
+    addr++;
     UNLOCK_MEM;
 #endif
     sim_debug (DBG_CORE, & cpu_dev,
@@ -3553,7 +3554,7 @@ int core_read2 (word24 addr, word36 *even, word36 *odd, const char * ctx)
     // if the even address is OK, the odd will be
     //nem_check (addr,  "core_read2 nem");
 #ifndef LOCKLESS
-    if (M[addr] & MEM_UNINITIALIZED)
+    if (M[(addr >> 18) & 077777][addr & 0777777] & MEM_UNINITIALIZED)
       {
         sim_debug (DBG_WARN, & cpu_dev,
                    "Unitialized memory accessed at address %08o; "
@@ -3566,7 +3567,7 @@ int core_read2 (word24 addr, word36 *even, word36 *odd, const char * ctx)
       {
         sim_msg ("WATCH [%"PRId64"] %05o:%06o read2  %08o %012"PRIo64" "
                     "(%s)\n", cpu.cycleCnt, cpu.PPR.PSR, cpu.PPR.IC, addr,
-                    M [addr], ctx);
+                    M[(addr >> 18) & 077777][addr & 0777777], ctx);
         traceInstruction (0);
       }
 #endif
@@ -3579,7 +3580,7 @@ int core_read2 (word24 addr, word36 *even, word36 *odd, const char * ctx)
     *odd = v & DMASK;
 #else
     LOCK_MEM_RD;
-    *odd = M[addr] & DMASK;
+    *odd = M[(addr >> 18) & 077777][addr & 0777777] & DMASK;
     UNLOCK_MEM;
 #endif
     sim_debug (DBG_CORE, & cpu_dev,
@@ -3669,7 +3670,8 @@ int core_write2 (word24 addr, word36 even, word36 odd, const char * ctx)
     addr++;
 #else
     LOCK_MEM_WR;
-    M[addr++] = even & DMASK;
+    M[(addr >> 18) & 077777][addr & 0777777] = even & DMASK;
+    addr++;
     UNLOCK_MEM;
 #endif
     sim_debug (DBG_CORE, & cpu_dev,
@@ -3693,7 +3695,7 @@ int core_write2 (word24 addr, word36 even, word36 odd, const char * ctx)
     STORE_REL_CORE_WORD(addr, odd);
 #else
     LOCK_MEM_WR;
-    M[addr] = odd & DMASK;
+    M[(addr >> 18) & 077777][addr & 0777777] = odd & DMASK;
     UNLOCK_MEM;
 #endif
 #endif
index 95b9d67..7f35295 100644 (file)
@@ -1961,7 +1961,7 @@ static inline int core_read (word24 addr, word36 *data, UNUSED const char * ctx)
     UNLOCK_MEM;
 #else
     LOCK_MEM_RD;
-    *data = M[addr] & DMASK;
+    *data = M[(addr >> 18) & 077777][addr & 0777777] & DMASK;
     UNLOCK_MEM;
 #endif
 #ifdef TR_WORK_MEM
@@ -2012,7 +2012,7 @@ static inline int core_write (word24 addr, word36 data, UNUSED const char * ctx)
     UNLOCK_MEM;
 #else
     LOCK_MEM_WR;
-    M[addr] = data & DMASK;
+    M[(addr >> 18) & 077777][addr & 0777777] = data & DMASK;
     UNLOCK_MEM;
 #endif
 #ifdef TR_WORK_MEM
@@ -2065,7 +2065,7 @@ static inline int core_write_zone (word24 addr, word36 data, UNUSED const char *
     UNLOCK_MEM;
 #else
     LOCK_MEM_WR;
-    M[addr] = (M[addr] & ~cpu.zone) | (data & cpu.zone);
+    M[(addr >> 18) & 077777][addr & 0777777] = (M[(addr >> 18) & 077777][addr & 0777777] & ~cpu.zone) | (data & cpu.zone);
     cpu.useZone = false; // Safety
     UNLOCK_MEM;
 #endif
@@ -2121,8 +2121,9 @@ static inline int core_read2 (word24 addr, word36 *even, word36 *odd,
     UNLOCK_MEM;
 #else
     LOCK_MEM_WR;
-    *even = M[addr++] & DMASK;
-    *odd = M[addr] & DMASK;
+    *even = M[(addr >> 18) & 077777][addr & 0777777] & DMASK;
+    addr++;
+    *odd = M[(addr >> 18) & 077777][addr & 0777777] & DMASK;
     UNLOCK_MEM;
 #endif
 #ifdef TR_WORK_MEM
@@ -2175,8 +2176,9 @@ static inline int core_write2 (word24 addr, word36 even, word36 odd,
     UNLOCK_MEM;
 #else
     LOCK_MEM_WR;
-    M[addr++] = even;
-    M[addr] = odd;
+    M[(addr >> 18) & 077777][addr & 0777777] = even;
+    addr++;
+    M[(addr >> 18) & 077777][addr & 0777777] = odd;
     UNLOCK_MEM;
 #endif
     PNL (trackport (addr - 1, even);)
@@ -2209,7 +2211,7 @@ int core_unlock_all();
   do                                                                   \
     {                                                                  \
       unsigned int i = DEADLOCK_DETECT;                                        \
-      while ( atomic_testandset_64((volatile u_long *)&M[addr], MEM_LOCKED_BIT) == 1 && i > 0) \
+      while ( atomic_testandset_64((volatile u_long *)&M[(addr >> 18) & 077777][addr & 0777777], MEM_LOCKED_BIT) == 1 && i > 0) \
        {                                                               \
          i--;                                                          \
          if ((i & 0xff) == 0) {                                        \
@@ -2232,14 +2234,14 @@ int core_unlock_all();
 #define LOAD_ACQ_CORE_WORD(res, addr)                  \
   do                                                   \
     {                                                  \
-      res = atomic_load_acq_64((volatile u_long *)&M[addr]);   \
+      res = atomic_load_acq_64((volatile u_long *)&M[(addr >> 18) & 077777][addr & 0777777]);  \
     }                                                          \
   while (0)
 
 #define STORE_REL_CORE_WORD(addr, data)                                        \
   do                                                                   \
     {                                                                  \
-      atomic_store_rel_64((volatile u_long *)&M[addr], data & DMASK);  \
+      atomic_store_rel_64((volatile u_long *)&M[(addr >> 18) & 077777][addr & 0777777], data & DMASK); \
     }                                                                  \
   while (0)
 
@@ -2255,7 +2257,7 @@ int core_unlock_all();
      do                                                                        \
        {                                                               \
         unsigned int i = DEADLOCK_DETECT;                                      \
-        while ((__sync_fetch_and_or((volatile u_long *)&M[addr], MEM_LOCKED) & MEM_LOCKED) \
+        while ((__sync_fetch_and_or((volatile u_long *)&M[(addr >> 18) & 077777][addr & 0777777], MEM_LOCKED) & MEM_LOCKED) \
                &&  i > 0)                                              \
           {                                                            \
            i--;                                                        \
@@ -2279,7 +2281,7 @@ int core_unlock_all();
 #define LOAD_ACQ_CORE_WORD(res, addr)                  \
      do                                                        \
        {                                               \
-        res = M[addr];                                 \
+        res = M[(addr >> 18) & 077777][addr & 0777777];                                        \
         MEM_BARRIER();                                 \
        }                                               \
      while (0)
@@ -2288,7 +2290,7 @@ int core_unlock_all();
   do                                                                   \
     {                                                                  \
       MEM_BARRIER();                                                   \
-      M[addr] = data & DMASK;                                          \
+      M[(addr >> 18) & 077777][addr & 0777777] = data & DMASK;                                         \
     }                                                                  \
   while (0)
 
index 900c44c..76e78c6 100644 (file)
@@ -1132,6 +1132,7 @@ void fetchInstruction (word18 addr)
             cpu.cu.IRODD = cpu.cu.IWB; 
           }
       }
+ //printf("PSR %05o IC %06o IWB %012llo\n", cpu.PPR.PSR, cpu.PPR.IC, cpu.cu.IWB);
 }
 
 #ifdef TESTING
@@ -1144,8 +1145,9 @@ void traceInstruction (uint flag)
 force:;
         char * compname;
         word18 compoffset;
-        char * where = lookup_address (cpu.PPR.PSR, cpu.PPR.IC, & compname,
-                                       & compoffset);
+ char *where = "somewhere";
+ //        char * where = lookup_address (cpu.PPR.PSR, cpu.PPR.IC, & compname,
+ //                                       & compoffset);
         bool isBAR = TST_I_NBAR ? false : true;
         if (where)
           {
@@ -1175,7 +1177,7 @@ force:;
                                cpu.PPR.PSR, cpu.PPR.IC, where);
                   }
               }
-            list_source (compname, compoffset, flag);
//            list_source (compname, compoffset, flag);
           }
         if (get_addr_mode () == ABSOLUTE_mode)
           {
@@ -2607,6 +2609,7 @@ static t_stat doInstruction (void)
 #endif
 #endif // PANEL
 
+ //printf("opcode10 %03o\n", opcode10);
     switch (opcode10)
       {
 
index 8e91cfc..1bbf247 100644 (file)
@@ -23,46 +23,47 @@ extern DEVICE scu_dev;
 #endif
 #endif
 
-#ifdef SPEED
-#define if_sim_debug(dbits, dptr) if ((0))
-
-#else
-      // ((dptr != & cpu_dev) || current_running_cpu_idx == 1) && 
-
-#define if_sim_debug(dbits, dptr) \
-  if ( \
-      sim_deb && \
-      isISOLTS && \
-      (((dptr)->dctrl & (dbits)) || (dbits) == 0) && \
-      ((dptr != & cpu_dev) || ((1 << current_running_cpu_idx) & dbgCPUMask)) && \
-      ((dptr != & cpu_dev) || (((dptr)->dctrl & (DBG_INTR | DBG_FAULT))) || (! sim_deb_segno_on) || sim_deb_segno[cpu.PPR.PSR & (DEBUG_SEGNO_LIMIT - 1)]) && \
-      ((dptr != & cpu_dev) || sim_deb_ringno == NO_SUCH_RINGNO || sim_deb_ringno == cpu . PPR. PRR) && \
-      ((dptr != & cpu_dev) || (! sim_deb_bar) || (! TST_I_NBAR)) && \
-      cpu.cycleCnt >= sim_deb_start && \
-      (sim_deb_stop == 0 || cpu.cycleCnt < sim_deb_stop) && \
-      (sim_deb_mme_cntdwn == 0) && \
-      ((dptr != & cpu_dev) | (((dbits) & DBG_TRACE) ? (sim_deb_skip_cnt ++ >= sim_deb_skip_limit) : (sim_deb_skip_cnt >= sim_deb_skip_limit))) \
-    ) 
-#endif
-
-#if !defined(THREADZ) && !defined(LOCKLESS)
-#define dps8_sim_debug _sim_debug
-#endif
-
-#undef sim_debug
-#if defined(THREADZ) || defined(LOCKLESS)
-#define sim_debug(dbits, dptr, ...) \
-  if_sim_debug((dbits), dptr) \
-    dps8_sim_debug ((dbits), dptr, DBG_CTR, __VA_ARGS__); \
-  else \
-    (void) 0
-#else
-#define sim_debug(dbits, dptr, ...) \
-  if_sim_debug((dbits), dptr) \
-    dps8_sim_debug ((dbits), dptr, __VA_ARGS__); \
-  else \
-    (void) 0
-#endif
+#define if_sim_debug(dbits, dptr)
+//#ifdef SPEED
+//#define if_sim_debug(dbits, dptr) if ((0))
+//
+//#else
+//      // ((dptr != & cpu_dev) || current_running_cpu_idx == 1) && 
+//
+//#define if_sim_debug(dbits, dptr) \
+//  if ( \
+//      sim_deb && \
+//      isISOLTS && \
+//      (((dptr)->dctrl & (dbits)) || (dbits) == 0) && \
+//      ((dptr != & cpu_dev) || ((1 << current_running_cpu_idx) & dbgCPUMask)) && \
+//      ((dptr != & cpu_dev) || (((dptr)->dctrl & (DBG_INTR | DBG_FAULT))) || (! sim_deb_segno_on) || sim_deb_segno[cpu.PPR.PSR & (DEBUG_SEGNO_LIMIT - 1)]) && \
+//      ((dptr != & cpu_dev) || sim_deb_ringno == NO_SUCH_RINGNO || sim_deb_ringno == cpu . PPR. PRR) && \
+//      ((dptr != & cpu_dev) || (! sim_deb_bar) || (! TST_I_NBAR)) && \
+//      cpu.cycleCnt >= sim_deb_start && \
+//      (sim_deb_stop == 0 || cpu.cycleCnt < sim_deb_stop) && \
+//      (sim_deb_mme_cntdwn == 0) && \
+//      ((dptr != & cpu_dev) | (((dbits) & DBG_TRACE) ? (sim_deb_skip_cnt ++ >= sim_deb_skip_limit) : (sim_deb_skip_cnt >= sim_deb_skip_limit))) \
+//    ) 
+//#endif
+//
+//#if !defined(THREADZ) && !defined(LOCKLESS)
+//#define dps8_sim_debug _sim_debug
+//#endif
+//
+//#undef sim_debug
+//#if defined(THREADZ) || defined(LOCKLESS)
+//#define sim_debug(dbits, dptr, ...) \
+//  if_sim_debug((dbits), dptr) \
+//    dps8_sim_debug ((dbits), dptr, DBG_CTR, __VA_ARGS__); \
+//  else \
+//    (void) 0
+//#else
+//#define sim_debug(dbits, dptr, ...) \
+//  if_sim_debug((dbits), dptr) \
+//    dps8_sim_debug ((dbits), dptr, __VA_ARGS__); \
+//  else \
+//    (void) 0
+//#endif
 
 /* scp Debug flags */
 
index 78697b0..c8e678e 100644 (file)
@@ -1,7 +1,11 @@
+#include <stdarg.h>
+#include <stdio.h>
 #include "dps8_sys.h"
 
 FILE *sim_log;
 
 #ifndef SCUMEM
-/*vol*/ word36 * M;
+/*vol*/ word36 *M[0100000];
 #endif
+
+uint64 sim_deb_mme_cntdwn = 0;
index 094f9bd..f3ff947 100644 (file)
@@ -9,7 +9,9 @@
 extern FILE *sim_log;
 
 #ifndef SCUMEM
-extern /*vol*/ word36 * M;
+extern /*vol*/ word36 *M[0100000];
 #endif
 
+extern uint64 sim_deb_mme_cntdwn;
+
 #endif
diff --git a/dps8/errs b/dps8/errs
deleted file mode 100644 (file)
index 988d982..0000000
--- a/dps8/errs
+++ /dev/null
@@ -1,239 +0,0 @@
-dps8_addrmods.c: In function ‘do_caf’:
-dps8_addrmods.c:561:9: warning: implicit declaration of function ‘ReadIndirect’ [-Wimplicit-function-declaration]
-         ReadIndirect ();
-         ^~~~~~~~~~~~
-dps8_addrmods.c:850:17: warning: implicit declaration of function ‘Read’; did you mean ‘fread’? [-Wimplicit-function-declaration]
-                 Read (indaddr, & indword, APU_DATA_READ);
-                 ^~~~
-                 fread
-dps8_addrmods.c:1019:21: warning: implicit declaration of function ‘Write’; did you mean ‘fwrite’? [-Wimplicit-function-declaration]
-                     Write (indaddr, indword, APU_DATA_STORE);
-                     ^~~~~
-                     fwrite
-dps8_cpu.c: In function ‘cpu_show_config’:
-dps8_cpu.c:133:17: error: ‘scu’ undeclared (first use in this function)
-                 scu [0].steady_clock);
-                 ^~~
-dps8_cpu.c:133:17: note: each undeclared identifier is reported only once for each function it appears in
-dps8_cpu.c: In function ‘cpu_set_config’:
-dps8_cpu.c:419:11: error: ‘scu’ undeclared (first use in this function)
-           scu [0].steady_clock = (uint) v;
-           ^~~
-dps8_cpu.c: In function ‘cpu_show_stall’:
-dps8_cpu.c:517:40: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 5 has type ‘long long int’ [-Wformat=]
-           sim_printf ("%2d %05o:%06o %6u\n", i, stall_points[i].segno, stall_points[i].offset, stall_points[i].time);
-                                      ~~^                                                       ~~~~~~~~~~~~~~~~~~~~
-                                      %6llu
-dps8_cpu.c: In function ‘cpu_reset_unit_idx’:
-dps8_cpu.c:647:13: error: ‘M’ undeclared (first use in this function)
-             M[i] &= (MASK36 | MEM_UNINITIALIZED);
-             ^
-dps8_cpu.c: At top level:
-dps8_cpu.c:746:8: error: unknown type name ‘uv_loop_t’
- static uv_loop_t * ev_poll_loop;
-        ^~~~~~~~~
-dps8_cpu.c:747:8: error: unknown type name ‘uv_timer_t’
- static uv_timer_t ev_poll_handle;
-        ^~~~~~~~~~
-dps8_cpu.c: In function ‘setup_scbank_map’:
-dps8_cpu.c:969:15: error: ‘cables’ undeclared (first use in this function); did you mean ‘mblen’?
-         if (! cables->cpu_to_scu[current_running_cpu_idx][port_num].in_use)
-               ^~~~~~
-               mblen
-dps8_cpu.c: At top level:
-dps8_cpu.c:1155:25: error: unknown type name ‘uv_timer_t’; did you mean ‘__timer_t’?
- static void ev_poll_cb (uv_timer_t * UNUSED handle)
-                         ^~~~~~~~~~
-                         __timer_t
-dps8_cpu.c: In function ‘cpu_init’:
-dps8_cpu.c:1228:5: error: ‘M’ undeclared (first use in this function)
-     M = system_state->M;
-     ^
-dps8_cpu.c:1228:9: error: ‘system_state’ undeclared (first use in this function); did you mean ‘setstate’?
-     M = system_state->M;
-         ^~~~~~~~~~~~
-         setstate
-dps8_cpu.c:1245:20: warning: implicit declaration of function ‘uv_default_loop’; did you mean ‘set_default_cmd’? [-Wimplicit-function-declaration]
-     ev_poll_loop = uv_default_loop ();
-                    ^~~~~~~~~~~~~~~
-                    set_default_cmd
-dps8_cpu.c:1245:18: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
-     ev_poll_loop = uv_default_loop ();
-                  ^
-dps8_cpu.c:1246:5: warning: implicit declaration of function ‘uv_timer_init’ [-Wimplicit-function-declaration]
-     uv_timer_init (ev_poll_loop, & ev_poll_handle);
-     ^~~~~~~~~~~~~
-dps8_cpu.c:1248:5: warning: implicit declaration of function ‘uv_timer_start’; did you mean ‘futimesat’? [-Wimplicit-function-declaration]
-     uv_timer_start (& ev_poll_handle, ev_poll_cb, sys_opts.sys_poll_interval, sys_opts.sys_poll_interval);
-     ^~~~~~~~~~~~~~
-     futimesat
-dps8_cpu.c:1248:39: error: ‘ev_poll_cb’ undeclared (first use in this function); did you mean ‘ev_poll_loop’?
-     uv_timer_start (& ev_poll_handle, ev_poll_cb, sys_opts.sys_poll_interval, sys_opts.sys_poll_interval);
-                                       ^~~~~~~~~~
-                                       ev_poll_loop
-dps8_cpu.c:1248:51: error: ‘sys_opts’ undeclared (first use in this function); did you mean ‘sim_puts’?
-     uv_timer_start (& ev_poll_handle, ev_poll_cb, sys_opts.sys_poll_interval, sys_opts.sys_poll_interval);
-                                                   ^~~~~~~~
-                                                   sim_puts
-dps8_cpu.c: In function ‘cpu_ex’:
-dps8_cpu.c:1309:17: error: ‘M’ undeclared (first use in this function)
-         *vptr = M[addr] & DMASK;
-                 ^
-dps8_cpu.c: In function ‘cpu_dep’:
-dps8_cpu.c:1325:5: error: ‘M’ undeclared (first use in this function)
-     M[addr] = val & DMASK;
-     ^
-dps8_cpu.c: In function ‘get_highest_intr’:
-dps8_cpu.c:1418:18: warning: implicit declaration of function ‘scu_get_highest_intr’; did you mean ‘get_highest_intr’? [-Wimplicit-function-declaration]
-             fp = scu_get_highest_intr (scu_unit_idx); // CALLED WITH SCU LOCK
-                  ^~~~~~~~~~~~~~~~~~~~
-                  get_highest_intr
-dps8_cpu.c: In function ‘simh_hooks’:
-dps8_cpu.c:1443:9: error: ‘breakEnable’ undeclared (first use in this function)
-     if (breakEnable && stop_cpu)
-         ^~~~~~~~~~~
-dps8_cpu.c: In function ‘sim_instr’:
-dps8_cpu.c:1915:39: error: ‘sys_opts’ undeclared (first use in this function); did you mean ‘sim_puts’?
-         if (fast_queue_subsample ++ > sys_opts.sys_poll_check_rate) // ~ 1KHz
-                                       ^~~~~~~~
-                                       sim_puts
-dps8_cpu.c:1923:13: warning: implicit declaration of function ‘uv_run’ [-Wimplicit-function-declaration]
-             uv_run (ev_poll_loop, UV_RUN_NOWAIT);
-             ^~~~~~
-dps8_cpu.c:1923:35: error: ‘UV_RUN_NOWAIT’ undeclared (first use in this function)
-             uv_run (ev_poll_loop, UV_RUN_NOWAIT);
-                                   ^~~~~~~~~~~~~
-dps8_cpu.c:1972:28: warning: implicit declaration of function ‘check_attn_key’; did you mean ‘check_events’? [-Wimplicit-function-declaration]
-         int con_unit_idx = check_attn_key ();
-                            ^~~~~~~~~~~~~~
-                            check_events
-dps8_cpu.c:1974:11: warning: implicit declaration of function ‘console_attn_idx’ [-Wimplicit-function-declaration]
-           console_attn_idx (con_unit_idx);
-           ^~~~~~~~~~~~~~~~
-dps8_cpu.c:2270:20: error: ‘luf_flag’ undeclared (first use in this function); did you mean ‘opc_flag’?
-             if (! (luf_flag && tmp_priv_mode))
-                    ^~~~~~~~
-                    opc_flag
-dps8_cpu.c: In function ‘read_operand’:
-dps8_cpu.c:2980:13: warning: implicit declaration of function ‘Read’; did you mean ‘read’? [-Wimplicit-function-declaration]
-             Read (addr, & cpu.CY, cyctyp);
-             ^~~~
-             read
-dps8_cpu.c:2985:13: warning: implicit declaration of function ‘Read2’; did you mean ‘read’? [-Wimplicit-function-declaration]
-             Read2 (addr, cpu.Ypair, cyctyp);
-             ^~~~~
-             read
-dps8_cpu.c:2990:13: warning: implicit declaration of function ‘Read8’; did you mean ‘read’? [-Wimplicit-function-declaration]
-             Read8 (addr, cpu.Yblock8, cpu.currentInstruction.b29);
-             ^~~~~
-             read
-dps8_cpu.c:2995:13: warning: implicit declaration of function ‘Read16’; did you mean ‘read’? [-Wimplicit-function-declaration]
-             Read16 (addr, cpu.Yblock16);
-             ^~~~~~
-             read
-dps8_cpu.c: In function ‘write_operand’:
-dps8_cpu.c:3019:13: warning: implicit declaration of function ‘Write’; did you mean ‘write’? [-Wimplicit-function-declaration]
-             Write (addr, cpu.CY, OPERAND_STORE);
-             ^~~~~
-             write
-dps8_cpu.c:3024:13: warning: implicit declaration of function ‘Write2’; did you mean ‘write’? [-Wimplicit-function-declaration]
-             Write2 (addr + 0, cpu.Ypair, OPERAND_STORE);
-             ^~~~~~
-             write
-dps8_cpu.c:3029:13: warning: implicit declaration of function ‘Write8’; did you mean ‘write’? [-Wimplicit-function-declaration]
-             Write8 (addr, cpu.Yblock8, cpu.currentInstruction.b29);
-             ^~~~~~
-             write
-dps8_cpu.c:3034:13: warning: implicit declaration of function ‘Write16’; did you mean ‘write’? [-Wimplicit-function-declaration]
-             Write16 (addr, cpu.Yblock16);
-             ^~~~~~~
-             write
-dps8_cpu.c:3041:13: warning: implicit declaration of function ‘Write32’; did you mean ‘write’? [-Wimplicit-function-declaration]
-             Write32 (addr, cpu.Yblock32);
-             ^~~~~~~
-             write
-dps8_cpu.c: In function ‘core_read’:
-dps8_cpu.c:3169:9: error: ‘M’ undeclared (first use in this function)
-     if (M[addr] & MEM_UNINITIALIZED)
-         ^
-dps8_cpu.c: In function ‘core_write’:
-dps8_cpu.c:3293:5: error: ‘M’ undeclared (first use in this function)
-     M[addr] = data & DMASK;
-     ^
-dps8_cpu.c: In function ‘core_write_zone’:
-dps8_cpu.c:3416:5: error: ‘M’ undeclared (first use in this function)
-     M[addr] = (M[addr] & ~cpu.zone) | (data & cpu.zone);
-     ^
-dps8_cpu.c: In function ‘core_read2’:
-dps8_cpu.c:3518:9: error: ‘M’ undeclared (first use in this function)
-     if (M[addr] & MEM_UNINITIALIZED)
-         ^
-dps8_cpu.c: In function ‘core_write2’:
-dps8_cpu.c:3672:5: error: ‘M’ undeclared (first use in this function)
-     M[addr++] = even & DMASK;
-     ^
-dps8_cpu.c: In function ‘get_serial_number’:
-dps8_cpu.c:1089:9: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
-         fgets (buffer, sizeof (buffer), fp);
-         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-dps8_eis.c: In function ‘EISWriteCache’:
-dps8_eis.c:549:13: warning: implicit declaration of function ‘Write8’; did you mean ‘fwrite’? [-Wimplicit-function-declaration]
-             Write8 (p->cachedAddr, p -> cachedParagraph, true);
-             ^~~~~~
-             fwrite
-dps8_eis.c: In function ‘EISReadCache’:
-dps8_eis.c:620:9: warning: implicit declaration of function ‘Read8’; did you mean ‘seed48’? [-Wimplicit-function-declaration]
-         Read8 (paragraphAddress, p -> cachedParagraph, true);
-         ^~~~~
-         seed48
-dps8_eis.c: In function ‘EISReadPage’:
-dps8_eis.c:786:9: warning: implicit declaration of function ‘ReadPage’; did you mean ‘EISReadPage’? [-Wimplicit-function-declaration]
-         ReadPage (addressN, data, true);
-         ^~~~~~~~
-         EISReadPage
-dps8_eis.c: In function ‘EISWritePage’:
-dps8_eis.c:848:9: warning: implicit declaration of function ‘WritePage’; did you mean ‘EISWritePage’? [-Wimplicit-function-declaration]
-         WritePage (addressN, data, true);
-         ^~~~~~~~~
-         EISWritePage
-dps8_ins.c: In function ‘writeOperands’:
-dps8_ins.c:134:9: warning: implicit declaration of function ‘Write’; did you mean ‘fwrite’? [-Wimplicit-function-declaration]
-         Write (cpu.ou.character_address, cpu.ou.character_data, OPERAND_STORE);
-         ^~~~~
-         fwrite
-dps8_ins.c: In function ‘read_tra_op’:
-dps8_ins.c:244:7: warning: implicit declaration of function ‘Read’; did you mean ‘fread’? [-Wimplicit-function-declaration]
-       Read (cpu.TPR.CA, &cpu.CY, OPERAND_READ);
-       ^~~~
-       fread
-dps8_ins.c:246:7: warning: implicit declaration of function ‘Read2’ [-Wimplicit-function-declaration]
-       Read2 (cpu.TPR.CA, cpu.Ypair, OPERAND_READ);
-       ^~~~~
-dps8_ins.c: In function ‘doInstruction’:
-dps8_ins.c:6669:19: warning: implicit declaration of function ‘get_scu_in_use’; did you mean ‘get_iwb_info’? [-Wimplicit-function-declaration]
-             if (! get_scu_in_use (current_running_cpu_idx, cpu_port_num))
-                   ^~~~~~~~~~~~~~
-                   get_iwb_info
-dps8_ins.c:6675:31: warning: implicit declaration of function ‘get_scu_idx’; did you mean ‘set_cpu_idx’? [-Wimplicit-function-declaration]
-             uint scuUnitIdx = get_scu_idx (current_running_cpu_idx, cpu_port_num);
-                               ^~~~~~~~~~~
-                               set_cpu_idx
-dps8_ins.c:6677:25: warning: implicit declaration of function ‘scu_rscr’; did you mean ‘strstr’? [-Wimplicit-function-declaration]
-             t_stat rc = scu_rscr ((uint) scuUnitIdx, current_running_cpu_idx,
-                         ^~~~~~~~
-                         strstr
-dps8_ins.c:7976:25: warning: implicit declaration of function ‘scu_rmcm’ [-Wimplicit-function-declaration]
-             t_stat rc = scu_rmcm ((uint) scuUnitIdx,
-                         ^~~~~~~~
-dps8_ins.c:8570:13: warning: implicit declaration of function ‘scu_cioc’ [-Wimplicit-function-declaration]
-             scu_cioc (current_running_cpu_idx, (uint) scuUnitIdx, scu_port_num,
-             ^~~~~~~~
-dps8_ins.c:8594:25: warning: implicit declaration of function ‘scu_smcm’ [-Wimplicit-function-declaration]
-             t_stat rc = scu_smcm ((uint) scuUnitIdx,
-                         ^~~~~~~~
-dps8_ins.c:8637:25: warning: implicit declaration of function ‘scu_smic’ [-Wimplicit-function-declaration]
-             t_stat rc = scu_smic ((uint) scuUnitIdx, current_running_cpu_idx,
-                         ^~~~~~~~
-dps8_ins.c:8668:25: warning: implicit declaration of function ‘scu_sscr’ [-Wimplicit-function-declaration]
-             t_stat rc = scu_sscr ((uint) scuUnitIdx, current_running_cpu_idx,
-                         ^~~~~~~~
index 895d8ba..80e8bf4 100644 (file)
@@ -236,7 +236,8 @@ void _sim_debug (uint32 dbits, void* dptr, const char *fmt, ...) GCC_FMT_ATTR(3,
 void sim_debug (uint32 dbits, DEVICE* dptr, const char *fmt, ...) GCC_FMT_ATTR(3, 4);\r
 #else\r
 void _sim_debug (uint32 dbits, DEVICE* dptr, const char *fmt, ...) GCC_FMT_ATTR(3, 4);\r
-#define sim_debug(dbits, dptr, ...) do { if (sim_deb && dptr && ((dptr)->dctrl & dbits)) _sim_debug (dbits, dptr, __VA_ARGS__);} while (0)\r
+//#define sim_debug(dbits, dptr, ...) do { if (sim_deb && dptr && ((dptr)->dctrl & dbits)) _sim_debug (dbits, dptr, __VA_ARGS__);} while (0)\r
+#define sim_debug(dbits, dptr, ...) printf(__VA_ARGS__)\r
 #endif\r
 #endif\r
 void fprint_stopped_gen (FILE *st, t_stat v, REG *pc, DEVICE *dptr);\r
index eede9ee..e3dd289 100644 (file)
@@ -10,6 +10,7 @@
 #include "definition_dcls.h"
 #include "dps8/dps8.h"
 #include "dps8/dps8_cpu.h"
+#include "dps8/dps8_sys.h"
 #include "object_map.h"
 #include "rassert.h"
 
@@ -51,6 +52,23 @@ int main(int argc, char **argv) {
     }
   }
 
+  // initialize CPU
+  cpu_reset_unit_idx(0, false);
+
+  // initialize memory
+  uint64_t *null_segment = mmap(
+    NULL,
+    01000000 * sizeof(uint64_t),
+    PROT_NONE,
+    MAP_ANONYMOUS | MAP_PRIVATE,
+    -1,
+    (off_t)0
+  );
+  rassert(null_segment != (uint64_t *)-1);
+  for (int i = 0; i < 0100000; ++i)
+    M[i] = (word36 *)null_segment;
+
+  // search for object segment
   int fd;
   int path_index;
   for (path_index = 0; path_index < N_PATHS; ++path_index) {
@@ -82,6 +100,7 @@ found_object_segment:
   );
   rassert(object_segment != (uint64_t *)-1);
 
+  // search for entry point in object segment
   uint64_t bitcount;
   {
     char index_name[0x1000];
@@ -199,17 +218,21 @@ found_bitcount:
 
 found_entry:
   ;
-  cpu_reset_unit_idx(0, false);
-  cpu.PPR.IC =
-    (object_map->text_offset + definition->thing_relp) & 0777777;
 
+  // map in segment and start executing
+  M[0] = (word36 *)object_segment;
+  cpu.PPR.PRR = 3; // ring
+  cpu.PPR.PSR = 0; // segment
+  cpu.PPR.P = 0; // privilege
+  cpu.PPR.IC = (object_map->text_offset + definition->thing_relp) & 0777777;
   printf(
-    "entry %s$%s at %06o -> %012lo\n",
+    "entry %s$%s at %06o -> %012llo\n",
     entry_segment,
     entry_name,
     cpu.PPR.IC,
-    object_segment[cpu.PPR.IC]
+    M[cpu.PPR.PSR][cpu.PPR.IC]
   );
+  sim_instr();
 
   return 0;
 }