Annotation of 43BSDReno/sys/vaxstand/ht.c, revision 1.1.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:  *     @(#)ht.c        7.5 (Berkeley) 4/4/90
                      7:  */
                      8: 
                      9: /*
                     10:  * TM03/TU?? tape driver
                     11:  */
                     12: #include "machine/pte.h"
                     13: 
                     14: #include "param.h"
                     15: 
                     16: #include "../vaxmba/htreg.h"
                     17: #include "../vaxmba/mbareg.h"
                     18: 
                     19: #include "saio.h"
                     20: #include "savax.h"
                     21: 
                     22: short  httypes[] =
                     23:        { MBDT_TM03, MBDT_TE16, MBDT_TU45, MBDT_TU77, 0 };
                     24: 
                     25: #define        MASKREG(reg)    ((reg)&0xffff)
                     26: 
                     27: htopen(io)
                     28:        register struct iob *io;
                     29: {
                     30:        register struct htdevice *htaddr;
                     31:        register int i, skip;
                     32: 
                     33:        htaddr = (struct htdevice *)mbadrv(io->i_adapt, io->i_ctlr);
                     34:        if (mbainit(io->i_adapt) == 0)
                     35:                return (EADAPT);
                     36:        for (i = 0;; i++) {
                     37:                if (!httypes[i]) {
                     38:                        printf("ht: not a tape\n");
                     39:                        return (ENXIO);
                     40:                }
                     41:                if (httypes[i] == (htaddr->htdt&MBDT_TYPE))
                     42:                        break;
                     43:        }
                     44:        htaddr->htcs1 = HT_DCLR|HT_GO;
                     45:        htstrategy(io, HT_REW);
                     46:        for (skip = io->i_part; skip--;) {
                     47:                io->i_cc = -1;
                     48:                while (htstrategy(io, HT_SFORW));
                     49:                DELAY(65536);
                     50:                htstrategy(io, HT_SENSE);
                     51:        }
                     52:        return (0);
                     53: }
                     54: 
                     55: htclose(io)
                     56:        register struct iob *io;
                     57: {
                     58:        htstrategy(io, HT_REW);
                     59: }
                     60: 
                     61: htstrategy(io, func)
                     62:        register struct iob *io;
                     63:        int func;
                     64: {
                     65:        register struct htdevice *htaddr;
                     66:        register int den, errcnt, ds;
                     67:        int er;
                     68:        short fc;
                     69: 
                     70:        errcnt = 0;
                     71:        htaddr = (struct htdevice *)mbadrv(io->i_adapt, io->i_ctlr);
                     72: retry:
                     73:        den = HTTC_1600BPI | HTTC_PDP11 | io->i_unit;
                     74:        htquiet(htaddr);
                     75:        htaddr->htcs1 = HT_DCLR|HT_GO;
                     76:        htaddr->httc = den;
                     77:        htaddr->htfc = -io->i_cc;
                     78:        if (func == HT_SREV) {
                     79:                htaddr->htfc = -1;
                     80:                htaddr->htcs1 = HT_SREV|HT_GO;
                     81:                return (0);
                     82:        }
                     83:        if (func == READ || func == WRITE)
                     84:                mbastart(io, io->i_ctlr, func);
                     85:        else
                     86:                htaddr->htcs1 = func|HT_GO;
                     87:        htquiet(htaddr);
                     88:        ds = htaddr->htds;
                     89:        er = htaddr->hter;
                     90:        if (ds & HTDS_TM) {
                     91:                htaddr->htcs1 = HT_DCLR|HT_GO;
                     92:                return (0);
                     93:        }
                     94:        if (ds & HTDS_ERR) {
                     95:                htaddr->htcs1 = HT_DCLR|HT_GO;
                     96:                if ((er & HTER_CORCRC) == 0) {
                     97:                        printf("ht error: ds=%b, er=%b\n",
                     98:                            MASKREG(ds), HTDS_BITS,
                     99:                            MASKREG(er), HTER_BITS);
                    100:                        if (errcnt++ == 10) {
                    101:                                printf("ht: unrecovered error\n");
                    102:                                return (-1);
                    103:                        }
                    104:                        htstrategy(io, HT_SREV);
                    105:                        goto retry;
                    106:                }
                    107:        }
                    108:        if (errcnt)
                    109:                printf("ht: recovered by retry\n");
                    110:        fc = htaddr->htfc;
                    111:        return (io->i_cc+fc);
                    112: }
                    113: 
                    114: static
                    115: htquiet(htaddr)
                    116:        register struct htdevice *htaddr;
                    117: {
                    118:        register int s;
                    119: 
                    120:        do
                    121:                s = htaddr->htds;
                    122:        while ((s & HTDS_DRY) == 0);
                    123: }

unix.superglobalmegacorp.com

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