diff options
author | dzwdz | 2021-10-15 17:25:12 +0200 |
---|---|---|
committer | dzwdz | 2021-10-15 17:25:12 +0200 |
commit | 946313af5905ac3679c1f496f000ba077ce038f0 (patch) | |
tree | bfed3f993ae97c3a72a945382c8686ad0ad2b832 /src | |
parent | d994f9517785aeba4a07ec8c4aecf6d5d969ab97 (diff) |
kernel: quit QEMU once there are no running processes left
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/arch/generic.h | 2 | ||||
-rw-r--r-- | src/kernel/arch/i386/boot.s | 10 | ||||
-rw-r--r-- | src/kernel/proc.c | 2 |
3 files changed, 13 insertions, 1 deletions
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 |