xref: /linux/arch/x86/boot/compressed/misc.h (revision 3a066990a35eb289d54036637d2793d4743b8f07)
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>
268fee13a4SYinghai Lu 
273c98e71bSChao Fan #define BOOT_CTYPE_H
283c98e71bSChao Fan #include <linux/acpi.h>
293c98e71bSChao Fan 
308fee13a4SYinghai Lu #define BOOT_BOOT_H
316238b47bSH. Peter Anvin #include "../ctype.h"
328fee13a4SYinghai Lu 
3382fa9637SKees Cook #ifdef CONFIG_X86_64
3482fa9637SKees Cook #define memptr long
3582fa9637SKees Cook #else
3682fa9637SKees Cook #define memptr unsigned
3782fa9637SKees Cook #endif
3882fa9637SKees Cook 
398fee13a4SYinghai Lu /* misc.c */
4082fa9637SKees Cook extern memptr free_mem_ptr;
4182fa9637SKees Cook extern memptr free_mem_end_ptr;
426655e0aaSKees Cook extern struct boot_params *boot_params;
437aac3015SJoe Millenbach void __putstr(const char *s);
4479063a7cSKees Cook void __puthex(unsigned long value);
457aac3015SJoe Millenbach #define error_putstr(__x)  __putstr(__x)
4679063a7cSKees Cook #define error_puthex(__x)  __puthex(__x)
477aac3015SJoe Millenbach 
487aac3015SJoe Millenbach #ifdef CONFIG_X86_VERBOSE_BOOTUP
497aac3015SJoe Millenbach 
507aac3015SJoe Millenbach #define debug_putstr(__x)  __putstr(__x)
5179063a7cSKees Cook #define debug_puthex(__x)  __puthex(__x)
5279063a7cSKees Cook #define debug_putaddr(__x) { \
5379063a7cSKees Cook 		debug_putstr(#__x ": 0x"); \
5479063a7cSKees Cook 		debug_puthex((unsigned long)(__x)); \
5579063a7cSKees Cook 		debug_putstr("\n"); \
5679063a7cSKees Cook 	}
577aac3015SJoe Millenbach 
587aac3015SJoe Millenbach #else
597aac3015SJoe Millenbach 
607aac3015SJoe Millenbach static inline void debug_putstr(const char *s)
617aac3015SJoe Millenbach { }
62c90beea2SJoerg Roedel static inline void debug_puthex(unsigned long value)
6379063a7cSKees Cook { }
6479063a7cSKees Cook #define debug_putaddr(x) /* */
657aac3015SJoe Millenbach 
667aac3015SJoe Millenbach #endif
678fee13a4SYinghai Lu 
688fee13a4SYinghai Lu /* cmdline.c */
698fee13a4SYinghai Lu int cmdline_find_option(const char *option, char *buffer, int bufsize);
708fee13a4SYinghai Lu int cmdline_find_option_bool(const char *option);
718fee13a4SYinghai Lu 
7202a3e3cdSChao Fan struct mem_vector {
73*3a066990SArvind Sankar 	u64 start;
74*3a066990SArvind Sankar 	u64 size;
7502a3e3cdSChao Fan };
768ab3820fSKees Cook 
778ab3820fSKees Cook #if CONFIG_RANDOMIZE_BASE
789b238748SKees Cook /* kaslr.c */
798391c73cSBaoquan He void choose_random_location(unsigned long input,
808ab3820fSKees Cook 			    unsigned long input_size,
818391c73cSBaoquan He 			    unsigned long *output,
828391c73cSBaoquan He 			    unsigned long output_size,
838391c73cSBaoquan He 			    unsigned long *virt_addr);
845bfce5efSKees Cook /* cpuflags.c */
855bfce5efSKees Cook bool has_cpuflag(int flag);
868ab3820fSKees Cook #else
878391c73cSBaoquan He static inline void choose_random_location(unsigned long input,
888ab3820fSKees Cook 					  unsigned long input_size,
898391c73cSBaoquan He 					  unsigned long *output,
908391c73cSBaoquan He 					  unsigned long output_size,
918391c73cSBaoquan He 					  unsigned long *virt_addr)
928ab3820fSKees Cook {
938ab3820fSKees Cook }
948ab3820fSKees Cook #endif
958ab3820fSKees Cook 
963a94707dSKees Cook #ifdef CONFIG_X86_64
9711fdf97aSKees Cook void initialize_identity_maps(void);
983a94707dSKees Cook void add_identity_map(unsigned long start, unsigned long size);
993a94707dSKees Cook void finalize_identity_maps(void);
1003a94707dSKees Cook extern unsigned char _pgtable[];
1013a94707dSKees Cook #else
10211fdf97aSKees Cook static inline void initialize_identity_maps(void)
10311fdf97aSKees Cook { }
1043a94707dSKees Cook static inline void add_identity_map(unsigned long start, unsigned long size)
1053a94707dSKees Cook { }
1063a94707dSKees Cook static inline void finalize_identity_maps(void)
1073a94707dSKees Cook { }
1083a94707dSKees Cook #endif
1093a94707dSKees Cook 
1108ab3820fSKees Cook #ifdef CONFIG_EARLY_PRINTK
1118fee13a4SYinghai Lu /* early_serial_console.c */
1128fee13a4SYinghai Lu extern int early_serial_base;
1138fee13a4SYinghai Lu void console_init(void);
114cec49df9SJoe Millenbach #else
115cec49df9SJoe Millenbach static const int early_serial_base;
116cec49df9SJoe Millenbach static inline void console_init(void)
117cec49df9SJoe Millenbach { }
118cec49df9SJoe Millenbach #endif
119cec49df9SJoe Millenbach 
12007344b15STom Lendacky void set_sev_encryption_mask(void);
1211958b5fcSTom Lendacky 
1223a63f70bSChao Fan /* acpi.c */
1233a63f70bSChao Fan #ifdef CONFIG_ACPI
1243a63f70bSChao Fan acpi_physical_address get_rsdp_addr(void);
1253a63f70bSChao Fan #else
1263a63f70bSChao Fan static inline acpi_physical_address get_rsdp_addr(void) { return 0; }
1273a63f70bSChao Fan #endif
12802a3e3cdSChao Fan 
12982df8261SBorislav Petkov #if defined(CONFIG_RANDOMIZE_BASE) && defined(CONFIG_MEMORY_HOTREMOVE) && defined(CONFIG_ACPI)
130690eaa53SChao Fan extern struct mem_vector immovable_mem[MAX_NUMNODES*2];
13102a3e3cdSChao Fan int count_immovable_mem_regions(void);
13202a3e3cdSChao Fan #else
13302a3e3cdSChao Fan static inline int count_immovable_mem_regions(void) { return 0; }
13402a3e3cdSChao Fan #endif
1350f02daedSBaoquan He 
1360f02daedSBaoquan He #endif /* BOOT_COMPRESSED_MISC_H */
137