How do i appropiately load the IDT?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

How do i appropiately load the IDT?

Post 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
Last edited by NunoLava1998 on Wed Dec 21, 2016 5:50 am, edited 1 time in total.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How do i appropiately load the IDT?

Post by iansjack »

NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

Re: How do i appropiately load the IDT?

Post 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.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
glauxosdever
Member
Member
Posts: 501
Joined: Wed Jun 17, 2015 9:40 am
Libera.chat IRC: glauxosdever
Location: Athens, Greece

Re: How do i appropiately load the IDT?

Post by glauxosdever »

Hi,


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

Hope this helps. :)


Regards,
glauxosdever
NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

Re: How do i appropiately load the IDT?

Post 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.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How do i appropiately load the IDT?

Post 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.
FusT
Member
Member
Posts: 91
Joined: Wed Sep 19, 2012 3:43 am
Location: The Netherlands

Re: How do i appropiately load the IDT?

Post 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.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How do i appropiately load the IDT?

Post by iansjack »

There's rather more to it than that. First you have to write the interrupt handlers and then construct the IDT.
NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

Re: How do i appropiately load the IDT?

Post 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.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
FusT
Member
Member
Posts: 91
Joined: Wed Sep 19, 2012 3:43 am
Location: The Netherlands

Re: How do i appropiately load the IDT?

Post 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.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How do i appropiately load the IDT?

Post 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.
NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

Re: How do i appropiately load the IDT?

Post 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.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How do i appropiately load the IDT?

Post 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.
NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

Re: How do i appropiately load the IDT?

Post 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.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
User avatar
crunch
Member
Member
Posts: 81
Joined: Wed Aug 31, 2016 9:53 pm
Libera.chat IRC: crunch
Location: San Diego, CA

Re: How do i appropiately load the IDT?

Post 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
Post Reply