setup.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_X86_SETUP_H
  3. #define _ASM_X86_SETUP_H
  4. #include <uapi/asm/setup.h>
  5. #define COMMAND_LINE_SIZE 2048
  6. #include <linux/linkage.h>
  7. #include <asm/page_types.h>
  8. #include <asm/ibt.h>
  9. #ifdef __i386__
  10. #include <linux/pfn.h>
  11. /*
  12. * Reserved space for vmalloc and iomap - defined in asm/page.h
  13. */
  14. #define MAXMEM_PFN PFN_DOWN(MAXMEM)
  15. #define MAX_NONPAE_PFN (1 << 20)
  16. #endif /* __i386__ */
  17. #define PARAM_SIZE 4096 /* sizeof(struct boot_params) */
  18. #define OLD_CL_MAGIC 0xA33F
  19. #define OLD_CL_ADDRESS 0x020 /* Relative to real mode data */
  20. #define NEW_CL_POINTER 0x228 /* Relative to real mode data */
  21. #ifndef __ASSEMBLY__
  22. #include <asm/bootparam.h>
  23. #include <asm/x86_init.h>
  24. extern u64 relocated_ramdisk;
  25. /* Interrupt control for vSMPowered x86_64 systems */
  26. #ifdef CONFIG_X86_64
  27. void vsmp_init(void);
  28. #else
  29. static inline void vsmp_init(void) { }
  30. #endif
  31. struct pt_regs;
  32. void setup_bios_corruption_check(void);
  33. void early_platform_quirks(void);
  34. extern unsigned long saved_video_mode;
  35. extern void reserve_standard_io_resources(void);
  36. extern void i386_reserve_resources(void);
  37. extern unsigned long __startup_64(unsigned long physaddr, struct boot_params *bp);
  38. extern void startup_64_setup_env(unsigned long physbase);
  39. extern void early_setup_idt(void);
  40. extern void __init do_early_exception(struct pt_regs *regs, int trapnr);
  41. #ifdef CONFIG_X86_INTEL_MID
  42. extern void x86_intel_mid_early_setup(void);
  43. #else
  44. static inline void x86_intel_mid_early_setup(void) { }
  45. #endif
  46. #ifdef CONFIG_X86_INTEL_CE
  47. extern void x86_ce4100_early_setup(void);
  48. #else
  49. static inline void x86_ce4100_early_setup(void) { }
  50. #endif
  51. #ifndef _SETUP
  52. #include <asm/espfix.h>
  53. #include <linux/kernel.h>
  54. /*
  55. * This is set up by the setup-routine at boot-time
  56. */
  57. extern struct boot_params boot_params;
  58. extern char _text[];
  59. static inline bool kaslr_enabled(void)
  60. {
  61. return IS_ENABLED(CONFIG_RANDOMIZE_MEMORY) &&
  62. !!(boot_params.hdr.loadflags & KASLR_FLAG);
  63. }
  64. /*
  65. * Apply no randomization if KASLR was disabled at boot or if KASAN
  66. * is enabled. KASAN shadow mappings rely on regions being PGD aligned.
  67. */
  68. static inline bool kaslr_memory_enabled(void)
  69. {
  70. return kaslr_enabled() && !IS_ENABLED(CONFIG_KASAN);
  71. }
  72. static inline unsigned long kaslr_offset(void)
  73. {
  74. return (unsigned long)&_text - __START_KERNEL;
  75. }
  76. /*
  77. * Do NOT EVER look at the BIOS memory size location.
  78. * It does not work on many machines.
  79. */
  80. #define LOWMEMSIZE() (0x9f000)
  81. /* exceedingly early brk-like allocator */
  82. extern unsigned long _brk_end;
  83. void *extend_brk(size_t size, size_t align);
  84. /*
  85. * Reserve space in the .brk section, which is a block of memory from which the
  86. * caller is allowed to allocate very early (before even memblock is available)
  87. * by calling extend_brk(). All allocated memory will be eventually converted
  88. * to memblock. Any leftover unallocated memory will be freed.
  89. *
  90. * The size is in bytes.
  91. */
  92. #define RESERVE_BRK(name, size) \
  93. __section(".bss..brk") __aligned(1) __used \
  94. static char __brk_##name[size]
  95. extern void probe_roms(void);
  96. void clear_bss(void);
  97. #ifdef __i386__
  98. asmlinkage void __init i386_start_kernel(void);
  99. #else
  100. asmlinkage void __init x86_64_start_kernel(char *real_mode);
  101. asmlinkage void __init x86_64_start_reservations(char *real_mode_data);
  102. #endif /* __i386__ */
  103. #endif /* _SETUP */
  104. #else /* __ASSEMBLY */
  105. .macro __RESERVE_BRK name, size
  106. .pushsection .bss..brk, "aw"
  107. SYM_DATA_START(__brk_\name)
  108. .skip \size
  109. SYM_DATA_END(__brk_\name)
  110. .popsection
  111. .endm
  112. #define RESERVE_BRK(name, size) __RESERVE_BRK name, size
  113. #endif /* __ASSEMBLY__ */
  114. #endif /* _ASM_X86_SETUP_H */