xref: /linux/arch/x86/boot/compressed/misc.h (revision 02a3e3cdb7f12fb8589e4a2e85d23c9e6544b54a)
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>
265dcd14ecSH. Peter Anvin #include <asm/bootparam_utils.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 { }
6379063a7cSKees Cook static inline void debug_puthex(const char *s)
6479063a7cSKees Cook { }
6579063a7cSKees Cook #define debug_putaddr(x) /* */
667aac3015SJoe Millenbach 
677aac3015SJoe Millenbach #endif
688fee13a4SYinghai Lu 
698ab3820fSKees Cook #if CONFIG_EARLY_PRINTK || CONFIG_RANDOMIZE_BASE
708fee13a4SYinghai Lu /* cmdline.c */
718fee13a4SYinghai Lu int cmdline_find_option(const char *option, char *buffer, int bufsize);
728fee13a4SYinghai Lu int cmdline_find_option_bool(const char *option);
738ab3820fSKees Cook #endif
748fee13a4SYinghai Lu 
75*02a3e3cdSChao Fan struct mem_vector {
76*02a3e3cdSChao Fan 	unsigned long long start;
77*02a3e3cdSChao Fan 	unsigned long long size;
78*02a3e3cdSChao Fan };
798ab3820fSKees Cook 
808ab3820fSKees Cook #if CONFIG_RANDOMIZE_BASE
819b238748SKees Cook /* kaslr.c */
828391c73cSBaoquan He void choose_random_location(unsigned long input,
838ab3820fSKees Cook 			    unsigned long input_size,
848391c73cSBaoquan He 			    unsigned long *output,
858391c73cSBaoquan He 			    unsigned long output_size,
868391c73cSBaoquan He 			    unsigned long *virt_addr);
875bfce5efSKees Cook /* cpuflags.c */
885bfce5efSKees Cook bool has_cpuflag(int flag);
898ab3820fSKees Cook #else
908391c73cSBaoquan He static inline void choose_random_location(unsigned long input,
918ab3820fSKees Cook 					  unsigned long input_size,
928391c73cSBaoquan He 					  unsigned long *output,
938391c73cSBaoquan He 					  unsigned long output_size,
948391c73cSBaoquan He 					  unsigned long *virt_addr)
958ab3820fSKees Cook {
968ab3820fSKees Cook }
978ab3820fSKees Cook #endif
988ab3820fSKees Cook 
993a94707dSKees Cook #ifdef CONFIG_X86_64
10011fdf97aSKees Cook void initialize_identity_maps(void);
1013a94707dSKees Cook void add_identity_map(unsigned long start, unsigned long size);
1023a94707dSKees Cook void finalize_identity_maps(void);
1033a94707dSKees Cook extern unsigned char _pgtable[];
1043a94707dSKees Cook #else
10511fdf97aSKees Cook static inline void initialize_identity_maps(void)
10611fdf97aSKees Cook { }
1073a94707dSKees Cook static inline void add_identity_map(unsigned long start, unsigned long size)
1083a94707dSKees Cook { }
1093a94707dSKees Cook static inline void finalize_identity_maps(void)
1103a94707dSKees Cook { }
1113a94707dSKees Cook #endif
1123a94707dSKees Cook 
1138ab3820fSKees Cook #ifdef CONFIG_EARLY_PRINTK
1148fee13a4SYinghai Lu /* early_serial_console.c */
1158fee13a4SYinghai Lu extern int early_serial_base;
1168fee13a4SYinghai Lu void console_init(void);
117cec49df9SJoe Millenbach #else
118cec49df9SJoe Millenbach static const int early_serial_base;
119cec49df9SJoe Millenbach static inline void console_init(void)
120cec49df9SJoe Millenbach { }
121cec49df9SJoe Millenbach #endif
122cec49df9SJoe Millenbach 
12307344b15STom Lendacky void set_sev_encryption_mask(void);
1241958b5fcSTom Lendacky 
1258fee13a4SYinghai Lu #endif
1263a63f70bSChao Fan 
1273a63f70bSChao Fan /* acpi.c */
1283a63f70bSChao Fan #ifdef CONFIG_ACPI
1293a63f70bSChao Fan acpi_physical_address get_rsdp_addr(void);
1303a63f70bSChao Fan #else
1313a63f70bSChao Fan static inline acpi_physical_address get_rsdp_addr(void) { return 0; }
1323a63f70bSChao Fan #endif
133*02a3e3cdSChao Fan 
134*02a3e3cdSChao Fan #if defined(CONFIG_RANDOMIZE_BASE) && defined(CONFIG_MEMORY_HOTREMOVE)
135*02a3e3cdSChao Fan int count_immovable_mem_regions(void);
136*02a3e3cdSChao Fan #else
137*02a3e3cdSChao Fan static inline int count_immovable_mem_regions(void) { return 0; }
138*02a3e3cdSChao Fan #endif
139