Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Apr 2019 05:37:18 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r346345 - in head/stand/efi: include libefi
Message-ID:  <201904180537.x3I5bIDQ082996@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Thu Apr 18 05:37:18 2019
New Revision: 346345
URL: https://svnweb.freebsd.org/changeset/base/346345

Log:
  Add a more generic efi_setenv function.
  
  efi_setenv allows any UEFI variable to be set.

Modified:
  head/stand/efi/include/efilib.h
  head/stand/efi/libefi/efienv.c

Modified: head/stand/efi/include/efilib.h
==============================================================================
--- head/stand/efi/include/efilib.h	Thu Apr 18 02:54:07 2019	(r346344)
+++ head/stand/efi/include/efilib.h	Thu Apr 18 05:37:18 2019	(r346345)
@@ -125,6 +125,7 @@ void cpy16to8(const CHAR16 *, char *, size_t);
 EFI_STATUS efi_freebsd_getenv(const char *v, void *data, __size_t *len);
 EFI_STATUS efi_getenv(EFI_GUID *g, const char *v, void *data, __size_t *len);
 EFI_STATUS efi_global_getenv(const char *v, void *data, __size_t *len);
+EFI_STATUS efi_setenv(EFI_GUID *guid, const char *varname, UINT32 attr, void *data, __size_t len);
 EFI_STATUS efi_setenv_freebsd_wcs(const char *varname, CHAR16 *valstr);
 
 /* guids and names */

Modified: head/stand/efi/libefi/efienv.c
==============================================================================
--- head/stand/efi/libefi/efienv.c	Thu Apr 18 02:54:07 2019	(r346344)
+++ head/stand/efi/libefi/efienv.c	Thu Apr 18 05:37:18 2019	(r346345)
@@ -68,6 +68,25 @@ efi_freebsd_getenv(const char *v, void *data, size_t *
 	return (efi_getenv(&FreeBSDBootVarGUID, v, data, len));
 }
 
+/*
+ * efi_setenv -- Sets an env variable.
+ */
+EFI_STATUS
+efi_setenv(EFI_GUID *guid, const char *varname, UINT32 attr, void *data, __size_t len)
+{
+	EFI_STATUS rv;
+	CHAR16 *uv;
+	size_t ul;
+
+	uv = NULL;
+	if (utf8_to_ucs2(varname, &uv, &ul) != 0)
+		return (EFI_OUT_OF_RESOURCES);
+
+	rv = RS->SetVariable(uv, guid, attr, len, data);
+	free(uv);
+	return (rv);
+}
+
 EFI_STATUS
 efi_setenv_freebsd_wcs(const char *varname, CHAR16 *valstr)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904180537.x3I5bIDQ082996>