panic: Go back to real mode instead of hanging with interrupts disabled so BIOS can handle events like ctrl-alt-delete

This commit is contained in:
mintsuki 2020-12-19 13:52:29 +01:00
parent 675e73e759
commit 09ae5a21cc
6 changed files with 34 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -5,6 +5,7 @@
#include <lib/blib.h>
#include <lib/print.h>
#include <lib/trace.h>
#include <lib/real.h>
uint8_t boot_drive;
int boot_partition = -1;
@ -78,9 +79,7 @@ __attribute__((noreturn)) void panic(const char *fmt, ...) {
print("\n");
print_stacktrace(NULL);
for (;;) {
asm volatile ("hlt" ::: "memory");
}
rm_hcf();
}
int digit_to_int(char c) {

View File

@ -1,5 +1,35 @@
section .realmode
global rm_hcf
rm_hcf:
; Jump to real mode
jmp 0x08:.bits16
.bits16:
bits 16
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov eax, cr0
btr ax, 0
mov cr0, eax
jmp 0x00:.cszero
.cszero:
xor ax, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
sti
.hang:
hlt
jmp .hang
bits 32
global rm_int
rm_int:
; Self-modifying code: int $int_no

View File

@ -28,4 +28,6 @@ struct rm_regs {
void rm_int(uint8_t int_no, struct rm_regs *out_regs, struct rm_regs *in_regs);
__attribute__((noreturn)) void rm_hcf(void);
#endif