1384740dcSRalf Baechle /*
2384740dcSRalf Baechle  * File created by Kanoj Sarcar 06/06/00.
3384740dcSRalf Baechle  * Copyright 2000 Silicon Graphics, Inc.
4384740dcSRalf Baechle  */
5384740dcSRalf Baechle #ifndef __ASM_SN_MAPPED_KERNEL_H
6384740dcSRalf Baechle #define __ASM_SN_MAPPED_KERNEL_H
7384740dcSRalf Baechle 
8384740dcSRalf Baechle #include <linux/mmzone.h>
9384740dcSRalf Baechle 
10384740dcSRalf Baechle /*
11384740dcSRalf Baechle  * Note on how mapped kernels work: the text and data section is
12384740dcSRalf Baechle  * compiled at cksseg segment (LOADADDR = 0xc001c000), and the
13384740dcSRalf Baechle  * init/setup/data section gets a 16M virtual address bump in the
14384740dcSRalf Baechle  * ld.script file (so that tlblo0 and tlblo1 maps the sections).
15384740dcSRalf Baechle  * The vmlinux.64 section addresses are put in the xkseg range
16384740dcSRalf Baechle  * using the change-addresses makefile option. Use elfdump -of
17384740dcSRalf Baechle  * on IRIX to see where the sections go. The Origin loader loads
18384740dcSRalf Baechle  * the two sections contiguously in physical memory. The loader
19384740dcSRalf Baechle  * sets the entry point into kernel_entry using a xkphys address,
20384740dcSRalf Baechle  * but instead of using 0xa800000001160000, it uses the address
21384740dcSRalf Baechle  * 0xa800000000160000, which is where it physically loaded that
22384740dcSRalf Baechle  * code. So no jumps can be done before we have switched to using
23384740dcSRalf Baechle  * cksseg addresses.
24384740dcSRalf Baechle  */
25384740dcSRalf Baechle #include <asm/addrspace.h>
26384740dcSRalf Baechle 
27384740dcSRalf Baechle #define REP_BASE	CAC_BASE
28384740dcSRalf Baechle 
29384740dcSRalf Baechle #ifdef CONFIG_MAPPED_KERNEL
30384740dcSRalf Baechle 
31384740dcSRalf Baechle #define MAPPED_ADDR_RO_TO_PHYS(x)	(x - REP_BASE)
32384740dcSRalf Baechle #define MAPPED_ADDR_RW_TO_PHYS(x)	(x - REP_BASE - 16777216)
33384740dcSRalf Baechle 
34384740dcSRalf Baechle #define MAPPED_KERN_RO_PHYSBASE(n) (hub_data(n)->kern_vars.kv_ro_baseaddr)
35384740dcSRalf Baechle #define MAPPED_KERN_RW_PHYSBASE(n) (hub_data(n)->kern_vars.kv_rw_baseaddr)
36384740dcSRalf Baechle 
37384740dcSRalf Baechle #define MAPPED_KERN_RO_TO_PHYS(x) \
38384740dcSRalf Baechle 				((unsigned long)MAPPED_ADDR_RO_TO_PHYS(x) | \
39384740dcSRalf Baechle 				MAPPED_KERN_RO_PHYSBASE(get_compact_nodeid()))
40384740dcSRalf Baechle #define MAPPED_KERN_RW_TO_PHYS(x) \
41384740dcSRalf Baechle 				((unsigned long)MAPPED_ADDR_RW_TO_PHYS(x) | \
42384740dcSRalf Baechle 				MAPPED_KERN_RW_PHYSBASE(get_compact_nodeid()))
43384740dcSRalf Baechle 
44384740dcSRalf Baechle #else /* CONFIG_MAPPED_KERNEL */
45384740dcSRalf Baechle 
46384740dcSRalf Baechle #define MAPPED_KERN_RO_TO_PHYS(x)	(x - REP_BASE)
47384740dcSRalf Baechle #define MAPPED_KERN_RW_TO_PHYS(x)	(x - REP_BASE)
48384740dcSRalf Baechle 
49384740dcSRalf Baechle #endif /* CONFIG_MAPPED_KERNEL */
50384740dcSRalf Baechle 
51384740dcSRalf Baechle #define MAPPED_KERN_RO_TO_K0(x)	PHYS_TO_K0(MAPPED_KERN_RO_TO_PHYS(x))
52384740dcSRalf Baechle #define MAPPED_KERN_RW_TO_K0(x)	PHYS_TO_K0(MAPPED_KERN_RW_TO_PHYS(x))
53384740dcSRalf Baechle 
54384740dcSRalf Baechle #endif /* __ASM_SN_MAPPED_KERNEL_H  */
55