Page 1 of 2

How do i appropiately load the IDT?

Posted: Wed Dec 21, 2016 4:13 am
by NunoLava1998
I need to load the Interrupt Descriptor Table in my environment (x86/32bit, compiled with C++, made in C/C++, i686-elf, protected mode).

However, i don't find much code or documentation about loading the IDT in this mode, and i have no idea how to load the IDT in my environment.

How do i?

Possible required info:
LIDT: function is in the kernel, code from Inline Assembly/Examples.
IO_WAIT: function is in the kernel, code from Inline Assembly/Examples.
IRQ1 handler: functions are in the kernel, code from OSDev wiki and mostly myself

Re: How do i appropiately load the IDT?

Posted: Wed Dec 21, 2016 4:34 am
by iansjack

Re: How do i appropiately load the IDT?

Posted: Wed Dec 21, 2016 5:51 am
by NunoLava1998
iansjack wrote:http://wiki.osdev.org/Interrupts
That explains absolutely nothing about my question, i already know what interrupts are and how they work, what i need help with is just loading the IDT.

Re: How do i appropiately load the IDT?

Posted: Wed Dec 21, 2016 6:05 am
by glauxosdever
Hi,


Next time please search better. The article describing IDT is here.

Hope this helps. :)


Regards,
glauxosdever

Re: How do i appropiately load the IDT?

Posted: Wed Dec 21, 2016 6:09 am
by NunoLava1998
glauxosdever wrote:Hi,


Next time please search better. The article describing IDT is here.

Hope this helps. :)


Regards,
glauxosdever
Thank you,
i just have no idea how to insert the data into the LIDT instruction.

Re: How do i appropiately load the IDT?

Posted: Wed Dec 21, 2016 6:46 am
by iansjack
NunoLava1998 wrote:I already know what interrupts are and how they work.
Everything that you have posted so far indicates that that is not true.

The article I linked to, and the references in it, explain everything.

Re: How do i appropiately load the IDT?

Posted: Wed Dec 21, 2016 6:51 am
by FusT
You should write an assembly routine (well, routine.. about 3 lines, actually) that takes a pointer to your IDTR struct (containing base and limit) and load that pointer using LIDT.

I'm not trying to sound mean or insult you, but if you can't figure out how to do this kind of very basic stuff than this is not (yet) the hobby for you.

Re: How do i appropiately load the IDT?

Posted: Wed Dec 21, 2016 6:54 am
by iansjack
There's rather more to it than that. First you have to write the interrupt handlers and then construct the IDT.

Re: How do i appropiately load the IDT?

Posted: Wed Dec 21, 2016 7:02 am
by NunoLava1998
iansjack wrote:There's rather more to it than that. First you have to write the interrupt handlers and then construct the IDT.
The ironic things is that i already made the interrupt handlers, i'm just trying to construct the IDT beacuse if i don't it triple faults.

Re: How do i appropiately load the IDT?

Posted: Wed Dec 21, 2016 7:05 am
by FusT
Of course there's more to it than that, but there is extensive documentation in the above linked wiki articles about what the IDT should look like.
Also, since those articles were linked, I assume that OP has read them before attempting to actually load an IDT, and understands that it's not as simple as just loading a value into the IDTR and expecting it to work.

Re: How do i appropiately load the IDT?

Posted: Wed Dec 21, 2016 7:18 am
by iansjack
I'm afraid that everything that the OP has posted so far indicates that he has no understanding of hardware interrupts. Let's face it, if you understand about interrupts and the IDT, loading the register is absolutely trivial. It's just the same as with the GDT.

Re: How do i appropiately load the IDT?

Posted: Wed Dec 21, 2016 7:22 am
by NunoLava1998
iansjack wrote:I'm afraid that everything that the OP has posted so far indicates that he has no understanding of hardware interrupts. Let's face it, if you understand about interrupts and the IDT, loading the register is absolutely trivial. It's just the same as with the GDT.
Oh, thanks for pointing that out (same as GDT).

I meant software interrupts, by the way.

Re: How do i appropiately load the IDT?

Posted: Wed Dec 21, 2016 7:53 am
by iansjack
NunoLava1998 wrote:I meant software interrupts, by the way.
I realize that.

Unfortunately, when considering a keyboard driver, it is hardware interrupts that you need to understand.

Re: How do i appropiately load the IDT?

Posted: Wed Dec 21, 2016 9:17 am
by NunoLava1998
iansjack wrote:
NunoLava1998 wrote:I meant software interrupts, by the way.
I realize that.

Unfortunately, when considering a keyboard driver, it is hardware interrupts that you need to understand.
And i actually have already made code for hardware interrupts, the only things i don't know about interrupts is how to work with things like lidt, lgdt, etc., but nothing else.

Re: How do i appropiately load the IDT?

Posted: Wed Dec 21, 2016 10:12 am
by crunch
Is your plan to just post about every single step in os development? Obviously you are not picking up on the fact that you MUST be able to read documentation and then be able to translate that into code.

There is no problem with asking questions. This stuff can be difficult to grasp. If you're getting stuck here, you're not going to make it much farther (without significant handholding) until you learn how to rtfm