efi_loader: new function efi_memcpy_runtime()
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Sun, 28 Jun 2020 14:30:29 +0000 (16:30 +0200)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Sat, 11 Jul 2020 21:14:17 +0000 (23:14 +0200)
Provide a memcpy() function that we can use at UEFI runtime.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
include/efi_loader.h
lib/efi_loader/efi_runtime.c

index be6cede..9894464 100644 (file)
@@ -792,6 +792,9 @@ bool efi_secure_boot_enabled(void);
 bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp,
                     WIN_CERTIFICATE **auth, size_t *auth_len);
 
+/* runtime implementation of memcpy() */
+void efi_memcpy_runtime(void *dest, const void *src, size_t n);
+
 #else /* CONFIG_IS_ENABLED(EFI_LOADER) */
 
 /* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */
index a4aa1d8..5b6506f 100644 (file)
@@ -138,6 +138,25 @@ efi_status_t efi_init_runtime_supported(void)
 }
 
 /**
+ * efi_memcpy_runtime() - copy memory area
+ *
+ * At runtime memcpy() is not available.
+ *
+ * @dest:      destination buffer
+ * @src:       source buffer
+ * @n:         number of bytes to copy
+ * Return:     pointer to destination buffer
+ */
+void __efi_runtime efi_memcpy_runtime(void *dest, const void *src, size_t n)
+{
+       u8 *d = dest;
+       const u8 *s = src;
+
+       for (; n; --n)
+               *d++ = *s++;
+}
+
+/**
  * efi_update_table_header_crc32() - Update crc32 in table header
  *
  * @table:     EFI table