OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Apr 23, 2018 9:14 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Interrupt Descriptor Table: minimum IDTR limit value
PostPosted: Thu Jan 04, 2018 11:42 am 
Offline

Joined: Tue Feb 07, 2012 6:55 pm
Posts: 8
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)


Top
 Profile  
 
 Post subject: Re: Interrupt Descriptor Table: minimum IDTR limit value
PostPosted: Fri Jan 05, 2018 4:23 am 
Offline

Joined: Tue Feb 28, 2017 10:22 am
Posts: 20
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.


Top
 Profile  
 
 Post subject: Re: Interrupt Descriptor Table: minimum IDTR limit value
PostPosted: Fri Jan 05, 2018 8:01 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8335
Location: At his keyboard!
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.


Top
 Profile  
 
 Post subject: Re: Interrupt Descriptor Table: minimum IDTR limit value
PostPosted: Fri Jan 05, 2018 3:10 pm 
Offline

Joined: Tue Feb 07, 2012 6:55 pm
Posts: 8
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group