IDT Line question

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.
Post Reply
User avatar
Almamu
Member
Member
Posts: 47
Joined: Wed Jul 07, 2010 9:41 am

IDT Line question

Post by Almamu »

Is this IDT line correctly writed?:

Code: Select all

void idt_set_gate(unsigned char num, unsigned long base,
                  unsigned short sel, unsigned char flags)
{
    idt[num].base_lo = (base & 0xFFFF);
    idt[num].base_hi = (base >> 16 & 0xFFFF);
    idt[num].always0 = 0;
    idt[num].sel = sel;
    idt[num].flags = flags;
}
I was reading a tutorial, but this function is for personal writing, there is this part of the tutorial:
We'll leave you to try and code this function: take the argument 'base' and split it up into a high and low 16-bits, storing them in idt[num].base_hi and base_lo. The rest of the fields that you must set in idt[num] are fairly self- explanatory when it comes to setup.

Im not sure if it this correctly programmed, its based on GDT example of the same tutorial...
Image
Fanael
Member
Member
Posts: 38
Joined: Fri Oct 16, 2009 9:20 am

Re: IDT Line question

Post by Fanael »

Almamu wrote:Is this IDT line correctly writed?
Yes, the function is written correctly.
User avatar
Almamu
Member
Member
Posts: 47
Joined: Wed Jul 07, 2010 9:41 am

Re: IDT Line question

Post by Almamu »

Fanael wrote:
Almamu wrote:Is this IDT line correctly writed?
Yes, the function is written correctly.
Ops, sorry, im spanish, so..., xD. Thanks for all!
Image
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: IDT Line question

Post by xenos »

The function looks fine, but you need to make sure that also the IDT struct is declared properly, so each field (base_hi, base_lo...) is placed where it belongs.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
User avatar
Almamu
Member
Member
Posts: 47
Joined: Wed Jul 07, 2010 9:41 am

Re: IDT Line question

Post by Almamu »

XenOS wrote:The function looks fine, but you need to make sure that also the IDT struct is declared properly, so each field (base_hi, base_lo...) is placed where it belongs.
What are you talking about? The variables order in the struct ?
Image
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: IDT Line question

Post by xenos »

Yes, the order and the type of the variables in the struct.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
User avatar
Almamu
Member
Member
Posts: 47
Joined: Wed Jul 07, 2010 9:41 am

Re: IDT Line question

Post by Almamu »

XenOS wrote:Yes, the order and the type of the variables in the struct.

Code: Select all

typedef struct idt_entry
{
	unsigned short base_low;
	unsigned short sel;
	unsigned char always0;
	unsigned char flags;
	unsigned short base_high;
} __attribute__((packed)) idt_entry_t;
It's working at the moment.
Image
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: IDT Line question

Post by xenos »

Looks fine to me, too.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
TylerH
Member
Member
Posts: 285
Joined: Tue Apr 13, 2010 8:00 pm
Contact:

Re: IDT Line question

Post by TylerH »

Can't "short" be 32 bit if you're compiling in 64 bit mode? Are you compiling 64 bit? Just a guess.
User avatar
Almamu
Member
Member
Posts: 47
Joined: Wed Jul 07, 2010 9:41 am

Re: IDT Line question

Post by Almamu »

TylerAnon wrote:Can't "short" be 32 bit if you're compiling in 64 bit mode? Are you compiling 64 bit? Just a guess.
Nop,only 32
Image
Post Reply