From 74756891cc3524084add9879d451cd67bf446bd7 Mon Sep 17 00:00:00 2001 From: Anup Patel Date: Sat, 6 Feb 2021 14:48:56 +0530 Subject: lib: sbi: Implement SBI HSM suspend function This patch implements the SBI HSM suspend function. Using this new SBI call, the S-mode software can put calling HART in platform specific suspend (i.e. low-power) state. For a successful retentive suspend, the SBI call will return without errors upon resuming whereas for a successful non-retentive suspend, the SBI call will resume from a user provided resume address. Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- lib/sbi/sbi_ecall_hsm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/sbi/sbi_ecall_hsm.c') diff --git a/lib/sbi/sbi_ecall_hsm.c b/lib/sbi/sbi_ecall_hsm.c index 79a9f21..a339abf 100644 --- a/lib/sbi/sbi_ecall_hsm.c +++ b/lib/sbi/sbi_ecall_hsm.c @@ -22,14 +22,13 @@ static int sbi_ecall_hsm_handler(unsigned long extid, unsigned long funcid, unsigned long *out_val, struct sbi_trap_info *out_trap) { - ulong smode; int ret = 0; struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); + ulong smode = (csr_read(CSR_MSTATUS) & MSTATUS_MPP) >> + MSTATUS_MPP_SHIFT; switch (funcid) { case SBI_EXT_HSM_HART_START: - smode = csr_read(CSR_MSTATUS); - smode = (smode & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT; ret = sbi_hsm_hart_start(scratch, sbi_domain_thishart_ptr(), regs->a0, regs->a1, smode, regs->a2); break; @@ -40,6 +39,10 @@ static int sbi_ecall_hsm_handler(unsigned long extid, unsigned long funcid, ret = sbi_hsm_hart_get_state(sbi_domain_thishart_ptr(), regs->a0); break; + case SBI_EXT_HSM_HART_SUSPEND: + ret = sbi_hsm_hart_suspend(scratch, regs->a0, regs->a1, + smode, regs->a2); + break; default: ret = SBI_ENOTSUPP; }; -- cgit v1.2.3