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