Annotation of 43BSD/sys/stand/ts.c, revision 1.1

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

unix.superglobalmegacorp.com

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