Exemple #1
0
t_stat ttpi_svc (UNIT *uptr)
{
int32 c, out;

sim_activate (uptr, KBD_WAIT (uptr->wait, lfc_poll));   /* continue poll */
ttp_sta = ttp_sta & ~STA_FR;                            /* clear break */
if ((c = sim_poll_kbd ()) < SCPE_KFLAG)                 /* no char or error? */
    return c;
ttp_sta = ttp_sta & ~STA_PF;                            /* clear parity err */
if (ttp_kchp)                                           /* overrun? */
    ttp_sta = ttp_sta | STA_OVR;
if (ttp_karm)
    SET_INT (v_TTP);
if (c & SCPE_BREAK) {                                   /* break? */
    ttp_sta = ttp_sta | STA_FR;                         /* framing error */
    uptr->buf = 0;                                      /* no character */
    }
else {
    out = c & 0x7F;                                     /* echo is 7b */
    c = sim_tt_inpcvt (c, TT_GET_MODE (uptr->flags));
    if (TT_GET_MODE (uptr->flags) != TT_MODE_8B)        /* not 8b mode? */
        c = pas_par (ttp_cmd, c);                       /* apply parity */
    uptr->buf = c;                                      /* save char */
    uptr->pos = uptr->pos + 1;                          /* incr count */
    ttp_kchp = 1;                                       /* char pending */
    if (ttp_cmd & CMD_ECHO) {
        out = sim_tt_outcvt (out, TT_GET_MODE (uptr->flags));
        if (c >= 0)
            sim_putchar (out);
        ttp_unit[TTO].pos = ttp_unit[TTO].pos + 1;
        }
    }
return SCPE_OK;
}
Exemple #2
0
t_stat muxi_rtc_svc (UNIT *uptr)
{
    t_stat r;
    int32 newln, ln, c;

    if ((mux_unit[MUXC].flags & UNIT_ATT) == 0)             /* attached? */
        return SCPE_OK;
    newln = tmxr_poll_conn (&mux_desc);                     /* look for connect */
    if ((newln >= 0) && (mux_sta[newln] & MUXL_REP)) {      /* rcv enb pending? */
        mux_ldsc[newln].rcve = 1;                           /* enable rcv */
        mux_sta[newln] &= ~MUXL_REP;                        /* clr pending */
    }
    tmxr_poll_rx (&mux_desc);                               /* poll for input */
    for (ln = 0; ln < MUX_NUMLIN; ln++) {                   /* loop thru lines */
        if (mux_ldsc[ln].conn) {                            /* connected? */
            if (c = tmxr_getc_ln (&mux_ldsc[ln])) {         /* get char */
                if (c & SCPE_BREAK)                         /* break? */
                    mux_sta[ln] |= MUXL_RBP;                /* set rcv brk */
                else {                                      /* normal char */
                    mux_sta[ln] &= ~MUXL_RBP;               /* clr rcv brk */
                    c = sim_tt_inpcvt (c, TT_GET_MODE (muxl_unit[ln].flags));
                    mux_rbuf[ln] = c;                       /* save char */
                    if ((muxc_cmd == MUXC_RCV) &&           /* chan active? */
                            (r = muxi_put_char (c, ln)))        /* char to chan */
                        return r;
                }                                       /* end else char */
            }                                           /* end if char */
        }                                               /* end if conn */
        else mux_sta[ln] &= ~MUXL_RBP;                      /* disconnected */
    }                                                   /* end for */
    return SCPE_OK;
}
Exemple #3
0
t_stat tti_svc (UNIT *uptr)
{
int32 c;

uptr->wait = sim_rtcn_calb (POLL_RATE, TMR_POLL);       /* calibrate poll timer */
sim_activate (uptr, uptr->wait);                        /* continue poll */

tty_shin = 0377;                                        /* assume inactive */
if (tty_lf) {                                           /* auto lf pending? */
    c = 012;                                            /* force lf */
    tty_lf = 0;
    }
else {
    if ((c = sim_poll_kbd ()) < SCPE_KFLAG) return c;   /* no char or error? */
    if (c & SCPE_BREAK) c = 0;                          /* break? */
    else c = sim_tt_inpcvt (c, TT_GET_MODE (uptr->flags));
    tty_lf = ((c & 0177) == 015) && (uptr->flags & UNIT_AUTOLF);
    }
if (tty_mode & TM_KBD) {                                /* keyboard enabled? */
    tty_buf = c;                                        /* put char in buf */
    uptr->pos = uptr->pos + 1;

    ttyio (&tty_dib, ioENF, 0);                         /* set flag */

    if (c) {
        tto_out (c);                                    /* echo? */
        return ttp_out (c);                             /* punch? */
        }
    }
else tty_shin = c;                                      /* no, char shifts in */
return SCPE_OK;
}
Exemple #4
0
t_stat ttix_svc (UNIT *uptr)
{
int32 ln, c, temp;

if ((uptr->flags & UNIT_ATT) == 0)                      /* attached? */
    return SCPE_OK;
sim_clock_coschedule (uptr, tmxr_poll);                 /* continue poll */
ln = tmxr_poll_conn (&ttx_desc);                        /* look for connect */
if (ln >= 0)                                            /* got one? rcv enb*/
    ttx_ldsc[ln].rcve = 1;
tmxr_poll_rx (&ttx_desc);                               /* poll for input */
for (ln = 0; ln < TTX_LINES; ln++) {                    /* loop thru lines */
    if (ttx_ldsc[ln].conn) {                            /* connected? */
        if (dev_done & (INT_TTI1 << ln))                /* Last character still pending? */
            continue;
        if ((temp = tmxr_getc_ln (&ttx_ldsc[ln]))) {    /* get char */
            if (temp & SCPE_BREAK)                      /* break? */
                c = 0;
            else c = sim_tt_inpcvt (temp, TT_GET_MODE (ttox_unit[ln].flags));
            ttix_buf[ln] = c;
            dev_done = dev_done | (INT_TTI1 << ln);
            int_req = INT_UPDATE;
            }
        }
    }
return SCPE_OK;
}
Exemple #5
0
t_stat tti_svc (UNIT *uptr)
{
int32 out, c;
UNIT *ruptr = &tty_unit[TTR];

sim_activate (uptr, uptr->wait);                        /* continue poll */
if ((c = sim_poll_kbd ()) >= SCPE_KFLAG) {              /* character? */
    out = c & 0177;                                     /* mask echo to 7b */
    if (c & SCPE_BREAK)                                 /* break? */
        c = 0;
    else c = sim_tt_inpcvt (c, TT_GET_MODE (uptr->flags) | TTUF_KSR);
    uptr->pos = uptr->pos + 1;
    }
else if (c != SCPE_OK)                                  /* error? */
    return c;
else if ((ruptr->flags & UNIT_ATT) &&                   /* TTR attached */
    (ruptr->STA & RUNNING)) {                           /* and running? */
    if (ruptr->STA & LF_PEND) {                         /* lf pending? */
        c = 0212;                                       /* char is lf */
        ruptr->STA &= ~LF_PEND;                         /* clear flag */
        }
    else {                                              /* normal read */
        if ((c = getc (ruptr->fileref)) == EOF) {       /* read byte */
            if (feof (ruptr->fileref)) {                /* EOF? */
                ruptr->STA &= ~RUNNING;                 /* stop reader */
                if (ttr_stopioe)
                    printf ("TTR end of file\n");
                else return SCPE_OK;
                }
            else perror ("TTR I/O error");
            clearerr (ruptr->fileref);
            return SCPE_IOERR;
            }
        if ((ruptr->flags & UNIT_UASC) && (c == '\n')) {
            c = 0215;                                   /* Unix ASCII NL? */
            ruptr->STA |= LF_PEND;                      /* LF pending */
            }
        else if ((ruptr->flags & UNIT_ASC) && (c != 0))
            c = c | 0200;                               /* ASCII nz? cvt */
        ruptr->pos = ftell (ruptr->fileref);
        }
    if (ttr_xoff_read != 0) {                           /* reader stopping? */
        if (c == RUBOUT)                                /* rubout? stop */
            ttr_xoff_read = 0;
        else ttr_xoff_read--;                           /* else decr state */
        if (ttr_xoff_read == 0)                         /* delay done? */
            ruptr->STA &= ~RUNNING;                     /* stop reader */
        }
    else if ((c & 0177) == XOFF)                        /* XOFF read? */
        ttr_xoff_read = 2;
    out = c;                                            /* echo char */
    }
else return SCPE_OK;                                    /* no char */
if (tty_mode == 0) {                                    /* input mode? */
    tty_buf = c & 0377;                                 /* put char in buf */
    SET_INT (INT_TTY);                                  /* set flag */
    }
tto_write (out);                                        /* echo to printer */
return ttp_write (out);                                 /* and punch */
}
Exemple #6
0
void tto_echo (int32 c)
{
uint32 cnt;

cnt = 1;
if (c == '\r')
    tto_pos = 0;
else if (c == '\n') {
    tto_pos = 0;
    sim_putchar ('\r');
    tt_unit[TTO].pos = tt_unit[TTO].pos + 1;
    }
else if (c == '\t') {
    c = ' ';
    cnt = 8 - (tto_pos % 8);
    }
else c = sim_tt_outcvt (c, TT_GET_MODE (tt_unit[TTO].flags));
if (c >= 0) {
    while (cnt-- > 0) {
        sim_putchar (c);
        tto_pos++;
        tt_unit[TTO].pos = tt_unit[TTO].pos + 1;
        }
    }
return;
}
Exemple #7
0
t_stat tto_write (int32 c)
{
UNIT *tuptr = &tty_unit[TTO];

c = sim_tt_outcvt (c, TT_GET_MODE (tuptr->flags) | TTUF_KSR);
tuptr->pos = tuptr->pos + 1;
if (c >= 0)
    return sim_putchar_s (c);
else return SCPE_OK;
}
Exemple #8
0
t_stat ttpo_svc (UNIT *uptr)
{
int32 c;
t_stat r;

if (TT_GET_MODE (uptr->flags) == TT_MODE_8B)            /* 8b? */
    c = pas_par (ttp_cmd, uptr->buf);                   /* apply parity */
else c = sim_tt_outcvt (uptr->buf, TT_GET_MODE (uptr->flags));
if (c >= 0) {
    if ((r = sim_putchar_s (c)) != SCPE_OK) {           /* output; error? */
        sim_activate (uptr, uptr->wait);                /* try again */
        return ((r == SCPE_STALL)? SCPE_OK: r);
        }
    }
ttp_sta = ttp_sta & ~STA_BSY;                           /* not busy */
if (ttp_tarm)                                           /* set intr */
    SET_INT (v_TTP + 1);
uptr->pos = uptr->pos + 1;                              /* incr count */
return SCPE_OK;
}
Exemple #9
0
t_stat tti_svc (UNIT *uptr)
{
int32 c;

sim_activate (uptr, KBD_WAIT (uptr->wait, tmr_poll));   /* continue poll */
if ((c = sim_poll_kbd ()) < SCPE_KFLAG) return c;       /* no char or error? */
if (c & SCPE_BREAK) uptr->buf = 0;                      /* break? */
else uptr->buf = sim_tt_inpcvt (c, TT_GET_MODE (uptr->flags));
uptr->pos = uptr->pos + 1;
tti_csr = tti_csr | CSR_DONE;
if (tti_csr & CSR_IE) SET_INT (TTI);
return SCPE_OK;
}
Exemple #10
0
t_stat tti_svc (UNIT *uptr)
{
int32 c;

sim_activate (uptr, uptr->wait);                        /* continue poll */
if ((c = sim_poll_kbd ()) < SCPE_KFLAG)                 /* no char or error? */
    return c;
if (c & SCPE_BREAK)                                     /* break? */
    uptr->buf = 0;
else uptr->buf = sim_tt_inpcvt (c, TT_GET_MODE (uptr->flags) | TTUF_KSR);
dev_done = dev_done | INT_TTI;                          /* set ready */
uptr->pos = uptr->pos + 1;
return SCPE_OK;
}
Exemple #11
0
t_stat tti_svc (UNIT *uptr)
{
int32 c;

sim_activate (uptr, KBD_WAIT (uptr->wait, tmxr_poll));  /* continue poll */
if ((c = sim_poll_kbd ()) < SCPE_KFLAG)                 /* no char or error? */
    return c;
if (c & SCPE_BREAK)                                     /* break? */
    uptr->buf = 0;
else uptr->buf = sim_tt_inpcvt (c, TT_GET_MODE (uptr->flags) | TTUF_KSR);
uptr->pos = uptr->pos + 1;
dev_done = dev_done | INT_TTI;                          /* set done */
int_req = INT_UPDATE;                                   /* update interrupts */
return SCPE_OK;
}
Exemple #12
0
t_stat tto_out (int32 c)
{
t_stat r;

if (tty_mode & TM_PRI) {                                /* printing? */
    c = sim_tt_outcvt (c, TT_GET_MODE (tty_unit[TTO].flags));
    if (c >= 0) {                                       /* valid? */
        r = sim_putchar_s (c);                          /* output char */
        if (r != SCPE_OK)
            return r;
        tty_unit[TTO].pos = tty_unit[TTO].pos + 1;
        }
    }
return SCPE_OK;
}
Exemple #13
0
t_stat tti_svc (UNIT *uptr)
{
int32 c;

sim_clock_coschedule (uptr, tmxr_poll);                 /* continue poll */
if ((c = sim_poll_kbd ()) < SCPE_KFLAG)                 /* no char or error? */
    return c;
if (c & SCPE_BREAK)                                     /* break? */
    uptr->buf = 0;
else uptr->buf = sim_tt_inpcvt (c, TT_GET_MODE (uptr->flags));
uptr->pos = uptr->pos + 1;
tti_csr = tti_csr | CSR_DONE;
if (tti_csr & CSR_IE)
    SET_INT (TTI);
return SCPE_OK;
}
Exemple #14
0
t_stat tto_svc (UNIT *uptr)
{
int32 c;
t_stat r;

c = sim_tt_outcvt (uptr->buf, TT_GET_MODE (uptr->flags) | TTUF_KSR);
if (c >= 0) {
    if ((r = sim_putchar_s (c)) != SCPE_OK) {           /* output; error? */
        sim_activate (uptr, uptr->wait);                /* try again */
        return ((r == SCPE_STALL)? SCPE_OK: r);         /* !stall? report */
        }
    }
dev_done = dev_done | INT_TTO;                          /* set ready */
uptr->pos = uptr->pos + 1;
return SCPE_OK;
}
t_stat tti_svc (UNIT *uptr)
{
int32 c;

sim_activate (uptr, KBD_WAIT (uptr->wait, tmr_poll));   /* continue poll */
if ((c = sim_poll_kbd ()) < SCPE_KFLAG)                 /* no char or error? */
    return c;
if (c & SCPE_BREAK)                                     /* break? */
    tti_buf = RXDB_ERR | RXDB_FRM;
else tti_buf = sim_tt_inpcvt (c, TT_GET_MODE (uptr->flags));
uptr->pos = uptr->pos + 1;
tti_csr = tti_csr | CSR_DONE;
if (tti_csr & CSR_IE)
    tti_int = 1;
return SCPE_OK;
}
Exemple #16
0
t_stat tto_svc (UNIT *uptr)
{
int32 c;
t_stat r;

c = sim_tt_outcvt (uptr->buf, TT_GET_MODE (uptr->flags));
if (c >= 0) {
    if ((r = sim_putchar_s (c)) != SCPE_OK) {           /* output; error? */
        sim_activate (uptr, uptr->wait);                /* try again */
        return ((r == SCPE_STALL)? SCPE_OK: r);         /* !stall? report */
        }
    }
tto_csr = tto_csr | CSR_DONE;
if (tto_csr & CSR_IE) SET_INT (TTO);
uptr->pos = uptr->pos + 1;
return SCPE_OK;
}
Exemple #17
0
t_stat tti_svc (UNIT *uptr)
{
    int32 c;

    sim_clock_coschedule (uptr, tmxr_poll);                 /* continue poll */
    if (dev_done & INT_TTI)                                 /* prior character still pending? */
        return SCPE_OK;
    if ((c = sim_poll_kbd ()) < SCPE_KFLAG)                 /* no char or error? */
        return c;
    if (c & SCPE_BREAK)                                     /* break? */
        uptr->buf = 0;
    else uptr->buf = sim_tt_inpcvt (c, TT_GET_MODE (uptr->flags) | TTUF_KSR);
    uptr->pos = uptr->pos + 1;
    dev_done = dev_done | INT_TTI;                          /* set done */
    int_req = INT_UPDATE;                                   /* update interrupts */
    return SCPE_OK;
}
Exemple #18
0
t_stat tti_svc (UNIT *uptr)
{
int32 c;

sim_clock_coschedule (uptr, tmxr_poll);                 /* continue poll */
if (tti_csr & CSR_DONE)                                 /* is last input processed yet? */
    return SCPE_OK;                                     /* wait */
if ((c = sim_poll_kbd ()) < SCPE_KFLAG)                 /* no char or error? */
    return c;
if (c & SCPE_BREAK)                                     /* break? */
    tti_buf = RXDB_ERR | RXDB_FRM;
else tti_buf = sim_tt_inpcvt (c, TT_GET_MODE (uptr->flags));
uptr->pos = uptr->pos + 1;
tti_csr = tti_csr | CSR_DONE;
if (tti_csr & CSR_IE)
    tti_int = 1;
return SCPE_OK;
}
Exemple #19
0
t_stat tti_svc (UNIT *uptr)
{
int32 c;

sim_activate (uptr, KBD_WAIT (uptr->wait, tmr_poll));   /* continue poll */
if ((c = sim_poll_kbd ()) < SCPE_KFLAG)                 /* no char or error? */
    return c;
if (c & SCPE_BREAK) {                                   /* break? */
    if (sysd_hlt_enb ())                                /* if enabled, halt */
        hlt_pin = 1;
    tti_unit.buf = TTIBUF_ERR | TTIBUF_FRM | TTIBUF_RBR;
    }
else tti_unit.buf = sim_tt_inpcvt (c, TT_GET_MODE (uptr->flags));
uptr->pos = uptr->pos + 1;
tti_csr = tti_csr | CSR_DONE;
if (tti_csr & CSR_IE)
    SET_INT (TTI);
return SCPE_OK;
}
t_stat tto_svc (UNIT *uptr)
{
int32 c;
t_stat r;

if ((tto_buf & TXDB_SEL) == 0) {                        /* for console? */
    c = sim_tt_outcvt (tto_buf, TT_GET_MODE (uptr->flags));
    if (c >= 0) {
        if ((r = sim_putchar_s (c)) != SCPE_OK) {       /* output; error? */
            sim_activate (uptr, uptr->wait);            /* retry */
            return ((r == SCPE_STALL)? SCPE_OK: r);     /* !stall? report */
            }
        }
    uptr->pos = uptr->pos + 1;
    }
tto_csr = tto_csr | CSR_DONE;
if (tto_csr & CSR_IE)
    tto_int = 1;
return SCPE_OK;
}
Exemple #21
0
t_stat tti_svc (UNIT *uptr)
{
int32 c;

sim_clock_coschedule (uptr, tmxr_poll);                 /* continue poll */
if ((tti_csr & CSR_DONE) &&                             /* input still pending and < 500ms? */
    ((sim_os_msec () - tti_buftime) < 500))
     return SCPE_OK;
if ((c = sim_poll_kbd ()) < SCPE_KFLAG)                 /* no char or error? */
    return c;
if (c & SCPE_BREAK)                                     /* break? */
    tti_buf = RXDB_ERR | RXDB_FRM;
else tti_buf = sim_tt_inpcvt (c, TT_GET_MODE (uptr->flags));
tti_buftime = sim_os_msec ();
uptr->pos = uptr->pos + 1;
tti_csr = tti_csr | CSR_DONE;
if (tti_csr & CSR_IE)
    tti_int = 1;
return SCPE_OK;
}
Exemple #22
0
t_stat ttox_svc (UNIT *uptr)
{
int32 c, ln = uptr - ttox_unit;                         /* line # */

if (ttx_ldsc[ln].conn) {                                /* connected? */
    if (ttx_ldsc[ln].xmte) {                            /* tx enabled? */
        TMLN *lp = &ttx_ldsc[ln];                       /* get line */
        c = sim_tt_outcvt (ttox_buf[ln], TT_GET_MODE (ttox_unit[ln].flags) | TTUF_KSR);
        if (c >= 0)                                     /* output char */
            tmxr_putc_ln (lp, c);
        tmxr_poll_tx (&ttx_desc);                       /* poll xmt */
        }
    else {
        tmxr_poll_tx (&ttx_desc);                       /* poll xmt */
        sim_activate (uptr, ttox_unit[ln].wait);        /* wait */
        return SCPE_OK;
        }
    }
ttox_set_done (ln);                                     /* set done */
return SCPE_OK;
}
Exemple #23
0
t_stat tti_svc (UNIT *uptr)
{
int32 c, ebcdic;
uint32 st;

if ((c = sim_poll_kbd ()) < SCPE_KFLAG)                 /* no char or err? */
    return c;
if (c & SCPE_BREAK) {                                   /* break? */
    if (tt_cmd == TTS_WRITE) {                          /* during write? */
        tt_cmd = TTS_IDLE;
        sim_cancel (&tt_unit[TTO]);                     /* cancel write */
        chan_uen (tt_dib.dva);                          /* uend */
        }
    return SCPE_OK;
    }
c = c & 0x7F;
if (c == tti_panel)                                     /* panel interrupt? */
    return io_set_pint ();
uptr->pos = uptr->pos + 1;                              /* incr count */
if (c == '\r')                                          /* map CR to NL */
    c = '\n';
if (c == 0x7F)                                          /* map ^H back */
    c = 0x08;
c = sim_tt_inpcvt (c, TT_GET_MODE (uptr->flags));       /* input conversion */
ebcdic = ascii_to_ebcdic[c];                            /* then to EBCDIC */
tto_echo (c);                                           /* echo character */
if ((tt_cmd & 0x7F) == TTS_READ) {                      /* waiting for input? */
    st = chan_WrMemB (tt_dib.dva, ebcdic);              /* write to memory */
    if (CHS_IFERR (st))                                 /* channel error? */
       return tt_chan_err (st);
    if ((st == CHS_ZBC) || (ebcdic == E_EOM) ||         /* channel end? */
        ((tt_cmd == TTS_READS) && ((ebcdic == E_HT) || (ebcdic == E_NL)))) {
        tt_cmd = TTS_END;                               /* new state */
        sim_activate (&tt_unit[TTO], chan_ctl_time);    /* start dev thread */
        }
    }
return SCPE_OK;
}
Exemple #24
0
t_stat ttix_svc (UNIT *uptr)
{
int32 ln, c, temp;

if ((uptr->flags & UNIT_ATT) == 0)                      /* attached? */
    return SCPE_OK;
sim_activate (uptr, clk_cosched (tmxr_poll));           /* continue poll */
ln = tmxr_poll_conn (&ttx_desc);                        /* look for connect */
if (ln >= 0)                                            /* got one? rcv enab */
    ttx_ldsc[ln].rcve = 1;
tmxr_poll_rx (&ttx_desc);                               /* poll for input */
for (ln = 0; ln < TTX_MAXL; ln++) {                     /* loop thru lines */
    if (ttx_ldsc[ln].conn) {                            /* connected? */
        if (temp = tmxr_getc_ln (&ttx_ldsc[ln])) {      /* get char */
            if (temp & SCPE_BREAK)                      /* break? */
                c = 0;
            else c = sim_tt_inpcvt (temp, TT_GET_MODE (ttox_unit[ln].flags) | TTUF_KSR);
            ttix_buf[ln] = c;
            ttix_set_done (ln);
            }
        }
    }
return SCPE_OK;
}
Exemple #25
0
t_stat tti_svc (UNIT *uptr)
{
    int32 c;

    sim_clock_coschedule_tmr (uptr, TMR_CLK, TMXR_MULT);    /* continue poll */

    if ((tti_csr & CSR_DONE) &&                             /* input still pending and < 500ms? */
            ((sim_os_msec () - tti_buftime) < 500))
        return SCPE_OK;
    if ((c = sim_poll_kbd ()) < SCPE_KFLAG)                 /* no char or error? */
        return c;
    if (c & SCPE_BREAK) {                                   /* break? */
        if (sysd_hlt_enb ())                                /* if enabled, halt */
            hlt_pin = 1;
        tti_unit.buf = TTIBUF_ERR | TTIBUF_FRM | TTIBUF_RBR;
    }
    else tti_unit.buf = sim_tt_inpcvt (c, TT_GET_MODE (uptr->flags));
    tti_buftime = sim_os_msec ();
    uptr->pos = uptr->pos + 1;
    tti_csr = tti_csr | CSR_DONE;
    if (tti_csr & CSR_IE)
        SET_INT (TTI);
    return SCPE_OK;
}
Exemple #26
0
t_stat muxo_svc (UNIT *uptr)
{
    int32 c;
    uint32 ln = uptr - muxl_unit;                           /* line # */

    if (mux_ldsc[ln].conn) {                                /* connected? */
        if (mux_ldsc[ln].xmte) {                            /* xmt enabled? */
            c = sim_tt_outcvt (mux_xbuf[ln], TT_GET_MODE (muxl_unit[ln].flags));
            if (c >= 0)
                tmxr_putc_ln (&mux_ldsc[ln], c);            /* output char */
            tmxr_poll_tx (&mux_desc);                       /* poll xmt */
            if (mux_sta[ln] & MUXL_XIA) {                   /* armed? */
                mux_sta[ln] |= MUXL_XIR;                    /* req intr */
                mux_scan_next (0);                          /* kick scanner */
            }
        }
        else {                                              /* buf full */
            tmxr_poll_tx (&mux_desc);                       /* poll xmt */
            sim_activate (uptr, muxl_unit[ln].wait);        /* wait */
            return SCPE_OK;
        }
    }
    return SCPE_OK;
}
t_stat tto_svc (UNIT *uptr)
{
int32 c = uptr->buf;

#ifdef CYR_CTLN_CTLO
c &= 0177;
if (c == ('N' & 037)) {
    tto_charconv = 1;
    c = -1;
} else if (c == ('O' & 037)) {
    tto_charconv = 0;
    c = -1;
} else if (tto_charconv && c >= '@') {
#ifdef _WIN32
    static uint8 tab[0100] = {
#if 0
        /* Codepage 1251 */
        0376, 0340, 0341, 0366, 0344, 0345, 0364, 0343, /* @ABCDEFG */
        0365, 0350, 0351, 0352, 0353, 0354, 0355, 0356, /* HIJKLMNO */
        0357, 0377, 0360, 0361, 0362, 0363, 0346, 0342, /* PQRSTUVW */
        0374, 0373, 0347, 0370, 0375, 0371, 0367, 0372, /* XYZ[\]^_ */
        0336, 0300, 0301, 0326, 0304, 0305, 0324, 0303, /* `abcdefg */
        0325, 0310, 0311, 0312, 0313, 0314, 0315, 0316, /* hijklmno */
        0317, 0337, 0320, 0321, 0322, 0323, 0306, 0302, /* pqrstuvw */
        0334, 0333, 0307, 0330, 0335, 0331, 0327, 0332, /* xyz{|}~  */
#else
        /* Codepage 866 */
        0356, 0240, 0241, 0346, 0244, 0245, 0344, 0243, /* @ABCDEFG */
        0345, 0250, 0251, 0252, 0253, 0254, 0255, 0256, /* HIJKLMNO */
        0257, 0357, 0340, 0341, 0342, 0343, 0246, 0242, /* PQRSTUVW */
        0354, 0353, 0247, 0350, 0355, 0351, 0347, 0352, /* XYZ[\]^_ */
        0236, 0200, 0201, 0226, 0204, 0205, 0224, 0203, /* `abcdefg */
        0225, 0210, 0211, 0212, 0213, 0214, 0215, 0216, /* hijklmno */
        0217, 0237, 0220, 0221, 0222, 0223, 0206, 0202, /* pqrstuvw */
        0234, 0233, 0207, 0230, 0235, 0231, 0227, 0232, /* xyz{|}~  */
#endif
        };
    c = tab [c - '@'];
#else /* _WIN32 */
    /* UTF-8 */
    static const char *tab[0100] = {
        "ю", "а", "б", "ц", "д", "е", "ф", "г",         /* @ABCDEFG */
        "х", "и", "й", "к", "л", "м", "н", "о",         /* HIJKLMNO */
        "п", "я", "р", "с", "т", "у", "ж", "в",         /* PQRSTUVW */
        "ь", "ы", "з", "ш", "э", "щ", "ч", "ъ",         /* XYZ[\]^_ */
        "Ю", "А", "Б", "Ц", "Д", "Е", "Ф", "Г",         /* `abcdefg */
        "Х", "И", "Й", "К", "Л", "М", "Н", "О",         /* hijklmno */
        "П", "Я", "Р", "С", "Т", "У", "Ж", "В",         /* pqrstuvw */
        "Ь", "Ы", "З", "Ш", "Э", "Щ", "Ч", "Ъ",         /* xyz{|}~  */
        };
    const char *str = tab[c-'@'];
    t_stat r = sim_putchar_s (str[0]);
    if (r != SCPE_OK) {                             /* output; error? */
        sim_activate (uptr, uptr->wait);            /* try again */
        return ((r == SCPE_STALL)? SCPE_OK: r);     /* !stall? report */
        }
    for (c=1; str[c]; c++)
        sim_putchar (str[c]);
    c = -1;
#endif /* _WIN32 */
    }
#else /* CYR_CTLN_CTLO */
c = sim_tt_outcvt (c, TT_GET_MODE (uptr->flags));
#endif /* CYR_CTLN_CTLO */

if (c >= 0) {
    t_stat r = sim_putchar_s (c);
    if (r != SCPE_OK) {                             /* output; error? */
        sim_activate (uptr, uptr->wait);            /* try again */
        return ((r == SCPE_STALL)? SCPE_OK: r);     /* !stall? report */
        }
    }
tto_csr = tto_csr | CSR_DONE;
if (tto_csr & CSR_IE)
    SET_INT (TTO);
uptr->pos = uptr->pos + 1;
return SCPE_OK;
}
Exemple #28
0
t_stat ports_xmt_svc(UNIT *uptr)
{
    uint8 cid, ln;
    char c;
    t_bool tx = FALSE; /* Did a tx ever occur? */
    cio_entry centry = {0};
    uint8 app_data[4] = {0};
    uint32 wait = 0x7fffffff;

    /* Scan all lines for output */
    for (ln = 0; ln < ports_desc.lines; ln++) {
        cid = LCID(ln);
        if (ports_ldsc[ln].conn && ports_state[ln].tx_chars > 0) {
            tx = TRUE; /* Even an attempt at TX counts for rescheduling */
            c = sim_tt_outcvt(pread_b(ports_state[ln].tx_addr),
                              TT_GET_MODE(ports_unit[0].flags));

            /* The PORTS card optionally handles NL->CRLF */
            if (c == 0xa &&
                (ports_state[ln].oflag & ONLCR) &&
                !(ports_state[ln].crlf)) {
                if (tmxr_putc_ln(&ports_ldsc[ln], 0xd) == SCPE_OK) {
                    wait = MIN(wait, ports_ldsc[ln].txdeltausecs);
                    sim_debug(IO_DBG, &ports_dev,
                              "[%08x] [ports_xmt_svc] [LINE %d] XMIT (crlf):  %02x (%c)\n",
                              R[NUM_PC], ln, 0xd, 0xd);
                    /* Indicate that we're in a CRLF translation */
                    ports_state[ln].crlf = TRUE;
                }

                break;
            }

            ports_state[ln].crlf = FALSE;

            if (tmxr_putc_ln(&ports_ldsc[ln], c) == SCPE_OK) {
                wait = MIN(wait, ports_ldsc[ln].txdeltausecs);
                ports_state[ln].tx_chars--;
                ports_state[ln].tx_addr++;
                sim_debug(IO_DBG, &ports_dev,
                          "[%08x] [ports_xmt_svc] [LINE %d] XMIT:         %02x (%c)\n",
                          R[NUM_PC], ln, c, c);
            }

            if (ports_state[ln].tx_chars == 0) {
                sim_debug(TRACE_DBG, &ports_dev,
                          "[%08x] [ports_xmt_svc] Done with xmit, card=%d port=%d. Interrupting.\n",
                          R[NUM_PC], cid, LPORT(ln));
                centry.byte_count = ports_state[ln].tx_req_chars;
                centry.subdevice = LPORT(ln);
                centry.opcode = PPC_XMIT;
                centry.address = ports_state[ln].tx_req_addr;
                app_data[0] = RC_FLU;
                cio_cqueue(cid, CIO_STAT, PPQESIZE, &centry, app_data);
                cio[cid].intr = TRUE;
            }
        }
    }

    tmxr_poll_tx(&ports_desc);

    if (tx) {
        tmxr_activate_after(uptr, wait);
    }

    return SCPE_OK;
}