diff options
author | Atish Patra <atish.patra@wdc.com> | 2020-02-11 17:32:38 -0800 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-02-24 18:11:47 +0530 |
commit | 5b4824082ff8826f77d6bc670e16068d0744ff7f (patch) | |
tree | c044271e32aef84c7fbac8b5bd762f7009d61eae /lib/sbi/sbi_hsm.c | |
parent | b677a9b8d641f1c16a4f8f52e00019a9bc747893 (diff) |
lib: Add possible hart status values
SBI HSM extension defines possible hart status values in the
specification.
Define all possible status values. Add a helper function to
convert hart state to status because hart states are internal
to OpenSBI only and may not match the status values defined in
the specification.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_hsm.c')
-rw-r--r-- | lib/sbi/sbi_hsm.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index f3207ee..36fafed 100644 --- a/lib/sbi/sbi_hsm.c +++ b/lib/sbi/sbi_hsm.c @@ -14,6 +14,7 @@ #include <sbi/sbi_bits.h> #include <sbi/sbi_console.h> #include <sbi/sbi_error.h> +#include <sbi/sbi_ecall_interface.h> #include <sbi/sbi_hart.h> #include <sbi/sbi_hsm.h> #include <sbi/sbi_init.h> @@ -30,6 +31,30 @@ struct sbi_hsm_data { atomic_t state; }; +int sbi_hsm_hart_state_to_status(int state) +{ + int ret; + + switch (state) { + case SBI_HART_STOPPED: + ret = SBI_HSM_HART_STATUS_STOPPED; + break; + case SBI_HART_STOPPING: + ret = SBI_HSM_HART_STATUS_STOP_PENDING; + break; + case SBI_HART_STARTING: + ret = SBI_HSM_HART_STATUS_START_PENDING; + break; + case SBI_HART_STARTED: + ret = SBI_HSM_HART_STATUS_STARTED; + break; + default: + ret = SBI_EINVAL; + } + + return ret; +} + int sbi_hsm_hart_get_state(struct sbi_scratch *scratch, u32 hartid) { struct sbi_hsm_data *hdata; |