After following GDT and IDT tutorial, everything's still fine and there's no change as both GDT and IDT changes happened internally. But after following ISR, my kernel hangs. Possible errors are here:
Code: Select all
isr_common_stub:
pusha
mov eax, esp
push eax
push gs
push fs
push es
push ds
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov eax,fault_handler
call eax
pop ds
pop es
pop fs
pop gs
pop eax
popa
add esp, 8
iret
Code: Select all
type
PRegisters = ^TRegisters;
TRegisters = record
gs,fs,es,ds: LongWord;
edi,esi,ebp,esp,ebx,edx,ecx,eax: LongWord;
InterruptNumber,ErrorCode: LongWord;
eip,cs,eflags,useresp,ss: LongWord;
end;
...
procedure FaultHandler(r: PRegisters); [public, alias: 'fault_handler'];
begin
if r^.InterruptNumber<32 then begin
WriteStr(ExceptionMessages[r^.InterruptNumber]);
WriteStrLn('Exception. System Halted!');
while true do ;
end;
end;