Page 1 of 1

IDT Line question

Posted: Mon Jul 19, 2010 11:33 am
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...

Re: IDT Line question

Posted: Mon Jul 19, 2010 12:16 pm
by Fanael
Almamu wrote:Is this IDT line correctly writed?
Yes, the function is written correctly.

Re: IDT Line question

Posted: Mon Jul 19, 2010 12:28 pm
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!

Re: IDT Line question

Posted: Mon Jul 19, 2010 11:53 pm
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.

Re: IDT Line question

Posted: Tue Jul 20, 2010 4:08 am
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 ?

Re: IDT Line question

Posted: Tue Jul 20, 2010 1:36 pm
by xenos
Yes, the order and the type of the variables in the struct.

Re: IDT Line question

Posted: Tue Jul 20, 2010 1:47 pm
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.

Re: IDT Line question

Posted: Wed Jul 21, 2010 12:03 am
by xenos
Looks fine to me, too.

Re: IDT Line question

Posted: Wed Jul 21, 2010 1:35 am
by TylerH
Can't "short" be 32 bit if you're compiling in 64 bit mode? Are you compiling 64 bit? Just a guess.

Re: IDT Line question

Posted: Wed Jul 21, 2010 4:12 am
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