1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 28fee13a4SYinghai Lu #ifndef BOOT_COMPRESSED_MISC_H 38fee13a4SYinghai Lu #define BOOT_COMPRESSED_MISC_H 48fee13a4SYinghai Lu 58fee13a4SYinghai Lu /* 6927392d7SIngo Molnar * Special hack: we have to be careful, because no indirections are allowed here, 7927392d7SIngo Molnar * and paravirt_ops is a kind of one. As it will only run in baremetal anyway, 8927392d7SIngo Molnar * we just keep it from happening. (This list needs to be extended when new 9927392d7SIngo Molnar * paravirt and debugging variants are added.) 108fee13a4SYinghai Lu */ 118fee13a4SYinghai Lu #undef CONFIG_PARAVIRT 12c00a280aSJuergen Gross #undef CONFIG_PARAVIRT_XXL 13927392d7SIngo Molnar #undef CONFIG_PARAVIRT_SPINLOCKS 14393f203fSAndrey Ryabinin #undef CONFIG_KASAN 158fee13a4SYinghai Lu 16ad3fe525SKirill A. Shutemov /* cpu_feature_enabled() cannot be used this early */ 17ad3fe525SKirill A. Shutemov #define USE_EARLY_PGTABLE_L5 1839b95522SKirill A. Shutemov 198fee13a4SYinghai Lu #include <linux/linkage.h> 208fee13a4SYinghai Lu #include <linux/screen_info.h> 218fee13a4SYinghai Lu #include <linux/elf.h> 228fee13a4SYinghai Lu #include <linux/io.h> 238fee13a4SYinghai Lu #include <asm/page.h> 248fee13a4SYinghai Lu #include <asm/boot.h> 258fee13a4SYinghai Lu #include <asm/bootparam.h> 2664e68263SJoerg Roedel #include <asm/desc_defs.h> 278fee13a4SYinghai Lu 283c98e71bSChao Fan #define BOOT_CTYPE_H 293c98e71bSChao Fan #include <linux/acpi.h> 303c98e71bSChao Fan 318fee13a4SYinghai Lu #define BOOT_BOOT_H 326238b47bSH. Peter Anvin #include "../ctype.h" 338fee13a4SYinghai Lu 3482fa9637SKees Cook #ifdef CONFIG_X86_64 3582fa9637SKees Cook #define memptr long 3682fa9637SKees Cook #else 3782fa9637SKees Cook #define memptr unsigned 3882fa9637SKees Cook #endif 3982fa9637SKees Cook 408fee13a4SYinghai Lu /* misc.c */ 4182fa9637SKees Cook extern memptr free_mem_ptr; 4282fa9637SKees Cook extern memptr free_mem_end_ptr; 436655e0aaSKees Cook extern struct boot_params *boot_params; 447aac3015SJoe Millenbach void __putstr(const char *s); 4579063a7cSKees Cook void __puthex(unsigned long value); 467aac3015SJoe Millenbach #define error_putstr(__x) __putstr(__x) 4779063a7cSKees Cook #define error_puthex(__x) __puthex(__x) 487aac3015SJoe Millenbach 497aac3015SJoe Millenbach #ifdef CONFIG_X86_VERBOSE_BOOTUP 507aac3015SJoe Millenbach 517aac3015SJoe Millenbach #define debug_putstr(__x) __putstr(__x) 5279063a7cSKees Cook #define debug_puthex(__x) __puthex(__x) 5379063a7cSKees Cook #define debug_putaddr(__x) { \ 5479063a7cSKees Cook debug_putstr(#__x ": 0x"); \ 5579063a7cSKees Cook debug_puthex((unsigned long)(__x)); \ 5679063a7cSKees Cook debug_putstr("\n"); \ 5779063a7cSKees Cook } 587aac3015SJoe Millenbach 597aac3015SJoe Millenbach #else 607aac3015SJoe Millenbach 617aac3015SJoe Millenbach static inline void debug_putstr(const char *s) 627aac3015SJoe Millenbach { } 63c90beea2SJoerg Roedel static inline void debug_puthex(unsigned long value) 6479063a7cSKees Cook { } 6579063a7cSKees Cook #define debug_putaddr(x) /* */ 667aac3015SJoe Millenbach 677aac3015SJoe Millenbach #endif 688fee13a4SYinghai Lu 698fee13a4SYinghai Lu /* cmdline.c */ 708fee13a4SYinghai Lu int cmdline_find_option(const char *option, char *buffer, int bufsize); 718fee13a4SYinghai Lu int cmdline_find_option_bool(const char *option); 728fee13a4SYinghai Lu 7302a3e3cdSChao Fan struct mem_vector { 743a066990SArvind Sankar u64 start; 753a066990SArvind Sankar u64 size; 7602a3e3cdSChao Fan }; 778ab3820fSKees Cook 788ab3820fSKees Cook #if CONFIG_RANDOMIZE_BASE 799b238748SKees Cook /* kaslr.c */ 808391c73cSBaoquan He void choose_random_location(unsigned long input, 818ab3820fSKees Cook unsigned long input_size, 828391c73cSBaoquan He unsigned long *output, 838391c73cSBaoquan He unsigned long output_size, 848391c73cSBaoquan He unsigned long *virt_addr); 855bfce5efSKees Cook /* cpuflags.c */ 865bfce5efSKees Cook bool has_cpuflag(int flag); 878ab3820fSKees Cook #else 888391c73cSBaoquan He static inline void choose_random_location(unsigned long input, 898ab3820fSKees Cook unsigned long input_size, 908391c73cSBaoquan He unsigned long *output, 918391c73cSBaoquan He unsigned long output_size, 928391c73cSBaoquan He unsigned long *virt_addr) 938ab3820fSKees Cook { 948ab3820fSKees Cook } 958ab3820fSKees Cook #endif 968ab3820fSKees Cook 973a94707dSKees Cook #ifdef CONFIG_X86_64 9811fdf97aSKees Cook void initialize_identity_maps(void); 993a94707dSKees Cook void add_identity_map(unsigned long start, unsigned long size); 1003a94707dSKees Cook void finalize_identity_maps(void); 1013a94707dSKees Cook extern unsigned char _pgtable[]; 1023a94707dSKees Cook #else 10311fdf97aSKees Cook static inline void initialize_identity_maps(void) 10411fdf97aSKees Cook { } 1053a94707dSKees Cook static inline void add_identity_map(unsigned long start, unsigned long size) 1063a94707dSKees Cook { } 1073a94707dSKees Cook static inline void finalize_identity_maps(void) 1083a94707dSKees Cook { } 1093a94707dSKees Cook #endif 1103a94707dSKees Cook 1118ab3820fSKees Cook #ifdef CONFIG_EARLY_PRINTK 1128fee13a4SYinghai Lu /* early_serial_console.c */ 1138fee13a4SYinghai Lu extern int early_serial_base; 1148fee13a4SYinghai Lu void console_init(void); 115cec49df9SJoe Millenbach #else 116cec49df9SJoe Millenbach static const int early_serial_base; 117cec49df9SJoe Millenbach static inline void console_init(void) 118cec49df9SJoe Millenbach { } 119cec49df9SJoe Millenbach #endif 120cec49df9SJoe Millenbach 12107344b15STom Lendacky void set_sev_encryption_mask(void); 1221958b5fcSTom Lendacky 1233a63f70bSChao Fan /* acpi.c */ 1243a63f70bSChao Fan #ifdef CONFIG_ACPI 1253a63f70bSChao Fan acpi_physical_address get_rsdp_addr(void); 1263a63f70bSChao Fan #else 1273a63f70bSChao Fan static inline acpi_physical_address get_rsdp_addr(void) { return 0; } 1283a63f70bSChao Fan #endif 12902a3e3cdSChao Fan 13082df8261SBorislav Petkov #if defined(CONFIG_RANDOMIZE_BASE) && defined(CONFIG_MEMORY_HOTREMOVE) && defined(CONFIG_ACPI) 131690eaa53SChao Fan extern struct mem_vector immovable_mem[MAX_NUMNODES*2]; 13202a3e3cdSChao Fan int count_immovable_mem_regions(void); 13302a3e3cdSChao Fan #else 13402a3e3cdSChao Fan static inline int count_immovable_mem_regions(void) { return 0; } 13502a3e3cdSChao Fan #endif 1360f02daedSBaoquan He 137*5f2bb016SJoerg Roedel /* ident_map_64.c */ 138*5f2bb016SJoerg Roedel #ifdef CONFIG_X86_5LEVEL 139*5f2bb016SJoerg Roedel extern unsigned int __pgtable_l5_enabled, pgdir_shift, ptrs_per_p4d; 140*5f2bb016SJoerg Roedel #endif 141*5f2bb016SJoerg Roedel 142*5f2bb016SJoerg Roedel /* Used by PAGE_KERN* macros: */ 143*5f2bb016SJoerg Roedel extern pteval_t __default_kernel_pte_mask; 144*5f2bb016SJoerg Roedel 14564e68263SJoerg Roedel /* idt_64.c */ 14664e68263SJoerg Roedel extern gate_desc boot_idt[BOOT_IDT_ENTRIES]; 14764e68263SJoerg Roedel extern struct desc_ptr boot_idt_desc; 14864e68263SJoerg Roedel 1490f02daedSBaoquan He #endif /* BOOT_COMPRESSED_MISC_H */ 150