From 50149ea37a21dcbed675297f1536c31a7db39c19 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Fri, 4 Mar 2016 01:10:01 +0100 Subject: efi_loader: Add runtime services After booting has finished, EFI allows firmware to still interact with the OS using the "runtime services". These callbacks live in a separate address space, since they are available long after U-Boot has been overwritten by the OS. This patch adds enough framework for arbitrary code inside of U-Boot to become a runtime service with the right section attributes set. For now, we don't make use of it yet though. We could maybe in the future map U-boot environment variables to EFI variables here. Signed-off-by: Alexander Graf Reviewed-by: Simon Glass Tested-by: Simon Glass --- include/efi_loader.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include/efi_loader.h') diff --git a/include/efi_loader.h b/include/efi_loader.h index d9e9d8f..8b3aadd 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -30,6 +30,7 @@ #define EFI_EXIT(ret) efi_exit_func(ret); +extern struct efi_runtime_services efi_runtime_services; extern struct efi_system_table systab; extern const struct efi_simple_text_output_protocol efi_con_out; @@ -40,6 +41,9 @@ extern const efi_guid_t efi_guid_console_control; extern const efi_guid_t efi_guid_device_path; extern const efi_guid_t efi_guid_loaded_image; +extern unsigned int __efi_runtime_start, __efi_runtime_stop; +extern unsigned int __efi_runtime_rel_start, __efi_runtime_rel_stop; + /* * While UEFI objects can have callbacks, you can also call functions on * protocols (classes) themselves. This struct maps a protocol GUID to its @@ -101,9 +105,22 @@ void efi_save_gd(void); void efi_restore_gd(void); /* Called from EFI_EXIT on callback exit to restore the gd register */ efi_status_t efi_exit_func(efi_status_t ret); +/* Call this to relocate the runtime section to an address space */ +void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map); + +/* + * Use these to indicate that your code / data should go into the EFI runtime + * section and thus still be available when the OS is running + */ +#define EFI_RUNTIME_DATA __attribute__ ((section ("efi_runtime_data"))) +#define EFI_RUNTIME_TEXT __attribute__ ((section ("efi_runtime_text"))) #else /* defined(EFI_LOADER) && !defined(CONFIG_SPL_BUILD) */ +/* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */ +#define EFI_RUNTIME_DATA +#define EFI_RUNTIME_TEXT + /* No loader configured, stub out EFI_ENTRY */ static inline void efi_restore_gd(void) { } -- cgit v1.1