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

unix.superglobalmegacorp.com

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