TIMER: Behave reasonably when a simulator doesn't associate a UNIT with a timer

This commit is contained in:
Mark Pizzolato 2017-03-12 17:59:23 -07:00
parent bd575651ca
commit 12f43e660f

View file

@ -827,7 +827,7 @@ if (rtc_currd[tmr])
time = rtc_currd[tmr]; time = rtc_currd[tmr];
if (!uptr) if (!uptr)
uptr = sim_clock_unit[tmr]; uptr = sim_clock_unit[tmr];
sim_debug (DBG_CAL, &sim_timer_dev, "sim_rtcn_init_unit(unit=%s, time=%d, tmr=%d)\n", sim_uname(uptr), time, tmr); 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 (uptr) {
if (!sim_clock_unit[tmr]) if (!sim_clock_unit[tmr])
sim_register_clock_unit_tmr (uptr, tmr); sim_register_clock_unit_tmr (uptr, tmr);
@ -2093,7 +2093,8 @@ int32 tmr;
sim_int_clk_tps = MIN(CLK_TPS, sim_os_tick_hz); sim_int_clk_tps = MIN(CLK_TPS, sim_os_tick_hz);
for (tmr=0; tmr<SIM_NTIMERS; tmr++) { for (tmr=0; tmr<SIM_NTIMERS; tmr++) {
if ((rtc_hz[tmr]) && if ((rtc_hz[tmr]) &&
(rtc_hz[tmr] <= (uint32)sim_os_tick_hz)) (rtc_hz[tmr] <= (uint32)sim_os_tick_hz) &&
(sim_clock_unit[tmr]))
break; break;
} }
if (tmr == SIM_NTIMERS) { /* None found? */ if (tmr == SIM_NTIMERS) { /* None found? */