Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef BOOT_COMPRESSED_EFI_H
0003 #define BOOT_COMPRESSED_EFI_H
0004 
0005 #if defined(_LINUX_EFI_H) || defined(_ASM_X86_EFI_H)
0006 #error Please do not include kernel proper namespace headers
0007 #endif
0008 
0009 typedef guid_t efi_guid_t __aligned(__alignof__(u32));
0010 
0011 #define EFI_GUID(a, b, c, d...) (efi_guid_t){ {                 \
0012     (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff,  \
0013     (b) & 0xff, ((b) >> 8) & 0xff,                      \
0014     (c) & 0xff, ((c) >> 8) & 0xff, d } }
0015 
0016 #define ACPI_TABLE_GUID             EFI_GUID(0xeb9d2d30, 0x2d88, 0x11d3,  0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
0017 #define ACPI_20_TABLE_GUID          EFI_GUID(0x8868e871, 0xe4f1, 0x11d3,  0xbc, 0x22, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81)
0018 #define EFI_CC_BLOB_GUID            EFI_GUID(0x067b1f5f, 0xcf26, 0x44c5, 0x85, 0x54, 0x93, 0xd7, 0x77, 0x91, 0x2d, 0x42)
0019 
0020 #define EFI32_LOADER_SIGNATURE  "EL32"
0021 #define EFI64_LOADER_SIGNATURE  "EL64"
0022 
0023 /*
0024  * Generic EFI table header
0025  */
0026 typedef struct {
0027     u64 signature;
0028     u32 revision;
0029     u32 headersize;
0030     u32 crc32;
0031     u32 reserved;
0032 } efi_table_hdr_t;
0033 
0034 #define EFI_CONVENTIONAL_MEMORY      7
0035 
0036 #define EFI_MEMORY_MORE_RELIABLE \
0037                 ((u64)0x0000000000010000ULL)    /* higher reliability */
0038 #define EFI_MEMORY_SP       ((u64)0x0000000000040000ULL)    /* soft reserved */
0039 
0040 #define EFI_PAGE_SHIFT      12
0041 
0042 typedef struct {
0043     u32 type;
0044     u32 pad;
0045     u64 phys_addr;
0046     u64 virt_addr;
0047     u64 num_pages;
0048     u64 attribute;
0049 } efi_memory_desc_t;
0050 
0051 #define efi_early_memdesc_ptr(map, desc_size, n)            \
0052     (efi_memory_desc_t *)((void *)(map) + ((n) * (desc_size)))
0053 
0054 typedef struct {
0055     efi_guid_t guid;
0056     u64 table;
0057 } efi_config_table_64_t;
0058 
0059 typedef struct {
0060     efi_guid_t guid;
0061     u32 table;
0062 } efi_config_table_32_t;
0063 
0064 typedef struct {
0065     efi_table_hdr_t hdr;
0066     u64 fw_vendor;  /* physical addr of CHAR16 vendor string */
0067     u32 fw_revision;
0068     u32 __pad1;
0069     u64 con_in_handle;
0070     u64 con_in;
0071     u64 con_out_handle;
0072     u64 con_out;
0073     u64 stderr_handle;
0074     u64 stderr;
0075     u64 runtime;
0076     u64 boottime;
0077     u32 nr_tables;
0078     u32 __pad2;
0079     u64 tables;
0080 } efi_system_table_64_t;
0081 
0082 typedef struct {
0083     efi_table_hdr_t hdr;
0084     u32 fw_vendor;  /* physical addr of CHAR16 vendor string */
0085     u32 fw_revision;
0086     u32 con_in_handle;
0087     u32 con_in;
0088     u32 con_out_handle;
0089     u32 con_out;
0090     u32 stderr_handle;
0091     u32 stderr;
0092     u32 runtime;
0093     u32 boottime;
0094     u32 nr_tables;
0095     u32 tables;
0096 } efi_system_table_32_t;
0097 
0098 /* kexec external ABI */
0099 struct efi_setup_data {
0100     u64 fw_vendor;
0101     u64 __unused;
0102     u64 tables;
0103     u64 smbios;
0104     u64 reserved[8];
0105 };
0106 
0107 static inline int efi_guidcmp (efi_guid_t left, efi_guid_t right)
0108 {
0109     return memcmp(&left, &right, sizeof (efi_guid_t));
0110 }
0111 
0112 #ifdef CONFIG_EFI
0113 bool __pure __efi_soft_reserve_enabled(void);
0114 
0115 static inline bool __pure efi_soft_reserve_enabled(void)
0116 {
0117     return IS_ENABLED(CONFIG_EFI_SOFT_RESERVE)
0118         && __efi_soft_reserve_enabled();
0119 }
0120 #else
0121 static inline bool efi_soft_reserve_enabled(void)
0122 {
0123     return false;
0124 }
0125 #endif /* CONFIG_EFI */
0126 #endif /* BOOT_COMPRESSED_EFI_H */