mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
Kernel/riscv64: Add support for legacy "System Shutdown" SBI extension
This commit is contained in:
parent
fbdb1a3d61
commit
cac7dc8d71
2 changed files with 23 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue