Created
July 16, 2019 21:49
-
-
Save nickdesaulniers/1b4853177ba67d9d918b3ae4a5c13f9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/arch/x86/purgatory/string.c b/arch/x86/purgatory/string.c | |
index 3cb67d44ca31..d2b2364ea2e8 100644 | |
--- a/arch/x86/purgatory/string.c | |
+++ b/arch/x86/purgatory/string.c | |
@@ -10,4 +10,27 @@ | |
#include <linux/types.h> | |
-#include "../boot/compressed/string.c" | |
+#include "../boot/string.c" | |
+ | |
+void *memcpy(void *dst, const void *src, size_t len) | |
+{ | |
+ asm( | |
+ "movq %0, %%rax\n\t" | |
+ "movq %2, %%rcx\n\t" | |
+ "rep movsb\n\t" | |
+ : "=r"(dst) : "r"(src), "ri"(len) : "rax", "rcx", "memory"); | |
+ return dst; | |
+} | |
+ | |
+void *memset(void *dst, int c, size_t len) | |
+{ | |
+ void* ret; | |
+ asm( | |
+ "movq %1, %%r8\n\t" | |
+ "movl %2, %%eax\n\t" | |
+ "movq %3, %%rcx\n\t" | |
+ "rep stosb\n\t" | |
+ "movq %%r8, %0" | |
+ : "=r"(ret) : "r"(dst), "ri"(c), "ri"(len) : "r8", "eax", "rcx", "memory"); | |
+ return ret; | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment