mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 14:14:45 +03:00
Kernel/riscv64: Add support for legacy "System Shutdown" SBI extension
This commit is contained in:
parent
fbdb1a3d61
commit
cac7dc8d71
Notes:
sideshowbarker
2024-07-17 08:35:21 +09:00
Author: https://github.com/spholz Commit: https://github.com/SerenityOS/serenity/commit/cac7dc8d71 Pull-request: https://github.com/SerenityOS/serenity/pull/22586
@ -86,6 +86,17 @@ SBIErrorOr<long> get_mimpid()
|
||||
|
||||
namespace Legacy {
|
||||
|
||||
static long sbi_legacy_ecall0(LegacyEID extension_id)
|
||||
{
|
||||
register unsigned long a0 asm("a0");
|
||||
register unsigned long a7 asm("a7") = to_underlying(extension_id);
|
||||
asm volatile("ecall"
|
||||
: "=r"(a0)
|
||||
: "r"(a7)
|
||||
: "memory");
|
||||
return static_cast<long>(a0);
|
||||
}
|
||||
|
||||
static long sbi_legacy_ecall1(LegacyEID extension_id, unsigned long arg0)
|
||||
{
|
||||
register unsigned long a0 asm("a0") = arg0;
|
||||
@ -115,6 +126,13 @@ LegacySBIErrorOr<void> console_putchar(int ch)
|
||||
return err;
|
||||
}
|
||||
|
||||
void shutdown()
|
||||
{
|
||||
sbi_legacy_ecall0(LegacyEID::SystemShutdown);
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace Timer {
|
||||
|
@ -133,6 +133,11 @@ LegacySBIErrorOr<void> set_timer(u64 stime_value);
|
||||
// Write data present in ch to debug console.
|
||||
LegacySBIErrorOr<void> console_putchar(int ch);
|
||||
|
||||
// System Shutdown (EID #0x08)
|
||||
// Puts all the harts to shutdown state from supervisor point of view.
|
||||
// This SBI call doesn’t return irrespective whether it succeeds or fails.
|
||||
[[noreturn]] void shutdown();
|
||||
|
||||
}
|
||||
|
||||
// Chapter 6. Timer Extension (EID #0x54494D45 "TIME")
|
||||
|
Loading…
Reference in New Issue
Block a user