diff options
author | Anup Patel <anup.patel@wdc.com> | 2020-03-12 10:21:25 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-03-13 12:22:02 +0530 |
commit | 823345ecaed0deb7770d9bac1c881004a6410e91 (patch) | |
tree | e3b71fb186be4bebd610e796cc12f2d3f33424e6 /include/sbi/riscv_asm.h | |
parent | 16e7071f6ddd5ba69d416b5a68e4aa191fc19d3b (diff) |
include: Make sbi_current_hartid() as macro in riscv_asm.h
The sbi_current_hartid() being a regular function is quite
expensive because for callers it is a function call instead
of a direct CSR read. This patch converts sbi_current_hartid()
into a macro in riscv_asm.h.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'include/sbi/riscv_asm.h')
-rw-r--r-- | include/sbi/riscv_asm.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/sbi/riscv_asm.h b/include/sbi/riscv_asm.h index 4445fa1..0d675f6 100644 --- a/include/sbi/riscv_asm.h +++ b/include/sbi/riscv_asm.h @@ -157,6 +157,8 @@ void csr_write_num(int csr_num, unsigned long val); __asm__ __volatile__("wfi" ::: "memory"); \ } while (0) +/* Get current HART id */ +#define current_hartid() ((unsigned int)csr_read(CSR_MHARTID)) /* determine CPU extension, return non-zero support */ int misa_extension_imp(char ext); |