Annotation of 42BSD/sys/stand/ts.c, revision 1.1.1.1

1.1       root        1: /*     ts.c    6.1     83/07/29        */
                      2: 
                      3: /*
                      4:  * TS11 tape driver
                      5:  */
                      6: #include "../machine/pte.h"
                      7: 
                      8: #include "../h/param.h"
                      9: #include "../h/inode.h"
                     10: #include "../h/fs.h"
                     11: 
                     12: #include "../vaxuba/tsreg.h"
                     13: #include "../vaxuba/ubareg.h"
                     14: 
                     15: #include "saio.h"
                     16: #include "savax.h"
                     17: 
                     18: 
                     19: u_short        tsstd[] = { 0772520 };
                     20: 
                     21: struct iob     ctsbuf;
                     22: 
                     23: u_short        ts_uba;                 /* Unibus address of ts structure */
                     24: 
                     25: struct tsdevice *tsaddr = 0;
                     26: 
                     27: struct ts {
                     28:        struct ts_cmd ts_cmd;
                     29:        struct ts_char ts_char;
                     30:        struct ts_sts ts_sts;
                     31: } ts;
                     32: 
                     33: tsopen(io)
                     34:        register struct iob *io;
                     35: {
                     36:        static struct ts *ts_ubaddr;
                     37:        long i = 0;
                     38: 
                     39:        if (tsaddr == 0)
                     40:                tsaddr = (struct tsdevice *)ubamem(io->i_unit, tsstd[0]);
                     41:        tsaddr->tssr = 0;
                     42:        while ((tsaddr->tssr & TS_SSR)==0) {
                     43:                DELAY(10);
                     44:                if (++i > 1000000) {
                     45:                        printf("ts: not ready\n");
                     46:                        return;
                     47:                }
                     48:        }
                     49:        if (tsaddr->tssr&TS_OFL) {
                     50:                printf("ts: offline\n");
                     51:                return;
                     52:        }
                     53:        if (tsaddr->tssr&TS_NBA) {
                     54:                int i;
                     55: 
                     56:                ctsbuf.i_ma = (caddr_t) &ts;
                     57:                ctsbuf.i_cc = sizeof(ts);
                     58:                if (ts_ubaddr == 0)
                     59:                        ts_ubaddr = (struct ts *)ubasetup(&ctsbuf, 2);
                     60:                ts_uba = (u_short)((long)ts_ubaddr + (((long)ts_ubaddr>>16)&03));
                     61:                ts.ts_char.char_addr = (int)&ts_ubaddr->ts_sts;
                     62:                ts.ts_char.char_size = sizeof(ts.ts_sts);
                     63:                ts.ts_char.char_mode = TS_ESS;
                     64:                ts.ts_cmd.c_cmd = TS_ACK|TS_SETCHR;
                     65:                i = (int)&ts_ubaddr->ts_char;
                     66:                ts.ts_cmd.c_loba = i;
                     67:                ts.ts_cmd.c_hiba = (i>>16)&3;
                     68:                ts.ts_cmd.c_size = sizeof(ts.ts_char);
                     69:                tsaddr->tsdb = ts_uba;
                     70:        }
                     71:        tsstrategy(io, TS_REW);
                     72:        if (io->i_cc = io->i_boff)
                     73:                tsstrategy(io, TS_SFORWF);
                     74: }
                     75: 
                     76: tsclose(io)
                     77:        register struct iob *io;
                     78: {
                     79: 
                     80:        tsstrategy(io, TS_REW);
                     81: }
                     82: 
                     83: tsstrategy(io, func)
                     84:        register struct iob *io;
                     85: {
                     86:        register int errcnt, info = 0;
                     87: 
                     88:        errcnt = 0;
                     89: retry:
                     90:        while ((tsaddr->tssr & TS_SSR) == 0)
                     91:                DELAY(100);
                     92:        if (func == TS_REW || func == TS_SFORWF)
                     93:                ts.ts_cmd.c_repcnt = io->i_cc;
                     94:        else {
                     95:                info = ubasetup(io, 1);
                     96:                ts.ts_cmd.c_size = io->i_cc;
                     97:                ts.ts_cmd.c_loba = info;
                     98:                ts.ts_cmd.c_hiba = (info>>16)&3;
                     99:        }
                    100:        if (func == READ)
                    101:                func = TS_RCOM;
                    102:        else if (func == WRITE)
                    103:                func = TS_WCOM;
                    104:        ts.ts_cmd.c_cmd = TS_ACK|TS_CVC|func;
                    105:        tsaddr->tsdb = ts_uba;
                    106:        do
                    107:                DELAY(100)
                    108:        while ((tsaddr->tssr & TS_SSR) == 0);
                    109:        if (info)
                    110:                ubafree(io, info);
                    111:        if (ts.ts_sts.s_xs0 & TS_TMK)
                    112:                return (0);
                    113:        if (tsaddr->tssr & TS_SC) {
                    114:                printf("ts tape error: er=%b, xs0=%b\n",
                    115:                    tsaddr->tssr, TSSR_BITS,
                    116:                    ts.ts_sts.s_xs0, TSXS0_BITS);
                    117:                if (errcnt==10) {
                    118:                        printf("ts: unrecovered error\n");
                    119:                        return (-1);
                    120:                }
                    121:                errcnt++;
                    122:                if (func == TS_RCOM || func == TS_WCOM)
                    123:                        func |= TS_RETRY;
                    124:                goto retry;
                    125:        }
                    126:        if (errcnt)
                    127:                printf("ts: recovered by retry\n");
                    128:        return (io->i_cc - ts.ts_sts.s_rbpcr);
                    129: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.