Page 3 of 3

Re: cross-compiler question

Posted: Mon Jun 07, 2010 6:28 pm
by Gman
1:Everything looks fine, but you can see it if you want.

Code: Select all

typedef struct IDT_struct{
	u16 offsetLow;
	u16 segSelector;
	u8 reserved;
	u8 attributes;
	u16 offsetHigh;
}__attribute__((packed)) IDT_t;	
here is my descriptor struct too incase your wondering.

Code: Select all

typedef struct IDT_Desc{
	u16 size;
	u32 offset;
}__attribute__((packed)) IDT_Desc_t;
2: yes, it is a linear address, in the form descriptor:offset, so data has a value of 0x10

Re: cross-compiler question

Posted: Mon Jun 07, 2010 7:04 pm
by gerryg400
2: yes, it is a linear address, in the form descriptor:offset, so data has a value of 0x10
lidt will load from a linear address. Only lidt, lgdt, sidt and sgdt do this. This means if your data segment is based at 0x1000 and your idt is at 0x2000, you need to lidt 0x3000. The processor does NOT look at the DS to get the base address, you must do it yourself.
I'm pretty sure that your base address of DS is zero (It usually is) so ignore this.

Re: cross-compiler question

Posted: Mon Jun 07, 2010 7:12 pm
by gerryg400
One more gotcha to check. Are you sure that gcc is generating code for the divide by zero.

if you just do

Code: Select all

 int i;

 i = 6/0;
gcc won't generate any code unless i is used for something. Make sure that code is generated and put a while (1); after the code just in case it doesn't.

I just went thru this type of pain to get into 64bit mode. Do you have the Intel software Developers Manual Vol 2A ? If you look for the "INT n" instruction it has pseudo code for what happens when an interrupt occurs. It goes thru the privilege checks that are made etc. I went thru it line by line over a weekend checking every step and eventually found that the problem was my interrupt stack wasn't aligned correctly.

Re: cross-compiler question

Posted: Mon Jun 07, 2010 10:04 pm
by Gman
I believe that my div intruction is being executed. In memory there is the instruction idic eax,ecx and eax = 4, while ecx = 0.
Also, the code doesn't continue after this point so i'm assuming an interrupt is called.
Sadly I don't have a copy of the developer manuals, but I can get them.

Re: cross-compiler question

Posted: Mon Jun 07, 2010 10:08 pm
by gerryg400

Re: cross-compiler question

Posted: Mon Jun 07, 2010 10:49 pm
by Gman
I'll look over it when I get more time.

Re: cross-compiler question

Posted: Tue Jun 08, 2010 9:48 pm
by Gman
Ok, There was a problem with my GDT, so it didn't work, but now after I finish my first interrupt and after I go into a while(1); loop, I get a int 8, followed by a bunch a int 13's. My question is, do you have any idea why the first double fault is being called. It's no like my code is doing anything, it is just looping.