Page 2 of 3

Re:Question about Interrupts and Exceptions

Posted: Sun May 21, 2006 12:30 pm
by elderK
Would you mind telling me how you go that data?
I step through the code in Bochs, but it ends up looping over and over... Not even CPU loop, some assembly code.

Anywho, now that we know where its pointing and such, what do you think I should do to correct it?

:( Ive still no idea what to do. :(

~Zeii.
PS: Its rapidly closing on the time when I must depart Home and start my journey via Bus to my University... Ill be online there too. :P hehe. I study CompSci.

Re:Question about Interrupts and Exceptions

Posted: Sun May 21, 2006 12:36 pm
by elderK
I have no Linker script, thats the problem.
I set the Addresses for the .data, .text, .rodata, .bss all myself...
The Linker error tells you what you need to set the overlapping segment to.

Also, What OS / GCC Version are you using?

But, what the error is telling you is:
in the makefile,
on the LD command

.data should equal = 10D30

However, making that change will also tell you, that you need to set rodata to its new value, then BSS will complain.

;) I need to make a Linker Script.
But I had issues with it, Ill read up on documentation at Uni.

~Zeii.

Re:Question about Interrupts and Exceptions

Posted: Sun May 21, 2006 12:39 pm
by elderK
If you can make a Linker script, feel free.

I want .data to start at the end of .text,
.rodata at the end of data, .bss at the end of rodata.

Im not sure how to do that in Linker script.
Every try ive had has meant String literals and such stop working inside the OS.

~Zeii.

Re:Question about Interrupts and Exceptions

Posted: Sun May 21, 2006 12:40 pm
by Midas
Sure.

I ran the code in Bochs, to find where it triple faulted (ie where your divide-by-zero test was). I then set a virtual address breakpoint for about then ([tt]vb 0x8:0x10010[/tt]) and dump the CPU status ([tt]dump_cpu[/tt]) to see what the IDTR register is set to.

I then dumped the part of that memory that would correspond to the divide-by-zero entry in the IDT ([tt]xp /8b 0x0E000000[/tt] dumps 8 bytes at physical address 0x0E000000).

Quite apart from anything else, the address that the base of the IDT is set to sounds extremely iffy. 0x0E000000 when the rest of your data is loaded around the 0x10000 mark makes me wonder if there's a problem in the code that sets up the IDT pointer than you load into the IDTR.

Now, that said, I see absolutely nothing wrong in that code. It's reasonably similar to mine.

Re:Question about Interrupts and Exceptions

Posted: Sun May 21, 2006 12:55 pm
by elderK
HHmmm....
Its definitely in the line that is setting the k_idtp.ip_base = &k_idt;
I wonder why the Address for the IDT is all bjorked up.
Hmmm....

Thanks for teaching me how to trace along with you! :)

~Zeii.

Re:Question about Interrupts and Exceptions

Posted: Sun May 21, 2006 12:55 pm
by Midas
I'm using a GCC cross compiler using GCC 4.0.2 and binutils 2.16.1 as per these instructions.

I've attached a linker script that works for me (and also allows me to successfully build your code ^.^).

Note that in order for this to work, you have to add

Code: Select all

global CitadelBootLoader
To the start of your *loader.asm so that it's visible as the entry point to your linker.

Re:Question about Interrupts and Exceptions

Posted: Sun May 21, 2006 12:58 pm
by elderK
If it helps, Ive determined the location of the IDT.
Its in memory at location : 0x10E00.

Odd, even if I forcefully tell k_idtp.ip_base = 0x10E00,
the IDTR value from CPU Dump says its all 0x0E000000.

*scratches head*

~Zeii.

Re:Question about Interrupts and Exceptions

Posted: Sun May 21, 2006 1:14 pm
by YeXo
The cpu idt register points to a special structure, in which you load the idt base and limit. You're only changing the base in that structure, setting the idt register can only be done with de lidt instruction.

Re:Question about Interrupts and Exceptions

Posted: Sun May 21, 2006 1:22 pm
by Midas
YeXo wrote: The cpu idt register points to a special structure, in which you load the idt base and limit. You're only changing the base in that structure, setting the idt register can only be done with de lidt instruction.
His code does that.

Re:Question about Interrupts and Exceptions

Posted: Sun May 21, 2006 1:34 pm
by YeXo
Odd, even if I forcefully tell k_idtp.ip_base = 0x10E00,
the IDTR value from CPU Dump says its all 0x0E000000.
This looks like he is trying to set the base in the structure forcefully to 0x10E00, but this has nothing to do with loading the right value in the idt register. Also note that you don't need the address of the idt in the idt register, but the address of the special structure.

Re:Question about Interrupts and Exceptions

Posted: Sun May 21, 2006 1:38 pm
by Midas
Yes, I know (and so it would appear, does he).

His code creates this special structure, and sets the base value to the base of his IDT, and set the limit to the correct size.

He then does lidt [thisspecialstructure] to load the IDTR register with this structure.

However, using Bochs to examine the IDTR register shows that the base value for the IDT which the IDTR register points to is not being set to the correct value, regardless of what he sets it to in the structure, while the limit is.

Re:Question about Interrupts and Exceptions

Posted: Sun May 21, 2006 2:33 pm
by elderK
Hmm.
I still have no idea why the IDTR is holding the wrong address.

*lays cards on the table*
Midas, you have any ideas?

Here at Uni, Im forced to use DevC++, so Ill see if I can compile all of this here.

~zeii.

Re:Question about Interrupts and Exceptions

Posted: Sun May 21, 2006 3:47 pm
by mystran
If you use DevC++ to compile it, set another compiler, instead of the default MinGW, because MinGW is going to be trouble...

Re:Question about Interrupts and Exceptions

Posted: Sun May 21, 2006 4:57 pm
by elderK
Hey guys, I just had an idea...

;) Could this be because the A20 Gate isnt enabled?

~zeii

Re:Question about Interrupts and Exceptions

Posted: Sun May 21, 2006 9:40 pm
by elderK
Nope, not the A20 Gate.
Its the Base Pointer for the IDT Pointer, that gets passed to lidt.

Hhmmm...
The Base Pointer and Limit values are bjorked up...