Add a minimal shutdown method, that only works on emulators (at least for now)

This commit is contained in:
apio 2022-09-06 12:13:43 +02:00
parent a8aca62771
commit 716974a916
3 changed files with 21 additions and 2 deletions

View File

@ -0,0 +1,3 @@
#pragma once
[[noreturn]] void shutdown();

View File

@ -15,7 +15,7 @@
#include "memory/KernelHeap.h"
#include "memory/Memory.h"
#include "panic/hang.h"
#include "power/reboot.h"
#include "power/shutdown.h"
#include "render/BBRenderer.h"
#include "render/Draw.h"
#include "render/TextRenderer.h"
@ -131,7 +131,7 @@ extern "C" void _start()
}
sleep(2500);
reboot();
shutdown();
while (1) halt();
loop:

View File

@ -0,0 +1,16 @@
#include "power/shutdown.h"
#include "io/IO.h"
#include "log/Log.h"
#include "panic/hang.h"
[[noreturn]] void shutdown()
{
kinfoln("Attempting shutdown using the Bochs method");
IO::outw(0xB004, 0x2000);
kinfoln("Attempting shutdown using the QEMU method");
IO::outw(0x604, 0x2000);
kinfoln("Attempting shutdown using the VirtualBox method");
IO::outw(0x4004, 0x3400);
kerrorln("Failed to shutdown, halting. It is now safe to turn off your computer manually, though.");
hang();
}