public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Takahiro Akashi <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 1/1] efi_loader: add RuntimeServicesSupported variable
Date: Mon, 17 Jun 2019 11:09:38 +0900	[thread overview]
Message-ID: <20190617020937.GD6610@linaro.org> (raw)
In-Reply-To: <20190614163038.16029-1-xypron.glpk@gmx.de>

On Fri, Jun 14, 2019 at 06:30:38PM +0200, Heinrich Schuchardt wrote:
> From: AKASHI Takahiro <takahiro.akashi@linaro.org>
> 
> This variable is defined in UEFI specification 2.8, section 8.1.
> Its value should be updated whenever we add any usable runtime services
> function.
> 
> Currently we only support SetVirtualAddress() for all systems and
> ResetSystem() for some.
> 
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Please make clear who changed what.

> ---
> v4
> 	CONFIG_IS_ENABLED() wants Kconfig variables without CONFIG_ prefix.

This macro is intended for CONFIG_SPL_XXX as well.
For UEFI, however, we won't support UEFI in SPL.

-Takahiro Akashi

> v3
> 	Ensure that efi_runtime_services_supported is initialized.
> v2
> 	Currently we only support SetVirtualAddress() for all systems and
> 	ResetSystem() for some.
> ---
>  include/efi_api.h            | 15 +++++++++++++++
>  include/efi_loader.h         |  3 +++
>  lib/efi_loader/efi_runtime.c | 24 ++++++++++++++++++++++++
>  lib/efi_loader/efi_setup.c   |  5 +++++
>  4 files changed, 47 insertions(+)
> 
> diff --git a/include/efi_api.h b/include/efi_api.h
> index 65584dd2d8..d7d95edd4d 100644
> --- a/include/efi_api.h
> +++ b/include/efi_api.h
> @@ -213,6 +213,21 @@ struct efi_capsule_header {
>  	u32 capsule_image_size;
>  };
> 
> +#define EFI_RT_SUPPORTED_GET_TIME			0x0001
> +#define EFI_RT_SUPPORTED_SET_TIME			0x0002
> +#define EFI_RT_SUPPORTED_GET_WAKEUP_TIME		0x0004
> +#define EFI_RT_SUPPORTED_SET_WAKEUP_TIME		0x0008
> +#define EFI_RT_SUPPORTED_GET_VARIABLE			0x0010
> +#define EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME		0x0020
> +#define EFI_RT_SUPPORTED_SET_VARIABLE			0x0040
> +#define EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP	0x0080
> +#define EFI_RT_SUPPORTED_CONVERT_POINTER		0x0100
> +#define EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT	0x0200
> +#define EFI_RT_SUPPORTED_RESET_SYSTEM			0x0400
> +#define EFI_RT_SUPPORTED_UPDATE_CAPSULE			0x0800
> +#define EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES	0x1000
> +#define EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO		0x2000
> +
>  struct efi_runtime_services {
>  	struct efi_table_hdr hdr;
>  	efi_status_t (EFIAPI *get_time)(struct efi_time *time,
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index f0e1313f93..b07155cecb 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -573,6 +573,9 @@ static inline int guidcmp(const efi_guid_t *g1, const efi_guid_t *g2)
>  #define __efi_runtime_data __attribute__ ((section (".data.efi_runtime")))
>  #define __efi_runtime __attribute__ ((section (".text.efi_runtime")))
> 
> +/* Indicate supported runtime services */
> +efi_status_t efi_init_runtime_supported(void);
> +
>  /* Update CRC32 in table header */
>  void __efi_runtime efi_update_table_header_crc32(struct efi_table_hdr *table);
> 
> diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
> index 432551d0c8..0c57d0abd7 100644
> --- a/lib/efi_loader/efi_runtime.c
> +++ b/lib/efi_loader/efi_runtime.c
> @@ -89,6 +89,30 @@ struct elf_rela {
>   * handle a good number of runtime callbacks
>   */
> 
> +efi_status_t efi_init_runtime_supported(void)
> +{
> +	u16 efi_runtime_services_supported = 0;
> +
> +	/*
> +	 * This value must be synced with efi_runtime_detach_list
> +	 * as well as efi_runtime_services.
> +	 */
> +#if CONFIG_IS_ENABLED(ARCH_BCM283X) || \
> +    CONFIG_IS_ENABLED(FSL_LAYERSCAPE) || \
> +    CONFIG_IS_ENABLED(SYSRESET_X86) || \
> +    CONFIG_IS_ENABLED(PSCI_RESET)
> +	efi_runtime_services_supported |= EFI_RT_SUPPORTED_RESET_SYSTEM;
> +#endif
> +	efi_runtime_services_supported |=
> +				EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP;
> +	return EFI_CALL(efi_set_variable(L"RuntimeServicesSupported",
> +					 &efi_global_variable_guid,
> +					 EFI_VARIABLE_BOOTSERVICE_ACCESS |
> +					 EFI_VARIABLE_RUNTIME_ACCESS,
> +					 sizeof(efi_runtime_services_supported),
> +					 &efi_runtime_services_supported));
> +}
> +
>  /**
>   * efi_update_table_header_crc32() - Update crc32 in table header
>   *
> diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
> index 8691d686d2..bfb57836fa 100644
> --- a/lib/efi_loader/efi_setup.c
> +++ b/lib/efi_loader/efi_setup.c
> @@ -117,6 +117,11 @@ efi_status_t efi_init_obj_list(void)
>  	if (ret != EFI_SUCCESS)
>  		goto out;
> 
> +	/* Indicate supported runtime services */
> +	ret = efi_init_runtime_supported();
> +	if (ret != EFI_SUCCESS)
> +		goto out;
> +
>  	/* Initialize system table */
>  	ret = efi_initialize_system_table();
>  	if (ret != EFI_SUCCESS)
> --
> 2.20.1
> 

      reply	other threads:[~2019-06-17  2:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-14 16:30 [U-Boot] [PATCH v4 1/1] efi_loader: add RuntimeServicesSupported variable Heinrich Schuchardt
2019-06-17  2:09 ` Takahiro Akashi [this message]

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=20190617020937.GD6610@linaro.org \
    --to=takahiro.akashi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox