Page MenuHomeFreeBSD

D24496.diff
No OneTemporary

D24496.diff

Index: head/sys/riscv/include/sbi.h
===================================================================
--- head/sys/riscv/include/sbi.h
+++ head/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
@@ -127,6 +138,30 @@
{
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
Index: head/sys/riscv/riscv/sbi.c
===================================================================
--- head/sys/riscv/riscv/sbi.c
+++ head/sys/riscv/riscv/sbi.c
@@ -113,6 +113,31 @@
printf("SBI Specification Version: %u.%u\n", major, minor);
}
+int
+sbi_hsm_hart_start(u_long hart, u_long start_addr, u_long priv)
+{
+ struct sbi_ret ret;
+
+ ret = SBI_CALL3(SBI_EXT_ID_HSM, SBI_HSM_HART_START, hart, start_addr, priv);
+ return (ret.error != 0 ? (int)ret.error : 0);
+}
+
+void
+sbi_hsm_hart_stop(void)
+{
+ (void)SBI_CALL0(SBI_EXT_ID_HSM, SBI_HSM_HART_STOP);
+}
+
+int
+sbi_hsm_hart_status(u_long hart)
+{
+ struct sbi_ret ret;
+
+ ret = SBI_CALL1(SBI_EXT_ID_HSM, SBI_HSM_HART_STATUS, hart);
+
+ return (ret.error != 0 ? (int)ret.error : (int)ret.value);
+}
+
void
sbi_init(void)
{

File Metadata

Mime Type
text/plain
Expires
Sun, Jan 12, 11:46 PM (20 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15773933
Default Alt Text
D24496.diff (2 KB)

Event Timeline