From 74a12ba59870df46a9ed6636a61796f911146a7c Mon Sep 17 00:00:00 2001 From: Nathaniel Graff Date: Wed, 21 Aug 2019 10:36:10 -0700 Subject: [PATCH] Don't call metal API in synchronize_harts() metal_cpu_get_current_hartid() might be in the ITIM and is not available at the time that synchronize_harts() is called. Use inline assembly instead Signed-off-by: Nathaniel Graff --- src/synchronize_harts.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/synchronize_harts.c b/src/synchronize_harts.c index 669590a1..b1548f9b 100644 --- a/src/synchronize_harts.c +++ b/src/synchronize_harts.c @@ -19,7 +19,9 @@ __attribute__((section(".init"))) void __metal_synchronize_harts() { #if __METAL_DT_MAX_HARTS > 1 - int hart = metal_cpu_get_current_hartid(); + int hart; + __asm__ volatile("csrr %0, mhartid" : "=r"(hart)::); + uintptr_t msip_base = 0; /* Get the base address of the MSIP registers */