int32 ptrio (int32 inst, int32 fnc, int32 dat, int32 dev) { switch (inst) { /* case on opcode */ case ioOCP: /* OCP */ if (fnc & 016) /* only fnc 0,1 */ return IOBADFNC (dat); ptr_motion = fnc ^ 1; if (fnc) /* fnc 1? stop */ sim_cancel (&ptr_unit); else sim_activate (&ptr_unit, ptr_unit.wait); /* fnc 0? start */ break; case ioSKS: /* SKS */ if (fnc & 013) /* only fnc 0,4 */ return IOBADFNC (dat); if (((fnc == 000) && TST_INT (INT_PTR)) || /* fnc 0? skip rdy */ ((fnc == 004) && !TST_INTREQ (INT_PTR))) /* fnc 4? skip !int */ return IOSKIP (dat); break; case ioINA: /* INA */ if (fnc) /* only fnc 0 */ return IOBADFNC (dat); if (TST_INT (INT_PTR)) { /* ready? */ CLR_INT (INT_PTR); /* clear ready */ if (ptr_motion) /* if motion, restart */ sim_activate (&ptr_unit, ptr_unit.wait); return IOSKIP (ptr_unit.buf | dat); /* ret buf, skip */ } break; } /* end case op */ return dat; }
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);
int32 ptpio (int32 inst, int32 fnc, int32 dat, int32 dev) { switch (inst) { /* case on opcode */ case ioOCP: /* OCP */ if (fnc & 016) /* only fnc 0,1 */ return IOBADFNC (dat); if (fnc) { /* fnc 1? pwr off */ CLR_INT (INT_PTP); /* not ready */ ptp_power = 0; /* turn off power */ sim_cancel (&ptp_unit); /* stop punch */ } else if (ptp_power == 0) /* fnc 0? start */ sim_activate (&ptp_unit, ptp_ptime); break; case ioSKS: /* SKS */ if ((fnc & 012) || (fnc == 005)) /* only 0, 1, 4 */ return IOBADFNC (dat); if (((fnc == 000) && TST_INT (INT_PTP)) || /* fnc 0? skip rdy */ ((fnc == 001) && /* fnc 1? skip ptp on */ (ptp_power || sim_is_active (&ptp_unit))) || ((fnc == 004) && !TST_INTREQ (INT_PTP))) /* fnc 4? skip !int */ return IOSKIP (dat); break; case ioOTA: /* OTA */ if (fnc) /* only fnc 0 */ return IOBADFNC (dat); if (TST_INT (INT_PTP)) { /* if ptp ready */ CLR_INT (INT_PTP); /* clear ready */ ptp_unit.buf = dat & 0377; /* store byte */ sim_activate (&ptp_unit, ptp_unit.wait); return IOSKIP (dat); /* skip return */ } break; } return dat; }
int32 lp62_65 (int32 dev, int32 pulse, int32 dat) { int32 i; if ((pulse & 01) && TST_INT (LPT)) /* LPSF */ dat = IOT_SKP | dat; if (pulse & 02) { int32 sb = pulse & 060; /* subopcode */ if (sb == 000) /* LPCF */ CLR_INT (LPT); if ((sb == 040) && (lp62_bp < BPTR_MAX)) { /* LPLD */ i = lp62_bp * 3; /* cvt to chr ptr */ lp62_buf[i] = fio_to_asc[(dat >> 12) & 077]; lp62_buf[i + 1] = fio_to_asc[(dat >> 6) & 077]; lp62_buf[i + 2] = fio_to_asc[dat & 077]; lp62_bp = (lp62_bp + 1) & BPTR_MASK; }
int32 ttyio (int32 inst, int32 fnc, int32 dat, int32 dev) { switch (inst) { /* case on opcode */ case ioOCP: /* OCP */ if (fnc & 016) /* only fnc 0,1 */ return IOBADFNC (dat); if (fnc && (tty_mode == 0)) { /* input to output? */ if (!sim_is_active (&tty_unit[TTO])) /* set ready */ SET_INT (INT_TTY); tty_mode = 1; /* mode is output */ } else if ((fnc == 0) && tty_mode) { /* output to input? */ CLR_INT (INT_TTY); /* clear ready */ tty_mode = 0; /* mode is input */ } break; case ioSKS: /* SKS */ if (fnc & 012) /* fnc 0,1,4,5 */ return IOBADFNC (dat); if (((fnc == 000) && TST_INT (INT_TTY)) || /* fnc 0? skip rdy */ ((fnc == 001) && /* fnc 1? skip !busy */ (!tty_mode || !sim_is_active (&tty_unit[TTO]))) || ((fnc == 004) && !TST_INTREQ (INT_TTY)) || /* fnc 4? skip !int */ ((fnc == 005) && (tty_mode || /* fnc 5? skip !xoff */ ((tty_buf & 0177) != XOFF)))) /* input & XOFF char */ return IOSKIP (dat); break; case ioINA: /* INA */ if (fnc & 005) /* only 0,2 */ return IOBADFNC (dat); if (TST_INT (INT_TTY)) { /* ready? */ if (tty_mode == 0) /* inp? clear rdy */ CLR_INT (INT_TTY); return IOSKIP (dat | (tty_buf & ((fnc & 002)? 077: 0377))); } break; case ioOTA: if (fnc & 015) /* only 0,2 */ return IOBADFNC (dat); if (TST_INT (INT_TTY)) { /* ready? */ tty_buf = dat & 0377; /* store char */ if (fnc & 002) { /* binary mode? */ tty_buf = tty_buf | 0100; /* set ch 7 */ if (tty_buf & 040) tty_buf = tty_buf & 0277; } if (tty_mode) { sim_activate (&tty_unit[TTO], tty_unit[TTO].wait); CLR_INT (INT_TTY); } return IOSKIP (dat); } break; } /* end case op */ return dat; }