Might? have fixed one race condition bug. Still crashing for unknown reasons on my laptop rarely

This commit is contained in:
Lucia Ceionia 2023-02-02 18:15:14 -06:00
parent 750b1edc16
commit 2114741766
3 changed files with 40 additions and 10 deletions

View File

@ -6,8 +6,8 @@ _fault_coda:
xchg bx,bx
mov ax, 0x10
mov es, ax
; move to TOP OF kernel stack
mov ebp, 0x400000
; move to 'safe' location
mov ebp, 0x318000
mov esp, ebp
call error_environment
.hlt:
@ -17,13 +17,30 @@ jmp .hlt
extern gpf_handler_v86
global gpfHandler
gpfHandler:
cli ; make sure we're in a 'friendly' env
push eax
push ebx
push ecx
; save old ds
mov bx, ds
mov ax, 0x10
mov ds, ax
mov word [_gpf_old_ds], bx
; relocate stack so other interrupts don't fuck us over
; not sure if this is necessary, it doesn't seem to fix our race conditions...
mov ebx, esp
sub esp, 0x1000
xor ecx, ecx
.l:
mov eax, [ebx]
mov [esp+ecx], eax
add ebx, 4
add ecx, 4
cmp ebx, 0x320000 ; tss esp0
jl .l
pop ecx
pop ebx
sti ; we shouldn't crash now?
mov eax, dword [esp+16] ; EFLAGS
and eax, 1 << 17 ; VM flag
test eax, eax

View File

@ -112,7 +112,7 @@ void error_environment() {
for (int i = 0; i < 80*50; i++)
vga_text[i] = error_screen[i];
uint8_t key;
for (key = get_key(); key != 'e' && key != 'E'; key = get_key());
while (key = get_key(), key != 'e' && key != 'E');
v86_entry = i386LinearToFp(v86TransFlag);
enter_v86(0x8000, 0xFF00, FP_SEG(v86_entry), FP_OFF(v86_entry), &regs);
}
@ -311,12 +311,22 @@ void start() {
kbd_wait();
vga_text = &((uint16_t*)0xB8000)[80*16];
vga_text += printStr("Press ` for a flagrant system error... ", vga_text);
while ((key = get_key()) != '`') {
*vga_text = (*vga_text & 0xFF00) | key;
vga_text++;
}
vga_text += printStr("Press E for a flagrant system error. Press C to continue... ", vga_text);
for (char l = 1;l;) { switch (key = get_key()) {
case 'e':
case 'E':
// flagrant system error
*((uint8_t*)0x1000000) = 0;
break;
case 'c':
case 'C':
// continue
l = 0;
break;
default:
*vga_text = (*vga_text & 0xFF00) | key;
vga_text++;
break;
}}
}

View File

@ -26,6 +26,9 @@ inc al
cmp eax, 200
jl .loop
mov eax, 0xA0000
;mov ecx, 1000000000
;.dbg:
;loop .dbg
int 0x30 ; Exit
mov edx, 0x105000 ; somewhere in kernel mem
mov edx, [edx] ; should page fault