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

Annotation of sys/arch/alpha/mcbus/mcbus.c, Revision 1.1

1.1     ! nbrk        1: /* $OpenBSD: mcbus.c,v 1.1 2007/03/16 21:22:27 robert Exp $ */
        !             2: /* $NetBSD: mcbus.c,v 1.19 2007/03/04 05:59:11 christos Exp $ */
        !             3:
        !             4: /*
        !             5:  * Copyright (c) 1998 by Matthew Jacob
        !             6:  * NASA AMES Research Center.
        !             7:  * All rights reserved.
        !             8:  *
        !             9:  * Redistribution and use in source and binary forms, with or without
        !            10:  * modification, are permitted provided that the following conditions
        !            11:  * are met:
        !            12:  * 1. Redistributions of source code must retain the above copyright
        !            13:  *    notice immediately at the beginning of the file, without modification,
        !            14:  *    this list of conditions, and the following disclaimer.
        !            15:  * 2. Redistributions in binary form must reproduce the above copyright
        !            16:  *    notice, this list of conditions and the following disclaimer in the
        !            17:  *    documentation and/or other materials provided with the distribution.
        !            18:  * 3. The name of the author may not be used to endorse or promote products
        !            19:  *    derived from this software without specific prior written permission.
        !            20:  *
        !            21:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
        !            22:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            23:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            24:  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
        !            25:  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            27:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            28:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            29:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            30:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            31:  * SUCH DAMAGE.
        !            32:  */
        !            33:
        !            34: /*
        !            35:  * Autoconfiguration routines for the MCBUS system
        !            36:  * bus found on AlphaServer 4100 systems.
        !            37:  */
        !            38:
        !            39: #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
        !            40: #include <sys/param.h>
        !            41: #include <sys/systm.h>
        !            42: #include <sys/device.h>
        !            43: #include <sys/malloc.h>
        !            44:
        !            45: #include <machine/autoconf.h>
        !            46: #include <machine/rpb.h>
        !            47: #include <machine/pte.h>
        !            48:
        !            49: #include <alpha/mcbus/mcbusreg.h>
        !            50: #include <alpha/mcbus/mcbusvar.h>
        !            51:
        !            52: #include <alpha/pci/mcpciareg.h>
        !            53:
        !            54: #define KV(_addr)      ((caddr_t)ALPHA_PHYS_TO_K0SEG((_addr)))
        !            55: #define        MCPCIA_EXISTS(mid, gid) \
        !            56:        (!badaddr((void *)KV(MCPCIA_BRIDGE_ADDR(gid, mid)), sizeof (u_int32_t)))
        !            57:
        !            58: struct mcbus_cpu_busdep mcbus_primary;
        !            59:
        !            60: int    mcbusmatch (struct device *, void *, void *);
        !            61: void   mcbusattach (struct device *, struct device *, void *);
        !            62: int    mcbusprint (void *, const char *);
        !            63: int    mcbussbm (struct device *, void *, void *);
        !            64:
        !            65: const  char *mcbus_node_type_str (u_int8_t);
        !            66:
        !            67: typedef struct {
        !            68:        struct device   mcbus_dev;
        !            69:        u_int8_t        mcbus_types[MCBUS_MID_MAX];
        !            70: } mcbus_softc_t;
        !            71:
        !            72: struct cfattach mcbus_ca = {
        !            73:        sizeof(mcbus_softc_t), mcbusmatch, mcbusattach
        !            74: };
        !            75:
        !            76: struct cfdriver mcbus_cd = {
        !            77:         NULL, "mcbus", DV_DULL,
        !            78: };
        !            79:
        !            80: /*
        !            81:  * Tru64 UNIX (formerly Digital UNIX (formerly DEC OSF/1)) probes for MCPCIAs
        !            82:  * in the following order:
        !            83:  *
        !            84:  *     5, 4, 7, 6
        !            85:  *
        !            86:  * This is so that the built-in CD-ROM on the internal 53c810 is always
        !            87:  * dka500.  We probe them in the same order, for consistency.
        !            88:  */
        !            89: const int mcbus_mcpcia_probe_order[] = { 5, 4, 7, 6 };
        !            90:
        !            91: extern void mcpcia_config_cleanup (void);
        !            92:
        !            93: int
        !            94: mcbusprint(aux, cp)
        !            95:        void *aux;
        !            96:        const char *cp;
        !            97: {
        !            98:        struct mcbus_dev_attach_args *tap = aux;
        !            99:        printf(" mid %d: %s", tap->ma_mid,
        !           100:            mcbus_node_type_str(tap->ma_type));
        !           101:        return (UNCONF);
        !           102: }
        !           103:
        !           104: int
        !           105: mcbussbm(parent, cf, aux)
        !           106:        struct device *parent;
        !           107:        void *cf;
        !           108:        void *aux;
        !           109: {
        !           110:        struct mcbus_dev_attach_args *tap = aux;
        !           111:        struct cfdata *mcf = (struct cfdata *)cf;
        !           112:
        !           113:        if (mcf->cf_loc[MCBUSCF_MID] != MCBUSCF_MID_DEFAULT &&
        !           114:            mcf->cf_loc[MCBUSCF_MID] != tap->ma_mid)
        !           115:                return (0);
        !           116:
        !           117:
        !           118:        return ((*mcf->cf_attach->ca_match)(parent, mcf, aux));
        !           119: }
        !           120:
        !           121: int
        !           122: mcbusmatch(parent, cf, aux)
        !           123:        struct device *parent;
        !           124:        void *cf;
        !           125:        void *aux;
        !           126: {
        !           127:        struct mainbus_attach_args *ma = aux;
        !           128:
        !           129:        /* Make sure we're looking for a MCBUS. */
        !           130:        if (strcmp(ma->ma_name, mcbus_cd.cd_name) != 0)
        !           131:                return (0);
        !           132:
        !           133:        /*
        !           134:         * Only available on 4100 processor type platforms.
        !           135:         */
        !           136:        if (cputype != ST_DEC_4100)
        !           137:                return (0);
        !           138:
        !           139:        return (1);
        !           140: }
        !           141:
        !           142: void
        !           143: mcbusattach(parent, self, aux)
        !           144:        struct device *parent;
        !           145:        struct device *self;
        !           146:        void *aux;
        !           147: {
        !           148:        static const char *bcs[CPU_BCacheMask + 1] = {
        !           149:                "No", "1MB", "2MB", "4MB",
        !           150:        };
        !           151:        struct mcbus_dev_attach_args ta;
        !           152:        mcbus_softc_t *mbp = (mcbus_softc_t *)self;
        !           153:        int i, mid;
        !           154:
        !           155:        printf(": %s BCache\n", mcbus_primary.mcbus_valid ?
        !           156:            bcs[mcbus_primary.mcbus_bcache] : "Unknown");
        !           157:
        !           158:        mbp->mcbus_types[0] = MCBUS_TYPE_RES;
        !           159:        for (mid = 1; mid <= MCBUS_MID_MAX; ++mid)
        !           160:                mbp->mcbus_types[mid] = MCBUS_TYPE_UNK;
        !           161:
        !           162:        /*
        !           163:         * Find and "configure" memory.
        !           164:         */
        !           165:        ta.ma_name = mcbus_cd.cd_name;
        !           166:        ta.ma_gid = MCBUS_GID_FROM_INSTANCE(0);
        !           167:        ta.ma_mid = 1;
        !           168:        ta.ma_type = MCBUS_TYPE_MEM;
        !           169:        mbp->mcbus_types[1] = MCBUS_TYPE_MEM;
        !           170:
        !           171:        (void) config_found_sm(self, &ta, mcbusprint, mcbussbm);
        !           172:
        !           173:        /*
        !           174:         * Now find PCI busses.
        !           175:         */
        !           176:        for (i = 0; i < MCPCIA_PER_MCBUS; i++) {
        !           177:                mid = mcbus_mcpcia_probe_order[i];
        !           178:                ta.ma_name = mcbus_cd.cd_name;
        !           179:                ta.ma_gid = MCBUS_GID_FROM_INSTANCE(0);
        !           180:                ta.ma_mid = mid;
        !           181:                ta.ma_type = MCBUS_TYPE_PCI;
        !           182:                if (MCPCIA_EXISTS(ta.ma_mid, ta.ma_gid))
        !           183:                        (void) config_found_sm(self, &ta, mcbusprint,
        !           184:                                        mcbussbm);
        !           185:        }
        !           186:
        !           187:        mcpcia_config_cleanup();
        !           188: }
        !           189:
        !           190: const char *
        !           191: mcbus_node_type_str(type)
        !           192:        u_int8_t type;
        !           193: {
        !           194:        switch (type) {
        !           195:        case MCBUS_TYPE_RES:
        !           196:                panic ("RESERVED TYPE IN MCBUS_NODE_TYPE_STR");
        !           197:                break;
        !           198:        case MCBUS_TYPE_UNK:
        !           199:                panic ("UNKNOWN TYPE IN MCBUS_NODE_TYPE_STR");
        !           200:                break;
        !           201:        case MCBUS_TYPE_MEM:
        !           202:                return ("Memory");
        !           203:        case MCBUS_TYPE_CPU:
        !           204:                return ("CPU");
        !           205:        case MCBUS_TYPE_PCI:
        !           206:                return ("PCI Bridge");
        !           207:        default:
        !           208:                panic("REALLY UNKNWON (%x) TYPE IN MCBUS_NODE_TYPE_STR", type);
        !           209:                break;
        !           210:        }
        !           211: }

CVSweb