linux/include/linux/efi.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_EFI_H
#define _LINUX_EFI_H

/*
 * Extensible Firmware Interface
 * Based on 'Extensible Firmware Interface Specification' version 0.9, April 30, 1999
 *
 * Copyright (C) 1999 VA Linux Systems
 * Copyright (C) 1999 Walt Drummond <[email protected]>
 * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co.
 *	David Mosberger-Tang <[email protected]>
 *	Stephane Eranian <[email protected]>
 */
#include <linux/init.h>
#include <linux/string.h>
#include <linux/time.h>
#include <linux/types.h>
#include <linux/proc_fs.h>
#include <linux/rtc.h>
#include <linux/ioport.h>
#include <linux/pfn.h>
#include <linux/pstore.h>
#include <linux/range.h>
#include <linux/reboot.h>
#include <linux/uuid.h>

#include <asm/page.h>

struct screen_info;

#define EFI_SUCCESS
#define EFI_LOAD_ERROR
#define EFI_INVALID_PARAMETER
#define EFI_UNSUPPORTED
#define EFI_BAD_BUFFER_SIZE
#define EFI_BUFFER_TOO_SMALL
#define EFI_NOT_READY
#define EFI_DEVICE_ERROR
#define EFI_WRITE_PROTECTED
#define EFI_OUT_OF_RESOURCES
#define EFI_NOT_FOUND
#define EFI_ACCESS_DENIED
#define EFI_TIMEOUT
#define EFI_ABORTED
#define EFI_SECURITY_VIOLATION

efi_status_t;
efi_bool_t;
efi_char16_t;		/* UNICODE character */
efi_physical_addr_t;
efi_handle_t;

#if defined(CONFIG_X86_64)
#define __efiapi
#elif defined(CONFIG_X86_32)
#define __efiapi
#else
#define __efiapi
#endif

/*
 * The UEFI spec and EDK2 reference implementation both define EFI_GUID as
 * struct { u32 a; u16; b; u16 c; u8 d[8]; }; and so the implied alignment
 * is 32 bits not 8 bits like our guid_t. In some cases (i.e., on 32-bit ARM),
 * this means that firmware services invoked by the kernel may assume that
 * efi_guid_t* arguments are 32-bit aligned, and use memory accessors that
 * do not tolerate misalignment. So let's set the minimum alignment to 32 bits.
 *
 * Note that the UEFI spec as well as some comments in the EDK2 code base
 * suggest that EFI_GUID should be 64-bit aligned, but this appears to be
 * a mistake, given that no code seems to exist that actually enforces that
 * or relies on it.
 */
efi_guid_t __aligned();

#define EFI_GUID(a, b, c, d...)

/*
 * Generic EFI table header
 */
efi_table_hdr_t;

/*
 * Memory map descriptor:
 */

/* Memory types: */
#define EFI_RESERVED_TYPE
#define EFI_LOADER_CODE
#define EFI_LOADER_DATA
#define EFI_BOOT_SERVICES_CODE
#define EFI_BOOT_SERVICES_DATA
#define EFI_RUNTIME_SERVICES_CODE
#define EFI_RUNTIME_SERVICES_DATA
#define EFI_CONVENTIONAL_MEMORY
#define EFI_UNUSABLE_MEMORY
#define EFI_ACPI_RECLAIM_MEMORY
#define EFI_ACPI_MEMORY_NVS
#define EFI_MEMORY_MAPPED_IO
#define EFI_MEMORY_MAPPED_IO_PORT_SPACE
#define EFI_PAL_CODE
#define EFI_PERSISTENT_MEMORY
#define EFI_UNACCEPTED_MEMORY
#define EFI_MAX_MEMORY_TYPE

/* Attribute values: */
#define EFI_MEMORY_UC
#define EFI_MEMORY_WC
#define EFI_MEMORY_WT
#define EFI_MEMORY_WB
#define EFI_MEMORY_UCE
#define EFI_MEMORY_WP
#define EFI_MEMORY_RP
#define EFI_MEMORY_XP
#define EFI_MEMORY_NV
#define EFI_MEMORY_MORE_RELIABLE
#define EFI_MEMORY_RO
#define EFI_MEMORY_SP
#define EFI_MEMORY_CPU_CRYPTO
#define EFI_MEMORY_RUNTIME
#define EFI_MEMORY_DESCRIPTOR_VERSION

#define EFI_PAGE_SHIFT
#define EFI_PAGE_SIZE
#define EFI_PAGES_MAX

efi_memory_desc_t;

efi_capsule_header_t;

/* EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER */
struct efi_manage_capsule_header {} __packed;

/* EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER */
struct efi_manage_capsule_image_header {} __packed;

/* WIN_CERTIFICATE */
struct win_cert {};

/* WIN_CERTIFICATE_UEFI_GUID */
struct win_cert_uefi_guid {};

/* EFI_FIRMWARE_IMAGE_AUTHENTICATION */
struct efi_image_auth {};

/*
 * EFI capsule flags
 */
#define EFI_CAPSULE_PERSIST_ACROSS_RESET
#define EFI_CAPSULE_POPULATE_SYSTEM_TABLE
#define EFI_CAPSULE_INITIATE_RESET

struct capsule_info {};

int efi_capsule_setup_info(struct capsule_info *cap_info, void *kbuff,
                           size_t hdr_bytes);
int __efi_capsule_setup_info(struct capsule_info *cap_info);

/*
 * Types and defines for Time Services
 */
#define EFI_TIME_ADJUST_DAYLIGHT
#define EFI_TIME_IN_DAYLIGHT
#define EFI_UNSPECIFIED_TIMEZONE

efi_time_t;

efi_time_cap_t;

efi_boot_services_t;

/*
 * Types and defines for EFI ResetSystem
 */
#define EFI_RESET_COLD
#define EFI_RESET_WARM
#define EFI_RESET_SHUTDOWN

/*
 * EFI Runtime Services table
 */
#define EFI_RUNTIME_SERVICES_SIGNATURE
#define EFI_RUNTIME_SERVICES_REVISION

efi_runtime_services_32_t;

efi_get_time_t;
efi_set_time_t;
efi_get_wakeup_time_t;
efi_set_wakeup_time_t;
efi_get_variable_t;
efi_get_next_variable_t;
efi_set_variable_t;
efi_get_next_high_mono_count_t;
efi_reset_system_t;
efi_set_virtual_address_map_t;
efi_query_variable_info_t;
efi_update_capsule_t;
efi_query_capsule_caps_t;
efi_query_variable_store_t;

efi_runtime_services_t;

void efi_native_runtime_setup(void);

/*
 * EFI Configuration Table and GUID definitions
 *
 * These are all defined in a single line to make them easier to
 * grep for and to see them at a glance - while still having a
 * similar structure to the definitions in the spec.
 *
 * Here's how they are structured:
 *
 * GUID: 12345678-1234-1234-1234-123456789012
 * Spec:
 *      #define EFI_SOME_PROTOCOL_GUID \
 *        {0x12345678,0x1234,0x1234,\
 *          {0x12,0x34,0x12,0x34,0x56,0x78,0x90,0x12}}
 * Here:
 *	#define SOME_PROTOCOL_GUID		EFI_GUID(0x12345678, 0x1234, 0x1234,  0x12, 0x34, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12)
 *					^ tabs					    ^extra space
 *
 * Note that the 'extra space' separates the values at the same place
 * where the UEFI SPEC breaks the line.
 */
#define NULL_GUID
#define ACPI_TABLE_GUID
#define ACPI_20_TABLE_GUID
#define SMBIOS_TABLE_GUID
#define SMBIOS3_TABLE_GUID
#define UGA_IO_PROTOCOL_GUID
#define EFI_GLOBAL_VARIABLE_GUID
#define UV_SYSTEM_TABLE_GUID
#define LINUX_EFI_CRASH_GUID
#define LOADED_IMAGE_PROTOCOL_GUID
#define LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID
#define EFI_DEVICE_PATH_PROTOCOL_GUID
#define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID
#define EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID
#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID
#define EFI_UGA_PROTOCOL_GUID
#define EFI_PCI_IO_PROTOCOL_GUID
#define EFI_FILE_INFO_ID
#define EFI_SYSTEM_RESOURCE_TABLE_GUID
#define EFI_FILE_SYSTEM_GUID
#define DEVICE_TREE_GUID
#define EFI_PROPERTIES_TABLE_GUID
#define EFI_RNG_PROTOCOL_GUID
#define EFI_RNG_ALGORITHM_RAW
#define EFI_MEMORY_ATTRIBUTES_TABLE_GUID
#define EFI_CONSOLE_OUT_DEVICE_GUID
#define APPLE_PROPERTIES_PROTOCOL_GUID
#define APPLE_SET_OS_PROTOCOL_GUID
#define EFI_TCG2_PROTOCOL_GUID
#define EFI_TCG2_FINAL_EVENTS_TABLE_GUID
#define EFI_LOAD_FILE_PROTOCOL_GUID
#define EFI_LOAD_FILE2_PROTOCOL_GUID
#define EFI_RT_PROPERTIES_TABLE_GUID
#define EFI_DXE_SERVICES_TABLE_GUID
#define EFI_SMBIOS_PROTOCOL_GUID
#define EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID

#define EFI_IMAGE_SECURITY_DATABASE_GUID
#define EFI_SHIM_LOCK_GUID

#define EFI_CERT_SHA256_GUID
#define EFI_CERT_X509_GUID
#define EFI_CERT_X509_SHA256_GUID
#define EFI_CC_BLOB_GUID
#define EFI_CC_MEASUREMENT_PROTOCOL_GUID
#define EFI_CC_FINAL_EVENTS_TABLE_GUID

/*
 * This GUID is used to pass to the kernel proper the struct screen_info
 * structure that was populated by the stub based on the GOP protocol instance
 * associated with ConOut
 */
#define LINUX_EFI_SCREEN_INFO_TABLE_GUID
#define LINUX_EFI_ARM_CPU_STATE_TABLE_GUID
#define LINUX_EFI_LOADER_ENTRY_GUID
#define LINUX_EFI_RANDOM_SEED_TABLE_GUID
#define LINUX_EFI_TPM_EVENT_LOG_GUID
#define LINUX_EFI_MEMRESERVE_TABLE_GUID
#define LINUX_EFI_INITRD_MEDIA_GUID
#define LINUX_EFI_MOK_VARIABLE_TABLE_GUID
#define LINUX_EFI_COCO_SECRET_AREA_GUID
#define LINUX_EFI_BOOT_MEMMAP_GUID
#define LINUX_EFI_UNACCEPTED_MEM_TABLE_GUID

#define RISCV_EFI_BOOT_PROTOCOL_GUID

/*
 * This GUID may be installed onto the kernel image's handle as a NULL protocol
 * to signal to the stub that the placement of the image should be respected,
 * and moving the image in physical memory is undesirable. To ensure
 * compatibility with 64k pages kernels with virtually mapped stacks, and to
 * avoid defeating physical randomization, this protocol should only be
 * installed if the image was placed at a randomized 128k aligned address in
 * memory.
 */
#define LINUX_EFI_LOADED_IMAGE_FIXED_GUID

/* OEM GUIDs */
#define DELLEMC_EFI_RCI2_TABLE_GUID
#define AMD_SEV_MEM_ENCRYPT_GUID

/* OVMF protocol GUIDs */
#define OVMF_SEV_MEMORY_ACCEPTANCE_PROTOCOL_GUID

efi_config_table_64_t;

efi_config_table_32_t;

efi_config_table_t;

efi_config_table_type_t;

#define EFI_SYSTEM_TABLE_SIGNATURE
#define EFI_DXE_SERVICES_TABLE_SIGNATURE

#define EFI_2_30_SYSTEM_TABLE_REVISION
#define EFI_2_20_SYSTEM_TABLE_REVISION
#define EFI_2_10_SYSTEM_TABLE_REVISION
#define EFI_2_00_SYSTEM_TABLE_REVISION
#define EFI_1_10_SYSTEM_TABLE_REVISION
#define EFI_1_02_SYSTEM_TABLE_REVISION

efi_system_table_64_t;

efi_system_table_32_t;

efi_simple_text_input_protocol_t;
efi_simple_text_output_protocol_t;

efi_system_table_t;

struct efi_boot_memmap {};

struct efi_unaccepted_memory {};

/*
 * Architecture independent structure for describing a memory map for the
 * benefit of efi_memmap_init_early(), and for passing context between
 * efi_memmap_alloc() and efi_memmap_install().
 */
struct efi_memory_map_data {};

struct efi_memory_map {};

struct efi_mem_range {};

efi_properties_table_t;

#define EFI_PROPERTIES_TABLE_VERSION
#define EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA

efi_rt_properties_table_t;

#define EFI_RT_PROPERTIES_TABLE_VERSION

#define EFI_INVALID_TABLE_ADDR

// BIT0 implies that Runtime code includes the forward control flow guard
// instruction, such as X86 CET-IBT or ARM BTI.
#define EFI_MEMORY_ATTRIBUTES_FLAGS_RT_FORWARD_CONTROL_FLOW_GUARD

efi_memory_attributes_table_t;

efi_signature_data_t;

efi_signature_list_t;

efi_sha256_hash_t;

efi_cert_x509_sha256_t;

extern unsigned long __ro_after_init efi_rng_seed;		/* RNG Seed table */

/*
 * All runtime access to EFI goes through this structure:
 */
extern struct efi {} efi;

#define EFI_RT_SUPPORTED_GET_TIME
#define EFI_RT_SUPPORTED_SET_TIME
#define EFI_RT_SUPPORTED_GET_WAKEUP_TIME
#define EFI_RT_SUPPORTED_SET_WAKEUP_TIME
#define EFI_RT_SUPPORTED_GET_VARIABLE
#define EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME
#define EFI_RT_SUPPORTED_SET_VARIABLE
#define EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP
#define EFI_RT_SUPPORTED_CONVERT_POINTER
#define EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT
#define EFI_RT_SUPPORTED_RESET_SYSTEM
#define EFI_RT_SUPPORTED_UPDATE_CAPSULE
#define EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES
#define EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO

#define EFI_RT_SUPPORTED_ALL

#define EFI_RT_SUPPORTED_TIME_SERVICES
#define EFI_RT_SUPPORTED_WAKEUP_SERVICES
#define EFI_RT_SUPPORTED_VARIABLE_SERVICES

extern struct mm_struct efi_mm;

static inline bool mm_is_efi(struct mm_struct *mm)
{}

static inline int
efi_guidcmp (efi_guid_t left, efi_guid_t right)
{}

static inline char *
efi_guid_to_str(efi_guid_t *guid, char *out)
{}

extern void efi_init (void);
extern void efi_earlycon_reprobe(void);
#ifdef CONFIG_EFI
extern void efi_enter_virtual_mode (void);	/* switch EFI to virtual mode, if possible */
#else
static inline void efi_enter_virtual_mode (void) {}
#endif
#ifdef CONFIG_X86
extern efi_status_t efi_query_variable_store(u32 attributes,
					     unsigned long size,
					     bool nonblocking);
#else

static inline efi_status_t efi_query_variable_store(u32 attributes,
						    unsigned long size,
						    bool nonblocking)
{
	return EFI_SUCCESS;
}
#endif

extern int __init __efi_memmap_init(struct efi_memory_map_data *data);
extern int __init efi_memmap_init_early(struct efi_memory_map_data *data);
extern int __init efi_memmap_init_late(phys_addr_t addr, unsigned long size);
extern void __init efi_memmap_unmap(void);

#ifdef CONFIG_EFI_ESRT
extern void __init efi_esrt_init(void);
#else
static inline void efi_esrt_init(void) { }
#endif
extern int efi_config_parse_tables(const efi_config_table_t *config_tables,
				   int count,
				   const efi_config_table_type_t *arch_tables);
extern int efi_systab_check_header(const efi_table_hdr_t *systab_hdr);
extern void efi_systab_report_header(const efi_table_hdr_t *systab_hdr,
				     unsigned long fw_vendor);
extern u64 efi_get_iobase (void);
extern int efi_mem_type(unsigned long phys_addr);
extern u64 efi_mem_attributes (unsigned long phys_addr);
extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size);
extern int __init efi_uart_console_only (void);
extern u64 efi_mem_desc_end(efi_memory_desc_t *md);
extern int efi_mem_desc_lookup(u64 phys_addr, efi_memory_desc_t *out_md);
extern int __efi_mem_desc_lookup(u64 phys_addr, efi_memory_desc_t *out_md);
extern void efi_mem_reserve(phys_addr_t addr, u64 size);
extern int efi_mem_reserve_persistent(phys_addr_t addr, u64 size);
extern void efi_initialize_iomem_resources(struct resource *code_resource,
		struct resource *data_resource, struct resource *bss_resource);
extern u64 efi_get_fdt_params(struct efi_memory_map_data *data);
extern struct kobject *efi_kobj;

extern int efi_reboot_quirk_mode;
extern bool efi_poweroff_required(void);

extern unsigned long efi_mem_attr_table;

/*
 * efi_memattr_perm_setter - arch specific callback function passed into
 *                           efi_memattr_apply_permissions() that updates the
 *                           mapping permissions described by the second
 *                           argument in the page tables referred to by the
 *                           first argument.
 */
efi_memattr_perm_setter;

extern int efi_memattr_init(void);
extern int efi_memattr_apply_permissions(struct mm_struct *mm,
					 efi_memattr_perm_setter fn);

/*
 * efi_memdesc_ptr - get the n-th EFI memmap descriptor
 * @map: the start of efi memmap
 * @desc_size: the size of space for each EFI memmap descriptor
 * @n: the index of efi memmap descriptor
 *
 * EFI boot service provides the GetMemoryMap() function to get a copy of the
 * current memory map which is an array of memory descriptors, each of
 * which describes a contiguous block of memory. It also gets the size of the
 * map, and the size of each descriptor, etc.
 *
 * Note that per section 6.2 of UEFI Spec 2.6 Errata A, the returned size of
 * each descriptor might not be equal to sizeof(efi_memory_memdesc_t),
 * since efi_memory_memdesc_t may be extended in the future. Thus the OS
 * MUST use the returned size of the descriptor to find the start of each
 * efi_memory_memdesc_t in the memory map array. This should only be used
 * during bootup since for_each_efi_memory_desc_xxx() is available after the
 * kernel initializes the EFI subsystem to set up struct efi_memory_map.
 */
#define efi_memdesc_ptr(map, desc_size, n)

/* Iterate through an efi_memory_map */
#define for_each_efi_memory_desc_in_map(m, md)

/**
 * for_each_efi_memory_desc - iterate over descriptors in efi.memmap
 * @md: the efi_memory_desc_t * iterator
 *
 * Once the loop finishes @md must not be accessed.
 */
#define for_each_efi_memory_desc(md)

/*
 * Format an EFI memory descriptor's type and attributes to a user-provided
 * character buffer, as per snprintf(), and return the buffer.
 */
char * __init efi_md_typeattr_format(char *buf, size_t size,
				     const efi_memory_desc_t *md);


efi_element_handler_t;
extern int __init parse_efi_signature_list(
	const char *source,
	const void *data, size_t size,
	efi_element_handler_t (*get_handler_for_guid)(const efi_guid_t *));

/**
 * efi_range_is_wc - check the WC bit on an address range
 * @start: starting kvirt address
 * @len: length of range
 *
 * Consult the EFI memory map and make sure it's ok to set this range WC.
 * Returns true or false.
 */
static inline int efi_range_is_wc(unsigned long start, unsigned long len)
{}

/*
 * We play games with efi_enabled so that the compiler will, if
 * possible, remove EFI-related code altogether.
 */
#define EFI_BOOT
#define EFI_CONFIG_TABLES
#define EFI_RUNTIME_SERVICES
#define EFI_MEMMAP
#define EFI_64BIT
#define EFI_PARAVIRT
#define EFI_ARCH_1
#define EFI_DBG
#define EFI_NX_PE_DATA
#define EFI_MEM_ATTR
#define EFI_MEM_NO_SOFT_RESERVE
#define EFI_PRESERVE_BS_REGIONS

#ifdef CONFIG_EFI
/*
 * Test whether the above EFI_* bits are enabled.
 */
static inline bool efi_enabled(int feature)
{}
extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused);

bool __pure __efi_soft_reserve_enabled(void);

static inline bool __pure efi_soft_reserve_enabled(void)
{}

static inline bool efi_rt_services_supported(unsigned int mask)
{}
extern void efi_find_mirror(void);
#else
static inline bool efi_enabled(int feature)
{
	return false;
}
static inline void
efi_reboot(enum reboot_mode reboot_mode, const char *__unused) {}

static inline bool efi_soft_reserve_enabled(void)
{
	return false;
}

static inline bool efi_rt_services_supported(unsigned int mask)
{
	return false;
}

static inline void efi_find_mirror(void) {}
#endif

extern int efi_status_to_err(efi_status_t status);

/*
 * Variable Attributes
 */
#define EFI_VARIABLE_NON_VOLATILE
#define EFI_VARIABLE_BOOTSERVICE_ACCESS
#define EFI_VARIABLE_RUNTIME_ACCESS
#define EFI_VARIABLE_HARDWARE_ERROR_RECORD
#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
#define EFI_VARIABLE_APPEND_WRITE

#define EFI_VARIABLE_MASK
/*
 * Length of a GUID string (strlen("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"))
 * not including trailing NUL
 */
#define EFI_VARIABLE_GUID_LEN

/*
 * EFI Device Path information
 */
#define EFI_DEV_HW
#define EFI_DEV_PCI
#define EFI_DEV_PCCARD
#define EFI_DEV_MEM_MAPPED
#define EFI_DEV_VENDOR
#define EFI_DEV_CONTROLLER
#define EFI_DEV_ACPI
#define EFI_DEV_BASIC_ACPI
#define EFI_DEV_EXPANDED_ACPI
#define EFI_DEV_MSG
#define EFI_DEV_MSG_ATAPI
#define EFI_DEV_MSG_SCSI
#define EFI_DEV_MSG_FC
#define EFI_DEV_MSG_1394
#define EFI_DEV_MSG_USB
#define EFI_DEV_MSG_USB_CLASS
#define EFI_DEV_MSG_I20
#define EFI_DEV_MSG_MAC
#define EFI_DEV_MSG_IPV4
#define EFI_DEV_MSG_IPV6
#define EFI_DEV_MSG_INFINIBAND
#define EFI_DEV_MSG_UART
#define EFI_DEV_MSG_VENDOR
#define EFI_DEV_MEDIA
#define EFI_DEV_MEDIA_HARD_DRIVE
#define EFI_DEV_MEDIA_CDROM
#define EFI_DEV_MEDIA_VENDOR
#define EFI_DEV_MEDIA_FILE
#define EFI_DEV_MEDIA_PROTOCOL
#define EFI_DEV_MEDIA_REL_OFFSET
#define EFI_DEV_BIOS_BOOT
#define EFI_DEV_END_PATH
#define EFI_DEV_END_PATH2
#define EFI_DEV_END_INSTANCE
#define EFI_DEV_END_ENTIRE

struct efi_generic_dev_path {} __packed;

struct efi_acpi_dev_path {} __packed;

struct efi_pci_dev_path {} __packed;

struct efi_vendor_dev_path {} __packed;

struct efi_rel_offset_dev_path {} __packed;

struct efi_mem_mapped_dev_path {} __packed;

struct efi_file_path_dev_path {} __packed;

struct efi_dev_path {} __packed;

struct device *efi_get_device_by_path(const struct efi_dev_path **node,
				      size_t *len);

static inline void memrange_efi_to_native(u64 *addr, u64 *npages)
{}

/*
 * EFI Variable support.
 *
 * Different firmware drivers can expose their EFI-like variables using
 * the following.
 */

struct efivar_operations {};

struct efivars {};

#ifdef CONFIG_X86
u64 __attribute_const__ efivar_reserved_space(void);
#else
static inline u64 efivar_reserved_space(void) { return 0; }
#endif

/*
 * There is no actual upper limit specified for the variable name size.
 *
 * This limit exists only for practical purposes, since name conversions
 * are bounds-checked and name data is occasionally stored in-line.
 */
#define EFI_VAR_NAME_LEN

int efivars_register(struct efivars *efivars,
		     const struct efivar_operations *ops);
int efivars_unregister(struct efivars *efivars);

#ifdef CONFIG_EFI
bool efivar_is_available(void);
#else
static inline bool efivar_is_available(void) { return false; }
#endif

bool efivar_supports_writes(void);

int efivar_lock(void);
int efivar_trylock(void);
void efivar_unlock(void);

efi_status_t efivar_get_variable(efi_char16_t *name, efi_guid_t *vendor,
				 u32 *attr, unsigned long *size, void *data);

efi_status_t efivar_get_next_variable(unsigned long *name_size,
				      efi_char16_t *name, efi_guid_t *vendor);

efi_status_t efivar_set_variable_locked(efi_char16_t *name, efi_guid_t *vendor,
					u32 attr, unsigned long data_size,
					void *data, bool nonblocking);

efi_status_t efivar_set_variable(efi_char16_t *name, efi_guid_t *vendor,
				 u32 attr, unsigned long data_size, void *data);

efi_status_t efivar_query_variable_info(u32 attr, u64 *storage_space,
					u64 *remaining_space,
					u64 *max_variable_size);

#if IS_ENABLED(CONFIG_EFI_CAPSULE_LOADER)
extern bool efi_capsule_pending(int *reset_type);

extern int efi_capsule_supported(efi_guid_t guid, u32 flags,
				 size_t size, int *reset);

extern int efi_capsule_update(efi_capsule_header_t *capsule,
			      phys_addr_t *pages);
#else
static inline bool efi_capsule_pending(int *reset_type) { return false; }
#endif

#ifdef CONFIG_EFI
extern bool efi_runtime_disabled(void);
#else
static inline bool efi_runtime_disabled(void) { return true; }
#endif

extern void efi_call_virt_check_flags(unsigned long flags, const void *caller);
extern unsigned long efi_call_virt_save_flags(void);

enum efi_secureboot_mode {};

static inline
enum efi_secureboot_mode efi_get_secureboot_mode(efi_get_variable_t *get_var)
{}

#ifdef CONFIG_EFI_EMBEDDED_FIRMWARE
void efi_check_for_embedded_firmwares(void);
#else
static inline void efi_check_for_embedded_firmwares(void) { }
#endif

#define arch_efi_call_virt(p, f, args...)

/*
 * Arch code must implement the following three routines:
 *
 *  * arch_efi_call_virt_setup()
 *
 *    Sets up the environment for the call (e.g. switching page tables,
 *    allowing kernel-mode use of floating point, if required).
 *
 *  * arch_efi_call_virt()
 *
 *    Performs the call. This routine takes a variable number of arguments so
 *    it must be implemented as a variadic preprocessor macro.
 *
 *  * arch_efi_call_virt_teardown()
 *
 *    Restores the usual kernel environment once the call has returned.
 */

#define efi_call_virt_pointer(p, f, args...)

#define EFI_RANDOM_SEED_SIZE

struct linux_efi_random_seed {};

struct linux_efi_tpm_eventlog {};

extern int efi_tpm_eventlog_init(void);

struct efi_tcg2_final_events_table {};
extern int efi_tpm_final_log_size;

extern unsigned long rci2_table_phys;

efi_status_t
efi_call_acpi_prm_handler(efi_status_t (__efiapi *handler_addr)(u64, void *),
			  u64 param_buffer_addr, void *context);

/*
 * efi_runtime_service() function identifiers.
 * "NONE" is used by efi_recover_from_page_fault() to check if the page
 * fault happened while executing an efi runtime service.
 */
enum efi_rts_ids {};

efi_rts_args;

/*
 * efi_runtime_work:	Details of EFI Runtime Service work
 * @args:		Pointer to union describing the arguments
 * @status:		Status of executing EFI Runtime Service
 * @efi_rts_id:		EFI Runtime Service function identifier
 * @efi_rts_comp:	Struct used for handling completions
 * @caller:		The caller of the runtime service
 */
struct efi_runtime_work {};

extern struct efi_runtime_work efi_rts_work;

/* Workqueue to queue EFI Runtime Services */
extern struct workqueue_struct *efi_rts_wq;

struct linux_efi_memreserve {};

#define EFI_MEMRESERVE_COUNT(size)

void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size);

char *efi_systab_show_arch(char *str);

/*
 * The LINUX_EFI_MOK_VARIABLE_TABLE_GUID config table can be provided
 * to the kernel by an EFI boot loader. The table contains a packed
 * sequence of these entries, one for each named MOK variable.
 * The sequence is terminated by an entry with a completely NULL
 * name and 0 data size.
 */
struct efi_mokvar_table_entry {} __attribute((packed));

#ifdef CONFIG_LOAD_UEFI_KEYS
extern void __init efi_mokvar_table_init(void);
extern struct efi_mokvar_table_entry *efi_mokvar_entry_next(
			struct efi_mokvar_table_entry **mokvar_entry);
extern struct efi_mokvar_table_entry *efi_mokvar_entry_find(const char *name);
#else
static inline void efi_mokvar_table_init(void) { }
static inline struct efi_mokvar_table_entry *efi_mokvar_entry_next(
			struct efi_mokvar_table_entry **mokvar_entry)
{
	return NULL;
}
static inline struct efi_mokvar_table_entry *efi_mokvar_entry_find(
			const char *name)
{
	return NULL;
}
#endif

extern void efifb_setup_from_dmi(struct screen_info *si, const char *opt);

struct linux_efi_coco_secret_area {};

struct linux_efi_initrd {};

/* Header of a populated EFI secret area */
#define EFI_SECRET_TABLE_HEADER_GUID

bool xen_efi_config_table_is_usable(const efi_guid_t *guid, unsigned long table);

static inline
bool efi_config_table_is_usable(const efi_guid_t *guid, unsigned long table)
{}

umode_t efi_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n);

/*
 * efivar ops event type
 */
#define EFIVAR_OPS_RDONLY
#define EFIVAR_OPS_RDWR

extern struct blocking_notifier_head efivar_ops_nh;

void efivars_generic_ops_register(void);
void efivars_generic_ops_unregister(void);

#endif /* _LINUX_EFI_H */