mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Michael Olbrich <m.olbrich@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] efi: add more helper functions to write EFI variables
Date: Wed, 13 Dec 2023 07:47:41 +0100	[thread overview]
Message-ID: <20231213064741.GG1318922@pengutronix.de> (raw)
In-Reply-To: <20231206131145.3096043-1-m.olbrich@pengutronix.de>

On Wed, Dec 06, 2023 at 02:11:44PM +0100, Michael Olbrich wrote:
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> ---
>  common/efi/payload/init.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/common/efi/payload/init.c b/common/efi/payload/init.c
> index b990b54b2678..19be7ff07fb6 100644
> --- a/common/efi/payload/init.c
> +++ b/common/efi/payload/init.c
> @@ -107,6 +107,44 @@ int efi_set_variable_usec(char *name, efi_guid_t *vendor, uint64_t usec)
>  				(strlen(buf)+1) * sizeof(wchar_t));
>  }
>  
> +static int efi_set_variable_printf(char *name, efi_guid_t *vendor, const char *fmt, ...)
> +{
> +	va_list args;
> +	char *buf;
> +	wchar_t *buf16;
> +
> +	va_start(args, fmt);
> +	buf = xvasprintf(fmt, args);
> +	va_end(args);
> +	buf16 = xstrdup_char_to_wchar(buf);
> +
> +	return efi_set_variable(name, vendor,
> +				EFI_VARIABLE_BOOTSERVICE_ACCESS |
> +				EFI_VARIABLE_RUNTIME_ACCESS, buf16,
> +				(strlen(buf)+1) * sizeof(wchar_t));
> +	free(buf);
> +	free(buf16);
> +}
> +
> +static int efi_set_variable_uint64_le(char *name, efi_guid_t *vendor, uint64_t value)
> +{
> +	uint8_t buf[8];
> +
> +	buf[0] = (uint8_t)(value >> 0U & 0xFF);
> +	buf[1] = (uint8_t)(value >> 8U & 0xFF);
> +	buf[2] = (uint8_t)(value >> 16U & 0xFF);
> +	buf[3] = (uint8_t)(value >> 24U & 0xFF);
> +	buf[4] = (uint8_t)(value >> 32U & 0xFF);
> +	buf[5] = (uint8_t)(value >> 40U & 0xFF);
> +	buf[6] = (uint8_t)(value >> 48U & 0xFF);
> +	buf[7] = (uint8_t)(value >> 56U & 0xFF);
> +
> +	return efi_set_variable(name, vendor,
> +				EFI_VARIABLE_BOOTSERVICE_ACCESS |
> +				EFI_VARIABLE_RUNTIME_ACCESS, buf,
> +				sizeof(buf));
> +}
> +
>  struct efi_boot {
>  	u32 attributes;
>  	u16 file_path_len;
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      parent reply	other threads:[~2023-12-13  6:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06 13:11 Michael Olbrich
2023-12-06 13:11 ` [PATCH 2/2] efi: fill more EFI runtime variables defined by systemd Michael Olbrich
2023-12-13  6:47 ` Sascha Hauer [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=20231213064741.GG1318922@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.olbrich@pengutronix.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