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