summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--src/kernel/arch/generic.h2
-rw-r--r--src/kernel/arch/i386/boot.s10
-rw-r--r--src/kernel/proc.c2
4 files changed, 14 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 886de4b..6f6f71c 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ endef
all: out/boot.iso check
boot: all out/hdd
- qemu-system-i386 -cdrom out/boot.iso $(QFLAGS) -no-shutdown \
+ qemu-system-i386 -cdrom out/boot.iso $(QFLAGS) \
-drive file=out/hdd,format=raw,media=disk
diff --git a/src/kernel/arch/generic.h b/src/kernel/arch/generic.h
index bbbb49f..fcc228e 100644
--- a/src/kernel/arch/generic.h
+++ b/src/kernel/arch/generic.h
@@ -15,6 +15,8 @@ extern char _bss_end;
__attribute__((noreturn))
void halt_cpu(void);
+__attribute__((noreturn))
+void cpu_shutdown(void);
// src/arch/i386/sysenter.s
_Noreturn void sysexit(struct registers);
diff --git a/src/kernel/arch/i386/boot.s b/src/kernel/arch/i386/boot.s
index 0101b40..9fd7d5d 100644
--- a/src/kernel/arch/i386/boot.s
+++ b/src/kernel/arch/i386/boot.s
@@ -7,6 +7,16 @@ _start:
push %ebx // address of the Multiboot struct
call kmain_early
+.global cpu_shutdown
+.type cpu_shutdown, @function
+cpu_shutdown:
+/* This quits QEMU. While I couldn't find this officially documented anywhere,
+ * it is used by QEMU in tests/tcg/i386/system/boot.S (as of commit 40d6ee), so
+ * I assume that this is safe-ish to use */
+ mov $0x604, %edx
+ mov $0x2000, %eax
+ outw %ax, %dx
+
.global halt_cpu
.type halt_cpu, @function
halt_cpu:
diff --git a/src/kernel/proc.c b/src/kernel/proc.c
index 17af0cd..4df6bd7 100644
--- a/src/kernel/proc.c
+++ b/src/kernel/proc.c
@@ -68,7 +68,7 @@ _Noreturn void process_switch_any(void) {
process_switch(found);
mem_debugprint();
- panic_unimplemented(); // TODO shutdown();
+ cpu_shutdown();
}
// TODO there's no check for going past the stack - VULN