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

Annotation of sys/arch/luna88k/luna88k/m8820x.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: m8820x.c,v 1.13 2006/10/30 14:32:27 aoyama Exp $      */
        !             2: /*
        !             3:  * Copyright (c) 2004, Miodrag Vallat.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms, with or without
        !             6:  * modification, are permitted provided that the following conditions
        !             7:  * are met:
        !             8:  * 1. Redistributions of source code must retain the above copyright
        !             9:  *    notice, this list of conditions and the following disclaimer.
        !            10:  * 2. Redistributions in binary form must reproduce the above copyright
        !            11:  *    notice, this list of conditions and the following disclaimer in the
        !            12:  *    documentation and/or other materials provided with the distribution.
        !            13:  *
        !            14:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            15:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        !            16:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        !            17:  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
        !            18:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
        !            19:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        !            20:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            21:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
        !            22:  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
        !            23:  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            24:  * POSSIBILITY OF SUCH DAMAGE.
        !            25:  */
        !            26: /*
        !            27:  * Copyright (c) 2001 Steve Murphree, Jr.
        !            28:  * Copyright (c) 1996 Nivas Madhur
        !            29:  * All rights reserved.
        !            30:  *
        !            31:  * Redistribution and use in source and binary forms, with or without
        !            32:  * modification, are permitted provided that the following conditions
        !            33:  * are met:
        !            34:  * 1. Redistributions of source code must retain the above copyright
        !            35:  *    notice, this list of conditions and the following disclaimer.
        !            36:  * 2. Redistributions in binary form must reproduce the above copyright
        !            37:  *    notice, this list of conditions and the following disclaimer in the
        !            38:  *    documentation and/or other materials provided with the distribution.
        !            39:  * 3. All advertising materials mentioning features or use of this software
        !            40:  *    must display the following acknowledgement:
        !            41:  *      This product includes software developed by Nivas Madhur.
        !            42:  * 4. The name of the author may not be used to endorse or promote products
        !            43:  *    derived from this software without specific prior written permission
        !            44:  *
        !            45:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            46:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
        !            47:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
        !            48:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
        !            49:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
        !            50:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
        !            51:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
        !            52:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        !            53:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
        !            54:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        !            55:  *
        !            56:  */
        !            57: /*
        !            58:  * Mach Operating System
        !            59:  * Copyright (c) 1993-1991 Carnegie Mellon University
        !            60:  * Copyright (c) 1991 OMRON Corporation
        !            61:  * All Rights Reserved.
        !            62:  *
        !            63:  * Permission to use, copy, modify and distribute this software and its
        !            64:  * documentation is hereby granted, provided that both the copyright
        !            65:  * notice and this permission notice appear in all copies of the
        !            66:  * software, derivative works or modified versions, and any portions
        !            67:  * thereof, and that both notices appear in supporting documentation.
        !            68:  *
        !            69:  * CARNEGIE MELLON AND OMRON ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            70:  * CONDITION.  CARNEGIE MELLON AND OMRON DISCLAIM ANY LIABILITY OF ANY KIND
        !            71:  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            72:  *
        !            73:  * Carnegie Mellon requests users of this software to return to
        !            74:  *
        !            75:  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
        !            76:  *  School of Computer Science
        !            77:  *  Carnegie Mellon University
        !            78:  *  Pittsburgh PA 15213-3890
        !            79:  *
        !            80:  * any improvements or extensions that they make and grant Carnegie the
        !            81:  * rights to redistribute these changes.
        !            82:  */
        !            83:
        !            84: #include <sys/param.h>
        !            85: #include <sys/systm.h>
        !            86:
        !            87: #include <uvm/uvm_extern.h>
        !            88:
        !            89: #include <machine/asm_macro.h>
        !            90: #include <machine/board.h>
        !            91: #include <machine/cmmu.h>
        !            92: #include <machine/cpu.h>
        !            93: #include <machine/m8820x.h>
        !            94:
        !            95: /*
        !            96:  * This routine sets up the CPU/CMMU configuration.
        !            97:  */
        !            98: void
        !            99: m8820x_setup_board_config()
        !           100: {
        !           101:        struct m8820x_cmmu *cmmu;
        !           102:        u_int num;
        !           103:
        !           104:        m8820x_cmmu[0].cmmu_regs = (void *)CMMU_I0;
        !           105:        m8820x_cmmu[1].cmmu_regs = (void *)CMMU_D0;
        !           106:        m8820x_cmmu[2].cmmu_regs = (void *)CMMU_I1;
        !           107:        m8820x_cmmu[3].cmmu_regs = (void *)CMMU_D1;
        !           108:        m8820x_cmmu[4].cmmu_regs = (void *)CMMU_I2;
        !           109:        m8820x_cmmu[5].cmmu_regs = (void *)CMMU_D2;
        !           110:        m8820x_cmmu[6].cmmu_regs = (void *)CMMU_I3;
        !           111:        m8820x_cmmu[7].cmmu_regs = (void *)CMMU_D3;
        !           112:
        !           113:        /*
        !           114:         * Probe CMMU address to discover which CPU slots are populated.
        !           115:         * On the luna88k, badaddr() returns 'good' on unpopulated slots,
        !           116:         * so we check the CMMU type value for each CMMU register address.
        !           117:         */
        !           118:        cmmu = m8820x_cmmu;
        !           119:
        !           120:        for (num = 0; num < 8; num++) {
        !           121:                volatile unsigned *cr = m8820x_cmmu[num].cmmu_regs;
        !           122:                int type;
        !           123:
        !           124:                type = CMMU_TYPE(cr[CMMU_IDR]);
        !           125:                if (type != M88200_ID && type != M88204_ID)
        !           126:                        break;
        !           127:        }
        !           128:
        !           129:        max_cpus = num >> 1;
        !           130:        max_cmmus = max_cpus << 1;
        !           131:        cmmu_shift = 1; /* fixed 2:1 configuration */
        !           132:
        !           133:        /*
        !           134:         * Now that we know which CMMUs are there, report every association
        !           135:         */
        !           136:        for (num = 0; num < max_cpus; num++) {
        !           137:                volatile unsigned *cr;
        !           138:                int type;
        !           139:
        !           140:                cr = m8820x_cmmu[num << cmmu_shift].cmmu_regs;
        !           141:
        !           142:                m88k_cpus[num].ci_alive = 1;    /* This cpu installed... */
        !           143:
        !           144:                type = CMMU_TYPE(cr[CMMU_IDR]);
        !           145:                printf("CPU%d is associated to %d MC8820%c CMMUs\n",
        !           146:                    num, 1 << cmmu_shift, type == M88204_ID ? '4' : '0');
        !           147:        }
        !           148: }
        !           149:
        !           150: /*
        !           151:  * Find out the CPU number from accessing CMMU
        !           152:  * Better be at splhigh, or even better, with interrupts
        !           153:  * disabled.
        !           154:  */
        !           155: #define ILLADDRESS     0x3ffffff0      /* any faulty address for luna88k2 */
        !           156:
        !           157: cpuid_t
        !           158: m8820x_cpu_number()
        !           159: {
        !           160:        u_int cmmu;
        !           161:        u_int i;
        !           162:
        !           163:        CMMU_LOCK;
        !           164:
        !           165:        for (i = 0; i < 10; i++) {
        !           166:                /* clear CMMU P-bus status registers */
        !           167:                for (cmmu = 0; cmmu < max_cmmus; cmmu++) {
        !           168:                        if (CMMU_MODE(cmmu) != INST_CMMU)
        !           169:                                m8820x_cmmu[cmmu].cmmu_regs[CMMU_PFSR] = 0;
        !           170:                }
        !           171:
        !           172:                /* access faulting address */
        !           173:                badaddr((vaddr_t)ILLADDRESS, 4);
        !           174:
        !           175:                /* check which CMMU is reporting the fault  */
        !           176:                for (cmmu = 0; cmmu < max_cmmus; cmmu++) {
        !           177:                        if (CMMU_MODE(cmmu) != INST_CMMU &&
        !           178:                            CMMU_PFSR_FAULT(m8820x_cmmu[cmmu].
        !           179:                              cmmu_regs[CMMU_PFSR]) != CMMU_PFSR_SUCCESS) {
        !           180:                                /* clean register, just in case... */
        !           181:                                m8820x_cmmu[cmmu].cmmu_regs[CMMU_PFSR] = 0;
        !           182:                                CMMU_UNLOCK;
        !           183:                                return cmmu >> 1;
        !           184:                        }
        !           185:                }
        !           186:        }
        !           187:        CMMU_UNLOCK;
        !           188:
        !           189:        panic("m8820x_cpu_number: could not determine my cpu number");
        !           190: }

CVSweb