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.
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: How do i appropiately load the IDT?

Post by JAAman »

if the LIDT instruction was your only problem, why did you post about it instead of just looking it up in the manuals? volume 2 is the proper answer to any question about an instruction
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 »

crunch wrote: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
So? I do rtfm sometimes.

And my IRQ1 handler? Made all by me. I just read documentation and... well, translated it into code.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
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 »

"IDTR(Limit) ← SRC[0:15];
IDTR(Base) ← SRC[16:47]; "

The thing is, how do i implement this?
I know i can implement the first with something like "char limit[16];", but i'm not sure how to do the second.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
User avatar
Velko
Member
Member
Posts: 153
Joined: Fri Oct 03, 2008 4:13 am
Location: Ogre, Latvia, EU

Re: How do i appropiately load the IDT?

Post by Velko »

NunoLava1998 wrote:"IDTR(Limit) ← SRC[0:15];
IDTR(Base) ← SRC[16:47]; "

The thing is, how do i implement this?
You have already implemented this. Function lidt() in your mainf.c, starting at line 104 does exactly that. (Assuming your Github DixiumOS repo is up to date).

Or did you copy the code from somewhere, without knowing what it is for? You have to quit that habit.

It is normal to look at other peoples code to see how things are done. Or even copy some, but you must always understand what it does.
Get inspired from it, play around, break it, fix it, break it again, but never copy blindly.

That being said, are you familiar with JamesM or Bran's kernel development tutorials?
If something looks overcomplicated, most likely it is.
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 »

Velko wrote:
NunoLava1998 wrote:"IDTR(Limit) ← SRC[0:15];
IDTR(Base) ← SRC[16:47]; "

The thing is, how do i implement this?
You have already implemented this. Function lidt() in your mainf.c, starting at line 104 does exactly that. (Assuming your Github DixiumOS repo is up to date).

Or did you copy the code from somewhere, without knowing what it is for? You have to quit that habit.

It is normal to look at other peoples code to see how things are done. Or even copy some, but you must always understand what it does.
Get inspired from it, play around, break it, fix it, break it again, but never copy blindly.

That being said, are you familiar with JamesM or Bran's kernel development tutorials?
I meant how to make something like:

"char limit[16];
char base[16..47];"
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: How do i appropiately load the IDT?

Post by alexfru »

NunoLava1998 wrote: I meant how to make something like:

"char limit[16];
char base[16..47];"
Learn C.
User avatar
Velko
Member
Member
Posts: 153
Joined: Fri Oct 03, 2008 4:13 am
Location: Ogre, Latvia, EU

Re: How do i appropiately load the IDT?

Post by Velko »

NunoLava1998 wrote:I meant how to make something like:

"char limit[16];
char base[16..47];"
You did understand it wrong. (32-bit) LIDT loads a structure that is 48 bits long, not bytes. 16 bits for IDT's length, and then 32 - its address.

C structure:

Code: Select all

struct {
        uint16_t length;
        void*    base;
} __attribute__((packed))
is a way how to describe that.
If something looks overcomplicated, most likely it is.
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 how to make something like:

"char limit[16];
char base[16..47];"
Why would you want to do that?
Post Reply