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