From 65194f8a5a1326f903babbd20584244054179a4e Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sun, 29 Jan 2023 15:57:31 -1000 Subject: [PATCH] TIMER: Leverage first time calibration info on subsequent boots - Also abort simulation if idle delay is crazy big which indicates a problem that has already happened. - Extend calibration initialization debug output to record optional ticks. --- sim_timer.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sim_timer.c b/sim_timer.c index 601c3ad4..1dc5d460 100644 --- a/sim_timer.c +++ b/sim_timer.c @@ -898,7 +898,10 @@ if (rtc->currd) time = rtc->currd; if (!uptr) uptr = rtc->clock_unit; -sim_debug (DBG_CAL, &sim_timer_dev, "sim_rtcn_init_unit(unit=%s, time=%d, tmr=%d)\n", uptr ? sim_uname(uptr) : "", time, tmr); +if (ticksper) + sim_debug (DBG_CAL, &sim_timer_dev, "sim_rtcn_init_unit_ticks(unit=%s, time=%d, tmr=%d, ticks=%d)\n", uptr ? sim_uname(uptr) : "", time, tmr, ticksper); +else + sim_debug (DBG_CAL, &sim_timer_dev, "sim_rtcn_init_unit(unit=%s, time=%d, tmr=%d)\n", uptr ? sim_uname(uptr) : "", time, tmr); if (uptr) { if (!rtc->clock_unit) sim_register_clock_unit_tmr (uptr, tmr); @@ -958,6 +961,8 @@ rtc = &rtcs[tmr]; if (rtc->hz != ticksper) { /* changing tick rate? */ uint32 prior_hz = rtc->hz; + if (tmr == sim_calb_tmr_last) /* restarting after having previously been the calibrated timer? */ + ticksper = rtc->last_hz; /* Use the prior tick rate */ if (rtc->hz == 0) rtc->clock_tick_start_time = sim_timenow_double (); if ((rtc->last_hz != ticksper) && (ticksper != 0)) @@ -1864,8 +1869,10 @@ if ((w_idle < 500) || (w_ms == 0)) { /* shorter than 1/2 the in_nowait = TRUE; return FALSE; } -if (w_ms > 1000) /* too long a wait (runaway calibration) */ - sim_debug (DBG_TIK, &sim_timer_dev, "waiting too long: w_ms=%d usecs, w_idle=%d usecs, sim_interval=%d, rtc->currd=%d\n", w_ms, w_idle, sim_interval, rtc->currd); +if (w_ms > 1000) { /* too long a wait (runaway calibration) */ + sim_printf ("sim_idle() - waiting too long: w_ms=%d usecs, w_idle=%d usecs, sim_interval=%d, rtc->currd=%d\n", w_ms, w_idle, sim_interval, rtc->currd); + SIM_SCP_ABORT ("sim_idle() - waiting too long"); + } in_nowait = FALSE; if (sim_clock_queue == QUEUE_LIST_END) sim_debug (DBG_IDL, &sim_timer_dev, "sleeping for %d ms - pending event in %d %s\n", w_ms, sim_interval, sim_vm_interval_units);