From b38cc8a367caaced8a7240e49209316b5733882f Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Fri, 5 Oct 2018 20:43:43 -0700 Subject: [PATCH] SCP: Allow "STEP -T nnn" to work Delay scheduling of long duration calibration events until a calibrated timer is established. --- scp.c | 22 +++++++++------------- sim_timer.c | 9 ++++++++- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/scp.c b/scp.c index 2b8cfe34..179cec3a 100644 --- a/scp.c +++ b/scp.c @@ -2788,7 +2788,6 @@ for (i=0; itext = newt; memcpy (newt + topic->len, text, len); topic->len +=len; newt[topic->len] = '\0'; -return; } /* Release memory held by a topic and its children. @@ -12940,7 +12938,6 @@ for (i = 0; i < topic->kids; i++) { free (child); } free (topic->children); -return; } /* Build a help tree from a string. @@ -13295,7 +13292,6 @@ fclose (tmp); remove (tmpnam); free (tmpnam); #endif -return; } /* Flatten and display help for those who say they prefer it. */ diff --git a/sim_timer.c b/sim_timer.c index f0a40053..46e2170c 100644 --- a/sim_timer.c +++ b/sim_timer.c @@ -2562,7 +2562,12 @@ if (usec_delay < 0.0) { sim_debug (DBG_QUE, &sim_timer_dev, "sim_timer_activate_after(%s, %.0f usecs) - surprising usec value\n", sim_uname(uptr), usec_delay); } -uptr->usecs_remaining = 0.0; +if ((sim_is_running) || (tmr <= SIM_NTIMERS)) + uptr->usecs_remaining = 0.0; +else { /* defer non timer wallclock activations until a calibrated timer is in effect */ + uptr->usecs_remaining = usec_delay; + usec_delay = 0; + } /* * Handle long delays by aligning with the calibrated timer's calibration * activities. Delays which would expire prior to the next calibration @@ -2577,6 +2582,8 @@ inst_delay_d = floor(inst_per_usec * usec_delay); inst_delay = (int32)inst_delay_d; if ((inst_delay == 0) && (usec_delay != 0)) inst_delay_d = inst_delay = 1; /* Minimum non-zero delay is 1 instruction */ +if (uptr->usecs_remaining != 0.0) /* No calibrated timer yet, wait one cycle */ + inst_delay_d = inst_delay = 1; /* Minimum non-zero delay is 1 instruction */ if ((sim_calb_tmr != -1) && (rtc_hz[sim_calb_tmr])) { /* Calibrated Timer available? */ int32 inst_til_tick = sim_activate_time (&sim_timer_units[sim_calb_tmr]) - 1; int32 ticks_til_calib = rtc_hz[sim_calb_tmr] - rtc_ticks[sim_calb_tmr];