diff options
author | Ben Dooks <ben.dooks@sifive.com> | 2023-05-05 09:02:06 +0100 |
---|---|---|
committer | Leo Yu-Chi Liang <ycliang@andestech.com> | 2023-07-06 17:28:08 +0800 |
commit | 551de2169a49962f9d6c02ee3faa4ccc41f32107 (patch) | |
tree | 84cee76aef0b9e0a773c42c438063c6b7bd155f3 | |
parent | 3c874711ba2d66361b6040df48814be666aa6b1d (diff) | |
download | u-boot-551de2169a49962f9d6c02ee3faa4ccc41f32107.zip u-boot-551de2169a49962f9d6c02ee3faa4ccc41f32107.tar.gz u-boot-551de2169a49962f9d6c02ee3faa4ccc41f32107.tar.bz2 |
riscv: implement local_irq_{save,restore} macros
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>
-rw-r--r-- | arch/riscv/include/asm/system.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/arch/riscv/include/asm/system.h b/arch/riscv/include/asm/system.h index 9d8e43e..ffa7649 100644 --- a/arch/riscv/include/asm/system.h +++ b/arch/riscv/include/asm/system.h @@ -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); |