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:
parent
675e73e759
commit
09ae5a21cc
BIN
limine-pxe.bin
BIN
limine-pxe.bin
Binary file not shown.
BIN
limine.bin
BIN
limine.bin
Binary file not shown.
BIN
stage2.map
BIN
stage2.map
Binary file not shown.
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user