Kernel hangs after isr creation

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Locked
leledumbo
Member
Member
Posts: 103
Joined: Wed Apr 23, 2008 8:46 pm

Kernel hangs after isr creation

Post by leledumbo »

This is the next episode of my previous post.
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
I try reversing from the original code, as Pascal uses left-to-right convention. The fault_handler and registers record are defined as below:

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;
After this, the kernel always hangs regardless the GDT, IDT, and ISR are installed.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Code: Select all

while true do ;
Erm...isn't this designed to hang the system - or am I missing something?
leledumbo
Member
Member
Posts: 103
Joined: Wed Apr 23, 2008 8:46 pm

Post by leledumbo »

I accidentally made two same topics. Please reply to the other one instead, there's an additional information there. Btw, while true do ; will not hang the system. It's just an infinite loop. And even if it's executed, the code before it should be executed and that means something must be printed. In my case, even the screen doesn't get cleared. Only the cursor moves to the top-left corner.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Thread locked to avoid confusion. See topic at:

http://www.osdev.org/phpBB2/viewtopic.php?t=17182

Adam
Locked