Skip to content

Instantly share code, notes, and snippets.

@jmontleon
Created June 24, 2024 18:35
Show Gist options
  • Save jmontleon/47a77854849f20d89ae054d5ca37ccf4 to your computer and use it in GitHub Desktop.
Save jmontleon/47a77854849f20d89ae054d5ca37ccf4 to your computer and use it in GitHub Desktop.
diff --git a/lib/Makefile b/lib/Makefile
index db9fa63..8a1aef4 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -60,6 +60,10 @@ FILES += $(ARCH)/uldiv $(ARCH)/ldivmod $(ARCH)/div $(ARCH)/llsl $(ARCH)/llsr \
$(ARCH)/mullu
endif
+ifeq ($(ARCH),riscv64)
+FILES += $(ARCH)/cache
+endif
+
OBJS = $(FILES:%=%.o) ctors.o
SUBDIRS = ia32 x86_64 ia64 aarch64 arm mips64el riscv64 loongarch64 runtime
diff --git a/lib/riscv64/cache.S b/lib/riscv64/cache.S
new file mode 100644
index 0000000..f1f5050
--- /dev/null
+++ b/lib/riscv64/cache.S
@@ -0,0 +1,10 @@
+#include "edk2asm.h"
+
+ .file "cache.S"
+ .text
+
+GCC_ASM_EXPORT(__riscv_flush_icache)
+
+ASM_PFX(__riscv_flush_icache):
+ fence.i
+ ret
diff --git a/lib/riscv64/edk2asm.h b/lib/riscv64/edk2asm.h
new file mode 100644
index 0000000..9515eaf
--- /dev/null
+++ b/lib/riscv64/edk2asm.h
@@ -0,0 +1,6 @@
+
+#define ASM_PFX(x) x
+#define GCC_ASM_EXPORT(x) \
+ .globl x ; \
+ .type x, %function
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment