cross-compiler 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.
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

Re: cross-compiler question

Post 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
"For those about to rock, we salute you"
-Brian Johnson
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: cross-compiler question

Post 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.
If a trainstation is where trains stop, what is a workstation ?
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: cross-compiler question

Post 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.
If a trainstation is where trains stop, what is a workstation ?
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

Re: cross-compiler question

Post 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.
"For those about to rock, we salute you"
-Brian Johnson
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: cross-compiler question

Post by gerryg400 »

If a trainstation is where trains stop, what is a workstation ?
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

Re: cross-compiler question

Post by Gman »

I'll look over it when I get more time.
"For those about to rock, we salute you"
-Brian Johnson
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

Re: cross-compiler question

Post 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.
"For those about to rock, we salute you"
-Brian Johnson
Post Reply