[PATCH 1/8] lib: sbi: add 64 bit csr macros
Radim Krčmář
rkrcmar at ventanamicro.com
Mon Apr 28 06:48:20 PDT 2025
2025-04-28T17:58:31+05:30, Anup Patel <anup at brainfault.org>:
> On Tue, Apr 15, 2025 at 8:13 PM Radim Krčmář <rkrcmar at ventanamicro.com> wrote:
>>
>> Most CSRs are XLEN bits wide, but some are 64 bit, so rv32 needs two
>> accesses, plaguing the code with ifdefs.
>>
>> Add new helpers that split 64 bit operation into two operations on rv32.
>>
>> The helpers don't use "csr + 0x10", but append "H" at the end of the csr
>> name to get a compile-time error when accessing a non 64 bit register.
>> This has the downside that you have to use the name when accessing them.
>> e.g. csr_read64(0x1234) or csr_read64(CSR_SATP) won't compile and the
>> error messages you get for these bugs are not straightforward.
>>
>> Signed-off-by: Radim Krčmář <rkrcmar at ventanamicro.com>
>> ---
>> diff --git a/include/sbi/riscv_asm.h b/include/sbi/riscv_asm.h
>> @@ -156,6 +156,27 @@
>> : "memory"); \
>> })
>>
>> +
>
> Redundant newline.
Oops, it will be gone in v2, thanks.
More information about the opensbi
mailing list