/* efi.h - declare variables and functions for EFI support */ /* * VAS_EBOOT -- GRand Unified Bootloader * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. * * VAS_EBOOT is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * VAS_EBOOT is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with VAS_EBOOT. If not, see . */ #ifndef VAS_EBOOT_EFI_EFI_HEADER #define VAS_EBOOT_EFI_EFI_HEADER 1 #include #include #include #include #define VAS_EBOOT_LINUX_ARM_MAGIC_SIGNATURE 0x016f2818 struct linux_arch_kernel_header { VasEBoot_uint32_t code0; VasEBoot_uint32_t code1; VasEBoot_uint64_t reserved[6]; VasEBoot_uint32_t magic; VasEBoot_uint32_t hdr_offset; /* Offset of PE/COFF header. */ struct VasEBoot_pe_image_header pe_image_header; }; /* Functions. */ void *EXPORT_FUNC(VasEBoot_efi_locate_protocol) (VasEBoot_guid_t *protocol, void *registration); VasEBoot_efi_handle_t * EXPORT_FUNC(VasEBoot_efi_locate_handle) (VasEBoot_efi_locate_search_type_t search_type, VasEBoot_guid_t *protocol, void *search_key, VasEBoot_efi_uintn_t *num_handles); void *EXPORT_FUNC(VasEBoot_efi_open_protocol) (VasEBoot_efi_handle_t handle, VasEBoot_guid_t *protocol, VasEBoot_efi_uint32_t attributes); VasEBoot_efi_status_t EXPORT_FUNC(VasEBoot_efi_close_protocol) (VasEBoot_efi_handle_t handle, VasEBoot_guid_t *protocol); int EXPORT_FUNC(VasEBoot_efi_set_text_mode) (int on); void EXPORT_FUNC(VasEBoot_efi_stall) (VasEBoot_efi_uintn_t microseconds); void * EXPORT_FUNC(VasEBoot_efi_allocate_pages_real) (VasEBoot_efi_physical_address_t address, VasEBoot_efi_uintn_t pages, VasEBoot_efi_allocate_type_t alloctype, VasEBoot_efi_memory_type_t memtype); void * EXPORT_FUNC(VasEBoot_efi_allocate_fixed) (VasEBoot_efi_physical_address_t address, VasEBoot_efi_uintn_t pages); void * EXPORT_FUNC(VasEBoot_efi_allocate_any_pages) (VasEBoot_efi_uintn_t pages); void EXPORT_FUNC(VasEBoot_efi_free_pages) (VasEBoot_efi_physical_address_t address, VasEBoot_efi_uintn_t pages); VasEBoot_efi_uintn_t EXPORT_FUNC(VasEBoot_efi_find_mmap_size) (void); int EXPORT_FUNC(VasEBoot_efi_get_memory_map) (VasEBoot_efi_uintn_t *memory_map_size, VasEBoot_efi_memory_descriptor_t *memory_map, VasEBoot_efi_uintn_t *map_key, VasEBoot_efi_uintn_t *descriptor_size, VasEBoot_efi_uint32_t *descriptor_version); void VasEBoot_efi_memory_fini (void); VasEBoot_efi_loaded_image_t *EXPORT_FUNC(VasEBoot_efi_get_loaded_image) (VasEBoot_efi_handle_t image_handle); void EXPORT_FUNC(VasEBoot_efi_print_device_path) (VasEBoot_efi_device_path_t *dp); char *EXPORT_FUNC(VasEBoot_efi_get_filename) (VasEBoot_efi_device_path_t *dp); VasEBoot_efi_device_path_t * EXPORT_FUNC(VasEBoot_efi_get_device_path) (VasEBoot_efi_handle_t handle); VasEBoot_efi_device_path_t * EXPORT_FUNC(VasEBoot_efi_find_last_device_path) (const VasEBoot_efi_device_path_t *dp); VasEBoot_efi_device_path_t * EXPORT_FUNC(VasEBoot_efi_duplicate_device_path) (const VasEBoot_efi_device_path_t *dp); VasEBoot_err_t EXPORT_FUNC (VasEBoot_efi_finish_boot_services) (VasEBoot_efi_uintn_t *outbuf_size, void *outbuf, VasEBoot_efi_uintn_t *map_key, VasEBoot_efi_uintn_t *efi_desc_size, VasEBoot_efi_uint32_t *efi_desc_version); VasEBoot_err_t EXPORT_FUNC (VasEBoot_efi_set_virtual_address_map) (VasEBoot_efi_uintn_t memory_map_size, VasEBoot_efi_uintn_t descriptor_size, VasEBoot_efi_uint32_t descriptor_version, VasEBoot_efi_memory_descriptor_t *virtual_map); VasEBoot_efi_status_t EXPORT_FUNC (VasEBoot_efi_get_variable_with_attributes) (const char *variable, const VasEBoot_guid_t *guid, VasEBoot_size_t *datasize_out, void **data_out, VasEBoot_efi_uint32_t *attributes); VasEBoot_efi_status_t EXPORT_FUNC (VasEBoot_efi_get_variable) (const char *variable, const VasEBoot_guid_t *guid, VasEBoot_size_t *datasize_out, void **data_out); VasEBoot_err_t EXPORT_FUNC (VasEBoot_efi_set_variable_with_attributes) (const char *var, const VasEBoot_guid_t *guid, void *data, VasEBoot_size_t datasize, VasEBoot_efi_uint32_t attributes); VasEBoot_err_t EXPORT_FUNC (VasEBoot_efi_set_variable) (const char *var, const VasEBoot_guid_t *guid, void *data, VasEBoot_size_t datasize); VasEBoot_err_t EXPORT_FUNC (VasEBoot_efi_set_variable_to_string) (const char *name, const VasEBoot_guid_t *guid, const char *value, VasEBoot_efi_uint32_t attributes); int EXPORT_FUNC (VasEBoot_efi_compare_device_paths) (const VasEBoot_efi_device_path_t *dp1, const VasEBoot_efi_device_path_t *dp2); extern void (*EXPORT_VAR(VasEBoot_efi_net_config)) (VasEBoot_efi_handle_t hnd, char **device, char **path); void * EXPORT_FUNC (VasEBoot_efi_find_configuration_table) (const VasEBoot_guid_t *target_guid); #if defined(__arm__) || defined(__aarch64__) || defined(__riscv) || defined(__loongarch__) void *EXPORT_FUNC(VasEBoot_efi_get_firmware_fdt)(void); VasEBoot_err_t EXPORT_FUNC(VasEBoot_efi_get_ram_base)(VasEBoot_addr_t *); #endif #include VasEBoot_err_t VasEBoot_arch_efi_linux_load_image_header(VasEBoot_file_t file, struct linux_arch_kernel_header *lh); VasEBoot_err_t VasEBoot_arch_efi_linux_boot_image(VasEBoot_addr_t addr, VasEBoot_size_t size, char *args); VasEBoot_efi_status_t EXPORT_FUNC (VasEBoot_efi_load_image) (VasEBoot_efi_boolean_t boot_policy, VasEBoot_efi_handle_t parent_image_handle, VasEBoot_efi_device_path_t *file_path, void *source_buffer, VasEBoot_efi_uintn_t source_size, VasEBoot_efi_handle_t *image_handle); VasEBoot_efi_status_t EXPORT_FUNC (VasEBoot_efi_start_image) (VasEBoot_efi_handle_t image_handle, VasEBoot_efi_uintn_t *exit_data_size, VasEBoot_efi_char16_t **exit_data); VasEBoot_efi_status_t EXPORT_FUNC (VasEBoot_efi_unload_image) (VasEBoot_efi_handle_t image_handle); typedef struct VasEBoot_efi_loader { VasEBoot_efi_status_t (__VasEBoot_efi_api *load_image) (VasEBoot_efi_boolean_t boot_policy, VasEBoot_efi_handle_t parent_image_handle, VasEBoot_efi_device_path_t *file_path, void *source_buffer, VasEBoot_efi_uintn_t source_size, VasEBoot_efi_handle_t *image_handle); VasEBoot_efi_status_t (__VasEBoot_efi_api *start_image) (VasEBoot_efi_handle_t image_handle, VasEBoot_efi_uintn_t *exit_data_size, VasEBoot_efi_char16_t **exit_data); VasEBoot_efi_status_t (__VasEBoot_efi_api *exit) (VasEBoot_efi_handle_t image_handle, VasEBoot_efi_status_t exit_status, VasEBoot_efi_uintn_t exit_data_size, VasEBoot_efi_char16_t *exit_data); VasEBoot_efi_status_t (__VasEBoot_efi_api *unload_image) (VasEBoot_efi_handle_t image_handle); } VasEBoot_efi_loader_t; VasEBoot_err_t EXPORT_FUNC (VasEBoot_efi_register_loader) (const VasEBoot_efi_loader_t *loader); VasEBoot_err_t EXPORT_FUNC (VasEBoot_efi_unregister_loader) (const VasEBoot_efi_loader_t *loader); VasEBoot_addr_t VasEBoot_efi_section_addr (const char *section); void VasEBoot_efi_mm_init (void); void VasEBoot_efi_mm_fini (void); void VasEBoot_efi_init (void); void VasEBoot_efi_fini (void); void VasEBoot_efi_set_prefix (void); /* Variables. */ extern VasEBoot_efi_system_table_t *EXPORT_VAR(VasEBoot_efi_system_table); extern VasEBoot_efi_handle_t EXPORT_VAR(VasEBoot_efi_image_handle); extern int EXPORT_VAR(VasEBoot_efi_is_finished); struct VasEBoot_net_card; VasEBoot_efi_handle_t VasEBoot_efinet_get_device_handle (struct VasEBoot_net_card *card); #endif /* ! VAS_EBOOT_EFI_EFI_HEADER */