OSDev.org
https://forum.osdev.org/

Interrupt Descriptor Table: minimum IDTR limit value
https://forum.osdev.org/viewtopic.php?f=8&t=32661
Page 1 of 1

Author:  Stijn [ Thu Jan 04, 2018 11:42 am ]
Post subject:  Interrupt Descriptor Table: minimum IDTR limit value

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

It says this for the IDTR limit value:
Quote:
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:
Quote:
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)

Author:  Ankeraout [ Fri Jan 05, 2018 4:23 am ]
Post subject:  Re: Interrupt Descriptor Table: minimum IDTR limit value

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.

Author:  Brendan [ Fri Jan 05, 2018 8:01 am ]
Post subject:  Re: Interrupt Descriptor Table: minimum IDTR limit value

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

Author:  Stijn [ Fri Jan 05, 2018 3:10 pm ]
Post subject:  Re: Interrupt Descriptor Table: minimum IDTR limit value

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.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/