Page 1 of 1

ISR Problem

Posted: Fri Apr 06, 2012 2:24 am
by dilipcs1992
Hi Everyone
i'm developing a os in fasm assembly language using grub
i've printed the string on the screen, and set my own GDT and IDT and defined ISR
every thing works fine, whe i call interup, interupt is triggered and i get message on screen
but problem is if i don't call any interupt also my os throwing Double Fault Exception, please help!
Thanks in Advance

Re: ISR Problem

Posted: Fri Apr 06, 2012 2:55 am
by brain
Its broken. :lol: e.g. damned if I know, you need to debug more and/or give more information afterwards.

Re: ISR Problem

Posted: Fri Apr 06, 2012 5:56 am
by dilipcs1992
berkus wrote:There's a bug in your code.
Where could be the Bug
I mean if,GDT not defined properly we get Double Fault Error
so what could be cause of Double Fault Eception GDT,IDT or ISR

sample of my os code

Code: Select all

; Global Descriptor Table (GDT)

InstallGDT:
        cli                                                                                                                                     ; clear interrupts
        pusha                                                                                                                           ; save registers
        lgdt    [GDT]                                                                                                           ; load GDT into GDTR
        sti                                                                                                                                     ; enable interrupts
        popa                                                                                                                            ; restore registers
        ret                                                                                                                                     ; All done!
        
GdtData: 
        dd              0                                                                                                                       ; null descriptor
        dd              0

        dw              0FFFFh                                                                                                          ; limit low
        dw              0                                                                                                                       ; base low
        db              0                                                                                                                       ; base middle
        db              10011010b                                                                                                       ; access
        db              11001111b                                                                                                       ; granularity
        db              0

        dw              0FFFFh                                                                                                          ; limit low
        dw              0                                                                                                                       ; base low
        db              0                                                                                                                       ; base middle
        db              10010010b                                                                                                       ; access
        db              11001111b                                                                                                       ; granularity
        db              0
EndOfGdt:

GDT: 
        dw              EndOfGdt - GdtData - 1                                                                          ; limit (Size of GDT)
        dd              GdtData     

;Interupt Descriptor Table

InstallIDT:
        cli
        pusha
        lidt    [IDT]
        sti
        popa
        ret
        
IdtData:

        dw              (isr0 and 0FFFFh)
        dw              00001000b
        db              0
        db              10001110b
        dw              (isr0 shr 16) and 0xFFFF

        dw              (isr1 and 0FFFFh)
        dw              00001000b
        db              0
        db              10001110b
        dw              (isr1 shr 16) and 0xFFFF    
EndOfIdt:

IDT:
        dw              EndOfIdt - IdtData - 1
        dd              IdtData 

macro isrStub errmsg
{
   pusha
   push ds
   push es
   push fs
   push gs
   mov ax, 0x10
   mov ds, ax
   mov es, ax
   mov fs, ax
   mov gs, ax
   mov eax, esp
   push ebx
        mov ebx,errmsg
        call Puts
        mov ebx,er
        call Puts
        hlt
   pop ebx
   pop gs
   pop fs
   pop es
   pop ds
   popa
   add esp, 8
   iret
}   

isr0:
   cli
   isrStub err0
isr1:
   cli
   isrStub err1  

er     db              'Exception System Halted!',10,0
err0    db             'Division By Zero',10,0
err1    db             'Debug',10,0

Re: ISR Problem

Posted: Fri Apr 06, 2012 6:10 am
by bluemoon
You provided none information on the issue.
Do you really want us to just wild guess on it? If so, okay I guess there is un-handled interrupt elsewhere.

Re: ISR Problem

Posted: Fri Apr 06, 2012 7:23 am
by Combuster
It's a crystal ball.
It insists on predicting 90% cloud coverage.

The rest of the time it says "wrong forum"

Re: ISR Problem

Posted: Fri Apr 06, 2012 8:52 am
by JAAman
i added code tags to your post, please do this yourself in the future

as for your problem, you first need to do a little investigating yourself, to at least find out where the problem is occurring, and then, if you still need help, give more information (the more the better -- most people here won't help someone who doesn't show that they tried to solve it themselves first) and relevant code (preferably the code that actually causes the error to appear, other things may be important, but at least start there)

for your own work: start by finding out exactly what your code does, and where it causes the problem, then look in the intel manuals:

intel 3A:5.14 for a list of reasons why that particular exception can occur

intel vol. 2 for the offending instruction to find which exceptions it can cause and why

for #DF i would recommend the former (since #DF is caused by something going wrong while fetching another exception handler, rather than caused directly by execution of an instruction)