Annotation of 43BSDReno/sys/vaxstand/kdb.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1988 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution is only permitted until one year after the first shipment
                      6:  * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
                      7:  * binary forms are permitted provided that: (1) source distributions retain
                      8:  * this entire copyright notice and comment, and (2) distributions including
                      9:  * binaries display the following acknowledgement:  This product includes
                     10:  * software developed by the University of California, Berkeley and its
                     11:  * contributors'' in the documentation or other materials provided with the
                     12:  * distribution and in all advertising materials mentioning features or use
                     13:  * of this software.  Neither the name of the University nor the names of
                     14:  * its contributors may be used to endorse or promote products derived from
                     15:  * this software without specific prior written permission.
                     16:  * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     17:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     18:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     19:  *
                     20:  *     @(#)kdb.c       7.7 (Berkeley) 6/28/90
                     21:  */
                     22: 
                     23: /*
                     24:  * KDB50/RAxx disk device driver
                     25:  */
                     26: #include "machine/pte.h"
                     27: 
                     28: #include "param.h"
                     29: #include "disklabel.h"
                     30: 
                     31: #include "saio.h"
                     32: #include "savax.h"
                     33: 
                     34: /*
                     35:  * N.B.: on KDB50, controller == adapter
                     36:  * here we just use the controller number
                     37:  */
                     38: 
                     39: #define        NKRA            8       /* max drive number */
                     40: #define        SECTSIZ         512     /* sector size in bytes */
                     41: 
                     42: /*
                     43:  * Parameters for the communications area:
                     44:  * command and response rings both one entry.
                     45:  */
                     46: #define        NRSP    1
                     47: #define        NCMD    1
                     48: 
                     49: #include "../vaxbi/bireg.h"
                     50: #include "../vaxbi/kdbreg.h"
                     51: #include "../vax/mscp.h"
                     52: 
                     53: struct kdb {
                     54:        struct kdbca    kdb_ca;
                     55:        struct mscp     kdb_rsp;
                     56:        struct mscp     kdb_cmd;
                     57: } kdb;
                     58: 
                     59: int    kdbinit[MAXNKDB];
                     60: struct disklabel kralabel[MAXNKDB][NKRA];
                     61: u_long kramedia[MAXNKDB][NKRA];
                     62: char   lbuf[SECTSIZ];
                     63: 
                     64: kraopen(io)
                     65:        register struct iob *io;
                     66: {
                     67:        register struct kdb_regs *kr;
                     68:        register struct disklabel *lp;
                     69:        register int ctlr, unit;
                     70:        struct iob tio;
                     71: 
                     72:        if ((u_int)(ctlr = io->i_ctlr) >= nkdb)
                     73:                return (EADAPT);
                     74:        if ((u_int)(unit = io->i_unit) >= NKRA)
                     75:                return (EUNIT);
                     76:        kr = (struct kdb_regs *)kdbaddr[ctlr];
                     77:        if (kdbinit[ctlr] == 0) {
                     78:                kr->kdb_bi.bi_csr |= BICSR_NRST;
                     79:                DELAY(10000);   /* ??? */
                     80:                /* clear any bus errors */
                     81:                kr->kdb_bi.bi_ber = ~(BIBER_MBZ|BIBER_NMR|BIBER_UPEN);
                     82:                while ((kr->kdb_sa & KDB_STEP1) == 0)
                     83:                        /* void */;
                     84:                kr->kdb_bi.bi_bcicsr |= BCI_STOPEN | BCI_IDENTEN;
                     85:                kr->kdb_sw = KDB_ERR;
                     86:                while ((kr->kdb_sa & KDB_STEP2) == 0)
                     87:                        /* void */;
                     88:                kr->kdb_sw = (int)&kdb.kdb_ca.ca_rspdsc[0];
                     89:                while ((kr->kdb_sa & KDB_STEP3) == 0)
                     90:                        /* void */;
                     91:                kr->kdb_sw = (int)&kdb.kdb_ca.ca_rspdsc[0] >> 16;
                     92:                while ((kr->kdb_sa & KDB_STEP4) == 0)
                     93:                        /* void */;
                     94:                kr->kdb_sw = KDB_GO;
                     95:                kdb.kdb_ca.ca_rspdsc[0] = (long)&kdb.kdb_rsp.mscp_cmdref;
                     96:                kdb.kdb_ca.ca_cmddsc[0] = (long)&kdb.kdb_cmd.mscp_cmdref;
                     97:                if (kdbcmd(M_OP_SETCTLRC, io)) {
                     98:                        printf("kra: open error, SETCTLRC\n");
                     99:                        return (ENXIO);
                    100:                }
                    101:                kdbinit[ctlr] = 1;
                    102:        }
                    103:        lp = &kralabel[ctlr][unit];
                    104:        if (kramedia[ctlr][unit] == 0) {
                    105:                kdb.kdb_cmd.mscp_unit = unit;
                    106:                if (kdbcmd(M_OP_ONLINE, io)) {
                    107:                        printf("kra: open error, ONLINE\n");
                    108:                        return (ENXIO);
                    109:                }
                    110:                kramedia[ctlr][unit] = kdb.kdb_rsp.mscp_onle.onle_mediaid;
                    111:                tio = *io;
                    112:                tio.i_bn = LABELSECTOR;
                    113:                tio.i_ma = lbuf;
                    114:                tio.i_cc = SECTSIZ;
                    115:                tio.i_flgs |= F_RDDATA;
                    116:                if (krastrategy(&tio, READ) != SECTSIZ)
                    117:                        return (ERDLAB);
                    118:                *lp = *(struct disklabel *)(lbuf + LABELOFFSET);
                    119:                if (lp->d_magic != DISKMAGIC || lp->d_magic2 != DISKMAGIC) {
                    120: #ifdef COMPAT_42
                    121:                        printf("kra%d: unlabeled\n", unit);
                    122:                        kramaptype(io, lp);
                    123: #else
                    124:                        return (EUNLAB);
                    125: #endif
                    126:                }
                    127:        }
                    128:        if ((u_int)io->i_part >= lp->d_npartitions ||
                    129:            (io->i_boff = lp->d_partitions[io->i_part].p_offset) == -1)
                    130:                return (EPART);
                    131:        return (0);
                    132: }
                    133: 
                    134: kdbcmd(op, io)
                    135:        int op;
                    136:        struct iob *io;
                    137: {
                    138:        register struct kdb *k = &kdb;
                    139:        register struct mscp *mp;
                    140:        register int i;
                    141: 
                    142:        k->kdb_cmd.mscp_opcode = op;
                    143:        k->kdb_rsp.mscp_msglen = MSCP_MSGLEN;
                    144:        k->kdb_cmd.mscp_msglen = MSCP_MSGLEN;
                    145:        k->kdb_ca.ca_rspdsc[0] |= MSCP_OWN | MSCP_INT;
                    146:        k->kdb_ca.ca_cmddsc[0] |= MSCP_OWN | MSCP_INT;
                    147:        i = ((struct kdb_regs *)kdbaddr[io->i_ctlr])->kdb_ip;
                    148: #ifdef lint
                    149:        i = i;
                    150: #endif
                    151:        mp = &k->kdb_rsp;
                    152:        for (;;) {
                    153:                if (k->kdb_ca.ca_cmdint)
                    154:                        k->kdb_ca.ca_cmdint = 0;
                    155:                if (k->kdb_ca.ca_rspint == 0)
                    156:                        continue;
                    157:                k->kdb_ca.ca_rspint = 0;
                    158:                if (mp->mscp_opcode == (op | M_OP_END))
                    159:                        break;
                    160:                printf("unexpected rsp type %x op %x ignored\n",
                    161:                        MSCP_MSGTYPE(mp->mscp_msgtc), mp->mscp_opcode);
                    162:                k->kdb_ca.ca_rspdsc[0] |= MSCP_OWN | MSCP_INT;
                    163:        }
                    164:        if ((mp->mscp_status & M_ST_MASK) != M_ST_SUCCESS)
                    165:                return (-1);
                    166:        return (0);
                    167: }
                    168: 
                    169: krastrategy(io, func)
                    170:        register struct iob *io;
                    171:        int func;
                    172: {
                    173:        register struct mscp *mp;
                    174: 
                    175:        mp = &kdb.kdb_cmd;
                    176:        mp->mscp_unit = io->i_unit;
                    177:        mp->mscp_seq.seq_lbn = io->i_bn;
                    178:        mp->mscp_seq.seq_bytecount = io->i_cc;
                    179:        mp->mscp_seq.seq_buffer = (long)io->i_ma | KDB_PHYS;
                    180:        if (kdbcmd(func == READ ? M_OP_READ : M_OP_WRITE, io)) {
                    181:                printf("kra: I/O error\n");
                    182:                return (-1);
                    183:        }
                    184:        return (io->i_cc);
                    185: }
                    186: 
                    187: #ifdef COMPAT_42
                    188: u_long kra60_off[] = { 0, 15884, 0, 49324, 131404, 49324, 242606, 49324 };
                    189: #define kra70_off kra60_off
                    190: u_long kra80_off[] = { 0, 15884, 0, -1, 49324, 49324, 49910, 131404 };
                    191: u_long kra81_off[] = { 0, 15884, 0, 131404, 49324, 498790, 563050, 131404 };
                    192: u_long kra82_off[] = { 0, 15884, 0, 375345, 391590, 699390, 375345, 83790 }; 
                    193: 
                    194: struct mediamap {
                    195:        u_long  id;             /* media ID */
                    196:        u_long  *off;           /* offsets */
                    197: } kra_map[] = {
                    198:        { MSCP_MKDRIVE2('R', 'A', 60),          kra60_off },
                    199:        { MSCP_MKDRIVE2('R', 'A', 70),          kra70_off },
                    200:        { MSCP_MKDRIVE2('R', 'A', 80),          kra80_off },
                    201:        { MSCP_MKDRIVE2('R', 'A', 81),          kra81_off },
                    202:        { MSCP_MKDRIVE2('R', 'A', 82),          kra82_off },
                    203:        0
                    204: };
                    205: 
                    206: kramaptype(io, lp)
                    207:        register struct iob *io;
                    208:        register struct disklabel *lp;
                    209: {
                    210:        register struct partition *pp;
                    211:        register u_long i;
                    212:        register struct mediamap *map;
                    213: 
                    214:        i = MSCP_MEDIA_DRIVE(kramedia[io->i_ctlr][io->i_unit]);
                    215:        for (map = kra_map; map->id != 0; map++) {
                    216:                if (map->id == i) {
                    217:                        lp->d_npartitions = 8;
                    218:                        for (pp = lp->d_partitions, i = 0; i < 8; pp++, i++)
                    219:                                pp->p_offset = map->off[i];
                    220:                        return;
                    221:                }
                    222:        }
                    223:        printf("kra%d: media type 0x%x unsupported\n", io->i_unit, i);
                    224:        lp->d_npartitions = 0;
                    225: }
                    226: #endif

unix.superglobalmegacorp.com

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