diff options
author | Mitchell Horne <mhorne@FreeBSD.org> | 2020-05-01 21:55:51 +0000 |
---|---|---|
committer | Mitchell Horne <mhorne@FreeBSD.org> | 2020-05-01 21:55:51 +0000 |
commit | bfe918fa0e72d54ec25357dc8874101a49cc242b (patch) | |
tree | 129e374021642904dc9cef331516dee09f43bac5 /sys/riscv/include/sbi.h | |
parent | df62bf00a5798041e4dc3dc37f831d998a631372 (diff) | |
download | src-bfe918fa0e72d54ec25357dc8874101a49cc242b.tar.gz src-bfe918fa0e72d54ec25357dc8874101a49cc242b.zip |
Add support for HSM SBI extension
The Hardware State Management (HSM) extension provides a set of SBI
calls that allow the supervisor software to start and stop hart
execution.
The HSM extension has been implemented in OpenSBI and is present in
the v0.7 release.
[1] https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc
Reviewed by: br
Differential Revision: https://reviews.freebsd.org/D24496
Notes
Notes:
svn path=/head/; revision=360552
Diffstat (limited to 'sys/riscv/include/sbi.h')
-rw-r--r-- | sys/riscv/include/sbi.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sys/riscv/include/sbi.h b/sys/riscv/include/sbi.h index 308359c0675b..1c09dc47f1e6 100644 --- a/sys/riscv/include/sbi.h +++ b/sys/riscv/include/sbi.h @@ -55,6 +55,7 @@ #define SBI_ERR_INVALID_PARAM -3 #define SBI_ERR_DENIED -4 #define SBI_ERR_INVALID_ADDRESS -5 +#define SBI_ERR_ALREADY_AVAILABLE -6 /* SBI Base Extension */ #define SBI_EXT_ID_BASE 0x10 @@ -66,6 +67,16 @@ #define SBI_BASE_GET_MARCHID 5 #define SBI_BASE_GET_MIMPID 6 +/* Hart State Management (HSM) Extension */ +#define SBI_EXT_ID_HSM 0x48534D +#define SBI_HSM_HART_START 0 +#define SBI_HSM_HART_STOP 1 +#define SBI_HSM_HART_STATUS 2 +#define SBI_HSM_STATUS_STARTED 0 +#define SBI_HSM_STATUS_STOPPED 1 +#define SBI_HSM_STATUS_START_PENDING 2 +#define SBI_HSM_STATUS_STOP_PENDING 3 + /* Legacy Extensions */ #define SBI_SET_TIMER 0 #define SBI_CONSOLE_PUTCHAR 1 @@ -128,6 +139,30 @@ sbi_probe_extension(long id) return (SBI_CALL1(SBI_EXT_ID_BASE, SBI_BASE_PROBE_EXTENSION, id).value); } +/* Hart State Management extension functions. */ + +/* + * Start execution on the specified hart at physical address start_addr. The + * register a0 will contain the hart's ID, and a1 will contain the value of + * priv. + */ +int sbi_hsm_hart_start(u_long hart, u_long start_addr, u_long priv); + +/* + * Stop execution on the current hart. Interrupts should be disabled, or this + * function may return. + */ +void sbi_hsm_hart_stop(void); + +/* + * Get the execution status of the specified hart. The status will be one of: + * - SBI_HSM_STATUS_STARTED + * - SBI_HSM_STATUS_STOPPED + * - SBI_HSM_STATUS_START_PENDING + * - SBI_HSM_STATUS_STOP_PENDING + */ +int sbi_hsm_hart_status(u_long hart); + /* Legacy extension functions. */ static __inline void sbi_console_putchar(int ch) |