flat assembler
Message board for the users of flat assembler.

Index > OS Construction > IDT... this big wall!

Author
Thread Post new topic Reply to topic
Nikso



Joined: 20 Oct 2003
Posts: 9
Location: Italy
Nikso 12 Jul 2004, 20:41
Hi there!
Finally I've reopen my OS project folder! ^_^ I've successfully start the protect mode with also vesa mode. I'm just starting to implement the multitasking but...

1. My bootloader initialize the PMODE so, somewhere after 0x7C00 there are the GDT.
2. My kernel is loaded at 0x10000 with ESP=0x90000
3. I load IDT dynamically and directly after the GDT in this way:

Code:
...
MOV     EAX,[IDTAddr] ; IDTAddr = GDTAddr + GDTLen
MOV     [IDT.Addr],EAX
MOV     [IDT.Size],(0x20*8)-1
... some SetDescriptor calls ...
LIDT    [CS:IDT]

FUNC SetDescriptor, IntNum,Selector,Offset,Privilege,Present
BeginF
     PUSH     EDX
     PUSH     EAX

     ; Get memory zone
     MOV      EDX,[IntNum]
     SHL      EDX,3
     ADD      EDX,[Kernel.Interupts.Data.IDT.Addr]

     ; set selector
     MOV      EAX,[Selector]
     MOV      [EDX+2],AX

     ; set offset
     MOV      EAX,[Offset]
     MOV      [EDX],AX
     SHR      EAX,16
     MOV      [EDX+6],AX

     ; Set flags
     MOV      EAX,[Present]
     AND      EAX,1
     SHL      AL,2
     OR       AL,BYTE [Privilege]
     AND    EAX,7
     SHL      AL,5
     OR       AL,00001110b
     MOV      [EDX+4],AX

     POP      EAX
     POP      EDX
EndF
    


I've try to set all the 0x20 exceptions interrupts.
I've also try a non-dynamic way (even if in fast manner).
And I'm quite sure that the function below works.

In any cases LIDT instruction work, but if I try to generate an exception (div 0) bochs go in BIOS panic.

So, IDT generation should be ok. What could be the problem?
Anyone can explain me how to correctly initialize interrupts????

Thanks everyone!
CIAO!
Post 12 Jul 2004, 20:41
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Octavio



Joined: 21 Jun 2003
Posts: 366
Location: Spain
Octavio 12 Jul 2004, 23:41
[quote="Nikso"]Hi there!

is your kernel code 32 bit and org=10000h cs=0 ds=0 ?
Post 12 Jul 2004, 23:41
View user's profile Send private message Visit poster's website Reply with quote
Nikso



Joined: 20 Oct 2003
Posts: 9
Location: Italy
Nikso 13 Jul 2004, 08:07
well, org=10000h but cs=0x08 and ds=0x10 because the global descriptor table is already in use...
Post 13 Jul 2004, 08:07
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Nikso



Joined: 20 Oct 2003
Posts: 9
Location: Italy
Nikso 13 Jul 2004, 15:02
Mmhhh...
I've try to define the IDT just in the bootloader and... it works!
But, if I leve it there and try to fill an entry with a handler defined in the kernel (after 0x10000) it doesn't work...
So maybe is because the hight part of the offset in the IDT entry is not 0 (is should be 0x0010 at least) and I don't enter it correcly... dunno

What about the function above? Do it generate a correct IDT item?

Thanks again
Post 13 Jul 2004, 15:02
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Nikso



Joined: 20 Oct 2003
Posts: 9
Location: Italy
Nikso 13 Jul 2004, 15:55
What can I say...
LOL
It was only a stupid mistake with the above function:
Code:
     ; Set flags
     MOV      EAX,[Present]
     AND          EAX,1
     SHL      AL,2
     OR       AL,BYTE [Privilege]
     AND          EAX,7
     SHL      AL,5
     OR       AL,00001110b
     SHL      EAX,8    ;<-- ------------ damn!!!
     MOV      [EDX+4],AX 
    


Exactly 1 day for find out a stupid mistake and 1 useless post Rolling Eyes

Whell... thanks in any cases ^_^

Bye[/b]
Post 13 Jul 2004, 15:55
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.