Ejemplo n.º 1
0
t_stat cdp_npr (UNIT *notused, int32 val, char *cptr, void *desc)
{
UNIT *uptr;

if (cdp_buf_full == 0)                                  /* any card? */
    return SCPE_OK;                                     /* no, done */
cdp_buf_full = 0;                                       /* buf empty */
if (s8sel)                                              /* stack 8? */
    uptr = &stack_unit[2];
else if (s4sel)                                         /* stack 4? */
    uptr = &stack_unit[4];
else uptr = &cdp_unit;                                  /* normal output */
if ((uptr->flags & UNIT_ATT) == 0)                      /* attached? */
    return SCPE_UNATT;
fputs (cdp_buf, uptr->fileref);                         /* output card */
fputc ('\n', uptr->fileref);                            /* plus new line */
uptr->pos = ftell (uptr->fileref);                      /* update position */
if (ferror (uptr->fileref)) {                           /* error? */
    sim_perror ("Card punch I/O error");
    clearerr (uptr->fileref);
    if (iochk)
        return SCPE_IOERR;
    ind[IN_PNCH] = 1;
    }
return SCPE_OK;
}
Ejemplo n.º 2
0
static t_stat sagelp_output(UNIT *uptr)
{
    if ((uptr->flags & UNIT_ATT)==0) {
        u39.portb |= U39B_PAPER;    /* unattached means: no paper */
        return SCPE_UNATT;
    } else if (uptr->flags & UNIT_OFFLINE) {
        u39.portb &= ~U39B_SEL;     /* offline means: SEL = 0 */ 
        return STOP_OFFLINE;
    }
    u39.portb &= ~U39B_PAPER;       /* has paper */
    u39.portb |= U39B_SEL;          /* is online */
    u39.portb |= U39B_FAULT;        /* no fault */
    u39.portb &= ~U39B_BUSY;            /* not busy */
    if ((u39.portc & U39C_STROBE)==0) { /* strobe presented */
        fputc (uptr->buf & 0177, uptr->fileref);    /* put out char */
        if (ferror (uptr->fileref)) {
            sim_perror ("LP I/O error");
            clearerr (uptr->fileref);
            return SCPE_IOERR;
        }
        sagelp_unit.pos = ftell(uptr->fileref); /* update pos */
        u39.portc |= U39C_STROBE;   /* XXX reset strobe directly */
        sage_raiseint(LP_PICINT);
        return SCPE_OK;
    }
    return SCPE_OK;
}
Ejemplo n.º 3
0
Archivo: id_dp.c Proyecto: B-Rich/simh
t_stat dp_wds (UNIT *uptr)
{
for ( ; dp_bptr < DP_NUMBY; dp_bptr++)
    dpxb[dp_bptr] = dp_db;                              /* fill with last */
fxwrite (dpxb, sizeof (uint8), DP_NUMBY, uptr->fileref);
if (ferror (uptr->fileref)) {                           /* error? */
    sim_perror ("DP I/O error");
    clearerr (uptr->fileref);
    dp_done (STC_DTE);
    return SCPE_IOERR;
    }
return SCPE_OK;
}
Ejemplo n.º 4
0
t_stat hsp_svc (UNIT *uptr)
{
dev_done = dev_done | INT_HSP;                          /* set ready */
if ((hsp_unit.flags & UNIT_ATT) == 0)                   /* attached? */
    return IORETURN (hsp_stopioe, SCPE_UNATT);
if (putc (hsp_unit.buf, hsp_unit.fileref) == EOF) {     /* write char */
    sim_perror ("HSP I/O error");                           /* error? */
    clearerr (hsp_unit.fileref);
    return SCPE_IOERR;
    }
hsp_unit.pos = hsp_unit.pos + 1;
return SCPE_OK;
}
Ejemplo n.º 5
0
t_stat ptp_svc (UNIT *uptr)
{
dev_done = dev_done | INT_PTP;                          /* set done */
int_req = INT_UPDATE;                                   /* update interrupts */
if ((ptp_unit.flags & UNIT_ATT) == 0)                   /* attached? */
    return IORETURN (ptp_stopioe, SCPE_UNATT);
if (putc (ptp_unit.buf, ptp_unit.fileref) == EOF) {
    sim_perror ("PTP I/O error");
    clearerr (ptp_unit.fileref);
    return SCPE_IOERR;
    }
ptp_unit.pos = ptp_unit.pos + 1;
return SCPE_OK;
}
Ejemplo n.º 6
0
t_stat lpt_print (void)
{
int32 i, chan, ctrl = lpt_savctrl;

if ((lpt_unit.flags & UNIT_ATT) == 0) {                 /* not attached? */
    ind[IN_PRCHK] = ind[IN_WRCHK] = 1;                  /* wr, pri check */
    return SCPE_UNATT;
    }

ind[IN_PRBSY] = 1;                                      /* print busy */
sim_activate (&lpt_unit, lpt_unit.wait);                /* start timer */

for (i = LPT_WIDTH; i <= LPT_BSIZE; i++)                /* clear unprintable */
    lpt_buf[i] = ' ';
while ((lpt_bptr > 0) && (lpt_buf[lpt_bptr - 1] == ' '))
    lpt_buf[--lpt_bptr] = 0;                            /* trim buffer */
if (lpt_bptr) {                                         /* any line? */
    fputs (lpt_buf, lpt_unit.fileref);                  /* print */
    lpt_unit.pos = ftell (lpt_unit.fileref);            /* update pos */
    lpt_buf_init ();                                    /* reinit buf */
    if (ferror (lpt_unit.fileref)) {                    /* error? */
        ind[IN_PRCHK] = ind[IN_WRCHK] = 1;              /* wr, pri check */
        sim_perror ("LPT I/O error");
        clearerr (lpt_unit.fileref);
        return SCPE_IOERR;
        }
    }

lpt_savctrl = 0x61;                                     /* reset ctrl */
if ((ctrl & K_LIN) == ((ctrl & K_IMM)? 0: K_LIN))       /* space lines? */
    return lpt_space (ctrl & K_LCNT, FALSE);
chan = lpt_savctrl & K_CHAN;                            /* basic chan */
if ((lpt_savctrl & K_CH10) == 0) {                      /* chan 10-12? */
    if (chan == 0)
        chan = 10;
    else if (chan == 3)
        chan = 11;
    else if (chan == 4)
        chan = 12;
    else chan = 0;
    }
if ((chan == 0) || (chan > 12))
    return STOP_INVFNC;
for (i = 1; i < cct_lnt + 1; i++) {                     /* sweep thru cct */
    if (CHP (chan, cct[(cct_ptr + i) % cct_lnt]))
        return lpt_space (i, TRUE);
    }
return STOP_CCT;                                        /* runaway channel */
}
Ejemplo n.º 7
0
Archivo: id_dp.c Proyecto: B-Rich/simh
t_stat dp_rds (UNIT *uptr)
{
uint32 i;

i = fxread (dpxb, sizeof (uint8), DP_NUMBY, uptr->fileref);
for ( ; i < DP_NUMBY; i++)                              /* fill with 0's */
    dpxb[i] = 0;
if (ferror (uptr->fileref)) {                           /* error? */
    sim_perror ("DP I/O error");
    clearerr (uptr->fileref);
    dp_done (STC_DTE);
    return SCPE_IOERR;
    }
return SCPE_OK;
}
Ejemplo n.º 8
0
t_stat ptr_svc (UNIT *uptr)
{
int32 temp;

if ((uptr->flags & UNIT_ATT) == 0) {                    /* attached? */
    if (ptr_wait)                                       /* if wait, clr ioh */
        ptr_wait = ioh = 0;
    if ((cpls & CPLS_PTR) || ptr_stopioe)
        return SCPE_UNATT;
    return SCPE_OK;
    }
if ((uptr->flags & UNIT_ASCII) && (ptr_state == 0))     /* ASCII mode, alpha read? */
    temp = ptr_get_ascii (uptr);                        /* get processed char */
else if ((temp = getc (uptr->fileref)) != EOF)          /* no, get raw char */
    uptr->pos = uptr->pos + 1;                          /* if not eof, count */
if (temp == EOF) {                                      /* end of file? */
    if (ptr_wait)                                       /* if wait, clr ioh */
        ptr_wait = ioh = 0;
    if (feof (uptr->fileref)) {
        if ((cpls & CPLS_PTR) || ptr_stopioe)
            sim_printf ("PTR end of file\n");
        else return SCPE_OK;
        }
    else sim_perror ("PTR I/O error");
    clearerr (uptr->fileref);
    return SCPE_IOERR;
    }
if (ptr_state == 0)                                     /* alpha */
    uptr->buf = temp & 0377;
else if (temp & 0200) {                                 /* binary */
    ptr_state = ptr_state - 6;
    uptr->buf = uptr->buf | ((temp & 077) << ptr_state);
    }
if (ptr_state == 0) {                                   /* done? */
    if (cpls & CPLS_PTR) {                              /* completion pulse? */
        iosta = iosta & ~IOS_PTR;                       /* clear flag */
        IO = uptr->buf;                                 /* fill IO */
        ios = 1;                                        /* restart */
        cpls = cpls & ~CPLS_PTR;
        }
    else {                                              /* no, interrupt */
        iosta = iosta | IOS_PTR;                        /* set flag */
        dev_req_int (ptr_sbs);                          /* req interrupt */
        }
    }
else sim_activate (uptr, uptr->wait);                   /* get next char */
return SCPE_OK;
}
Ejemplo n.º 9
0
t_stat lpt_svc (UNIT *uptr)
{
DEV_CLR_BUSY( INT_LPT ) ;
DEV_SET_DONE( INT_LPT ) ;
DEV_UPDATE_INTR ;
if ((lpt_unit.flags & UNIT_ATT) == 0)                   /* attached? */
    return IORETURN (lpt_stopioe, SCPE_UNATT);
fputc (uptr->buf, uptr->fileref);
uptr->pos = ftell (uptr->fileref);
if (ferror (uptr->fileref)) {
    sim_perror ("LPT I/O error");
    clearerr (uptr->fileref);
    return SCPE_IOERR;
    }
return SCPE_OK;
}
Ejemplo n.º 10
0
t_stat ptp_svc (UNIT *uptr)
{
ptp_csr = ptp_csr | CSR_ERR | CSR_DONE;
if (ptp_csr & CSR_IE)
    SET_INT (PTP);
if ((ptp_unit.flags & UNIT_ATT) == 0)
    return IORETURN (ptp_stopioe, SCPE_UNATT);
if (putc (ptp_unit.buf, ptp_unit.fileref) == EOF) {
    sim_perror ("PTP I/O error");
    clearerr (ptp_unit.fileref);
    return SCPE_IOERR;
    }
ptp_csr = ptp_csr & ~CSR_ERR;
ptp_unit.pos = ptp_unit.pos + 1;
return SCPE_OK;
}
Ejemplo n.º 11
0
t_stat lpt_end_line (UNIT *uptr)
{
uint32 i, col, row, bufw, colbin;
const char *pch;
char bcd, lpt_cbuf[LPT_CHRLNT + 1];
t_uint64 dat;

pch = pch_table[GET_PCHAIN (lpt_unit.flags)];           /* get print chain */
for (col = 0; col < (LPT_CHRLNT + 1); col++)            /* clear ascii buf */
    lpt_cbuf[col] = ' '; 
for (col = 0; col < 72; col++) {                        /* proc 72 columns */
    colbin = 0;
    dat = bit_masks[35 - (col % 36)];                   /* mask for column */
    for (row = 0; row < 12; row++) {                    /* proc 12 rows */
        bufw = (row * 2) + (col / 36);                  /* index to buffer */
        if (lpt_bbuf[bufw] & dat)
            colbin |= col_masks[row];
        }
    bcd = colbin_to_bcd (colbin);                       /* column bin -> BCD */
    lpt_cbuf[col] = pch[bcd];                           /* -> ASCII */
    }
for (i = LPT_CHRLNT; (i > 0) &&
    (lpt_cbuf[i - 1] == ' '); --i) ;                    /* trim spaces */
lpt_cbuf[i] = 0;                                        /* append nul */
if (uptr->flags & UNIT_ATT) {                           /* file? */
    fputs (lpt_cbuf, uptr->fileref);                    /* write line */
    fputc ('\n', uptr->fileref);                        /* append nl */
    uptr->pos = ftell (uptr->fileref);                  /* update position */
    if (ferror (uptr->fileref)) {                       /* error? */
        sim_perror ("LPT I/O error");
        clearerr (uptr->fileref);
        return SCPE_IOERR;
        }
    }
else if (uptr->flags & UNIT_CONS) {                     /* print to console? */
    for (i = 0; lpt_cbuf[i] != 0; i++)
        sim_putchar (lpt_cbuf[i]);
    sim_putchar ('\r');
    sim_putchar ('\n');
    }
else return SCPE_UNATT;                                 /* otherwise error */
lpt_sta = LPS_END;                                      /* end line state */
sim_cancel (uptr);                                      /* cancel current */
sim_activate (uptr, lpt_tstop);                         /* long timer */
return SCPE_OK;
}
Ejemplo n.º 12
0
Archivo: sds_lp.c Proyecto: B-Rich/simh
t_stat lpt_status (UNIT *uptr)
{
if (uptr->flags & UNIT_ATT) {                           /* attached? */
    uptr->pos = ftell (uptr->fileref);                  /* update position */
    if (ferror (uptr->fileref)) {                       /* I/O error? */
        lpt_end_op (CHF_EOR | CHF_ERR);                 /* set err, disc */
        sim_perror ("LPT I/O error");                       /* print msg */
        clearerr (uptr->fileref);
        return SCPE_IOERR;                              /* ret error */
        }
    }
else {
    lpt_end_op (CHF_EOR | CHF_ERR);                     /* set err, disc */
    CRETIOE (lpt_stopioe, SCPE_UNATT);                  /* ret error */
    }
return SCPE_OK;
}
Ejemplo n.º 13
0
Archivo: id_lp.c Proyecto: ST3ALth/simh
t_stat lpt_svc (UNIT *uptr)
{
int32 t;
t_stat r = SCPE_OK;

lpt_sta = 0;                                            /* clear busy */
if (lpt_arm)                                            /* armed? intr */
    SET_INT (v_LPT);
if ((uptr->flags & UNIT_ATT) == 0)                      /* attached? */
    return IORETURN (lpt_stopioe, SCPE_UNATT);
t = uptr->buf;                                          /* get character */
if (lpt_spnd || ((t >= LF) && (t < CR))) {              /* spc pend or spc op? */
    lpt_spnd = 0;
    if (lpt_bufout (uptr) != SCPE_OK)                   /* print */
        return SCPE_IOERR;
    if ((t == 1) || (t == LF))                          /* single space */
        lpt_spc (uptr, 1);
    else if (t == VT)                                   /* VT->VFU */
        r = lpt_vfu (uptr, VT_VFU - 1);
    else if (t == 0xC)                                  /* FF->VFU */
        r = lpt_vfu (uptr, FF_VFU - 1);
    else if ((t >= SPC_BASE) && (t < VFU_BASE))
        lpt_spc (uptr, t - SPC_BASE);                   /* space */
    else if ((t >= VFU_BASE) && (t < VFU_BASE + VFU_WIDTH))
        r = lpt_vfu (uptr, t - VFU_BASE);               /* VFU */
    else fputs ("\r", uptr->fileref);                   /* overprint */
    uptr->pos = ftell (uptr->fileref);                  /* update position */
    if (ferror (lpt_unit.fileref)) {
        sim_perror ("LPT I/O error");
        clearerr (uptr->fileref);
        return SCPE_IOERR;
        }
    }
else if (t == CR) {                                     /* CR? */
    lpt_spnd = 1;                                       /* set spc pend */
    return lpt_bufout (uptr);                           /* print line */
    }
else if (t >= 0x20) {                                   /* printable? */
    if ((uptr->flags & UNIT_UC) && islower (t))         /* UC only? */
        t = toupper (t);
    if (lpt_bptr < LPT_WIDTH)
        lpxb[lpt_bptr++] = t;
    }
return r;
}
Ejemplo n.º 14
0
t_stat cdr_svc (UNIT *uptr)
{
if (s1sel)                                              /* stacker 1? */
    uptr = &stack_unit[1];
else if (s2sel)                                         /* stacker 2? */
    uptr = &stack_unit[2];
else uptr = &stack_unit[0];                             /* then default */
if ((uptr->flags & UNIT_ATT) == 0)                      /* attached? */
    return SCPE_OK;
fputs (cdr_buf, uptr->fileref);                         /* write card */
uptr->pos = ftell (uptr->fileref);                      /* update position */
if (ferror (uptr->fileref)) {                           /* error? */
    sim_perror ("Card stacker I/O error");
    clearerr (uptr->fileref);
    if (iochk)
        return SCPE_IOERR;
    }
return SCPE_OK;
}
Ejemplo n.º 15
0
uint32 lp_space (UNIT *uptr, uint32 cnt, t_bool skp)
{
uint32 i;

lp_cctp = (lp_cctp + cnt) % lp_cctl;                    /* adv cct, mod lnt */
if (skp && CHP (CH_TOF, lp_cct[lp_cctp]))               /* skip, TOF? */
        fputs ("\f", uptr->fileref);                    /* ff */
    else {                                              /* space */
        for (i = 0; i < cnt; i++)
            fputc ('\n', uptr->fileref);
        }
uptr->pos = ftell (uptr->fileref);                      /* update position */
if (ferror (uptr->fileref)) {                           /* error? */
    sim_perror ("Line printer I/O error");
    clearerr (uptr->fileref);
    chan_set_chf (lp_dib.dva, CHF_XMDE);
    return SCPE_IOERR;
    }
return 0;
}
Ejemplo n.º 16
0
t_stat ptp_svc (UNIT *uptr)
{
int32 c;

if (cpls & CPLS_PTP) {                                  /* completion pulse? */
    ios = 1;                                            /* restart */
    cpls = cpls & ~CPLS_PTP;
    }
iosta = iosta | IOS_PTP;                                /* set flag */
dev_req_int (ptp_sbs);                                  /* req interrupt */
if ((uptr->flags & UNIT_ATT) == 0)                      /* not attached? */
    return IORETURN (ptp_stopioe, SCPE_UNATT);
if ((uptr->flags & UNIT_ASCII) != 0) {                  /* ASCII mode? */
    int32 c1 = uptr->buf & 077;
    if (uptr->buf == 0)                                 /* ignore nulls */
        return SCPE_OK;
    if (c1 == FIODEC_UC) {                              /* UC? absorb */
        ptp_uc = UC;
        return SCPE_OK;
        }
    else if (c1 == FIODEC_LC) {                         /* LC? absorb */
        ptp_uc = 0;
        return SCPE_OK;
        }
    else c = fiodec_to_ascii[c1 | ptp_uc];
    if (c == 0)
        return SCPE_OK;
    if (c == '\n') {                                    /* new line? */
        putc ('\r', uptr->fileref);                     /* cr first */
        uptr->pos = uptr->pos + 1;
        }
    }
else c = uptr->buf;        
if (putc (c, uptr->fileref) == EOF) {                   /* I/O error? */
    sim_perror ("PTP I/O error");
    clearerr (uptr->fileref);
    return SCPE_IOERR;
    }
uptr->pos = uptr->pos + 1;
return SCPE_OK;
}
Ejemplo n.º 17
0
t_stat hsr_svc (UNIT *uptr)
{
int32 temp;

if ((hsr_unit.flags & UNIT_ATT) == 0)                   /* attached? */
    return IORETURN (hsr_stopioe, SCPE_UNATT);
if ((temp = getc (hsr_unit.fileref)) == EOF) {          /* read char */
    if (feof (hsr_unit.fileref)) {                      /* err or eof? */
        if (hsr_stopioe)
            sim_printf ("HSR end of file\n");
        else return SCPE_OK;
        }
    else sim_perror ("HSR I/O error");
    clearerr (hsr_unit.fileref);
    return SCPE_IOERR;
    }
dev_done = dev_done | INT_HSR;                          /* set ready */
hsr_unit.buf = temp & 0377;                             /* save char */
hsr_unit.pos = hsr_unit.pos + 1;
return SCPE_OK;
}
Ejemplo n.º 18
0
t_stat cdr_read_file (char *buf, int32 sz)
{
fgets (buf, sz, cdr_unit.fileref);                      /* rd bin/char card */
if (feof (cdr_unit.fileref))                            /* eof? */
    return STOP_NOCD;
if (ferror (cdr_unit.fileref)) {                        /* error? */
    ind[IN_READ] = 1;  
    sim_perror ("Card reader I/O error");
    clearerr (cdr_unit.fileref);
    if (iochk)
        return SCPE_IOERR;
    return SCPE_OK;
    }
cdr_unit.pos = ftell (cdr_unit.fileref);                /* update position */
if (ssa) {                                              /* if last cd on */
    getc (cdr_unit.fileref);                            /* see if more */
    if (feof (cdr_unit.fileref))                        /* eof? set flag */
        ind[IN_LST] = 1;
    fseek (cdr_unit.fileref, cdr_unit.pos, SEEK_SET);
    }
return SCPE_OK;
}
Ejemplo n.º 19
0
t_stat lpt_space (int32 count, int32 sflag)
{
int32 i;

cct_ptr = (cct_ptr + count) % cct_lnt;                  /* adv cct, mod lnt */
if (sflag && CHP (0, cct[cct_ptr]))                     /* skip, top of form? */
    fputs ("\n\f", lpt_unit.fileref);                   /* nl, ff */
else {
    for (i = 0; i < count; i++)                         /* count lines */
        fputc ('\n', lpt_unit.fileref);
    }
lpt_unit.pos = ftell (lpt_unit.fileref);                /* update position */
ind[IN_PRCH9] = CHP (9, cct[cct_ptr]) != 0;             /* set indicators */
ind[IN_PRCH12] = CHP (12, cct[cct_ptr]) != 0;
if (ferror (lpt_unit.fileref)) {                        /* error? */
    ind[IN_PRCHK] = ind[IN_WRCHK] = 1;                  /* wr, pri check */
    sim_perror ("LPT I/O error");
    clearerr (lpt_unit.fileref);
    return SCPE_IOERR;
    }
return SCPE_OK;
}
Ejemplo n.º 20
0
t_stat ptr_svc (UNIT *uptr)
{
int32 temp;

if ((ptr_unit.flags & UNIT_ATT) == 0)                   /* attached? */
    return IORETURN (ptr_stopioe, SCPE_UNATT);
if ((temp = getc (ptr_unit.fileref)) == EOF) {
    if (feof (ptr_unit.fileref)) {
        if (ptr_stopioe)
            sim_printf ("PTR end of file\n");
        else return SCPE_OK;
        }
    else sim_perror ("PTR I/O error");
    clearerr (ptr_unit.fileref);
    return SCPE_IOERR;
    }
dev_done = dev_done | INT_PTR;                          /* set done */
int_req = INT_UPDATE;                                   /* update interrupts */
ptr_unit.buf = temp & 0377;
ptr_unit.pos = ptr_unit.pos + 1;
return SCPE_OK;
}
Ejemplo n.º 21
0
uint32 lp_print (UNIT *uptr)
{
uint32 i, bp, c;
uint32 max = (lp_model == LP_7440)? BUF_LNT4: BUF_LNT5;
uint32 st;

if (lp_pass == 0) {                                     /* pass 1? clr buf */
    for (i = 0; i < BUF_LNT4; i++) lp_buf[i] = ' ';
    }
for (bp = 0, st = 0; (bp < max) && !st; bp++) {          /* fill buffer */
    st = chan_RdMemB (lp_dib.dva, &c);                  /* get char */
    if (CHS_IFERR (st))                                 /* channel error? */
        return st;                                      /* caller handles */
    if ((lp_model == LP_7440) ||                        /* 7440 or */
        ((bp & 1) == lp_pass))                          /* correct pass? */
        lp_buf[bp] = lp_to_ascii[c & 0x3F];
    }
if ((lp_model == LP_7440) || lp_pass) {                 /* ready to print? */
    lp_pass = 0;
    for (i = BUF_LNT4; (i > 0) && (lp_buf[i - 1] == ' '); i--) ; /* trim */
    if (i)                                              /* write line */
        sim_fwrite (lp_buf, 1, i, uptr->fileref);
    fputc (lp_inh? '\r': '\n', uptr->fileref);          /* cr or nl */
    uptr->pos = ftell (uptr->fileref);                  /* update position */
    if (ferror (uptr->fileref)) {                       /* error? */
        sim_perror ("Line printer I/O error");
        clearerr (uptr->fileref);
        chan_set_chf (lp_dib.dva, CHF_XMDE);
        return SCPE_IOERR;
        }
    if ((lp_model == LP_7440) &&                        /* 7440? */
        ((bp != BUF_LNT4) || (st != CHS_ZBC)) &&        /* check lnt err */
        chan_set_chf (lp_dib.dva, CHF_LNTE))
        return CHS_INACTV;                              /* stop if asked */
    }
else lp_pass = 1;                                       /* 7450 pass 2 */
lp_cmd = LPS_END;                                       /* end state */
return 0;
}
Ejemplo n.º 22
0
Archivo: id_lp.c Proyecto: ST3ALth/simh
t_stat lpt_bufout (UNIT *uptr)
{
int32 i;
t_stat r = SCPE_OK;

if (lpt_bptr == 0) return SCPE_OK;                      /* any char in buf? */
for (i = LPT_WIDTH - 1; (i >= 0) && (lpxb[i] == ' '); i--)
    lpxb[i] = 0;                                        /* backscan line */
if (lpxb[0]) {                                          /* any char left? */
    fputs (lpxb, uptr->fileref);                        /* write line */
    lpt_unit.pos = ftell (uptr->fileref);               /* update position */
    if (ferror (uptr->fileref)) {
        sim_perror ("LPT I/O error");
        clearerr (uptr->fileref);
        r = SCPE_IOERR;
        }
    }   
lpt_bptr = 0;                                           /* reset buffer */
for (i = 0; i < LPT_WIDTH; i++)
    lpxb[i] = ' ';
lpxb[LPT_WIDTH] = 0;
return r;
}
Ejemplo n.º 23
0
t_stat ptr_svc (UNIT *uptr)
{
int32 temp;

ptr_csr = (ptr_csr | CSR_ERR) & ~CSR_BUSY;
if (ptr_csr & CSR_IE) SET_INT (PTR);
if ((ptr_unit.flags & UNIT_ATT) == 0)
    return IORETURN (ptr_stopioe, SCPE_UNATT);
if ((temp = getc (ptr_unit.fileref)) == EOF) {
    if (feof (ptr_unit.fileref)) {
        if (ptr_stopioe)
            sim_printf ("PTR end of file\n");
        else return SCPE_OK;
        }
    else sim_perror ("PTR I/O error");
    clearerr (ptr_unit.fileref);
    return SCPE_IOERR;
    }
ptr_csr = (ptr_csr | CSR_DONE) & ~CSR_ERR;
ptr_unit.buf = temp & 0377;
ptr_unit.pos = ptr_unit.pos + 1;
return SCPE_OK;
}
Ejemplo n.º 24
0
t_stat cdr_svc (UNIT *uptr)
{
uint32 i, col, row, bufw, colbin;
char cdr_cbuf[(2 * CD_CHRLNT) + 2];
t_uint64 dat = 0;

if ((uptr->flags & UNIT_ATT) == 0)                      /* not attached? */
    return SCPE_UNATT;
switch (cdr_sta) {                                      /* case on state */

    case CDS_INIT:                                      /* initial state */
        for (i = 0; i < CD_BINLNT; i++)                 /* clear bin buf */ 
             cdr_bbuf[i] = 0;
        for (i = 0; i < ((2 * CD_CHRLNT) + 2); i++)     /* clear char buf */
            cdr_cbuf[i] = ' ';
        cdr_sta = CDS_DATA;                             /* data state */
        cdr_bptr = 0;                                   /* init buf ptr */
        fgets (cdr_cbuf, (uptr->flags & UNIT_CBN)? (2 * CD_CHRLNT) + 2: CD_CHRLNT + 2,
            uptr->fileref);                             /* read card */
        if (feof (uptr->fileref))                       /* eof? */
            return ch6_err_disc (CH_A, U_CDR, CHF_EOF); /* set EOF, disc */
        if (ferror (uptr->fileref)) {                   /* error? */
            sim_perror ("CDR I/O error");
            clearerr (uptr->fileref);
            return SCPE_IOERR;                          /* stop */
            }
        uptr->pos = ftell (uptr->fileref);              /* update position */
        for (i = 0; i < (2 * CD_CHRLNT); i++)           /* convert to BCD */
            cdr_cbuf[i] = ascii_to_bcd[cdr_cbuf[i] & 0177] & 077;
        for (col = 0; col < 72; col++) {                /* process 72 columns */
            if (uptr->flags & UNIT_CBN)                 /* column binary? */
                colbin = (((uint32) cdr_cbuf[2 * col]) << 6) |
                ((uint32) cdr_cbuf[(2 * col) + 1]);     /* 2 chars -> col bin */
            else colbin = bcd_to_colbin[cdr_cbuf[col]]; /* cvt to col binary */
            dat = bit_masks[35 - (col % 36)];           /* mask for column */
            for (row = 0; row < 12; row++) {            /* rows 9..0, 11, 12 */
                bufw = (row * 2) + (col / 36);          /* index to buffer */
                if (colbin & col_masks[row])            /* row bit set? */
                    cdr_bbuf[bufw] |= dat;
                }
            }

    case CDS_DATA:                                      /* data state */
        dat = cdr_bbuf[cdr_bptr++];                     /* get next word */
        if (cdr_bptr >= CD_BINLNT) {                    /* last word? */
            cdr_sta = CDS_END;                          /* end state */
            ch6_req_rd (CH_A, U_CDR, dat, CH6DF_EOR);   /* req chan, dat, EOR */
            sim_activate (uptr, cdr_tstop);
            }
        else {
            ch6_req_rd (CH_A, U_CDR, dat, 0);           /* req chan, dat */
            sim_activate (uptr, (cdr_bptr & 1)? cdr_tleft: cdr_tright);
            }
        break;

    case CDS_END:                                       /* end state */
        if (ch6_qconn (CH_A, U_CDR)) {                  /* if cdr still conn */
            cdr_sta = CDS_INIT;                         /* return to init */
            sim_activate (uptr, 1);                     /* next card */
            }
        break;
        }

return SCPE_OK;
}
Ejemplo n.º 25
0
t_stat rp_svc (UNIT *uptr)
{
int32 f, u, comp, cyl, sect, surf;
int32 err, pa, da, wc, awc, i;

u = (int32) (uptr - rp_dev.units);                      /* get drv number */
f = uptr->FUNC;                                         /* get function */
if (f == FN_IDLE) {                                     /* idle? */
    rp_busy = 0;                                        /* clear busy */
    return SCPE_OK;
    }

if ((f == FN_SEEK) || (f == FN_RECAL)) {                /* seek or recal? */
    rp_busy = 0;                                        /* not busy */
    cyl = (f == FN_SEEK)? GET_CYL (rp_da, uptr->flags): 0; /* get cylinder */
    sim_activate (uptr, MAX (RP_MIN, abs (cyl - uptr->CYL) * rp_swait));
    uptr->CYL = cyl;                                    /* on cylinder */
    uptr->FUNC = FN_SEEK | FN_2ND;                      /* set second state */
    rp_updsta (0, 0);                                   /* update status */
    return SCPE_OK;
    }

if (f == (FN_SEEK | FN_2ND)) {                          /* seek done? */
    rp_updsta (0, rp_stb | (1 << (STB_V_ATT0 - u)));    /* set attention */
    return SCPE_OK;
    }

if ((uptr->flags & UNIT_ATT) == 0) {                    /* not attached? */
    rp_updsta (STA_DON, STB_SUFU);                      /* done, unsafe */
    return IORETURN (rp_stopioe, SCPE_UNATT);
    }

if ((f == FN_WRITE) && (uptr->flags & UNIT_WPRT)) {     /* write locked? */
    rp_updsta (STA_DON | STA_WPE, 0);                   /* error */
    return SCPE_OK;
    }

if (GET_SECT (rp_da) >= RP_NUMSC)
    rp_updsta (STA_NXS, 0);
if (GET_SURF (rp_da) >= RP_NUMSF)
    rp_updsta (STA_NXF, 0);
if (GET_CYL (rp_da, uptr->flags) >= RP_QCYL (uptr->flags))
    rp_updsta (STA_NXC, 0);
if (rp_sta & (STA_NXS | STA_NXF | STA_NXC)) {           /* or bad disk addr? */
    rp_updsta (STA_DON, STB_SUFU);                      /* done, unsafe */
    return SCPE_OK;
    }

uptr->CYL = GET_CYL (rp_da, uptr->flags);               /* on cylinder */
pa = rp_ma & AMASK;                                     /* get mem addr */
da = GET_DA (rp_da, uptr->flags) * RP_NUMWD;            /* get disk addr */
wc = 01000000 - rp_wc;                                  /* get true wc */
if (((uint32) (pa + wc)) > MEMSIZE) {                   /* memory overrun? */
    nexm = 1;                                           /* set nexm flag */
    wc = MEMSIZE - pa;                                  /* limit xfer */
    }
if ((da + wc) > RP_QSIZE (uptr->flags)) {               /* disk overrun? */
    rp_updsta (0, STB_EOP);                             /* error */
    wc = RP_QSIZE (uptr->flags) - da;                   /* limit xfer */
    }

err = fseek (uptr->fileref, da * sizeof (int32), SEEK_SET);

if ((f == FN_READ) && (err == 0)) {                     /* read? */
    awc = fxread (&M[pa], sizeof (int32), wc, uptr->fileref);
    for ( ; awc < wc; awc++)
        M[pa + awc] = 0;
    err = ferror (uptr->fileref);
    }

if ((f == FN_WRITE) && (err == 0)) {                    /* write? */
    fxwrite (&M[pa], sizeof (int32), wc, uptr->fileref);
    err = ferror (uptr->fileref);
    if ((err == 0) && (i = (wc & (RP_NUMWD - 1)))) {
        fxwrite (fill, sizeof (int32), i, uptr->fileref);
        err = ferror (uptr->fileref);
        }
    }

if ((f == FN_WRCHK) && (err == 0)) {                    /* write check? */
    for (i = 0; (err == 0) && (i < wc); i++)  {
        awc = fxread (&comp, sizeof (int32), 1, uptr->fileref);
        if (awc == 0)
            comp = 0;
        if (comp != M[pa + i])
            rp_updsta (0, STB_WCE);
        }
    err = ferror (uptr->fileref);
    }

rp_wc = (rp_wc + wc) & DMASK;                           /* final word count */
rp_ma = (rp_ma + wc) & DMASK;                           /* final mem addr */
da = (da + wc + (RP_NUMWD - 1)) / RP_NUMWD;             /* final sector num */
cyl = da / (RP_NUMSC * RP_NUMSF);                       /* get cyl */
if (cyl >= RP_QCYL (uptr->flags))                       /* cyl ovflo wraps */
    cyl = 0;
surf = (da % (RP_NUMSC * RP_NUMSF)) / RP_NUMSC;         /* get surface */
sect = (da % (RP_NUMSC * RP_NUMSF)) % RP_NUMSC;         /* get sector */
rp_da = ((cyl & DA_M_CYL) << DA_V_CYL) | (surf << DA_V_SURF) | (sect << DA_V_SECT);
if ((cyl >= 256) && ((uptr->flags & UNIT_RP03) != 0))   /* cyl >= 8 bits && RP03 */
    rp_da = rp_da | DA_C256;
rp_busy = 0;                                            /* clear busy */
rp_updsta (STA_DON, 0);                                 /* set done */

if (err != 0) {                                         /* error? */
    sim_perror ("RP I/O error");
    clearerr (uptr->fileref);
    return IORETURN (rp_stopioe, SCPE_IOERR);
    }
return SCPE_OK;
}
Ejemplo n.º 26
0
t_stat rk_svc (UNIT *uptr)
{
int32 err, wc, wc1, awc, swc, pa, da;
UNIT *seluptr;

if (uptr->FUNC == RKC_SEEK) {                           /* seek? */
    seluptr = rk_dev.units + GET_DRIVE (rk_cmd);        /* see if selected */
    if ((uptr == seluptr) && ((rk_cmd & RKC_SKDN) != 0)) {
        rk_sta = rk_sta | RKS_DONE;
        RK_INT_UPDATE;
        }
    return SCPE_OK;
    }

if ((uptr->flags & UNIT_ATT) == 0) {                    /* not att? abort */
    rk_sta = rk_sta | RKS_DONE | RKS_NRDY | RKS_STAT;
    rk_busy = 0;
    RK_INT_UPDATE;
    return IORETURN (rk_stopioe, SCPE_UNATT);
    }

if ((uptr->FUNC == RKC_WRITE) && (uptr->flags & UNIT_WPRT)) {
    rk_sta = rk_sta | RKS_DONE | RKS_WLK;               /* write and locked? */
    rk_busy = 0;
    RK_INT_UPDATE;
    return SCPE_OK;
    }

pa = GET_MEX (rk_cmd) | rk_ma;                          /* phys address */
da = GET_DA (rk_cmd, rk_da) * RK_NUMWD * sizeof (int16);/* disk address */
swc = wc = (rk_cmd & RKC_HALF)? RK_NUMWD / 2: RK_NUMWD; /* get transfer size */
if ((wc1 = ((rk_ma + wc) - 010000)) > 0)                /* if wrap, limit */
    wc = wc - wc1;
err = fseek (uptr->fileref, da, SEEK_SET);              /* locate sector */

if ((uptr->FUNC == RKC_READ) && (err == 0) && MEM_ADDR_OK (pa)) { /* read? */
    awc = fxread (&M[pa], sizeof (int16), wc, uptr->fileref);
    for ( ; awc < wc; awc++)                            /* fill if eof */
        M[pa + awc] = 0;
    err = ferror (uptr->fileref);
    if ((wc1 > 0) && (err == 0))  {                     /* field wraparound? */
        pa = pa & 070000;                               /* wrap phys addr */
        awc = fxread (&M[pa], sizeof (int16), wc1, uptr->fileref);
        for ( ; awc < wc1; awc++)                       /* fill if eof */
            M[pa + awc] = 0;
        err = ferror (uptr->fileref);
        }
    }

if ((uptr->FUNC == RKC_WRITE) && (err == 0)) {          /* write? */
    fxwrite (&M[pa], sizeof (int16), wc, uptr->fileref);
    err = ferror (uptr->fileref);
    if ((wc1 > 0) && (err == 0)) {                      /* field wraparound? */
        pa = pa & 070000;                               /* wrap phys addr */
        fxwrite (&M[pa], sizeof (int16), wc1, uptr->fileref);
        err = ferror (uptr->fileref);
        }
    if ((rk_cmd & RKC_HALF) && (err == 0)) {            /* fill half sector */
        fxwrite (fill, sizeof (int16), RK_NUMWD/2, uptr->fileref);
        err = ferror (uptr->fileref);
        }
    }

rk_ma = (rk_ma + swc) & 07777;                          /* incr mem addr reg */
rk_sta = rk_sta | RKS_DONE;                             /* set done */
rk_busy = 0;
RK_INT_UPDATE;

if (err != 0) {
    sim_perror ("RK I/O error");
    clearerr (uptr->fileref);
    return SCPE_IOERR;
    }
return SCPE_OK;
}