1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * This file is subject to the terms and conditions of the GNU General Public 3*4882a593Smuzhiyun * License. See the file "COPYING" in the main directory of this archive 4*4882a593Smuzhiyun * for more details. 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * Copyright (C) 2000 Silicon Graphics, Inc. 7*4882a593Smuzhiyun * Copyright (C) 2005 Ralf Baechle <ralf@linux-mips.org> 8*4882a593Smuzhiyun */ 9*4882a593Smuzhiyun #ifndef __ASM_MACH_IP27_KERNEL_ENTRY_H 10*4882a593Smuzhiyun #define __ASM_MACH_IP27_KERNEL_ENTRY_H 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun #include <asm/sn/addrs.h> 13*4882a593Smuzhiyun #include <asm/sn/agent.h> 14*4882a593Smuzhiyun #include <asm/sn/klkernvars.h> 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun /* 17*4882a593Smuzhiyun * TLB bits 18*4882a593Smuzhiyun */ 19*4882a593Smuzhiyun #define PAGE_GLOBAL (1 << 6) 20*4882a593Smuzhiyun #define PAGE_VALID (1 << 7) 21*4882a593Smuzhiyun #define PAGE_DIRTY (1 << 8) 22*4882a593Smuzhiyun #define CACHE_CACHABLE_COW (5 << 9) 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun /* 25*4882a593Smuzhiyun * inputs are the text nasid in t1, data nasid in t2. 26*4882a593Smuzhiyun */ 27*4882a593Smuzhiyun .macro MAPPED_KERNEL_SETUP_TLB 28*4882a593Smuzhiyun #ifdef CONFIG_MAPPED_KERNEL 29*4882a593Smuzhiyun /* 30*4882a593Smuzhiyun * This needs to read the nasid - assume 0 for now. 31*4882a593Smuzhiyun * Drop in 0xffffffffc0000000 in tlbhi, 0+VG in tlblo_0, 32*4882a593Smuzhiyun * 0+DVG in tlblo_1. 33*4882a593Smuzhiyun */ 34*4882a593Smuzhiyun dli t0, 0xffffffffc0000000 35*4882a593Smuzhiyun dmtc0 t0, CP0_ENTRYHI 36*4882a593Smuzhiyun li t0, 0x1c000 # Offset of text into node memory 37*4882a593Smuzhiyun dsll t1, NASID_SHFT # Shift text nasid into place 38*4882a593Smuzhiyun dsll t2, NASID_SHFT # Same for data nasid 39*4882a593Smuzhiyun or t1, t1, t0 # Physical load address of kernel text 40*4882a593Smuzhiyun or t2, t2, t0 # Physical load address of kernel data 41*4882a593Smuzhiyun dsrl t1, 12 # 4K pfn 42*4882a593Smuzhiyun dsrl t2, 12 # 4K pfn 43*4882a593Smuzhiyun dsll t1, 6 # Get pfn into place 44*4882a593Smuzhiyun dsll t2, 6 # Get pfn into place 45*4882a593Smuzhiyun li t0, ((PAGE_GLOBAL | PAGE_VALID | CACHE_CACHABLE_COW) >> 6) 46*4882a593Smuzhiyun or t0, t0, t1 47*4882a593Smuzhiyun mtc0 t0, CP0_ENTRYLO0 # physaddr, VG, cach exlwr 48*4882a593Smuzhiyun li t0, ((PAGE_GLOBAL | PAGE_VALID | PAGE_DIRTY | CACHE_CACHABLE_COW) >> 6) 49*4882a593Smuzhiyun or t0, t0, t2 50*4882a593Smuzhiyun mtc0 t0, CP0_ENTRYLO1 # physaddr, DVG, cach exlwr 51*4882a593Smuzhiyun li t0, 0x1ffe000 # MAPPED_KERN_TLBMASK, TLBPGMASK_16M 52*4882a593Smuzhiyun mtc0 t0, CP0_PAGEMASK 53*4882a593Smuzhiyun li t0, 0 # KMAP_INX 54*4882a593Smuzhiyun mtc0 t0, CP0_INDEX 55*4882a593Smuzhiyun li t0, 1 56*4882a593Smuzhiyun mtc0 t0, CP0_WIRED 57*4882a593Smuzhiyun tlbwi 58*4882a593Smuzhiyun #else 59*4882a593Smuzhiyun mtc0 zero, CP0_WIRED 60*4882a593Smuzhiyun #endif 61*4882a593Smuzhiyun .endm 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun /* 64*4882a593Smuzhiyun * Intentionally empty macro, used in head.S. Override in 65*4882a593Smuzhiyun * arch/mips/mach-xxx/kernel-entry-init.h when necessary. 66*4882a593Smuzhiyun */ 67*4882a593Smuzhiyun .macro kernel_entry_setup 68*4882a593Smuzhiyun GET_NASID_ASM t1 69*4882a593Smuzhiyun move t2, t1 # text and data are here 70*4882a593Smuzhiyun MAPPED_KERNEL_SETUP_TLB 71*4882a593Smuzhiyun .endm 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun /* 74*4882a593Smuzhiyun * Do SMP slave processor setup necessary before we can safely execute C code. 75*4882a593Smuzhiyun */ 76*4882a593Smuzhiyun .macro smp_slave_setup 77*4882a593Smuzhiyun GET_NASID_ASM t1 78*4882a593Smuzhiyun dli t0, KLDIR_OFFSET + (KLI_KERN_VARS * KLDIR_ENT_SIZE) + \ 79*4882a593Smuzhiyun KLDIR_OFF_POINTER + CAC_BASE 80*4882a593Smuzhiyun dsll t1, NASID_SHFT 81*4882a593Smuzhiyun or t0, t0, t1 82*4882a593Smuzhiyun ld t0, 0(t0) # t0 points to kern_vars struct 83*4882a593Smuzhiyun lh t1, KV_RO_NASID_OFFSET(t0) 84*4882a593Smuzhiyun lh t2, KV_RW_NASID_OFFSET(t0) 85*4882a593Smuzhiyun MAPPED_KERNEL_SETUP_TLB 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun /* 88*4882a593Smuzhiyun * We might not get launched at the address the kernel is linked to, 89*4882a593Smuzhiyun * so we jump there. 90*4882a593Smuzhiyun */ 91*4882a593Smuzhiyun PTR_LA t0, 0f 92*4882a593Smuzhiyun jr t0 93*4882a593Smuzhiyun 0: 94*4882a593Smuzhiyun .endm 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun #endif /* __ASM_MACH_IP27_KERNEL_ENTRY_H */ 97