forked from Mirrors/opensbi
lib: Remove target_hart and hartid parameter from TIMER callbacks
The target_hart and hartid paramter of TIMER callbacks is not required because it always current hartid which can be obtained using sbi_current_hartid() API. Signed-off-by: Anup Patel <anup.patel@wdc.com>
This commit is contained in:
@@ -96,11 +96,11 @@ struct sbi_platform {
|
||||
/** Get MMIO timer value */
|
||||
u64 (*timer_value)(void);
|
||||
/** Start MMIO timer event for a target HART */
|
||||
void (*timer_event_start)(u32 target_hart, u64 next_event);
|
||||
void (*timer_event_start)(u64 next_event);
|
||||
/** Stop MMIO timer event for a target HART */
|
||||
void (*timer_event_stop)(u32 target_hart);
|
||||
void (*timer_event_stop)(void);
|
||||
/** Initialize MMIO timer for given HART */
|
||||
int (*timer_init)(u32 hartid, bool cold_boot);
|
||||
int (*timer_init)(bool cold_boot);
|
||||
|
||||
/** Reboot the platform */
|
||||
int (*system_reboot)(u32 type);
|
||||
@@ -393,44 +393,39 @@ static inline u64 sbi_platform_timer_value(struct sbi_platform *plat)
|
||||
* Start MMIO timer event for a target HART
|
||||
*
|
||||
* @param plat pointer to struct struct sbi_platform
|
||||
* @param target_hart HART ID of timer event target
|
||||
* @param next_event timer value when timer event will happen
|
||||
*/
|
||||
static inline void sbi_platform_timer_event_start(struct sbi_platform *plat,
|
||||
u32 target_hart,
|
||||
u64 next_event)
|
||||
{
|
||||
if (plat && plat->timer_event_start)
|
||||
plat->timer_event_start(target_hart, next_event);
|
||||
plat->timer_event_start(next_event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop MMIO timer event for a target HART
|
||||
*
|
||||
* @param plat pointer to struct sbi_platform
|
||||
* @param target_hart HART ID of timer event target
|
||||
*/
|
||||
static inline void sbi_platform_timer_event_stop(struct sbi_platform *plat,
|
||||
u32 target_hart)
|
||||
static inline void sbi_platform_timer_event_stop(struct sbi_platform *plat)
|
||||
{
|
||||
if (plat && plat->timer_event_stop)
|
||||
plat->timer_event_stop(target_hart);
|
||||
plat->timer_event_stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the platform MMIO timer for given HART
|
||||
*
|
||||
* @param plat pointer to struct sbi_platform
|
||||
* @param hartid HART ID
|
||||
* @param cold_boot whether cold boot (TRUE) or warm_boot (FALSE)
|
||||
*
|
||||
* @return 0 on success and negative error code on failure
|
||||
*/
|
||||
static inline int sbi_platform_timer_init(struct sbi_platform *plat,
|
||||
u32 hartid, bool cold_boot)
|
||||
bool cold_boot)
|
||||
{
|
||||
if (plat && plat->timer_init)
|
||||
return plat->timer_init(hartid, cold_boot);
|
||||
return plat->timer_init(cold_boot);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -16,14 +16,12 @@ struct sbi_scratch;
|
||||
|
||||
u64 sbi_timer_value(struct sbi_scratch *scratch);
|
||||
|
||||
void sbi_timer_event_stop(struct sbi_scratch *scratch, u32 hartid);
|
||||
void sbi_timer_event_stop(struct sbi_scratch *scratch);
|
||||
|
||||
void sbi_timer_event_start(struct sbi_scratch *scratch, u32 hartid,
|
||||
u64 next_event);
|
||||
void sbi_timer_event_start(struct sbi_scratch *scratch, u64 next_event);
|
||||
|
||||
void sbi_timer_process(struct sbi_scratch *scratch, u32 hartid);
|
||||
void sbi_timer_process(struct sbi_scratch *scratch);
|
||||
|
||||
int sbi_timer_init(struct sbi_scratch *scratch, u32 hartid,
|
||||
bool cold_boot);
|
||||
int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot);
|
||||
|
||||
#endif
|
||||
|
@@ -38,10 +38,10 @@ int sbi_ecall_handler(u32 hartid, ulong mcause,
|
||||
switch (regs->a7) {
|
||||
case SBI_ECALL_SET_TIMER:
|
||||
#if __riscv_xlen == 32
|
||||
sbi_timer_event_start(scratch, hartid,
|
||||
sbi_timer_event_start(scratch,
|
||||
(((u64)regs->a1 << 32) || (u64)regs->a0));
|
||||
#else
|
||||
sbi_timer_event_start(scratch, hartid, (u64)regs->a0);
|
||||
sbi_timer_event_start(scratch, (u64)regs->a0);
|
||||
#endif
|
||||
ret = 0;
|
||||
break;
|
||||
|
@@ -53,7 +53,7 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
||||
if (rc)
|
||||
sbi_hart_hang();
|
||||
|
||||
rc = sbi_timer_init(scratch, hartid, TRUE);
|
||||
rc = sbi_timer_init(scratch, TRUE);
|
||||
if (rc)
|
||||
sbi_hart_hang();
|
||||
|
||||
@@ -119,7 +119,7 @@ static void __noreturn init_warmboot(struct sbi_scratch *scratch, u32 hartid)
|
||||
if (rc)
|
||||
sbi_hart_hang();
|
||||
|
||||
rc = sbi_timer_init(scratch, hartid, FALSE);
|
||||
rc = sbi_timer_init(scratch, FALSE);
|
||||
if (rc)
|
||||
sbi_hart_hang();
|
||||
|
||||
|
@@ -47,29 +47,27 @@ u64 sbi_timer_value(struct sbi_scratch *scratch)
|
||||
return get_ticks();
|
||||
}
|
||||
|
||||
void sbi_timer_event_stop(struct sbi_scratch *scratch, u32 hartid)
|
||||
void sbi_timer_event_stop(struct sbi_scratch *scratch)
|
||||
{
|
||||
sbi_platform_timer_event_stop(sbi_platform_ptr(scratch), hartid);
|
||||
sbi_platform_timer_event_stop(sbi_platform_ptr(scratch));
|
||||
}
|
||||
|
||||
void sbi_timer_event_start(struct sbi_scratch *scratch, u32 hartid,
|
||||
u64 next_event)
|
||||
void sbi_timer_event_start(struct sbi_scratch *scratch, u64 next_event)
|
||||
{
|
||||
sbi_platform_timer_event_start(sbi_platform_ptr(scratch),
|
||||
hartid, next_event);
|
||||
next_event);
|
||||
csr_clear(mip, MIP_STIP);
|
||||
csr_set(mie, MIP_MTIP);
|
||||
}
|
||||
|
||||
void sbi_timer_process(struct sbi_scratch *scratch, u32 hartid)
|
||||
void sbi_timer_process(struct sbi_scratch *scratch)
|
||||
{
|
||||
csr_clear(mie, MIP_MTIP);
|
||||
csr_set(mip, MIP_STIP);
|
||||
}
|
||||
|
||||
int sbi_timer_init(struct sbi_scratch *scratch, u32 hartid,
|
||||
bool cold_boot)
|
||||
int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot)
|
||||
{
|
||||
return sbi_platform_timer_init(sbi_platform_ptr(scratch),
|
||||
hartid, cold_boot);
|
||||
cold_boot);
|
||||
}
|
||||
|
@@ -147,7 +147,7 @@ void sbi_trap_handler(struct sbi_trap_regs *regs,
|
||||
mcause &= ~(1UL << (__riscv_xlen - 1));
|
||||
switch (mcause) {
|
||||
case IRQ_M_TIMER:
|
||||
sbi_timer_process(scratch, hartid);
|
||||
sbi_timer_process(scratch);
|
||||
break;
|
||||
case IRQ_M_SOFT:
|
||||
sbi_ipi_process(scratch);
|
||||
|
@@ -24,11 +24,11 @@ int clint_cold_ipi_init(unsigned long base, u32 hart_count);
|
||||
|
||||
u64 clint_timer_value(void);
|
||||
|
||||
void clint_timer_event_stop(u32 target_hart);
|
||||
void clint_timer_event_stop(void);
|
||||
|
||||
void clint_timer_event_start(u32 target_hart, u64 next_event);
|
||||
void clint_timer_event_start(u64 next_event);
|
||||
|
||||
int clint_warm_timer_init(u32 target_hart);
|
||||
int clint_warm_timer_init(void);
|
||||
|
||||
int clint_cold_timer_init(unsigned long base, u32 hart_count);
|
||||
|
||||
|
@@ -90,8 +90,10 @@ u64 clint_timer_value(void)
|
||||
return readq_relaxed(clint_time_val);
|
||||
}
|
||||
|
||||
void clint_timer_event_stop(u32 target_hart)
|
||||
void clint_timer_event_stop(void)
|
||||
{
|
||||
u32 target_hart = sbi_current_hartid();
|
||||
|
||||
if (clint_time_hart_count <= target_hart)
|
||||
return;
|
||||
|
||||
@@ -99,8 +101,10 @@ void clint_timer_event_stop(u32 target_hart)
|
||||
writeq_relaxed(-1ULL, &clint_time_cmp[target_hart]);
|
||||
}
|
||||
|
||||
void clint_timer_event_start(u32 target_hart, u64 next_event)
|
||||
void clint_timer_event_start(u64 next_event)
|
||||
{
|
||||
u32 target_hart = sbi_current_hartid();
|
||||
|
||||
if (clint_time_hart_count <= target_hart)
|
||||
return;
|
||||
|
||||
@@ -108,8 +112,10 @@ void clint_timer_event_start(u32 target_hart, u64 next_event)
|
||||
writeq_relaxed(next_event, &clint_time_cmp[target_hart]);
|
||||
}
|
||||
|
||||
int clint_warm_timer_init(u32 target_hart)
|
||||
int clint_warm_timer_init(void)
|
||||
{
|
||||
u32 target_hart = sbi_current_hartid();
|
||||
|
||||
if (clint_time_hart_count <= target_hart ||
|
||||
!clint_time_base)
|
||||
return -1;
|
||||
|
@@ -68,7 +68,7 @@ static int k210_ipi_init(bool cold_boot)
|
||||
return clint_warm_ipi_init();
|
||||
}
|
||||
|
||||
static int k210_timer_init(u32 hartid, bool cold_boot)
|
||||
static int k210_timer_init(bool cold_boot)
|
||||
{
|
||||
int rc;
|
||||
|
||||
@@ -79,7 +79,7 @@ static int k210_timer_init(u32 hartid, bool cold_boot)
|
||||
return rc;
|
||||
}
|
||||
|
||||
return clint_warm_timer_init(hartid);
|
||||
return clint_warm_timer_init();
|
||||
}
|
||||
|
||||
static int k210_system_reboot(u32 type)
|
||||
|
@@ -105,7 +105,7 @@ static int sifive_u_ipi_init(bool cold_boot)
|
||||
return clint_warm_ipi_init();
|
||||
}
|
||||
|
||||
static int sifive_u_timer_init(u32 hartid, bool cold_boot)
|
||||
static int sifive_u_timer_init(bool cold_boot)
|
||||
{
|
||||
int rc;
|
||||
|
||||
@@ -116,7 +116,7 @@ static int sifive_u_timer_init(u32 hartid, bool cold_boot)
|
||||
return rc;
|
||||
}
|
||||
|
||||
return clint_warm_timer_init(hartid);
|
||||
return clint_warm_timer_init();
|
||||
}
|
||||
|
||||
static int sifive_u_system_down(u32 type)
|
||||
|
@@ -106,7 +106,7 @@ static int virt_ipi_init(bool cold_boot)
|
||||
return clint_warm_ipi_init();
|
||||
}
|
||||
|
||||
static int virt_timer_init(u32 hartid, bool cold_boot)
|
||||
static int virt_timer_init(bool cold_boot)
|
||||
{
|
||||
int rc;
|
||||
|
||||
@@ -117,7 +117,7 @@ static int virt_timer_init(u32 hartid, bool cold_boot)
|
||||
return rc;
|
||||
}
|
||||
|
||||
return clint_warm_timer_init(hartid);
|
||||
return clint_warm_timer_init();
|
||||
}
|
||||
|
||||
static int virt_system_down(u32 type)
|
||||
|
@@ -158,7 +158,7 @@ static int fu540_ipi_init(bool cold_boot)
|
||||
return clint_warm_ipi_init();
|
||||
}
|
||||
|
||||
static int fu540_timer_init(u32 hartid, bool cold_boot)
|
||||
static int fu540_timer_init(bool cold_boot)
|
||||
{
|
||||
int rc;
|
||||
|
||||
@@ -169,7 +169,7 @@ static int fu540_timer_init(u32 hartid, bool cold_boot)
|
||||
return rc;
|
||||
}
|
||||
|
||||
return clint_warm_timer_init(hartid);
|
||||
return clint_warm_timer_init();
|
||||
}
|
||||
|
||||
static int fu540_system_down(u32 type)
|
||||
|
Reference in New Issue
Block a user