]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
riscv: implement local_irq_{save,restore} macros
authorBen Dooks <ben.dooks@sifive.com>
Fri, 5 May 2023 08:02:06 +0000 (09:02 +0100)
committerLeo Yu-Chi Liang <ycliang@andestech.com>
Thu, 6 Jul 2023 09:28:08 +0000 (17:28 +0800)
Add implementations of the local_irq_{save,restore} macros so that
<asm/atomic.h> can be used with riscv.

Signed-off-by: Ben Dooks <ben.dooks@sifive.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
arch/riscv/include/asm/system.h

index 9d8e43e394269883bec2883bb1e0e94334473419..ffa7649f3f9e16125d408b99c0b2afb6eb25454f 100644 (file)
@@ -7,15 +7,24 @@
 #ifndef __ASM_RISCV_SYSTEM_H
 #define __ASM_RISCV_SYSTEM_H
 
+#include <asm/csr.h>
+
 struct event;
 
 /*
- * Interrupt configuring macros.
- *
- * TODO
- *
+ * Interupt configuration macros
  */
 
+#define local_irq_save(__flags)                                 \
+    do {                                                        \
+        __flags = csr_read_clear(CSR_SSTATUS, SR_SIE) & SR_SIE; \
+    } while (0)
+
+#define local_irq_restore(__flags)              \
+    do {                                        \
+        csr_set(CSR_SSTATUS, __flags & SR_SIE); \
+    } while (0)
+
 /* Hook to set up the CPU (called from SPL too) */
 int riscv_cpu_setup(void *ctx, struct event *event);