xref: /OK3568_Linux_fs/kernel/arch/mips/include/asm/sn/mapped_kernel.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * File created by Kanoj Sarcar 06/06/00.
4*4882a593Smuzhiyun  * Copyright 2000 Silicon Graphics, Inc.
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun #ifndef __ASM_SN_MAPPED_KERNEL_H
7*4882a593Smuzhiyun #define __ASM_SN_MAPPED_KERNEL_H
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #include <linux/mmzone.h>
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun /*
12*4882a593Smuzhiyun  * Note on how mapped kernels work: the text and data section is
13*4882a593Smuzhiyun  * compiled at cksseg segment (LOADADDR = 0xc001c000), and the
14*4882a593Smuzhiyun  * init/setup/data section gets a 16M virtual address bump in the
15*4882a593Smuzhiyun  * ld.script file (so that tlblo0 and tlblo1 maps the sections).
16*4882a593Smuzhiyun  * The vmlinux.64 section addresses are put in the xkseg range
17*4882a593Smuzhiyun  * using the change-addresses makefile option. Use elfdump -of
18*4882a593Smuzhiyun  * on IRIX to see where the sections go. The Origin loader loads
19*4882a593Smuzhiyun  * the two sections contiguously in physical memory. The loader
20*4882a593Smuzhiyun  * sets the entry point into kernel_entry using a xkphys address,
21*4882a593Smuzhiyun  * but instead of using 0xa800000001160000, it uses the address
22*4882a593Smuzhiyun  * 0xa800000000160000, which is where it physically loaded that
23*4882a593Smuzhiyun  * code. So no jumps can be done before we have switched to using
24*4882a593Smuzhiyun  * cksseg addresses.
25*4882a593Smuzhiyun  */
26*4882a593Smuzhiyun #include <asm/addrspace.h>
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun #define REP_BASE	CAC_BASE
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun #ifdef CONFIG_MAPPED_KERNEL
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun #define MAPPED_ADDR_RO_TO_PHYS(x)	(x - REP_BASE)
33*4882a593Smuzhiyun #define MAPPED_ADDR_RW_TO_PHYS(x)	(x - REP_BASE - 16777216)
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #define MAPPED_KERN_RO_PHYSBASE(n) (hub_data(n)->kern_vars.kv_ro_baseaddr)
36*4882a593Smuzhiyun #define MAPPED_KERN_RW_PHYSBASE(n) (hub_data(n)->kern_vars.kv_rw_baseaddr)
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun #define MAPPED_KERN_RO_TO_PHYS(x) \
39*4882a593Smuzhiyun 				((unsigned long)MAPPED_ADDR_RO_TO_PHYS(x) | \
40*4882a593Smuzhiyun 				MAPPED_KERN_RO_PHYSBASE(get_nasid()))
41*4882a593Smuzhiyun #define MAPPED_KERN_RW_TO_PHYS(x) \
42*4882a593Smuzhiyun 				((unsigned long)MAPPED_ADDR_RW_TO_PHYS(x) | \
43*4882a593Smuzhiyun 				MAPPED_KERN_RW_PHYSBASE(get_nasid()))
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun #else /* CONFIG_MAPPED_KERNEL */
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun #define MAPPED_KERN_RO_TO_PHYS(x)	(x - REP_BASE)
48*4882a593Smuzhiyun #define MAPPED_KERN_RW_TO_PHYS(x)	(x - REP_BASE)
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun #endif /* CONFIG_MAPPED_KERNEL */
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun #define MAPPED_KERN_RO_TO_K0(x) PHYS_TO_K0(MAPPED_KERN_RO_TO_PHYS(x))
53*4882a593Smuzhiyun #define MAPPED_KERN_RW_TO_K0(x) PHYS_TO_K0(MAPPED_KERN_RW_TO_PHYS(x))
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun #endif /* __ASM_SN_MAPPED_KERNEL_H  */
56