Skip to content

Commit

Permalink
<SiFive> Fixed error handling in platform timer
Browse files Browse the repository at this point in the history
- Minor bugfix in status check coreid

Issue: #237 #265
  • Loading branch information
akashkollipara committed Jan 1, 2024
1 parent ce87773 commit c42e1c4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/include/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ typedef enum status
} status_t;

#define STATUS_CHECK_POINTER(x) RET_ON_FAIL(x, error_inval_pointer)
#define STATUS_CHECK_COREID(x) RET_ON_FAIL((x <= N_CORES), error_system_inval_cpu)
#define STATUS_CHECK_COREID(x) RET_ON_FAIL((x < N_CORES), error_system_inval_cpu)
17 changes: 15 additions & 2 deletions src/platform/sifive/common_fe310/platform/plat_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <interrupt.h>
#include <visor_call.h>
#include <resource.h>
#include <platform.h>
#include <hal/clint.h>
#include <terravisor/timer.h>

Expand Down Expand Up @@ -50,7 +51,13 @@ static void plat_tmr_isr(void)
{
arch_di_mtime();
uint64_t t = clint_read_time();
clint_config_tcmp(arch_core_index(), (t + ticks));
status_t ret = clint_config_tcmp(arch_core_index(), (t + ticks));
if(ret)
{
syslog_stdout_enable();
syslog(fail, "Failed to configure timer, Err = %p\n", ret);
plat_panic_handler();
}
arch_ei_mtime();

if(tmr_cb != NULL)
Expand Down Expand Up @@ -119,7 +126,13 @@ static void plat_timer_set_period(unsigned int p)
ticks = plat_get_timer_ticks_msec(tm->clk);
ticks *= p;
nt = ticks + clint_read_time();
clint_config_tcmp(arch_core_index(), nt);
status_t ret = clint_config_tcmp(arch_core_index(), nt);
if(ret)
{
syslog_stdout_enable();
syslog(fail, "Failed to configure timer, Err = %p\n", ret);
plat_panic_handler();
}
arch_ei_mtime();
}

Expand Down

0 comments on commit c42e1c4

Please sign in to comment.