Interrupt Descriptor Table: minimum IDTR limit value

All about the OSDev Wiki. Discussions about the organization and general structure of articles and how to use the wiki. Request changes here if you don't know how to use the wiki.
Post Reply
Stijn
Posts: 10
Joined: Tue Feb 07, 2012 6:55 pm

Interrupt Descriptor Table: minimum IDTR limit value

Post by Stijn »

Article: http://wiki.osdev.org/Interrupt_Descriptor_Table

It says this for the IDTR limit value:
Defines the length of the IDT in bytes - 1 (minimum value is 100h, a value of 1000h means 200h interrupts).
Where does this limit come from? I can't find it anywhere else, including the 80386 manual. Besides, shouldn't a potential minimum limit be 0x7ff instead of 0xfff (or 0x1000), given an IDT entry size of 8 bytes and and IDT of 256 entries?

I also found the article to be a bit confusing during my first reading of it, and the following from the Discussion page seems to agree with me:
Looking through this article, this appears to be nothing more than a massive pile of randomly sawn-together pieces of information. This needs some serious reordering, or even better, rework. I might look into doing this, however I can and will not guarantee this. -- no92 10:51, 10 May 2017 (CDT)
Ankeraout
Member
Member
Posts: 25
Joined: Tue Feb 28, 2017 10:22 am

Re: Interrupt Descriptor Table: minimum IDTR limit value

Post by Ankeraout »

This is a great question, but I'd say that it is 0x100 because :

1 entry = 8 bytes
0x100 / 8 = 32

There are 32 exceptions (0x00 - 0x1F)

So you have to map the first 32 interrupts for exceptions.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Interrupt Descriptor Table: minimum IDTR limit value

Post by Brendan »

Hi,
Stijn wrote:Where does this limit come from? I can't find it anywhere else, including the 80386 manual. Besides, shouldn't a potential minimum limit be 0x7ff instead of 0xfff (or 0x1000), given an IDT entry size of 8 bytes and and IDT of 256 entries?
The absolute minimum value is zero. In this case any interrupt will cause a triple fault (and in rare cases, like early boot code that switches CPU modes and wants predictable behaviour if an NMI occurs, this might be exactly what you want).

The minimum usable value is "0x0D*8-1 = 0x0067 = 103" or (for long mode where IDT entries are 16 bytes) "0x0D*16-1 = 0x00CF = 207". In this case if a higher numbered interrupt occurs you get a general protection fault (because of the IDT limit) and the general protection fault handler can examine its error code and figure out which interrupt was intended and start the intended interrupt handler.

The maximum value is 0xFFFF, but there are only 256 interrupts so any value from 0x07FF to 0xFFFF (for 32-bit) or from 0x0FFF to 0xFFFF (long mode) would behave the same (allow entries for all 256 possible interrupts). In this way your 0x07FF could be considered the minimum "maximum value".

For normal use the IDT limit can be anything you want. For example, if you want 32 interrupts for exceptions plus 16 interrupts for PIC chips, then you could set the IDT limit to "(32+16)*8-1 = 0x017F = 383" to avoid wasting memory for IDT entries that you don't use.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Stijn
Posts: 10
Joined: Tue Feb 07, 2012 6:55 pm

Re: Interrupt Descriptor Table: minimum IDTR limit value

Post by Stijn »

Thank you both for the info. I only just noticed the article says the minimum is 0x100, I kept reading it as the minimum being 0x1000.
Post Reply