diff options
author | Anup Patel <anup.patel@wdc.com> | 2021-02-06 12:18:56 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2021-03-03 11:21:15 +0300 |
commit | 74756891cc3524084add9879d451cd67bf446bd7 (patch) | |
tree | d7203cd1281640443a469c57f441a213eb431511 /lib/sbi/sbi_ecall_hsm.c | |
parent | 807d71c4ff11b8dd9a6366819314db704e0f6aca (diff) | |
download | opensbi-74756891cc3524084add9879d451cd67bf446bd7.tar.xz |
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_ecall_hsm.c')
-rw-r--r-- | lib/sbi/sbi_ecall_hsm.c | 9 |
1 files changed, 6 insertions, 3 deletions
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; }; |