diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2015-07-17 21:22:41 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-07-27 07:23:18 +0200 |
commit | ceb217682cefb8a06c729df00e5060f83731b820 (patch) | |
tree | 88dd61c33c4a5e5053643174fe84398ca97cf680 /arch/efi/efi | |
parent | 4faf797ec81291e9d76c6dc1a538987f170cff32 (diff) | |
download | barebox-ceb217682cefb8a06c729df00e5060f83731b820.tar.gz barebox-ceb217682cefb8a06c729df00e5060f83731b820.tar.xz |
efi: add helper functions to write EFI variables
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/efi/efi')
-rw-r--r-- | arch/efi/efi/efi.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/efi/efi/efi.c b/arch/efi/efi/efi.c index c05d183c02..b0e98f95b0 100644 --- a/arch/efi/efi/efi.c +++ b/arch/efi/efi/efi.c @@ -83,6 +83,33 @@ out: return buf; } +int efi_set_variable(char *name, efi_guid_t *vendor, uint32_t attributes, + void *buf, unsigned long size) +{ + efi_status_t efiret = EFI_SUCCESS; + s16 *name16 = strdup_char_to_wchar(name); + + efiret = RT->set_variable(name16, vendor, attributes, size, buf); + + free(name16); + + return -efi_errno(efiret); +} + +int efi_set_variable_usec(char *name, efi_guid_t *vendor, uint64_t usec) +{ + char buf[20]; + wchar_t buf16[40]; + + snprintf(buf, sizeof(buf), "%lld", usec); + strcpy_char_to_wchar(buf16, buf); + + return efi_set_variable(name, vendor, + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, buf16, + (strlen(buf)+1) * sizeof(wchar_t)); +} + struct efi_boot { u32 attributes; u16 file_path_len; |