[PATCH] firmware: payload: test: Add SBI shutdown call after test message
Xiang W
wxjstz at 126.com
Tue Jun 24 01:41:46 PDT 2025
Previously, 'make run' would hang in WFI after printing the test message.
This commit adds an SBI ecall to ensure QEMU exits cleanly after the test
payload runs.
Signed-off-by: Xiang W <wxjstz at 126.com>
---
firmware/payloads/test_main.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/firmware/payloads/test_main.c b/firmware/payloads/test_main.c
index 194dbbe6..021bc3b8 100644
--- a/firmware/payloads/test_main.c
+++ b/firmware/payloads/test_main.c
@@ -46,6 +46,13 @@ static inline void sbi_ecall_console_puts(const char *str)
sbi_strlen(str), (unsigned long)str, 0, 0, 0, 0);
}
+static inline void sbi_ecall_shutdown(void)
+{
+ sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET,
+ SBI_SRST_RESET_TYPE_SHUTDOWN, SBI_SRST_RESET_REASON_NONE,
+ 0, 0, 0, 0);
+}
+
#define wfi() \
do { \
__asm__ __volatile__("wfi" ::: "memory"); \
@@ -54,6 +61,7 @@ static inline void sbi_ecall_console_puts(const char *str)
void test_main(unsigned long a0, unsigned long a1)
{
sbi_ecall_console_puts("\nTest payload running\n");
+ sbi_ecall_shutdown();
while (1)
wfi();
--
2.47.2
More information about the opensbi
mailing list