From: Leif Lindholm <leif.lindholm@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 06/14] efi_loader: Add runtime services
Date: Thu, 21 Jan 2016 17:20:18 +0000 [thread overview]
Message-ID: <20160121172018.GD25034@bivouac.eciton.net> (raw)
In-Reply-To: <1452834380-164453-7-git-send-email-agraf@suse.de>
On Fri, Jan 15, 2016 at 06:06:12AM +0100, Alexander Graf wrote:
> 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 <agraf@suse.de>
Just a couple of return value issues:
> ---
>
> v1 -> v2:
>
> - Fix runtime service sections
> - Add runtime detach
> - Enable runtime relocations
> - Add get_time
> - Fix relocation
> - Fix 32bit
> - Add am335x support
> - Move section definition to header
> - Add systab to runtime section
> - Add self-relocation hook table
> - Fix self-relocation
> - Relocate efi_runtime section early during bootup
> - Fix return values for a number of callbacks to be more UEFI compliant
> - Move to GPLv2+
> ---
> arch/arm/config.mk | 4 +
> arch/arm/cpu/armv8/u-boot.lds | 16 +++
> arch/arm/cpu/u-boot.lds | 30 +++++
> arch/arm/lib/sections.c | 4 +
> board/ti/am335x/u-boot.lds | 30 +++++
> common/board_r.c | 4 +
> include/efi_loader.h | 10 ++
> lib/efi_loader/efi_boottime.c | 6 +-
> lib/efi_loader/efi_runtime.c | 300 ++++++++++++++++++++++++++++++++++++++++++
> 9 files changed, 401 insertions(+), 3 deletions(-)
> create mode 100644 lib/efi_loader/efi_runtime.c
>
...
> diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
> new file mode 100644
> index 0000000..b7aa1e9
> --- /dev/null
> +++ b/lib/efi_loader/efi_runtime.c
> @@ -0,0 +1,300 @@
> +/*
> + * EFI application runtime services
> + *
> + * Copyright (c) 2016 Alexander Graf
> + *
> + * SPDX-License-Identifier: GPL-2.0+
> + */
> +
> +#include <common.h>
> +#include <efi_loader.h>
> +#include <command.h>
> +#include <asm/global_data.h>
> +#include <rtc.h>
> +
> +/* For manual relocation support */
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +static efi_status_t EFI_RUNTIME_TEXT efi_unimplemented(void);
> +static efi_status_t EFI_RUNTIME_TEXT efi_device_error(void);
> +static efi_status_t EFI_RUNTIME_TEXT efi_invalid_parameter(void);
> +
> +#if defined(CONFIG_ARM64)
> +#define R_RELATIVE 1027
> +#define R_MASK 0xffffffffULL
> +#define IS_RELA 1
> +#elif defined(CONFIG_ARM)
> +#define R_RELATIVE 23
> +#define R_MASK 0xffULL
> +#else
> +#error Need to add relocation awareness
> +#endif
> +
> +struct elf_rel {
> + ulong *offset;
> + ulong info;
> +};
> +
> +struct elf_rela {
> + ulong *offset;
> + ulong info;
> + long addend;
> +};
> +
> +/*
> + * EFI Runtime code lives in 2 stages. In the first stage, U-Boot and an EFI
> + * payload are running concurrently at the same time. In this mode, we can
> + * handle a good number of runtime callbacks
> + */
> +
> +static void efi_reset_system(enum efi_reset_type reset_type,
> + efi_status_t reset_status, unsigned long data_size,
> + void *reset_data)
> +{
> + EFI_ENTRY("%d %lx %lx %p", reset_type, reset_status, data_size, reset_data);
> +
> + switch (reset_type) {
> + case EFI_RESET_COLD:
> + case EFI_RESET_WARM:
> + do_reset(NULL, 0, 0, NULL);
> + break;
> + case EFI_RESET_SHUTDOWN:
> + /* We don't have anything to map this to */
> + break;
> + }
> +
> + EFI_EXIT(EFI_SUCCESS);
> +}
> +
> +static efi_status_t efi_get_time(struct efi_time *time,
> + struct efi_time_cap *capabilities)
> +{
> +#ifdef CONFIG_CMD_DATE
> +
> + struct rtc_time tm;
> + int r;
> +#ifdef CONFIG_DM_RTC
> + struct udevice *dev;
> +#endif
> +
> + EFI_ENTRY("%p %p", time, capabilities);
> +
> +#ifdef CONFIG_DM_RTC
> + r = uclass_get_device(UCLASS_RTC, 0, &dev);
> + if (r)
> + return EFI_EXIT(EFI_UNSUPPORTED);
EFI_DEVICE_ERROR?
> +#endif
> +
> +#ifdef CONFIG_DM_RTC
> + r = dm_rtc_get(dev, &tm);
> +#else
> + r = rtc_get(&tm);
> +#endif
> + if (r)
> + return EFI_EXIT(EFI_UNSUPPORTED);
EFI_DEVICE_ERROR?
> +
> + memset(time, 0, sizeof(*time));
> + time->year = tm.tm_year;
> + time->month = tm.tm_mon;
> + time->day = tm.tm_mday;
> + time->hour = tm.tm_hour;
> + time->minute = tm.tm_min;
> + time->daylight = tm.tm_isdst;
> +
> + return EFI_EXIT(EFI_SUCCESS);
> +
> +#else /* CONFIG_CMD_DATE */
> +
> + return EFI_DEVICE_ERROR;
> +
> +#endif /* CONFIG_CMD_DATE */
> +}
next prev parent reply other threads:[~2016-01-21 17:20 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-15 5:06 [U-Boot] [PATCH 00/14] EFI payload / application support v2 Alexander Graf
2016-01-15 5:06 ` [U-Boot] [PATCH 01/14] disk/part.c: Expose list of available block drivers Alexander Graf
2016-01-15 5:06 ` [U-Boot] [PATCH 02/14] include/efi_api.h: Add more detailed API definitions Alexander Graf
2016-01-31 15:17 ` Simon Glass
2016-02-01 22:46 ` Alexander Graf
2016-01-15 5:06 ` [U-Boot] [PATCH 03/14] efi_loader: Add PE image loader Alexander Graf
2016-01-31 15:18 ` Simon Glass
2016-02-01 22:58 ` Alexander Graf
2016-01-15 5:06 ` [U-Boot] [PATCH 04/14] efi_loader: Add boot time services Alexander Graf
2016-01-20 0:16 ` Leif Lindholm
2016-02-02 1:52 ` Alexander Graf
2016-01-31 15:19 ` Simon Glass
2016-02-01 23:45 ` Alexander Graf
2016-02-01 23:54 ` Simon Glass
2016-02-02 0:02 ` Alexander Graf
2016-01-15 5:06 ` [U-Boot] [PATCH 05/14] efi_loader: Add console interface Alexander Graf
2016-01-31 15:19 ` Simon Glass
2016-01-15 5:06 ` [U-Boot] [PATCH 06/14] efi_loader: Add runtime services Alexander Graf
2016-01-21 17:20 ` Leif Lindholm [this message]
2016-01-31 15:20 ` Simon Glass
2016-02-01 23:57 ` Alexander Graf
2016-01-15 5:06 ` [U-Boot] [PATCH 07/14] efi_loader: Add disk interfaces Alexander Graf
2016-01-31 15:23 ` Simon Glass
2016-02-02 0:32 ` Alexander Graf
2016-01-15 5:06 ` [U-Boot] [PATCH 08/14] efi_loader: Add "bootefi" command Alexander Graf
2016-01-31 15:23 ` Simon Glass
2016-01-15 5:06 ` [U-Boot] [PATCH 09/14] efi_loader: Implement memory allocation and map Alexander Graf
2016-01-31 15:23 ` Simon Glass
2016-02-02 0:59 ` Alexander Graf
2016-01-15 5:06 ` [U-Boot] [PATCH 10/14] arm64: Allow exceptions to return Alexander Graf
2016-01-15 5:06 ` [U-Boot] [PATCH 11/14] arm64: Allow EFI payload code to take exceptions Alexander Graf
2016-01-15 5:06 ` [U-Boot] [PATCH 12/14] efi_loader: Add DCACHE_OFF support for arm64 Alexander Graf
2016-01-15 5:06 ` [U-Boot] [PATCH 13/14] efi_loader: hook up in build environment Alexander Graf
2016-01-31 15:24 ` Simon Glass
2016-01-15 5:06 ` [U-Boot] [PATCH 14/14] efi_loader: Add distro boot script for removable media Alexander Graf
2016-01-31 15:24 ` Simon Glass
2016-02-02 1:05 ` Alexander Graf
2016-01-31 15:17 ` [U-Boot] [PATCH 00/14] EFI payload / application support v2 Simon Glass
2016-01-31 21:43 ` Alexander Graf
2016-02-01 2:52 ` Simon Glass
2016-02-01 3:25 ` Simon Glass
2016-02-01 21:38 ` Alexander Graf
2016-02-02 0:02 ` Simon Glass
2016-02-02 0:16 ` Alexander Graf
2016-02-02 0:28 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160121172018.GD25034@bivouac.eciton.net \
--to=leif.lindholm@linaro.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.