xref: /OK3568_Linux_fs/kernel/arch/x86/include/asm/boot.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _ASM_X86_BOOT_H
3*4882a593Smuzhiyun #define _ASM_X86_BOOT_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun 
6*4882a593Smuzhiyun #include <asm/pgtable_types.h>
7*4882a593Smuzhiyun #include <uapi/asm/boot.h>
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun /* Physical address where kernel should be loaded. */
10*4882a593Smuzhiyun #define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
11*4882a593Smuzhiyun 				+ (CONFIG_PHYSICAL_ALIGN - 1)) \
12*4882a593Smuzhiyun 				& ~(CONFIG_PHYSICAL_ALIGN - 1))
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun /* Minimum kernel alignment, as a power of two */
15*4882a593Smuzhiyun #ifdef CONFIG_X86_64
16*4882a593Smuzhiyun # define MIN_KERNEL_ALIGN_LG2	PMD_SHIFT
17*4882a593Smuzhiyun #else
18*4882a593Smuzhiyun # define MIN_KERNEL_ALIGN_LG2	(PAGE_SHIFT + THREAD_SIZE_ORDER)
19*4882a593Smuzhiyun #endif
20*4882a593Smuzhiyun #define MIN_KERNEL_ALIGN	(_AC(1, UL) << MIN_KERNEL_ALIGN_LG2)
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun #if (CONFIG_PHYSICAL_ALIGN & (CONFIG_PHYSICAL_ALIGN-1)) || \
23*4882a593Smuzhiyun 	(CONFIG_PHYSICAL_ALIGN < MIN_KERNEL_ALIGN)
24*4882a593Smuzhiyun # error "Invalid value for CONFIG_PHYSICAL_ALIGN"
25*4882a593Smuzhiyun #endif
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #if defined(CONFIG_KERNEL_BZIP2)
28*4882a593Smuzhiyun # define BOOT_HEAP_SIZE		0x400000
29*4882a593Smuzhiyun #elif defined(CONFIG_KERNEL_ZSTD)
30*4882a593Smuzhiyun /*
31*4882a593Smuzhiyun  * Zstd needs to allocate the ZSTD_DCtx in order to decompress the kernel.
32*4882a593Smuzhiyun  * The ZSTD_DCtx is ~160KB, so set the heap size to 192KB because it is a
33*4882a593Smuzhiyun  * round number and to allow some slack.
34*4882a593Smuzhiyun  */
35*4882a593Smuzhiyun # define BOOT_HEAP_SIZE		 0x30000
36*4882a593Smuzhiyun #else
37*4882a593Smuzhiyun # define BOOT_HEAP_SIZE		 0x10000
38*4882a593Smuzhiyun #endif
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun #ifdef CONFIG_X86_64
41*4882a593Smuzhiyun # define BOOT_STACK_SIZE	0x4000
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun # define BOOT_INIT_PGT_SIZE	(6*4096)
44*4882a593Smuzhiyun # ifdef CONFIG_RANDOMIZE_BASE
45*4882a593Smuzhiyun /*
46*4882a593Smuzhiyun  * Assuming all cross the 512GB boundary:
47*4882a593Smuzhiyun  * 1 page for level4
48*4882a593Smuzhiyun  * (2+2)*4 pages for kernel, param, cmd_line, and randomized kernel
49*4882a593Smuzhiyun  * 2 pages for first 2M (video RAM: CONFIG_X86_VERBOSE_BOOTUP).
50*4882a593Smuzhiyun  * Total is 19 pages.
51*4882a593Smuzhiyun  */
52*4882a593Smuzhiyun #  ifdef CONFIG_X86_VERBOSE_BOOTUP
53*4882a593Smuzhiyun #   define BOOT_PGT_SIZE	(19*4096)
54*4882a593Smuzhiyun #  else /* !CONFIG_X86_VERBOSE_BOOTUP */
55*4882a593Smuzhiyun #   define BOOT_PGT_SIZE	(17*4096)
56*4882a593Smuzhiyun #  endif
57*4882a593Smuzhiyun # else /* !CONFIG_RANDOMIZE_BASE */
58*4882a593Smuzhiyun #  define BOOT_PGT_SIZE		BOOT_INIT_PGT_SIZE
59*4882a593Smuzhiyun # endif
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun #else /* !CONFIG_X86_64 */
62*4882a593Smuzhiyun # define BOOT_STACK_SIZE	0x1000
63*4882a593Smuzhiyun #endif
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun #endif /* _ASM_X86_BOOT_H */
66