mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 23:39:02 +00:00
Kernel+Userland: Addd reboot syscall (#334)
Rolling with the theme of adding a dialog to shutdown the machine, it is probably nice to have a way to reboot the machine without performing a full system powerdown. A reboot program has been added to `/bin/` as well as a corresponding `syscall` (SC_reboot). This syscall works by attempting to pulse the 8042 keyboard controller. Note that this is NOT supported on new machines, and should only be a fallback until we have proper ACPI support. The implementation causes a triple fault in QEMU, which then restarts the system. The filesystems are locked and synchronized before this occurs, so there shouldn't be any corruption etctera.
This commit is contained in:
parent
23d45532fc
commit
a27c9e3e01
Notes:
sideshowbarker
2024-07-19 13:10:28 +09:00
Author: https://github.com/Quaker762
Commit: a27c9e3e01
Pull-request: https://github.com/SerenityOS/serenity/pull/334
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/rburchell
7 changed files with 45 additions and 2 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <Kernel/FileSystem/FileDescription.h>
|
||||
#include <Kernel/FileSystem/SharedMemory.h>
|
||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
#include <Kernel/IO.h>
|
||||
#include <Kernel/KSyms.h>
|
||||
#include <Kernel/Multiboot.h>
|
||||
#include <Kernel/Net/Socket.h>
|
||||
|
@ -19,8 +20,8 @@
|
|||
#include <Kernel/ProcessTracer.h>
|
||||
#include <Kernel/RTC.h>
|
||||
#include <Kernel/Scheduler.h>
|
||||
#include <Kernel/StdLib.h>
|
||||
#include <Kernel/SharedBuffer.h>
|
||||
#include <Kernel/StdLib.h>
|
||||
#include <Kernel/Syscall.h>
|
||||
#include <Kernel/TTY/MasterPTY.h>
|
||||
#include <Kernel/kmalloc.h>
|
||||
|
@ -2635,6 +2636,21 @@ int Process::sys$systrace(pid_t pid)
|
|||
return fd;
|
||||
}
|
||||
|
||||
int Process::sys$reboot()
|
||||
{
|
||||
if (!is_superuser())
|
||||
return -EPERM;
|
||||
|
||||
dbgprintf("acquiring FS locks...\n");
|
||||
FS::lock_all();
|
||||
dbgprintf("syncing mounted filesystems...\n");
|
||||
FS::sync();
|
||||
dbgprintf("attempting reboot via KB Controller...\n");
|
||||
IO::out8(0x64, 0xFE);
|
||||
|
||||
return ESUCCESS;
|
||||
}
|
||||
|
||||
ProcessTracer& Process::ensure_tracer()
|
||||
{
|
||||
if (!m_tracer)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue