Might? have fixed one race condition bug. Still crashing for unknown reasons on my laptop rarely
This commit is contained in:
parent
750b1edc16
commit
2114741766
21
fault.nasm
21
fault.nasm
@ -6,8 +6,8 @@ _fault_coda:
|
|||||||
xchg bx,bx
|
xchg bx,bx
|
||||||
mov ax, 0x10
|
mov ax, 0x10
|
||||||
mov es, ax
|
mov es, ax
|
||||||
; move to TOP OF kernel stack
|
; move to 'safe' location
|
||||||
mov ebp, 0x400000
|
mov ebp, 0x318000
|
||||||
mov esp, ebp
|
mov esp, ebp
|
||||||
call error_environment
|
call error_environment
|
||||||
.hlt:
|
.hlt:
|
||||||
@ -17,13 +17,30 @@ jmp .hlt
|
|||||||
extern gpf_handler_v86
|
extern gpf_handler_v86
|
||||||
global gpfHandler
|
global gpfHandler
|
||||||
gpfHandler:
|
gpfHandler:
|
||||||
|
cli ; make sure we're in a 'friendly' env
|
||||||
push eax
|
push eax
|
||||||
push ebx
|
push ebx
|
||||||
|
push ecx
|
||||||
|
; save old ds
|
||||||
mov bx, ds
|
mov bx, ds
|
||||||
mov ax, 0x10
|
mov ax, 0x10
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
mov word [_gpf_old_ds], bx
|
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
|
pop ebx
|
||||||
|
sti ; we shouldn't crash now?
|
||||||
mov eax, dword [esp+16] ; EFLAGS
|
mov eax, dword [esp+16] ; EFLAGS
|
||||||
and eax, 1 << 17 ; VM flag
|
and eax, 1 << 17 ; VM flag
|
||||||
test eax, eax
|
test eax, eax
|
||||||
|
26
kernel.c
26
kernel.c
@ -112,7 +112,7 @@ void error_environment() {
|
|||||||
for (int i = 0; i < 80*50; i++)
|
for (int i = 0; i < 80*50; i++)
|
||||||
vga_text[i] = error_screen[i];
|
vga_text[i] = error_screen[i];
|
||||||
uint8_t key;
|
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);
|
v86_entry = i386LinearToFp(v86TransFlag);
|
||||||
enter_v86(0x8000, 0xFF00, FP_SEG(v86_entry), FP_OFF(v86_entry), ®s);
|
enter_v86(0x8000, 0xFF00, FP_SEG(v86_entry), FP_OFF(v86_entry), ®s);
|
||||||
}
|
}
|
||||||
@ -311,12 +311,22 @@ void start() {
|
|||||||
kbd_wait();
|
kbd_wait();
|
||||||
|
|
||||||
vga_text = &((uint16_t*)0xB8000)[80*16];
|
vga_text = &((uint16_t*)0xB8000)[80*16];
|
||||||
vga_text += printStr("Press ` for a flagrant system error... ", vga_text);
|
vga_text += printStr("Press E for a flagrant system error. Press C to continue... ", vga_text);
|
||||||
while ((key = get_key()) != '`') {
|
for (char l = 1;l;) { switch (key = get_key()) {
|
||||||
*vga_text = (*vga_text & 0xFF00) | key;
|
case 'e':
|
||||||
vga_text++;
|
case 'E':
|
||||||
}
|
// flagrant system error
|
||||||
// flagrant system error
|
*((uint8_t*)0x1000000) = 0;
|
||||||
*((uint8_t*)0x1000000) = 0;
|
break;
|
||||||
|
case 'c':
|
||||||
|
case 'C':
|
||||||
|
// continue
|
||||||
|
l = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
*vga_text = (*vga_text & 0xFF00) | key;
|
||||||
|
vga_text++;
|
||||||
|
break;
|
||||||
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,9 @@ inc al
|
|||||||
cmp eax, 200
|
cmp eax, 200
|
||||||
jl .loop
|
jl .loop
|
||||||
mov eax, 0xA0000
|
mov eax, 0xA0000
|
||||||
|
;mov ecx, 1000000000
|
||||||
|
;.dbg:
|
||||||
|
;loop .dbg
|
||||||
int 0x30 ; Exit
|
int 0x30 ; Exit
|
||||||
mov edx, 0x105000 ; somewhere in kernel mem
|
mov edx, 0x105000 ; somewhere in kernel mem
|
||||||
mov edx, [edx] ; should page fault
|
mov edx, [edx] ; should page fault
|
||||||
|
Loading…
Reference in New Issue
Block a user