1 /*
2  * Copyright (c) 2006-2021, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef MEMORY_LAYOUT_H__
7 #define MEMORY_LAYOUT_H__
8 
9 #include "../rtconfig.h"
10 
11 /*
12  * Physical Memory layout:
13  *
14  * +---------+ <- CONFIG_MEM_TOTAL_SIZE
15  * | ......  | maybe zero
16  * +---------+ <- CONFIG_MEM_MMZ_BASE + CONFIG_MEM_MMZ_SIZE
17  * |         |
18  * |         |
19  * |         |
20  * |         |
21  * |         |
22  * |         |
23  * |         |
24  * |         |
25  * |---------| <- CONFIG_MEM_MMZ_BASE
26  * | ......  | maybe zero
27  * +---------+ <- CONFIG_MEM_RTSMART_SIZE
28  * | guard   | MEM_GUARD_SIZE
29  * +---------+ <- End of Kerenl
30  * |         |
31  * |         |
32  * +---------+
33  * | heap    | CONFIG_MEM_RTSMART_HEAP_SIZE
34  * +---------+
35  * |         |
36  * +---------+ <- Beginning of Kernel <- mapping to KERNEL_VADDR_START + MEM_OPENSBI_SIZE
37  * | opensbi | MEM_OPENSBI_SIZE
38  * +---------+ <- Beginning of Physical Memory (0)  <- mapping to KERNEL_VADDR_START
39  */
40 
41 #define MEM_OPENSBI_SIZE	0x20000	// 128K
42 #define MEM_GUARD_SIZE		0x1000	// 4K
43 
44 /*
45  * The value of CONFIG_XXX may come from rtconfig.h. This is mainly for
46  * compatibility with compiling RT-Thread in the SDK environment and using
47  * the SDK configuration.
48  *
49  * If CONFIG_XXX is defined, it means that the value comes from the SDK
50  * configuration, otherwise the default configuration of bsp/k230 in RT-Thead
51  * is used. The default configuration of bsp/k230 is for the 01Studio CanMV
52  * development board that supports 512MB of memory.
53  */
54 #ifndef CONFIG_MEM_TOTAL_SIZE
55 #define CONFIG_MEM_TOTAL_SIZE	0x20000000 // 512M
56 #endif
57 
58 #ifndef CONFIG_MEM_RTSMART_SIZE
59 #define CONFIG_MEM_RTSMART_SIZE	0x10000000 // 256M
60 #endif
61 
62 #ifndef CONFIG_MEM_RTSMART_HEAP_SIZE
63 #define CONFIG_MEM_RTSMART_HEAP_SIZE	0x2000000 // 32M
64 #endif
65 
66 #ifndef CONFIG_MEM_MMZ_BASE
67 #define CONFIG_MEM_MMZ_BASE	0x10000000 // 512M
68 #endif
69 
70 #ifndef CONFIG_MEM_MMZ_SIZE
71 #define CONFIG_MEM_MMZ_SIZE	0x10000000 // 256M
72 #endif
73 
74 #define MEM_KERNEL_SIZE (CONFIG_MEM_RTSMART_SIZE - MEM_OPENSBI_SIZE - MEM_GUARD_SIZE)
75 
76 #endif // MEMORY_LAYOUT_H__