[BACK]Return to ka750.c CVS log [TXT][DIR] Up to [local] / sys / arch / vax / vax

Annotation of sys/arch/vax/vax/ka750.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: ka750.c,v 1.10 2003/06/02 23:27:59 millert Exp $ */
        !             2: /*     $NetBSD: ka750.c,v 1.30 1999/08/14 11:30:48 ragge Exp $ */
        !             3: /*
        !             4:  * Copyright (c) 1982, 1986, 1988 The Regents of the University of California.
        !             5:  * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
        !             6:  * All rights reserved.
        !             7:  *
        !             8:  * Redistribution and use in source and binary forms, with or without
        !             9:  * modification, are permitted provided that the following conditions
        !            10:  * are met:
        !            11:  * 1. Redistributions of source code must retain the above copyright
        !            12:  *    notice, this list of conditions and the following disclaimer.
        !            13:  * 2. Redistributions in binary form must reproduce the above copyright
        !            14:  *    notice, this list of conditions and the following disclaimer in the
        !            15:  *    documentation and/or other materials provided with the distribution.
        !            16:  * 3. Neither the name of the University nor the names of its contributors
        !            17:  *    may be used to endorse or promote products derived from this software
        !            18:  *    without specific prior written permission.
        !            19:  *
        !            20:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            21:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            22:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            23:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            24:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            25:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            26:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            27:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            28:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            29:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            30:  * SUCH DAMAGE.
        !            31:  *
        !            32:  *     @(#)ka750.c     7.4 (Berkeley) 5/9/91
        !            33:  *     @(#)autoconf.c  7.20 (Berkeley) 5/9/91
        !            34:  */
        !            35:
        !            36: #include <sys/param.h>
        !            37: #include <sys/device.h>
        !            38: #include <sys/systm.h>
        !            39:
        !            40: #include <machine/ka750.h>
        !            41: #include <machine/mtpr.h>
        !            42: #include <machine/cpu.h>
        !            43: #include <machine/clock.h>
        !            44: #include <machine/sid.h>
        !            45:
        !            46: #include <vax/vax/gencons.h>
        !            47:
        !            48: void   ctuattach(void);
        !            49: static void    ka750_clrf(void);
        !            50: static void    ka750_conf(void);
        !            51: static void    ka750_memerr(void);
        !            52: static int     ka750_mchk(caddr_t);
        !            53:
        !            54:
        !            55: struct cpu_dep ka750_calls = {
        !            56:        0,
        !            57:        ka750_mchk,
        !            58:        ka750_memerr,
        !            59:        ka750_conf,
        !            60:        generic_clkread,
        !            61:        generic_clkwrite,
        !            62:        1,      /* ~VUPS */
        !            63:        4,      /* SCB pages */
        !            64:        0,      /* halt call */
        !            65:        0,      /* Reboot call */
        !            66:        ka750_clrf,
        !            67: };
        !            68:
        !            69: static caddr_t mcraddr[4];     /* XXX */
        !            70:
        !            71: void
        !            72: ka750_conf()
        !            73: {
        !            74:        printf("cpu0: KA750, hardware rev %d, ucode rev %d, ",
        !            75:            V750HARDW(vax_cpudata), V750UCODE(vax_cpudata));
        !            76:        if (mfpr(PR_ACCS) & 255) {
        !            77:                printf("FPA present, enabling.\n");
        !            78:                mtpr(0x8000, PR_ACCS);
        !            79:        } else
        !            80:                printf("no FPA\n");
        !            81:
        !            82:        if (mfpr(PR_TODR) == 0) { /* Check for failing battery */
        !            83:                mtpr(1, PR_TODR);
        !            84:                printf("WARNING: TODR battery broken\n");
        !            85:        }
        !            86:
        !            87:        /* Call ctuattach() here so it can setup its vectors. */
        !            88:        ctuattach();
        !            89: }
        !            90:
        !            91: int ka750_memmatch(struct  device  *, struct cfdata     *, void *);
        !            92: void ka750_memenable(struct     device  *, struct  device  *, void *);
        !            93:
        !            94: struct cfattach mem_cmi_ca = {
        !            95:        sizeof(struct device), ka750_memmatch, ka750_memenable
        !            96: };
        !            97:
        !            98: int
        !            99: ka750_memmatch(parent, cf, aux)
        !           100:        struct  device  *parent;
        !           101:        struct cfdata *cf;
        !           102:        void    *aux;
        !           103: {
        !           104:        struct  sbi_attach_args *sa = (struct sbi_attach_args *)aux;
        !           105:
        !           106:        if (cf->cf_loc[CMICF_TR] != sa->nexnum && cf->cf_loc[CMICF_TR] > -1)
        !           107:                return 0;
        !           108:
        !           109:        if (sa->type != NEX_MEM16)
        !           110:                return 0;
        !           111:
        !           112:        return 1;
        !           113: }
        !           114:
        !           115: struct mcr750 {
        !           116:        int     mc_err;                 /* error bits */
        !           117:        int     mc_inh;                 /* inhibit crd */
        !           118:        int     mc_inf;                 /* info bits */
        !           119: };
        !           120:
        !           121: #define M750_ICRD      0x10000000      /* inhibit crd interrupts, in [1] */
        !           122: #define M750_UNCORR    0xc0000000      /* uncorrectable error, in [0] */
        !           123: #define M750_CORERR    0x20000000      /* correctable error, in [0] */
        !           124:
        !           125: #define M750_INH(mcr)  ((mcr)->mc_inh = 0)
        !           126: #define M750_ENA(mcr)  ((mcr)->mc_err = (M750_UNCORR|M750_CORERR), \
        !           127:                         (mcr)->mc_inh = M750_ICRD)
        !           128: #define M750_ERR(mcr)  ((mcr)->mc_err & (M750_UNCORR|M750_CORERR))
        !           129:
        !           130: #define M750_SYN(err)  ((err) & 0x7f)
        !           131: #define M750_ADDR(err) (((err) >> 9) & 0x7fff)
        !           132:
        !           133: /* enable crd interrupts */
        !           134: void
        !           135: ka750_memenable(parent, self, aux)
        !           136:        struct  device  *parent, *self;
        !           137:        void    *aux;
        !           138: {
        !           139:        struct  sbi_attach_args *sa = (struct sbi_attach_args *)aux;
        !           140:        struct mcr750 *mcr = (struct mcr750 *)sa->nexaddr;
        !           141:        int k, l, m, cardinfo;
        !           142:
        !           143:        mcraddr[self->dv_unit] = (caddr_t)sa->nexaddr;
        !           144:
        !           145:        /* We will use this info for error reporting - later! */
        !           146:        cardinfo = mcr->mc_inf;
        !           147:        switch ((cardinfo >> 24) & 3) {
        !           148:        case 0: printf(": L0011 ");
        !           149:                break;
        !           150:
        !           151:        case 1: printf(": L0016 ");
        !           152:                m = cardinfo & 0xaaaa;
        !           153:                for (k = l = 0; k < 16; k++){
        !           154:                        if (m & 1)
        !           155:                                l++;
        !           156:                        m >>= 1;
        !           157:                }
        !           158:                printf("with %d M8750",l);
        !           159:                break;
        !           160:
        !           161:        case 3: printf(": L0022 ");
        !           162:                m = cardinfo & 0x5555;
        !           163:                for (k = l = 0; k < 16; k++) {
        !           164:                        if (m & 1)
        !           165:                                l++;
        !           166:                        m>>=1;
        !           167:                }
        !           168:                printf("with %d M7199",l);
        !           169:                m = cardinfo & 0xaaaa;
        !           170:                if (m) {
        !           171:                        for (k = l = 0; k < 16; k++) {
        !           172:                                if (m & 1)
        !           173:                                        l++;
        !           174:                                m >>= 1;
        !           175:                        }
        !           176:                        printf(" and %d M8750",l);
        !           177:                }
        !           178:                break;
        !           179:        }
        !           180:        printf("\n");
        !           181:
        !           182:
        !           183:        M750_ENA((struct mcr750 *)mcraddr[0]);
        !           184: }
        !           185:
        !           186: /* log crd errors */
        !           187: void
        !           188: ka750_memerr()
        !           189: {
        !           190:        register struct mcr750 *mcr = (struct mcr750 *)mcraddr[0];
        !           191:        register int err;
        !           192:
        !           193:        if (M750_ERR(mcr)) {
        !           194:                err = mcr->mc_err;      /* careful with i/o space refs */
        !           195:                printf("mcr0: %s", err & M750_UNCORR ?
        !           196:                    "hard error" : "soft ecc");
        !           197:                printf(" addr %x syn %x\n", M750_ADDR(err), M750_SYN(err));
        !           198:                M750_INH(mcr);
        !           199:        }
        !           200: }
        !           201:
        !           202: char *mc750[]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13",
        !           203:        "14","15"};
        !           204:
        !           205: struct mc750frame {
        !           206:        int     mc5_bcnt;               /* byte count == 0x28 */
        !           207:        int     mc5_summary;            /* summary parameter (as above) */
        !           208:        int     mc5_va;                 /* virtual address register */
        !           209:        int     mc5_errpc;              /* error pc */
        !           210:        int     mc5_mdr;
        !           211:        int     mc5_svmode;             /* saved mode register */
        !           212:        int     mc5_rdtimo;             /* read lock timeout */
        !           213:        int     mc5_tbgpar;             /* tb group parity error register */
        !           214:        int     mc5_cacherr;            /* cache error register */
        !           215:        int     mc5_buserr;             /* bus error register */
        !           216:        int     mc5_mcesr;              /* machine check status register */
        !           217:        int     mc5_pc;                 /* trapped pc */
        !           218:        int     mc5_psl;                /* trapped psl */
        !           219: };
        !           220:
        !           221: #define MC750_TBERR    2               /* type code of cp tbuf par */
        !           222: #define MC750_TBPAR    4               /* tbuf par bit in mcesr */
        !           223:
        !           224: int
        !           225: ka750_mchk(cmcf)
        !           226:        caddr_t cmcf;
        !           227: {
        !           228:        register struct mc750frame *mcf = (struct mc750frame *)cmcf;
        !           229:        register int type = mcf->mc5_summary;
        !           230:        int mcsr = mfpr(PR_MCSR);
        !           231:
        !           232:        printf("machine check %x: %s%s\n", type, mc750[type&0xf],
        !           233:            (type&0xf0) ? " abort" : " fault");
        !           234:        printf(
        !           235: "\tva %x errpc %x mdr %x smr %x rdtimo %x tbgpar %x cacherr %x\n",
        !           236:            mcf->mc5_va, mcf->mc5_errpc, mcf->mc5_mdr, mcf->mc5_svmode,
        !           237:            mcf->mc5_rdtimo, mcf->mc5_tbgpar, mcf->mc5_cacherr);
        !           238:        printf("\tbuserr %x mcesr %x pc %x psl %x mcsr %x\n",
        !           239:            mcf->mc5_buserr, mcf->mc5_mcesr, mcf->mc5_pc, mcf->mc5_psl,
        !           240:            mcsr);
        !           241:        mtpr(0, PR_TBIA);
        !           242:        mtpr(0xf, PR_MCESR);
        !           243:        if (type == MC750_TBERR && (mcf->mc5_mcesr&0xe) == MC750_TBPAR) {
        !           244:                printf("tbuf par: flushing and returning\n");
        !           245:                return (MCHK_RECOVERED);
        !           246:        }
        !           247:        return (MCHK_PANIC);
        !           248: }
        !           249:
        !           250: void
        !           251: ka750_clrf()
        !           252: {
        !           253:        int s = splhigh();
        !           254:
        !           255: #define WAIT   while ((mfpr(PR_TXCS) & GC_RDY) == 0) ;
        !           256:
        !           257:        WAIT;
        !           258:
        !           259:        mtpr(GC_CWFL|GC_CONS, PR_TXDB);
        !           260:
        !           261:        WAIT;
        !           262:        mtpr(GC_CCFL|GC_CONS, PR_TXDB);
        !           263:
        !           264:        WAIT;
        !           265:        splx(s);
        !           266: }

CVSweb