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

Annotation of sys/arch/sh/sh/mmu.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: mmu.c,v 1.2 2007/02/28 19:37:55 deraadt Exp $ */
        !             2: /*     $NetBSD: mmu.c,v 1.15 2006/02/12 02:30:55 uwe Exp $     */
        !             3:
        !             4: /*-
        !             5:  * Copyright (c) 2002 The NetBSD Foundation, Inc.
        !             6:  * All rights reserved.
        !             7:  *
        !             8:  * This code is derived from software contributed to The NetBSD Foundation
        !             9:  * by UCHIYAMA Yasushi.
        !            10:  *
        !            11:  * Redistribution and use in source and binary forms, with or without
        !            12:  * modification, are permitted provided that the following conditions
        !            13:  * are met:
        !            14:  * 1. Redistributions of source code must retain the above copyright
        !            15:  *    notice, this list of conditions and the following disclaimer.
        !            16:  * 2. Redistributions in binary form must reproduce the above copyright
        !            17:  *    notice, this list of conditions and the following disclaimer in the
        !            18:  *    documentation and/or other materials provided with the distribution.
        !            19:  * 3. All advertising materials mentioning features or use of this software
        !            20:  *    must display the following acknowledgement:
        !            21:  *        This product includes software developed by the NetBSD
        !            22:  *        Foundation, Inc. and its contributors.
        !            23:  * 4. Neither the name of The NetBSD Foundation nor the names of its
        !            24:  *    contributors may be used to endorse or promote products derived
        !            25:  *    from this software without specific prior written permission.
        !            26:  *
        !            27:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
        !            28:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
        !            29:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
        !            30:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
        !            31:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        !            32:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        !            33:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        !            34:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        !            35:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        !            36:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            37:  * POSSIBILITY OF SUCH DAMAGE.
        !            38:  */
        !            39:
        !            40: #include <sys/param.h>
        !            41: #include <sys/systm.h>
        !            42:
        !            43: #include <sh/mmu.h>
        !            44: #include <sh/mmu_sh3.h>
        !            45: #include <sh/mmu_sh4.h>
        !            46:
        !            47: #if defined(SH3) && defined(SH4)
        !            48: void (*__sh_mmu_start)(void);
        !            49: void (*__sh_tlb_invalidate_addr)(int, vaddr_t);
        !            50: void (*__sh_tlb_invalidate_asid)(int);
        !            51: void (*__sh_tlb_invalidate_all)(void);
        !            52: void (*__sh_tlb_update)(int, vaddr_t, uint32_t);
        !            53: #endif /* SH3 && SH4 */
        !            54:
        !            55: void
        !            56: sh_mmu_init(void)
        !            57: {
        !            58:        /*
        !            59:         * Assign function hooks but only if both SH3 and SH4 are defined.
        !            60:         * They are called directly otherwise.  See <sh3/mmu.h>.
        !            61:         */
        !            62: #if defined(SH3) && defined(SH4)
        !            63:        if (CPU_IS_SH3) {
        !            64:                __sh_mmu_start = sh3_mmu_start;
        !            65:                __sh_tlb_invalidate_addr = sh3_tlb_invalidate_addr;
        !            66:                __sh_tlb_invalidate_asid = sh3_tlb_invalidate_asid;
        !            67:                __sh_tlb_invalidate_all = sh3_tlb_invalidate_all;
        !            68:                __sh_tlb_update = sh3_tlb_update;
        !            69:        }
        !            70:        else if (CPU_IS_SH4) {
        !            71:                __sh_mmu_start = sh4_mmu_start;
        !            72:                __sh_tlb_invalidate_addr = sh4_tlb_invalidate_addr;
        !            73:                __sh_tlb_invalidate_asid = sh4_tlb_invalidate_asid;
        !            74:                __sh_tlb_invalidate_all = sh4_tlb_invalidate_all;
        !            75:                __sh_tlb_update = sh4_tlb_update;
        !            76:        }
        !            77: #endif /* SH3 && SH4 */
        !            78: }
        !            79:
        !            80: void
        !            81: sh_mmu_information(void)
        !            82: {
        !            83: #ifdef DEBUG
        !            84:        uint32_t r;
        !            85: #ifdef SH3
        !            86:        if (CPU_IS_SH3) {
        !            87:                printf("cpu0: 4-way set-associative 128 TLB entries\n");
        !            88:                r = _reg_read_4(SH3_MMUCR);
        !            89:                printf("cpu0: %s mode, %s virtual storage mode\n",
        !            90:                    r & SH3_MMUCR_IX ? "ASID+VPN" : "VPN",
        !            91:                    r & SH3_MMUCR_SV ? "single" : "multiple");
        !            92:        }
        !            93: #endif
        !            94: #ifdef SH4
        !            95:        if (CPU_IS_SH4) {
        !            96:                printf("cpu0: fully-associative 4 ITLB, 64 UTLB entries\n");
        !            97:                r = _reg_read_4(SH4_MMUCR);
        !            98:                printf("cpu0: %s virtual storage mode, SQ access: kernel%s, ",
        !            99:                    r & SH3_MMUCR_SV ? "single" : "multiple",
        !           100:                    r & SH4_MMUCR_SQMD ? "" : "/user");
        !           101:                printf("wired %d\n",
        !           102:                    (r & SH4_MMUCR_URB_MASK) >> SH4_MMUCR_URB_SHIFT);
        !           103:        }
        !           104: #endif
        !           105: #endif /* DEBUG */
        !           106: }
        !           107:
        !           108: void
        !           109: sh_tlb_set_asid(int asid)
        !           110: {
        !           111:        _reg_write_4(SH_(PTEH), asid);
        !           112: }

CVSweb