18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_BOOTPARAM_H 38c2ecf20Sopenharmony_ci#define _ASM_X86_BOOTPARAM_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* setup_data/setup_indirect types */ 68c2ecf20Sopenharmony_ci#define SETUP_NONE 0 78c2ecf20Sopenharmony_ci#define SETUP_E820_EXT 1 88c2ecf20Sopenharmony_ci#define SETUP_DTB 2 98c2ecf20Sopenharmony_ci#define SETUP_PCI 3 108c2ecf20Sopenharmony_ci#define SETUP_EFI 4 118c2ecf20Sopenharmony_ci#define SETUP_APPLE_PROPERTIES 5 128c2ecf20Sopenharmony_ci#define SETUP_JAILHOUSE 6 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#define SETUP_INDIRECT (1<<31) 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* SETUP_INDIRECT | max(SETUP_*) */ 178c2ecf20Sopenharmony_ci#define SETUP_TYPE_MAX (SETUP_INDIRECT | SETUP_JAILHOUSE) 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* ram_size flags */ 208c2ecf20Sopenharmony_ci#define RAMDISK_IMAGE_START_MASK 0x07FF 218c2ecf20Sopenharmony_ci#define RAMDISK_PROMPT_FLAG 0x8000 228c2ecf20Sopenharmony_ci#define RAMDISK_LOAD_FLAG 0x4000 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* loadflags */ 258c2ecf20Sopenharmony_ci#define LOADED_HIGH (1<<0) 268c2ecf20Sopenharmony_ci#define KASLR_FLAG (1<<1) 278c2ecf20Sopenharmony_ci#define QUIET_FLAG (1<<5) 288c2ecf20Sopenharmony_ci#define KEEP_SEGMENTS (1<<6) 298c2ecf20Sopenharmony_ci#define CAN_USE_HEAP (1<<7) 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci/* xloadflags */ 328c2ecf20Sopenharmony_ci#define XLF_KERNEL_64 (1<<0) 338c2ecf20Sopenharmony_ci#define XLF_CAN_BE_LOADED_ABOVE_4G (1<<1) 348c2ecf20Sopenharmony_ci#define XLF_EFI_HANDOVER_32 (1<<2) 358c2ecf20Sopenharmony_ci#define XLF_EFI_HANDOVER_64 (1<<3) 368c2ecf20Sopenharmony_ci#define XLF_EFI_KEXEC (1<<4) 378c2ecf20Sopenharmony_ci#define XLF_5LEVEL (1<<5) 388c2ecf20Sopenharmony_ci#define XLF_5LEVEL_ENABLED (1<<6) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#include <linux/types.h> 438c2ecf20Sopenharmony_ci#include <linux/screen_info.h> 448c2ecf20Sopenharmony_ci#include <linux/apm_bios.h> 458c2ecf20Sopenharmony_ci#include <linux/edd.h> 468c2ecf20Sopenharmony_ci#include <asm/ist.h> 478c2ecf20Sopenharmony_ci#include <video/edid.h> 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci/* extensible setup data list node */ 508c2ecf20Sopenharmony_cistruct setup_data { 518c2ecf20Sopenharmony_ci __u64 next; 528c2ecf20Sopenharmony_ci __u32 type; 538c2ecf20Sopenharmony_ci __u32 len; 548c2ecf20Sopenharmony_ci __u8 data[0]; 558c2ecf20Sopenharmony_ci}; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci/* extensible setup indirect data node */ 588c2ecf20Sopenharmony_cistruct setup_indirect { 598c2ecf20Sopenharmony_ci __u32 type; 608c2ecf20Sopenharmony_ci __u32 reserved; /* Reserved, must be set to zero. */ 618c2ecf20Sopenharmony_ci __u64 len; 628c2ecf20Sopenharmony_ci __u64 addr; 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistruct setup_header { 668c2ecf20Sopenharmony_ci __u8 setup_sects; 678c2ecf20Sopenharmony_ci __u16 root_flags; 688c2ecf20Sopenharmony_ci __u32 syssize; 698c2ecf20Sopenharmony_ci __u16 ram_size; 708c2ecf20Sopenharmony_ci __u16 vid_mode; 718c2ecf20Sopenharmony_ci __u16 root_dev; 728c2ecf20Sopenharmony_ci __u16 boot_flag; 738c2ecf20Sopenharmony_ci __u16 jump; 748c2ecf20Sopenharmony_ci __u32 header; 758c2ecf20Sopenharmony_ci __u16 version; 768c2ecf20Sopenharmony_ci __u32 realmode_swtch; 778c2ecf20Sopenharmony_ci __u16 start_sys_seg; 788c2ecf20Sopenharmony_ci __u16 kernel_version; 798c2ecf20Sopenharmony_ci __u8 type_of_loader; 808c2ecf20Sopenharmony_ci __u8 loadflags; 818c2ecf20Sopenharmony_ci __u16 setup_move_size; 828c2ecf20Sopenharmony_ci __u32 code32_start; 838c2ecf20Sopenharmony_ci __u32 ramdisk_image; 848c2ecf20Sopenharmony_ci __u32 ramdisk_size; 858c2ecf20Sopenharmony_ci __u32 bootsect_kludge; 868c2ecf20Sopenharmony_ci __u16 heap_end_ptr; 878c2ecf20Sopenharmony_ci __u8 ext_loader_ver; 888c2ecf20Sopenharmony_ci __u8 ext_loader_type; 898c2ecf20Sopenharmony_ci __u32 cmd_line_ptr; 908c2ecf20Sopenharmony_ci __u32 initrd_addr_max; 918c2ecf20Sopenharmony_ci __u32 kernel_alignment; 928c2ecf20Sopenharmony_ci __u8 relocatable_kernel; 938c2ecf20Sopenharmony_ci __u8 min_alignment; 948c2ecf20Sopenharmony_ci __u16 xloadflags; 958c2ecf20Sopenharmony_ci __u32 cmdline_size; 968c2ecf20Sopenharmony_ci __u32 hardware_subarch; 978c2ecf20Sopenharmony_ci __u64 hardware_subarch_data; 988c2ecf20Sopenharmony_ci __u32 payload_offset; 998c2ecf20Sopenharmony_ci __u32 payload_length; 1008c2ecf20Sopenharmony_ci __u64 setup_data; 1018c2ecf20Sopenharmony_ci __u64 pref_address; 1028c2ecf20Sopenharmony_ci __u32 init_size; 1038c2ecf20Sopenharmony_ci __u32 handover_offset; 1048c2ecf20Sopenharmony_ci __u32 kernel_info_offset; 1058c2ecf20Sopenharmony_ci} __attribute__((packed)); 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_cistruct sys_desc_table { 1088c2ecf20Sopenharmony_ci __u16 length; 1098c2ecf20Sopenharmony_ci __u8 table[14]; 1108c2ecf20Sopenharmony_ci}; 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci/* Gleaned from OFW's set-parameters in cpu/x86/pc/linux.fth */ 1138c2ecf20Sopenharmony_cistruct olpc_ofw_header { 1148c2ecf20Sopenharmony_ci __u32 ofw_magic; /* OFW signature */ 1158c2ecf20Sopenharmony_ci __u32 ofw_version; 1168c2ecf20Sopenharmony_ci __u32 cif_handler; /* callback into OFW */ 1178c2ecf20Sopenharmony_ci __u32 irq_desc_table; 1188c2ecf20Sopenharmony_ci} __attribute__((packed)); 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_cistruct efi_info { 1218c2ecf20Sopenharmony_ci __u32 efi_loader_signature; 1228c2ecf20Sopenharmony_ci __u32 efi_systab; 1238c2ecf20Sopenharmony_ci __u32 efi_memdesc_size; 1248c2ecf20Sopenharmony_ci __u32 efi_memdesc_version; 1258c2ecf20Sopenharmony_ci __u32 efi_memmap; 1268c2ecf20Sopenharmony_ci __u32 efi_memmap_size; 1278c2ecf20Sopenharmony_ci __u32 efi_systab_hi; 1288c2ecf20Sopenharmony_ci __u32 efi_memmap_hi; 1298c2ecf20Sopenharmony_ci}; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci/* 1328c2ecf20Sopenharmony_ci * This is the maximum number of entries in struct boot_params::e820_table 1338c2ecf20Sopenharmony_ci * (the zeropage), which is part of the x86 boot protocol ABI: 1348c2ecf20Sopenharmony_ci */ 1358c2ecf20Sopenharmony_ci#define E820_MAX_ENTRIES_ZEROPAGE 128 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci/* 1388c2ecf20Sopenharmony_ci * The E820 memory region entry of the boot protocol ABI: 1398c2ecf20Sopenharmony_ci */ 1408c2ecf20Sopenharmony_cistruct boot_e820_entry { 1418c2ecf20Sopenharmony_ci __u64 addr; 1428c2ecf20Sopenharmony_ci __u64 size; 1438c2ecf20Sopenharmony_ci __u32 type; 1448c2ecf20Sopenharmony_ci} __attribute__((packed)); 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci/* 1478c2ecf20Sopenharmony_ci * Smallest compatible version of jailhouse_setup_data required by this kernel. 1488c2ecf20Sopenharmony_ci */ 1498c2ecf20Sopenharmony_ci#define JAILHOUSE_SETUP_REQUIRED_VERSION 1 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci/* 1528c2ecf20Sopenharmony_ci * The boot loader is passing platform information via this Jailhouse-specific 1538c2ecf20Sopenharmony_ci * setup data structure. 1548c2ecf20Sopenharmony_ci */ 1558c2ecf20Sopenharmony_cistruct jailhouse_setup_data { 1568c2ecf20Sopenharmony_ci struct { 1578c2ecf20Sopenharmony_ci __u16 version; 1588c2ecf20Sopenharmony_ci __u16 compatible_version; 1598c2ecf20Sopenharmony_ci } __attribute__((packed)) hdr; 1608c2ecf20Sopenharmony_ci struct { 1618c2ecf20Sopenharmony_ci __u16 pm_timer_address; 1628c2ecf20Sopenharmony_ci __u16 num_cpus; 1638c2ecf20Sopenharmony_ci __u64 pci_mmconfig_base; 1648c2ecf20Sopenharmony_ci __u32 tsc_khz; 1658c2ecf20Sopenharmony_ci __u32 apic_khz; 1668c2ecf20Sopenharmony_ci __u8 standard_ioapic; 1678c2ecf20Sopenharmony_ci __u8 cpu_ids[255]; 1688c2ecf20Sopenharmony_ci } __attribute__((packed)) v1; 1698c2ecf20Sopenharmony_ci struct { 1708c2ecf20Sopenharmony_ci __u32 flags; 1718c2ecf20Sopenharmony_ci } __attribute__((packed)) v2; 1728c2ecf20Sopenharmony_ci} __attribute__((packed)); 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci/* The so-called "zeropage" */ 1758c2ecf20Sopenharmony_cistruct boot_params { 1768c2ecf20Sopenharmony_ci struct screen_info screen_info; /* 0x000 */ 1778c2ecf20Sopenharmony_ci struct apm_bios_info apm_bios_info; /* 0x040 */ 1788c2ecf20Sopenharmony_ci __u8 _pad2[4]; /* 0x054 */ 1798c2ecf20Sopenharmony_ci __u64 tboot_addr; /* 0x058 */ 1808c2ecf20Sopenharmony_ci struct ist_info ist_info; /* 0x060 */ 1818c2ecf20Sopenharmony_ci __u64 acpi_rsdp_addr; /* 0x070 */ 1828c2ecf20Sopenharmony_ci __u8 _pad3[8]; /* 0x078 */ 1838c2ecf20Sopenharmony_ci __u8 hd0_info[16]; /* obsolete! */ /* 0x080 */ 1848c2ecf20Sopenharmony_ci __u8 hd1_info[16]; /* obsolete! */ /* 0x090 */ 1858c2ecf20Sopenharmony_ci struct sys_desc_table sys_desc_table; /* obsolete! */ /* 0x0a0 */ 1868c2ecf20Sopenharmony_ci struct olpc_ofw_header olpc_ofw_header; /* 0x0b0 */ 1878c2ecf20Sopenharmony_ci __u32 ext_ramdisk_image; /* 0x0c0 */ 1888c2ecf20Sopenharmony_ci __u32 ext_ramdisk_size; /* 0x0c4 */ 1898c2ecf20Sopenharmony_ci __u32 ext_cmd_line_ptr; /* 0x0c8 */ 1908c2ecf20Sopenharmony_ci __u8 _pad4[116]; /* 0x0cc */ 1918c2ecf20Sopenharmony_ci struct edid_info edid_info; /* 0x140 */ 1928c2ecf20Sopenharmony_ci struct efi_info efi_info; /* 0x1c0 */ 1938c2ecf20Sopenharmony_ci __u32 alt_mem_k; /* 0x1e0 */ 1948c2ecf20Sopenharmony_ci __u32 scratch; /* Scratch field! */ /* 0x1e4 */ 1958c2ecf20Sopenharmony_ci __u8 e820_entries; /* 0x1e8 */ 1968c2ecf20Sopenharmony_ci __u8 eddbuf_entries; /* 0x1e9 */ 1978c2ecf20Sopenharmony_ci __u8 edd_mbr_sig_buf_entries; /* 0x1ea */ 1988c2ecf20Sopenharmony_ci __u8 kbd_status; /* 0x1eb */ 1998c2ecf20Sopenharmony_ci __u8 secure_boot; /* 0x1ec */ 2008c2ecf20Sopenharmony_ci __u8 _pad5[2]; /* 0x1ed */ 2018c2ecf20Sopenharmony_ci /* 2028c2ecf20Sopenharmony_ci * The sentinel is set to a nonzero value (0xff) in header.S. 2038c2ecf20Sopenharmony_ci * 2048c2ecf20Sopenharmony_ci * A bootloader is supposed to only take setup_header and put 2058c2ecf20Sopenharmony_ci * it into a clean boot_params buffer. If it turns out that 2068c2ecf20Sopenharmony_ci * it is clumsy or too generous with the buffer, it most 2078c2ecf20Sopenharmony_ci * probably will pick up the sentinel variable too. The fact 2088c2ecf20Sopenharmony_ci * that this variable then is still 0xff will let kernel 2098c2ecf20Sopenharmony_ci * know that some variables in boot_params are invalid and 2108c2ecf20Sopenharmony_ci * kernel should zero out certain portions of boot_params. 2118c2ecf20Sopenharmony_ci */ 2128c2ecf20Sopenharmony_ci __u8 sentinel; /* 0x1ef */ 2138c2ecf20Sopenharmony_ci __u8 _pad6[1]; /* 0x1f0 */ 2148c2ecf20Sopenharmony_ci struct setup_header hdr; /* setup header */ /* 0x1f1 */ 2158c2ecf20Sopenharmony_ci __u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)]; 2168c2ecf20Sopenharmony_ci __u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 0x290 */ 2178c2ecf20Sopenharmony_ci struct boot_e820_entry e820_table[E820_MAX_ENTRIES_ZEROPAGE]; /* 0x2d0 */ 2188c2ecf20Sopenharmony_ci __u8 _pad8[48]; /* 0xcd0 */ 2198c2ecf20Sopenharmony_ci struct edd_info eddbuf[EDDMAXNR]; /* 0xd00 */ 2208c2ecf20Sopenharmony_ci __u8 _pad9[276]; /* 0xeec */ 2218c2ecf20Sopenharmony_ci} __attribute__((packed)); 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci/** 2248c2ecf20Sopenharmony_ci * enum x86_hardware_subarch - x86 hardware subarchitecture 2258c2ecf20Sopenharmony_ci * 2268c2ecf20Sopenharmony_ci * The x86 hardware_subarch and hardware_subarch_data were added as of the x86 2278c2ecf20Sopenharmony_ci * boot protocol 2.07 to help distinguish and support custom x86 boot 2288c2ecf20Sopenharmony_ci * sequences. This enum represents accepted values for the x86 2298c2ecf20Sopenharmony_ci * hardware_subarch. Custom x86 boot sequences (not X86_SUBARCH_PC) do not 2308c2ecf20Sopenharmony_ci * have or simply *cannot* make use of natural stubs like BIOS or EFI, the 2318c2ecf20Sopenharmony_ci * hardware_subarch can be used on the Linux entry path to revector to a 2328c2ecf20Sopenharmony_ci * subarchitecture stub when needed. This subarchitecture stub can be used to 2338c2ecf20Sopenharmony_ci * set up Linux boot parameters or for special care to account for nonstandard 2348c2ecf20Sopenharmony_ci * handling of page tables. 2358c2ecf20Sopenharmony_ci * 2368c2ecf20Sopenharmony_ci * These enums should only ever be used by x86 code, and the code that uses 2378c2ecf20Sopenharmony_ci * it should be well contained and compartamentalized. 2388c2ecf20Sopenharmony_ci * 2398c2ecf20Sopenharmony_ci * KVM and Xen HVM do not have a subarch as these are expected to follow 2408c2ecf20Sopenharmony_ci * standard x86 boot entries. If there is a genuine need for "hypervisor" type 2418c2ecf20Sopenharmony_ci * that should be considered separately in the future. Future guest types 2428c2ecf20Sopenharmony_ci * should seriously consider working with standard x86 boot stubs such as 2438c2ecf20Sopenharmony_ci * the BIOS or EFI boot stubs. 2448c2ecf20Sopenharmony_ci * 2458c2ecf20Sopenharmony_ci * WARNING: this enum is only used for legacy hacks, for platform features that 2468c2ecf20Sopenharmony_ci * are not easily enumerated or discoverable. You should not ever use 2478c2ecf20Sopenharmony_ci * this for new features. 2488c2ecf20Sopenharmony_ci * 2498c2ecf20Sopenharmony_ci * @X86_SUBARCH_PC: Should be used if the hardware is enumerable using standard 2508c2ecf20Sopenharmony_ci * PC mechanisms (PCI, ACPI) and doesn't need a special boot flow. 2518c2ecf20Sopenharmony_ci * @X86_SUBARCH_LGUEST: Used for x86 hypervisor demo, lguest, deprecated 2528c2ecf20Sopenharmony_ci * @X86_SUBARCH_XEN: Used for Xen guest types which follow the PV boot path, 2538c2ecf20Sopenharmony_ci * which start at asm startup_xen() entry point and later jump to the C 2548c2ecf20Sopenharmony_ci * xen_start_kernel() entry point. Both domU and dom0 type of guests are 2558c2ecf20Sopenharmony_ci * currently supportd through this PV boot path. 2568c2ecf20Sopenharmony_ci * @X86_SUBARCH_INTEL_MID: Used for Intel MID (Mobile Internet Device) platform 2578c2ecf20Sopenharmony_ci * systems which do not have the PCI legacy interfaces. 2588c2ecf20Sopenharmony_ci * @X86_SUBARCH_CE4100: Used for Intel CE media processor (CE4100) SoC 2598c2ecf20Sopenharmony_ci * for settop boxes and media devices, the use of a subarch for CE4100 2608c2ecf20Sopenharmony_ci * is more of a hack... 2618c2ecf20Sopenharmony_ci */ 2628c2ecf20Sopenharmony_cienum x86_hardware_subarch { 2638c2ecf20Sopenharmony_ci X86_SUBARCH_PC = 0, 2648c2ecf20Sopenharmony_ci X86_SUBARCH_LGUEST, 2658c2ecf20Sopenharmony_ci X86_SUBARCH_XEN, 2668c2ecf20Sopenharmony_ci X86_SUBARCH_INTEL_MID, 2678c2ecf20Sopenharmony_ci X86_SUBARCH_CE4100, 2688c2ecf20Sopenharmony_ci X86_NR_SUBARCHS, 2698c2ecf20Sopenharmony_ci}; 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */ 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci#endif /* _ASM_X86_BOOTPARAM_H */ 274