[BACK]Return to syscon.c CVS log [TXT][DIR] Up to [local] / sys / arch / aviion / dev

Annotation of sys/arch/aviion/dev/syscon.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: syscon.c,v 1.3 2006/11/16 23:21:56 miod Exp $ */
                      2: /*
                      3:  * Copyright (c) 1999 Steve Murphree, Jr.
                      4:  * All rights reserved.
                      5:  *
                      6:  * Redistribution and use in source and binary forms, with or without
                      7:  * modification, are permitted provided that the following conditions
                      8:  * are met:
                      9:  * 1. Redistributions of source code must retain the above copyright
                     10:  *    notice, this list of conditions and the following disclaimer.
                     11:  * 2. Redistributions in binary form must reproduce the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer in the
                     13:  *    documentation and/or other materials provided with the distribution.
                     14:  *
                     15:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     16:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     17:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     18:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     19:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     20:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     21:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     22:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     23:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     24:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     25:  */
                     26:
                     27: #include <sys/param.h>
                     28: #include <sys/conf.h>
                     29: #include <sys/systm.h>
                     30: #include <sys/kernel.h>
                     31: #include <sys/device.h>
                     32:
                     33: #include <machine/autoconf.h>
                     34: #include <machine/cpu.h>
                     35:
                     36: #include <machine/avcommon.h>
                     37: #include <aviion/dev/sysconreg.h>
                     38:
                     39: struct sysconsoftc {
                     40:        struct device   sc_dev;
                     41:
                     42:        struct intrhand sc_abih;        /* `abort' switch */
                     43:        struct intrhand sc_acih;        /* `ac fail' */
                     44:        struct intrhand sc_sfih;        /* `sys fail' */
                     45: };
                     46:
                     47: void   sysconattach(struct device *, struct device *, void *);
                     48: int    sysconmatch(struct device *, void *, void *);
                     49:
                     50: int    syscon_print(void *, const char *);
                     51: int    syscon_scan(struct device *, void *, void *);
                     52: int    sysconabort(void *);
                     53: int    sysconacfail(void *);
                     54: int    sysconsysfail(void *);
                     55: int    sysconav400(void *);
                     56:
                     57: struct cfattach syscon_ca = {
                     58:        sizeof(struct sysconsoftc), sysconmatch, sysconattach
                     59: };
                     60:
                     61: struct cfdriver syscon_cd = {
                     62:        NULL, "syscon", DV_DULL
                     63: };
                     64:
                     65: int
                     66: sysconmatch(struct device *parent, void *cf, void *args)
                     67: {
                     68:        return (syscon_cd.cd_ndevs == 0);
                     69: }
                     70:
                     71: void
                     72: sysconattach(struct device *parent, struct device *self, void *args)
                     73: {
                     74:        struct sysconsoftc *sc = (struct sysconsoftc *)self;
                     75:
                     76:        printf("\n");
                     77:
                     78:        /*
                     79:         * Clear SYSFAIL if lit.
                     80:         */
                     81:        *(volatile u_int32_t *)AV_UCSR |= UCSR_DRVSFBIT;
                     82:
                     83:        /*
                     84:         * pseudo driver, abort interrupt handler
                     85:         */
                     86:        sc->sc_abih.ih_fn = sysconabort;
                     87:        sc->sc_abih.ih_arg = 0;
                     88:        sc->sc_abih.ih_wantframe = 1;
                     89:        sc->sc_abih.ih_ipl = IPL_ABORT;
                     90:
                     91:        sc->sc_acih.ih_fn = sysconacfail;
                     92:        sc->sc_acih.ih_arg = 0;
                     93:        sc->sc_acih.ih_wantframe = 1;
                     94:        sc->sc_acih.ih_ipl = IPL_ABORT;
                     95:
                     96:        sc->sc_sfih.ih_fn = sysconsysfail;
                     97:        sc->sc_sfih.ih_arg = 0;
                     98:        sc->sc_sfih.ih_wantframe = 1;
                     99:        sc->sc_sfih.ih_ipl = IPL_ABORT;
                    100:
                    101:        sysconintr_establish(SYSCV_ABRT, &sc->sc_abih, "abort");
                    102:        sysconintr_establish(SYSCV_ACF, &sc->sc_acih, "acfail");
                    103:        sysconintr_establish(SYSCV_SYSF, &sc->sc_sfih, "sysfail");
                    104:
                    105:        config_search(syscon_scan, self, args);
                    106: }
                    107:
                    108: int
                    109: syscon_scan(struct device *parent, void *child, void *args)
                    110: {
                    111:        struct cfdata *cf = child;
                    112:        struct confargs oca, *ca = args;
                    113:
                    114:        bzero(&oca, sizeof oca);
                    115:        oca.ca_iot = ca->ca_iot;
                    116:        oca.ca_offset = (paddr_t)cf->cf_loc[0];
                    117:        if (oca.ca_offset != (paddr_t)-1)
                    118:                oca.ca_paddr = ca->ca_paddr + oca.ca_offset;
                    119:        else
                    120:                oca.ca_paddr = (paddr_t)-1;
                    121:        oca.ca_ipl = (u_int)cf->cf_loc[1];
                    122:
                    123:        if ((*cf->cf_attach->ca_match)(parent, cf, &oca) == 0)
                    124:                return (0);
                    125:
                    126:        config_attach(parent, cf, &oca, syscon_print);
                    127:        return (1);
                    128: }
                    129:
                    130: int
                    131: syscon_print(void *args, const char *pnp)
                    132: {
                    133:        struct confargs *ca = args;
                    134:
                    135:        if (ca->ca_offset != (paddr_t)-1)
                    136:                printf(" offset 0x%x", ca->ca_offset);
                    137:        if (ca->ca_ipl != (u_int)-1)
                    138:                printf(" ipl %u", ca->ca_ipl);
                    139:        return (UNCONF);
                    140: }
                    141:
                    142: int
                    143: sysconintr_establish(u_int vec, struct intrhand *ih, const char *name)
                    144: {
                    145: #ifdef DIAGNOSTIC
                    146:        if (vec < 0 || vec >= SYSCON_NVEC) {
                    147:                printf("sysconintr_establish: illegal vector 0x%x\n", vec);
                    148:                return (EINVAL);
                    149:        }
                    150: #endif
                    151:
                    152:        return (intr_establish(SYSCON_VECT + vec, ih, name));
                    153: }
                    154:
                    155: int
                    156: sysconabort(void *eframe)
                    157: {
                    158:        *(volatile u_int32_t *)AV_CLRINT = ISTATE_ABORT;
                    159:        nmihand(eframe);
                    160:        return (1);
                    161: }
                    162:
                    163: int
                    164: sysconsysfail(void *eframe)
                    165: {
                    166:        *(volatile u_int32_t *)AV_CLRINT = ISTATE_SYSFAIL;
                    167:        printf("WARNING: SYSFAIL* ASSERTED\n");
                    168:        return (1);
                    169: }
                    170:
                    171: int
                    172: sysconacfail(void *eframe)
                    173: {
                    174:        *(volatile u_int32_t *)AV_CLRINT = ISTATE_ACFAIL;
                    175:        printf("WARNING: ACFAIL* ASSERTED\n");
                    176:        return (1);
                    177: }

CVSweb