mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Olbrich <m.olbrich@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Michael Olbrich <m.olbrich@pengutronix.de>
Subject: [PATCH 6/7] efi: add helper functions to write EFI variables
Date: Thu, 16 Jul 2015 10:43:55 +0200	[thread overview]
Message-ID: <1437036236-19096-7-git-send-email-m.olbrich@pengutronix.de> (raw)
In-Reply-To: <1437036236-19096-1-git-send-email-m.olbrich@pengutronix.de>

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
 arch/efi/efi/efi.c          | 27 +++++++++++++++++++++++++++
 arch/efi/include/mach/efi.h |  4 ++++
 2 files changed, 31 insertions(+)

diff --git a/arch/efi/efi/efi.c b/arch/efi/efi/efi.c
index c05d183c02fa..b0e98f95b02b 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;
diff --git a/arch/efi/include/mach/efi.h b/arch/efi/include/mach/efi.h
index 1e9782a136c2..2b25cf1868ad 100644
--- a/arch/efi/include/mach/efi.h
+++ b/arch/efi/include/mach/efi.h
@@ -21,4 +21,8 @@ static inline void *efi_get_global_var(char *name, int *var_size)
 	return efi_get_variable(name, &efi_global_variable_guid, var_size);
 }
 
+int efi_set_variable(char *name, efi_guid_t *vendor, uint32_t attributes,
+		     void *buf, unsigned long size);
+int efi_set_variable_usec(char *name, efi_guid_t *vendor, uint64_t usec);
+
 #endif /* __MACH_EFI_H */
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-07-16  8:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16  8:43 [PATCH 0/7] EFI updates Michael Olbrich
2015-07-16  8:43 ` [PATCH 1/7] efi: improve malloc pool allocation Michael Olbrich
2015-07-16  8:43 ` [PATCH 2/7] efi: refactor & improve application loading code Michael Olbrich
2015-07-16  8:43 ` [PATCH 3/7] efi: add support for initrd loading Michael Olbrich
2015-07-16  8:43 ` [PATCH 4/7] efi: add helper to get the GPT partition UUID for a device Michael Olbrich
2015-07-16  9:34   ` Marc Kleine-Budde
2015-07-16  9:43     ` Michael Olbrich
2015-07-16  8:43 ` [PATCH 5/7] efi: export device_path_from_handle() Michael Olbrich
2015-07-16  8:43 ` Michael Olbrich [this message]
2015-07-16  8:43 ` [PATCH 7/7] efi: write volatile EFI variables used by systemd Michael Olbrich
2015-07-16 20:08   ` Sascha Hauer
2015-07-17  7:05     ` Michael Olbrich
2015-07-17  7:19       ` Sascha Hauer

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=1437036236-19096-7-git-send-email-m.olbrich@pengutronix.de \
    --to=m.olbrich@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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