1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _ARCH_X86_REALMODE_H 3 #define _ARCH_X86_REALMODE_H 4 5 /* 6 * Flag bit definitions for use with the flags field of the trampoline header 7 * in the CONFIG_X86_64 variant. 8 */ 9 #define TH_FLAGS_SME_ACTIVE_BIT 0 10 #define TH_FLAGS_SME_ACTIVE BIT(TH_FLAGS_SME_ACTIVE_BIT) 11 12 #ifndef __ASSEMBLY__ 13 14 #include <linux/types.h> 15 #include <asm/io.h> 16 17 /* This must match data at realmode.S */ 18 struct real_mode_header { 19 u32 text_start; 20 u32 ro_end; 21 /* SMP trampoline */ 22 u32 trampoline_start; 23 u32 trampoline_status; 24 u32 trampoline_header; 25 #ifdef CONFIG_X86_64 26 u32 trampoline_pgd; 27 #endif 28 /* ACPI S3 wakeup */ 29 #ifdef CONFIG_ACPI_SLEEP 30 u32 wakeup_start; 31 u32 wakeup_header; 32 #endif 33 /* APM/BIOS reboot */ 34 u32 machine_real_restart_asm; 35 #ifdef CONFIG_X86_64 36 u32 machine_real_restart_seg; 37 #endif 38 }; 39 40 /* This must match data at trampoline_32/64.S */ 41 struct trampoline_header { 42 #ifdef CONFIG_X86_32 43 u32 start; 44 u16 gdt_pad; 45 u16 gdt_limit; 46 u32 gdt_base; 47 #else 48 u64 start; 49 u64 efer; 50 u32 cr4; 51 u32 flags; 52 #endif 53 }; 54 55 extern struct real_mode_header *real_mode_header; 56 extern unsigned char real_mode_blob_end[]; 57 58 extern unsigned long initial_code; 59 extern unsigned long initial_gs; 60 extern unsigned long initial_stack; 61 62 extern unsigned char real_mode_blob[]; 63 extern unsigned char real_mode_relocs[]; 64 65 #ifdef CONFIG_X86_32 66 extern unsigned char startup_32_smp[]; 67 extern unsigned char boot_gdt[]; 68 #else 69 extern unsigned char secondary_startup_64[]; 70 #endif 71 72 static inline size_t real_mode_size_needed(void) 73 { 74 if (real_mode_header) 75 return 0; /* already allocated. */ 76 77 return ALIGN(real_mode_blob_end - real_mode_blob, PAGE_SIZE); 78 } 79 80 void set_real_mode_mem(phys_addr_t mem, size_t size); 81 void reserve_real_mode(void); 82 83 #endif /* __ASSEMBLY__ */ 84 85 #endif /* _ARCH_X86_REALMODE_H */ 86