1129198Scognet/* $NetBSD: cpufunc_asm_arm7tdmi.S,v 1.1 2001/11/10 23:14:09 thorpej Exp $ */ 2129198Scognet 3139735Simp/*- 4129198Scognet * Copyright (c) 2001 John Fremlin 5129198Scognet * All rights reserved. 6129198Scognet * 7129198Scognet * Redistribution and use in source and binary forms, with or without 8129198Scognet * modification, are permitted provided that the following conditions 9129198Scognet * are met: 10129198Scognet * 1. Redistributions of source code must retain the above copyright 11129198Scognet * notice, this list of conditions and the following disclaimer. 12129198Scognet * 2. Redistributions in binary form must reproduce the above copyright 13129198Scognet * notice, this list of conditions and the following disclaimer in the 14129198Scognet * documentation and/or other materials provided with the distribution. 15129198Scognet * 3. All advertising materials mentioning features or use of this software 16129198Scognet * must display the following acknowledgement: 17129198Scognet * This product includes software developed by Causality Limited. 18129198Scognet * 4. The name of Causality Limited may not be used to endorse or promote 19129198Scognet * products derived from this software without specific prior written 20129198Scognet * permission. 21129198Scognet * 22129198Scognet * THIS SOFTWARE IS PROVIDED BY CAUSALITY LIMITED ``AS IS'' AND ANY EXPRESS 23129198Scognet * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24129198Scognet * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25129198Scognet * DISCLAIMED. IN NO EVENT SHALL CAUSALITY LIMITED BE LIABLE FOR ANY DIRECT, 26129198Scognet * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27129198Scognet * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28129198Scognet * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29129198Scognet * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30129198Scognet * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31129198Scognet * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32129198Scognet * SUCH DAMAGE. 33129198Scognet * 34129198Scognet * ARM7TDMI assembly functions for CPU / MMU / TLB specific operations 35129198Scognet * 36129198Scognet */ 37251866Sscottl 38129198Scognet#include <machine/asm.h> 39129198Scognet__FBSDID("$FreeBSD$"); 40129198Scognet 41129198Scognet/* 42129198Scognet * Functions to set the MMU Translation Table Base register 43129198Scognet * 44129198Scognet * We need to clean and flush the cache as it uses virtual 45129198Scognet * addresses that are about to change. 46129198Scognet */ 47129198ScognetENTRY(arm7tdmi_setttb) 48129198Scognet mov r1, r0 /* store the TTB in a safe place */ 49129198Scognet mov r2, lr /* ditto with lr */ 50129198Scognet 51129198Scognet bl _C_LABEL(arm7tdmi_cache_flushID) 52129198Scognet 53129198Scognet /* Write the TTB */ 54129198Scognet mcr p15, 0, r1, c2, c0, 0 55129198Scognet 56129198Scognet /* If we have updated the TTB we must flush the TLB */ 57129198Scognet bl _C_LABEL(arm7tdmi_tlb_flushID) 58129198Scognet 59129198Scognet /* For good measure we will flush the IDC as well */ 60129198Scognet bl _C_LABEL(arm7tdmi_cache_flushID) 61129198Scognet 62129198Scognet mov pc, r2 63129198Scognet 64129198Scognet/* 65129198Scognet * TLB functions 66129198Scognet */ 67129198ScognetENTRY(arm7tdmi_tlb_flushID) 68129198Scognet mov r0, #0 69129198Scognet mcr p15, 0, r0, c8, c7, 0 70137463Scognet RET 71129198Scognet 72129198ScognetENTRY(arm7tdmi_tlb_flushID_SE) 73129198Scognet mcr p15, 0, r0, c8, c7, 1 74137463Scognet RET 75129198Scognet 76129198Scognet/* 77129198Scognet * Cache functions 78129198Scognet */ 79129198ScognetENTRY(arm7tdmi_cache_flushID) 80129198Scognet mov r0, #0 81129198Scognet 82129198Scognet mcr p15, 0, r0, c7, c7, 0 83129198Scognet 84129198Scognet /* Make sure that the pipeline is emptied */ 85129198Scognet mov r0, r0 86129198Scognet mov r0, r0 87129198Scognet 88137463Scognet RET 89129198Scognet 90129198Scognet/* 91129198Scognet * Context switch. 92129198Scognet * 93129198Scognet * These is the CPU-specific parts of the context switcher cpu_switch() 94129198Scognet * These functions actually perform the TTB reload. 95129198Scognet * 96129198Scognet * NOTE: Special calling convention 97129198Scognet * r1, r4-r13 must be preserved 98129198Scognet */ 99129198ScognetENTRY(arm7tdmi_context_switch) 100129198Scognet b _C_LABEL(arm7tdmi_setttb) 101