[PATCH v4] Add system reset extension


Anup Patel
 

This patch adds SBI v0.2 compliant system reset extension. It defines
the sbi_system_reset function which does different things based on
reset_type parameter:
1. shutdown - Power-off the entire system
2. cold reboot - Power-cycle the entire system
3. warm reboot - Power-cycle only parts of system based on SOC vendor
design choices

The sbi_system_reset function defined here is also a replacement of
SBI v0.1 shutdown function.

Signed-off-by: Atish Patra <atish.patra@...>
Signed-off-by: Anup Patel <anup.patel@...>
Reviewed-by: Bin Meng <bmeng.cn@...>
---
riscv-sbi.adoc | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)

diff --git a/riscv-sbi.adoc b/riscv-sbi.adoc
index 8137686..a1353ac 100644
--- a/riscv-sbi.adoc
+++ b/riscv-sbi.adoc
@@ -615,6 +615,53 @@ state of the hart at the time of return value verification.
| sbi_hart_get_status | 2 | 0x48534D
|===

+== System Reset Extension, Extension ID: 0x53525354 (SRST)
+
+The System Reset Extension provides a function that allow the supervisor
+software to request system-level reboot or shutdown.
+
+[source, C]
+----
+struct sbiret sbi_system_reset(unsigned long reset_type)
+----
+
+Reset the system based on provided reset_type. This is a synchronous call
+and does not return if it succeeds.
+
+The reset_type parameter is 32 bit wide and has following possible values:
+
+[cols="<,>",options="header,compact"]
+|===
+| Value | Description
+| 0x00000000 | Shutdown
+| 0x00000001 | Cold reboot
+| 0x00000002 | Warm reboot
+| 0x00000003 - 0xEFFFFFFF | Reserved for future use
+| 0xF0000000 - 0xFFFFFFFF | Vendor or platform specific reset type
+| 0x100000000 - 2^XELN-1 | Reserved and unusable on RV32
+|===
+
+Cold reboot results in complete power cycle of the entire system while warm
+reboot depends on SOC vendor design choices.
+
+*Returns* one of the following possible SBI error codes through sbiret.error
+upon failure.
+
+[cols="<,>",options="header,compact"]
+|===
+| Error code | Description
+| SBI_ERR_INVALID_PARAM | `reset_type` is not valid.
+| SBI_ERR_FAILED | Reset request failed for unknown reasons.
+|===
+
+=== SRST Function Listing
+
+[cols="<,,>",options="header,compact"]
+|===
+| Function Name | Function ID | Extension ID
+| sbi_system_reset | 0 | 0x53525354
+|===
+
== Experimental SBI Extension Space, Extension IDs 0x0800000 through 0x08FFFFFF

No management.
--
2.25.1