diff options
| author | Xiang W <[email protected]> | 2025-07-21 09:02:21 +0800 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2025-07-21 16:34:03 +0530 |
| commit | 3876f8cd1e3c0c203a315bdc6e8ced176bb49e0a (patch) | |
| tree | 7bcc90a186c450cc1362a99235d503940f07007f | |
| parent | 5b305e30a55d93d507006dd11685bdeb7e7207e8 (diff) | |
firmware: payload: test: Add SBI shutdown call after test message
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.
Reviewed-by: Anup Patel <[email protected]>
Signed-off-by: Xiang W <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Anup Patel <[email protected]>
| -rw-r--r-- | firmware/payloads/test_main.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/firmware/payloads/test_main.c b/firmware/payloads/test_main.c index 194dbbe6..03f6ba39 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,7 +61,6 @@ 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"); - - while (1) - wfi(); + sbi_ecall_shutdown(); + sbi_ecall_console_puts("sbi_ecall_shutdown failed to execute.\n"); } |
