[PATCH 01/12] efi_loader: add runtime memset helper
Harsimran Singh Tungal
harsimransingh.tungal at arm.com
Fri Apr 24 19:31:40 CEST 2026
Add efi_memset_runtime() for EFI runtime paths
This keeps buffer initialization in runtime-resident code after
ExitBootServices() and avoids relying on non-runtime helpers.
Signed-off-by: Harsimran Singh Tungal <harsimransingh.tungal at arm.com>
---
include/efi_loader.h | 3 +++
lib/efi_loader/efi_runtime.c | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 3a4d502631c..63944192aeb 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -1151,6 +1151,9 @@ void efi_memcpy_runtime(void *dest, const void *src, size_t n);
/* runtime implementation of memcmp() */
int efi_memcmp_runtime(const void *s1, const void *s2, size_t n);
+/* runtime implementation of memset */
+__efi_runtime void *efi_memset_runtime(void *dest, int c, size_t n);
+
/* commonly used helper functions */
u16 *efi_create_indexed_name(u16 *buffer, size_t buffer_size, const char *name,
unsigned int index);
diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 73d4097464c..d9604399209 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -233,6 +233,27 @@ int __efi_runtime efi_memcmp_runtime(const void *s1, const void *s2, size_t n)
return 0;
}
+/**
+ * efi_memset_runtime() - fill a memory region with a byte value
+ *
+ * At runtime memset() is not available.
+ *
+ * @dest: pointer to the block of memory to fill.
+ * @c: value to be set. The value is passed as an int, but the
+ * function fills the block of memory using the u8 conversion of this value.
+ * @n: number of bytes to be set to the value.
+ * Return: dest is returned
+ */
+__efi_runtime void *efi_memset_runtime(void *dest, int c, size_t n)
+{
+ u8 *d = dest;
+
+ for (; n; --n)
+ *d++ = c;
+
+ return dest;
+}
+
/**
* efi_update_table_header_crc32() - Update crc32 in table header
*
--
2.34.1
More information about the U-Boot
mailing list