1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:57:44 +00:00

Kernel/riscv64: Add support for legacy "System Shutdown" SBI extension

This commit is contained in:
Sönke Holz 2024-01-04 18:16:55 +01:00 committed by Andrew Kaster
parent fbdb1a3d61
commit cac7dc8d71
2 changed files with 23 additions and 0 deletions

View file

@ -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 {