misc.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef BOOT_COMPRESSED_MISC_H
  3. #define BOOT_COMPRESSED_MISC_H
  4. /*
  5. * Special hack: we have to be careful, because no indirections are allowed here,
  6. * and paravirt_ops is a kind of one. As it will only run in baremetal anyway,
  7. * we just keep it from happening. (This list needs to be extended when new
  8. * paravirt and debugging variants are added.)
  9. */
  10. #undef CONFIG_PARAVIRT
  11. #undef CONFIG_PARAVIRT_SPINLOCKS
  12. #undef CONFIG_KASAN
  13. /* cpu_feature_enabled() cannot be used this early */
  14. #define USE_EARLY_PGTABLE_L5
  15. #include <linux/linkage.h>
  16. #include <linux/screen_info.h>
  17. #include <linux/elf.h>
  18. #include <linux/io.h>
  19. #include <asm/page.h>
  20. #include <asm/boot.h>
  21. #include <asm/bootparam.h>
  22. #define BOOT_BOOT_H
  23. #include "../ctype.h"
  24. #ifdef CONFIG_X86_64
  25. #define memptr long
  26. #else
  27. #define memptr unsigned
  28. #endif
  29. /* misc.c */
  30. extern memptr free_mem_ptr;
  31. extern memptr free_mem_end_ptr;
  32. extern struct boot_params *boot_params;
  33. void __putstr(const char *s);
  34. void __puthex(unsigned long value);
  35. #define error_putstr(__x) __putstr(__x)
  36. #define error_puthex(__x) __puthex(__x)
  37. #ifdef CONFIG_X86_VERBOSE_BOOTUP
  38. #define debug_putstr(__x) __putstr(__x)
  39. #define debug_puthex(__x) __puthex(__x)
  40. #define debug_putaddr(__x) { \
  41. debug_putstr(#__x ": 0x"); \
  42. debug_puthex((unsigned long)(__x)); \
  43. debug_putstr("\n"); \
  44. }
  45. #else
  46. static inline void debug_putstr(const char *s)
  47. { }
  48. static inline void debug_puthex(const char *s)
  49. { }
  50. #define debug_putaddr(x) /* */
  51. #endif
  52. #if CONFIG_EARLY_PRINTK || CONFIG_RANDOMIZE_BASE
  53. /* cmdline.c */
  54. int cmdline_find_option(const char *option, char *buffer, int bufsize);
  55. int cmdline_find_option_bool(const char *option);
  56. #endif
  57. #if CONFIG_RANDOMIZE_BASE
  58. /* kaslr.c */
  59. void choose_random_location(unsigned long input,
  60. unsigned long input_size,
  61. unsigned long *output,
  62. unsigned long output_size,
  63. unsigned long *virt_addr);
  64. /* cpuflags.c */
  65. bool has_cpuflag(int flag);
  66. #else
  67. static inline void choose_random_location(unsigned long input,
  68. unsigned long input_size,
  69. unsigned long *output,
  70. unsigned long output_size,
  71. unsigned long *virt_addr)
  72. {
  73. }
  74. #endif
  75. #ifdef CONFIG_X86_64
  76. void initialize_identity_maps(void);
  77. void add_identity_map(unsigned long start, unsigned long size);
  78. void finalize_identity_maps(void);
  79. extern unsigned char _pgtable[];
  80. #else
  81. static inline void initialize_identity_maps(void)
  82. { }
  83. static inline void add_identity_map(unsigned long start, unsigned long size)
  84. { }
  85. static inline void finalize_identity_maps(void)
  86. { }
  87. #endif
  88. #ifdef CONFIG_EARLY_PRINTK
  89. /* early_serial_console.c */
  90. extern int early_serial_base;
  91. void console_init(void);
  92. #else
  93. static const int early_serial_base;
  94. static inline void console_init(void)
  95. { }
  96. #endif
  97. void set_sev_encryption_mask(void);
  98. #endif