int32 clk (int32 pulse, int32 code, int32 AC) { if (code == ioDOA) { /* DOA */ clk_sel = AC & 3; /* save select */ sim_rtc_init (clk_time[clk_sel]); /* init calibr */ } switch (pulse) { /* decode IR<8:9> */ case iopS: /* start */ DEV_SET_BUSY( INT_CLK ) ; DEV_CLR_DONE( INT_CLK ) ; DEV_UPDATE_INTR ; if (!sim_is_active (&clk_unit)) /* not running? */ sim_activate (&clk_unit, /* activate */ sim_rtc_init (clk_time[clk_sel])); /* init calibr */ break; case iopC: /* clear */ DEV_CLR_BUSY( INT_CLK ) ; DEV_CLR_DONE( INT_CLK ) ; DEV_UPDATE_INTR ; sim_cancel (&clk_unit); /* deactivate unit */ break; } /* end switch */ return 0; }
t_stat rtc_fo (int32 op) { if (op & RTC_OFF) /* clock off? */ sim_cancel (&rtc_unit); if ((op & RTC_ON) && !sim_is_active (&rtc_unit)) /* clock on? */ sim_activate (&rtc_unit, sim_rtc_init (rtc_unit.wait)); if (op & RTC_OV) /* clr ovflo? */ dev_done = dev_done & ~INT_RTC; return SCPE_OK; }
int32 clkio (int32 inst, int32 fnc, int32 dat, int32 dev) { switch (inst) { /* case on opcode */ case ioOCP: /* OCP */ if (fnc & 015) /* only fnc 0,2 */ return IOBADFNC (dat); CLR_INT (INT_CLK); /* reset ready */ if (fnc) /* fnc = 2? stop */ sim_cancel (&clk_unit); else { /* fnc = 0? */ if (!sim_is_active (&clk_unit)) sim_activate (&clk_unit, /* activate */ sim_rtc_init (clk_unit.wait)); /* init calibr */ } break; case ioSKS: /* SKS */ if (fnc == 000) { /* clock skip !int */ if (!TST_INTREQ (INT_CLK)) return IOSKIP (dat); } else if ((fnc & 007) == 002) { /* mem parity? */ if (((fnc == 002) && !TST_INT (INT_MPE)) || ((fnc == 012) && TST_INT (INT_MPE))) return IOSKIP (dat); } else return IOBADFNC (dat); /* invalid fnc */ break; case ioOTA: /* OTA */ if (fnc == 000) /* SMK */ dev_enb = dat; else if (fnc == 010) { /* OTK */ C = (dat >> 15) & 1; /* set C */ if (cpu_unit.flags & UNIT_HSA) /* HSA included? */ dp = (dat >> 14) & 1; /* set dp */ if (cpu_unit.flags & UNIT_EXT) { /* ext opt? */ if (dat & 020000) { /* ext set? */ ext = 1; /* yes, set */ extoff_pending = 0; } else extoff_pending = 1; /* no, clr later */ } sc = dat & 037; /* set sc */ } else return IOBADFNC (dat);