Page 1 of 2
IDT and GDT
Posted: Sun Apr 07, 2002 9:14 am
by f2
What are these? What do they do? When are they set up? How are they set up?
Re:IDT and GDT
Posted: Sun Apr 07, 2002 5:21 pm
by K.J.
IDT:
Interrupt
Descriptor
Table
(from the Intel 386 Reference Manual)
The interrupt descriptor table (IDT) associates each interrupt or exception identifier with a descriptor for the instructions that service the associated event.
GDT:
Global
Descriptor
Table
(from the Intel 386 Reference Manula)
A descriptor table is simply a memory array of 8-byte entries that contain descriptors... A descriptor table is variable in length and may contain up to 8192 (2^(13)) descriptors. The first entry of the GDT (INDEX=0) is not used by the processor, however.
Descriptor:
(from the Intel 386 Reference Manual)
The segment descriptor provides the processor with the data it needs to map a logical address into a linear address. Descriptors are created by compilers, linkers, loaders, or the operating system, not by applications programmers.
The location of the GDT is specified with the
lgdt assembly instruction. The location of the IDT is specified with the
lidt assembly instruction.
The Intel 386 Reference Manual can be downloaded here:
http://www.execpc.com/~geezer/os/386intel.zip
Hope that helps you,
K.J.
Re:IDT and GDT
Posted: Sun Apr 07, 2002 5:28 pm
by f2
How do us programmers write this IDT? And where is the source code placed? How is it organized?
>> The segment descriptor provides the processor with the data it needs to map a logical address into a linear address. <<
And what are linear addresses? Logical addresses? How are they different/alike?
Thanks!
Re:IDT and GDT
Posted: Sun Apr 07, 2002 5:51 pm
by K.J.
Download Chris Geise's OSD example kernels(written in C and ASM) for an example of setting up and using an IDT and a GDT:
http://www.execpc.com/~geezer/osd/code/osd.zip
K.J.
Re:IDT and GDT
Posted: Sun Apr 07, 2002 8:19 pm
by f2
And what are linear addresses? Logical addresses? How are they different/alike?
And, should the link be
http://www.execpc.com/geezer/osd/code/osd.zip because the '~' is screwing up the link, I think. Thanks!
Re:IDT and GDT
Posted: Sun Apr 07, 2002 8:53 pm
by K.J.
The links should be:
http://www.execpc.com/~geezer/os/386intel.zip
and
http://www.execpc.com/~geezer/osd/code/osd.zip
As for the differences/similarities or linear and lagical adresses, I don't know for sure, they seem to have "double" meaning.
K.J.
Re:IDT and GDT
Posted: Mon Apr 08, 2002 4:13 am
by f2
So why would you need to map a logical to linear if they're the same? I'm pretty confused about what these really are. Addressing?
Re:IDT and GDT
Posted: Mon Apr 08, 2002 6:49 am
by DTShadowWolf
Logical Addresses are used in pmode with Virtual Memory by applications during run-time. It's supposed to be easier to use, ala Paging & what-not.
Linear Addresses occur from a flat memory layout ( generally before the GDT & IDT are setup along with virtual memory ), it can exist in PMode, but Logical Addresses w/ Paging are easier as Linear Addresses use Segmentation.
That's what I gather, maybe I'm off?
Re:IDT and GDT
Posted: Mon Apr 08, 2002 12:25 pm
by f2
So this GDT just converts these addressings? Do we program this GDT, or is it just...there?
Re:IDT and GDT
Posted: Tue Apr 09, 2002 3:50 am
by The_Legend
Well basically you set it up and exec the LGDT instruction
to load it. But another question: Do you think it gets
permantly changed? (Gates or whatever, or do you stick
with interrupt gates which only affect the IDT?)
Re:IDT and GDT
Posted: Tue Apr 09, 2002 1:49 pm
by f2
Is LGDT a NASM instruction? I don't recall it, but I'll go look it up. Thanks!
Re:IDT and GDT
Posted: Tue Apr 09, 2002 2:56 pm
by K.J.
[tt]lgdt[/tt] loads a gdt and [tt]lidt[/tt] loads an idt. They both work in NASM and are a standard x86 assembly instuction.
K.J.
Re:IDT and GDT
Posted: Tue Apr 09, 2002 4:44 pm
by f2
Where does it load the GDT and IDT? Into memory? How is this of use to us?
Re:IDT and GDT
Posted: Tue Apr 09, 2002 10:05 pm
by Chris Giese
Descriptors define memory usage in protected mode. They
provide address translation, which means the code can be
linked to run at one address, but can be loaded into memory
at a different address. They also provide protection. Both
of these are very useful for multitasking.
The GDT is a table of descriptors. The LGDT instruction
tells the CPU where the GDT is, and how big it is.
The interrupt descriptor table (IDT) tells the CPU where
to jump when an interrupt occurs. The LIDT instruction
tells the CPU where the IDT is, and how big it is.
You get to write the GDT and IDT. They can be stored
anywhere in memory.
"Normal" addresses are relative to the segment base. A
linear address is relative to 0. I'm not sure, but Intel's
docs may have a different meaning for "linear". I also
don't know what a "logical" address is. Most of the
online lecture notes for OS design classes use the
terms "virtual address" and "physical address".
Here is some code and a .GIF that might help explain the GDT:
http://www.execpc.com/~geezer/osd/pmode/pmode.gif
http://www.execpc.com/~geezer/osd/pmode/quick.zip
Re:IDT and GDT
Posted: Sun May 12, 2002 6:01 am
by jedld
After setting up the GDT and entering
protected mode, is there any way
to change the contents and size of the GDT?,
I tried to add an entry to the GDT and then
when I assigned its corresponding selector
to the SS register,it reboots. How do you
change the GDT after entering pmode?