WKern
Loading...
Searching...
No Matches
shutdown.c
Go to the documentation of this file.
1/*
2WKern - A Bare Metal OS / Kernel I am maKing (For Fun)
3Copyright (C) 2025 Wdboyes13
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 3 of the License, or
8any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <https://www.gnu.org/licenses/>.
17*/
18
19#include <err/kerror.h>
20#include <io/kio.h>
21#include <utils/util.h>
27__attribute__((noreturn)) void QemuShutdown() {
28 Kprintf("\nShutting Down...\n");
29 ZZZ(20);
30 Outw(0x604, 0x2000); // Magic value to ACPI shutdown in QEMU
31 Outw(0xB004, 0x2000); // BacKup for older versions
33 __builtin_unreachable();
34}
void Outw(u16 port, u16 val)
Write a 16-bit word to the specified I/O port.
Definition asm.c:52
void TripleFault()
void Kprintf(const char *fmt,...)
Formatted output to the screen.
Definition printer.c:152
void ZZZ(int ms)
Sleeps for 10ms.
Definition ksleep.c:25
__attribute__((noreturn))
Shutdown QEMU VM Using ACPI Port.
Definition shutdown.c:27
void QemuShutdown()