xref: /OK3568_Linux_fs/kernel/arch/hexagon/include/asm/mem-layout.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Memory layout definitions for the Hexagon architecture
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #ifndef _ASM_HEXAGON_MEM_LAYOUT_H
9*4882a593Smuzhiyun #define _ASM_HEXAGON_MEM_LAYOUT_H
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #include <linux/const.h>
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun /*
14*4882a593Smuzhiyun  * Have to do this for ginormous numbers, else they get printed as
15*4882a593Smuzhiyun  * negative numbers, which the linker no likey when you try to
16*4882a593Smuzhiyun  * assign it to the location counter.
17*4882a593Smuzhiyun  */
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #define PAGE_OFFSET			_AC(0xc0000000, UL)
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun /*
22*4882a593Smuzhiyun  * Compiling for a platform that needs a crazy physical offset
23*4882a593Smuzhiyun  * (like if the memory starts at 1GB and up) means we need
24*4882a593Smuzhiyun  * an actual PHYS_OFFSET.  Should be set up in head.S.
25*4882a593Smuzhiyun  */
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #ifdef CONFIG_HEXAGON_PHYS_OFFSET
28*4882a593Smuzhiyun #ifndef __ASSEMBLY__
29*4882a593Smuzhiyun extern unsigned long	__phys_offset;
30*4882a593Smuzhiyun #endif
31*4882a593Smuzhiyun #define PHYS_OFFSET	__phys_offset
32*4882a593Smuzhiyun #endif
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun #ifndef PHYS_OFFSET
35*4882a593Smuzhiyun #define PHYS_OFFSET	0
36*4882a593Smuzhiyun #endif
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun #define PHYS_PFN_OFFSET	(PHYS_OFFSET >> PAGE_SHIFT)
39*4882a593Smuzhiyun #define ARCH_PFN_OFFSET	PHYS_PFN_OFFSET
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun #define TASK_SIZE			(PAGE_OFFSET)
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun /*  not sure how these are used yet  */
44*4882a593Smuzhiyun #define STACK_TOP			TASK_SIZE
45*4882a593Smuzhiyun #define STACK_TOP_MAX			TASK_SIZE
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun #ifndef __ASSEMBLY__
48*4882a593Smuzhiyun enum fixed_addresses {
49*4882a593Smuzhiyun 	FIX_KMAP_BEGIN,
50*4882a593Smuzhiyun 	FIX_KMAP_END,  /*  check for per-cpuism  */
51*4882a593Smuzhiyun 	__end_of_fixed_addresses
52*4882a593Smuzhiyun };
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun #define MIN_KERNEL_SEG (PAGE_OFFSET >> PGDIR_SHIFT)   /* L1 shift is 22 bits */
55*4882a593Smuzhiyun extern int max_kernel_seg;
56*4882a593Smuzhiyun 
57*4882a593Smuzhiyun /*
58*4882a593Smuzhiyun  * Start of vmalloc virtual address space for kernel;
59*4882a593Smuzhiyun  * supposed to be based on the amount of physical memory available
60*4882a593Smuzhiyun  */
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun #define VMALLOC_START ((unsigned long) __va(high_memory + VMALLOC_OFFSET))
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun /* Gap between physical ram and vmalloc space for guard purposes. */
65*4882a593Smuzhiyun #define VMALLOC_OFFSET PAGE_SIZE
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun /*
68*4882a593Smuzhiyun  * Create the space between VMALLOC_START and FIXADDR_TOP backwards
69*4882a593Smuzhiyun  * from the ... "top".
70*4882a593Smuzhiyun  *
71*4882a593Smuzhiyun  * Permanent IO mappings will live at 0xfexx_xxxx
72*4882a593Smuzhiyun  * Hypervisor occupies the last 16MB page at 0xffxxxxxx
73*4882a593Smuzhiyun  */
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun #define FIXADDR_TOP     0xfe000000
76*4882a593Smuzhiyun #define FIXADDR_SIZE    (__end_of_fixed_addresses << PAGE_SHIFT)
77*4882a593Smuzhiyun #define FIXADDR_START   (FIXADDR_TOP - FIXADDR_SIZE)
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun /*
80*4882a593Smuzhiyun  * "permanent kernel mappings", defined as long-lasting mappings of
81*4882a593Smuzhiyun  * high-memory page frames into the kernel address space.
82*4882a593Smuzhiyun  */
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun #define LAST_PKMAP	PTRS_PER_PTE
85*4882a593Smuzhiyun #define LAST_PKMAP_MASK	(LAST_PKMAP - 1)
86*4882a593Smuzhiyun #define PKMAP_NR(virt)	((virt - PKMAP_BASE) >> PAGE_SHIFT)
87*4882a593Smuzhiyun #define PKMAP_ADDR(nr)	(PKMAP_BASE + ((nr) << PAGE_SHIFT))
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun /*
90*4882a593Smuzhiyun  * To the "left" of the fixed map space is the kmap space
91*4882a593Smuzhiyun  *
92*4882a593Smuzhiyun  * "Permanent Kernel Mappings"; fancy (or less fancy) PTE table
93*4882a593Smuzhiyun  * that looks like it's actually walked.
94*4882a593Smuzhiyun  * Need to check the alignment/shift usage; some archs use
95*4882a593Smuzhiyun  * PMD_MASK on this value
96*4882a593Smuzhiyun  */
97*4882a593Smuzhiyun #define PKMAP_BASE (FIXADDR_START-PAGE_SIZE*LAST_PKMAP)
98*4882a593Smuzhiyun 
99*4882a593Smuzhiyun /*
100*4882a593Smuzhiyun  * 2 pages of guard gap between where vmalloc area ends
101*4882a593Smuzhiyun  * and pkmap_base begins.
102*4882a593Smuzhiyun  */
103*4882a593Smuzhiyun #define VMALLOC_END (PKMAP_BASE-PAGE_SIZE*2)
104*4882a593Smuzhiyun #endif /*  !__ASSEMBLY__  */
105*4882a593Smuzhiyun 
106*4882a593Smuzhiyun 
107*4882a593Smuzhiyun #endif /* _ASM_HEXAGON_MEM_LAYOUT_H */
108