forked from Mirrors/opensbi
lib: Emit lr and sc instructions based on -march flags
When -march=rv64im_zalrsc_zicsr is used, provide atomic operations and locks using lr and sc instructions only. Signed-off-by: Chao-ying Fu <cfu@mips.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20250226014727.19710-1-cfu@mips.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -59,8 +59,18 @@ _try_lottery:
|
||||
/* Jump to relocation wait loop if we don't get relocation lottery */
|
||||
lla a6, _boot_lottery
|
||||
li a7, BOOT_LOTTERY_ACQUIRED
|
||||
#ifdef __riscv_atomic
|
||||
amoswap.w a6, a7, (a6)
|
||||
bnez a6, _wait_for_boot_hart
|
||||
#elif __riscv_zalrsc
|
||||
_sc_fail:
|
||||
lr.w t0, (a6)
|
||||
sc.w t1, a7, (a6)
|
||||
bnez t1, _sc_fail
|
||||
bnez t0, _wait_for_boot_hart
|
||||
#else
|
||||
#error "need a or zalrsc"
|
||||
#endif
|
||||
|
||||
/* relocate the global table content */
|
||||
li t0, FW_TEXT_START /* link start */
|
||||
|
Reference in New Issue
Block a user