dump more registers on panic, print register names
This commit is contained in:
1 parent
5c9987e99b
commit
035bba16f6
1 file changed
+72
-40
@@ -218,6 +218,10 @@ main:
|
||||
|
||||
mov eax, 0xa1b2c3d4
|
||||
mov ebx, 0x12345678
|
||||
mov ecx, 0xdeadbeef
|
||||
mov edx, 0xcafebabe
|
||||
mov esi, 0xfeedface
|
||||
mov edi, 0x66778899
|
||||
call panic_fancy
|
||||
|
||||
call test_a20
|
||||
@@ -237,61 +241,71 @@ main:
|
||||
hlt
|
||||
|
||||
|
||||
; Wrapper function around panic_fancy which provides default arguments.
|
||||
; Arguments: none
|
||||
; Does not return
|
||||
panic_default:
|
||||
push bp
|
||||
mov bp, sp
|
||||
push word 0
|
||||
push word 0
|
||||
; Spoof return address
|
||||
push dword [bp]
|
||||
jmp panic_fancy
|
||||
|
||||
|
||||
; Print a panic message then terminate.
|
||||
; Arguments:
|
||||
; - [sp - 2]: panic message segment
|
||||
; - [sp + 2]: panic message segment
|
||||
; - [sp]: panic message offset
|
||||
; Does not return
|
||||
panic_fancy:
|
||||
push bp
|
||||
mov bp, sp
|
||||
|
||||
sub sp, 16 ; Buffer: bp - 16
|
||||
|
||||
push eax ; bp - 20
|
||||
push ebx ; bp - 24
|
||||
push ecx ; bp - 28
|
||||
push edx ; bp - 32
|
||||
push esi ; bp - 36
|
||||
push edi ; bp - 40
|
||||
; Flags first so we don't cobber them when we sub (uwu)
|
||||
pushfd ; Temp flags: bp - 0x04
|
||||
sub sp, 16 ; Buffer: bp - 0x14
|
||||
push eax ; eax: bp - 0x18
|
||||
push ebx ; ebx: bp - 0x1c
|
||||
push ecx ; ecx: bp - 0x20
|
||||
push edx ; edx: bp - 0x24
|
||||
push esi ; esi: bp - 0x28
|
||||
push edi ; edi: bp - 0x2c
|
||||
sub sp, 4 ; Flags: bp - 0x30
|
||||
mov eax, [bp - 0x04]
|
||||
mov [bp - 0x30], eax
|
||||
|
||||
mov word [GLOBALS + VGA_COL], 0x4f00
|
||||
call vga_clear
|
||||
|
||||
mov ax, ss
|
||||
mov es, ax
|
||||
|
||||
xor bx, bx
|
||||
mov di, VGA_WIDTH * 3
|
||||
.loop_dump_regs:
|
||||
cmp bx, 7
|
||||
jae .loop_dump_regs_done
|
||||
|
||||
mov ax, bx
|
||||
shl ax, 1
|
||||
mov si, table_reg_msgs
|
||||
add si, ax
|
||||
mov cx, [si]
|
||||
mov ax, di
|
||||
add ax, 1
|
||||
mov dx, 6
|
||||
call vga_print_raw
|
||||
|
||||
; Format the current saved register value as hex
|
||||
lea si, [bp - 0x18]
|
||||
mov ax, bx
|
||||
shl ax, 2
|
||||
sub si, ax
|
||||
mov ecx, ss:[si]
|
||||
lea ax, [bp - 0x14]
|
||||
call dump_reg
|
||||
|
||||
mov ax, di
|
||||
add ax, 7
|
||||
lea cx, [bp - 0x14]
|
||||
mov dx, 8
|
||||
call vga_print_raw
|
||||
|
||||
inc bx
|
||||
add di, VGA_WIDTH
|
||||
jmp .loop_dump_regs
|
||||
|
||||
.loop_dump_regs_done:
|
||||
|
||||
lea ax, [bp - 16]
|
||||
push ax
|
||||
mov ecx, [bp - 20]
|
||||
call dump_reg
|
||||
pop cx
|
||||
xor ax, ax
|
||||
mov dx, 8
|
||||
call vga_print_raw
|
||||
|
||||
lea ax, [bp - 16]
|
||||
push ax
|
||||
mov ecx, [bp - 24]
|
||||
call dump_reg
|
||||
pop cx
|
||||
mov ax, VGA_WIDTH
|
||||
mov dx, 8
|
||||
call vga_print_raw
|
||||
|
||||
.halt:
|
||||
hlt
|
||||
; Handle non-maskable interrupts
|
||||
@@ -583,6 +597,24 @@ msg_a20_enabled db "a20 enabled", 0
|
||||
msg_a20_disabled db "a20 not enabled", 0
|
||||
msg_panic db "panic!", 0
|
||||
|
||||
msg_reg_eax db "eax", 0
|
||||
msg_reg_ebx db "ebx", 0
|
||||
msg_reg_ecx db "ecx", 0
|
||||
msg_reg_edx db "edx", 0
|
||||
msg_reg_esi db "esi", 0
|
||||
msg_reg_edi db "edi", 0
|
||||
msg_reg_flags db "flags", 0
|
||||
|
||||
table_reg_msgs:
|
||||
dw msg_reg_eax
|
||||
dw msg_reg_ebx
|
||||
dw msg_reg_ecx
|
||||
dw msg_reg_edx
|
||||
dw msg_reg_esi
|
||||
dw msg_reg_edi
|
||||
dw msg_reg_flags
|
||||
dw 0
|
||||
|
||||
boot1_magic dd BOOT1_MAGIC
|
||||
|
||||
BOOT1_TOTAL_LEN equ $ - $$
|
||||
|
||||
Reference in new issue
Block a user