flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Does the IDT need to have 256 entries, or can it have less?

Author
Thread Post new topic Reply to topic
StringCheesian



Joined: 20 Feb 2004
Posts: 20
StringCheesian 27 Feb 2004, 09:42
What's the bare minimum?
Post 27 Feb 2004, 09:42
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 27 Feb 2004, 12:23
(It's been a number of years since I messed with this last, so I could be wrong).

Iirc the IDT has both base and limit, so you can have less than 256 entries. You should however have entries for at least the IA32 exceptions, and unless you want to run with hardware interrupts masked, for those as well (they will need to be remapped for pmode, as the original IBM definitions clash with the intel-reserved ints for exceptions).

In my toy kernel, I made a full 256-entry IDT (most entries were dummies, though). This made it easy to patch IDT entries later on, if needed - back then I wanted loadable subsystems, and it was the idea to have each subsystem install a service routine accessible via INT xx.
Post 27 Feb 2004, 12:23
View user's profile Send private message Visit poster's website Reply with quote
Ralph



Joined: 04 Oct 2003
Posts: 86
Ralph 28 Feb 2004, 05:54
f0dder is completly right, but if I may add something, I don't see why you need to create entries for all. It's just a waste of space. I just use a structure like this:
Code:
struc interrupt id1,id2,id3,id4 {
      .Offset0_15   dw id1  ;low word of int offset
      .Selector0_15 dw id2  ;segment selector
      .Flags        dw id3  ;flags
      .Offset16_31  dw id4  ;high word of int offset
}
    

And then just create an idt like this:
Code:
idt:
       idt_limit dw idt_end-int_00-1
       idt_base  dd int_00
       int_00    interrupt interrupt_00,0008h,8E00h,0001h
       ......
idt_end:
    

This lets me fill memory above 1mb with interrupt code. I keep all my interrupts between 1mb and 2mb, so I just need to change the interrupt_00 label to create a new one if needed.
Hope this helps~
Post 28 Feb 2004, 05:54
View user's profile Send private message Reply with quote
StringCheesian



Joined: 20 Feb 2004
Posts: 20
StringCheesian 28 Feb 2004, 06:19
Thanks! One more question:
Say I wanted to have int 9 point somewhere, would I have to make 0-8 point to a dummy int handler or could 0-8 be disabled somehow? Would a null selector work or just cause errors?
Post 28 Feb 2004, 06:19
View user's profile Send private message Reply with quote
Ralph



Joined: 04 Oct 2003
Posts: 86
Ralph 29 Feb 2004, 03:15
Remember that the IDT is a table, and the interrupts are indices. That means that the interrupt number will be used as the index into the IDT to find the correct handler. The processor doesn't care what is at that address, and merily execute what you told it to.
In other words, yes you will have to create 9 entries if you plan on using 9 indices into the table. What is in those 8 other entries is irrelevant as long as you don't execute them.
Post 29 Feb 2004, 03:15
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 29 Feb 2004, 03:28
...and when you're doing protected mode, you will want an IDT that contains at least enough entries to handle all the possible exceptions (and dummy handlers for reserved stuff). If you don't do this and an exception happens... well, I can't remember the details, refer to the intel docs, but iirc you end up with a triple fault.
Post 29 Feb 2004, 03:28
View user's profile Send private message Visit poster's website 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.