Page 1 of 1
Bochs: fetch_raw_descriptor??
Posted: Sun Oct 21, 2007 3:51 pm
by LordMage
I am trying to configure the PICs using the code from brans tutorial. here is the code and the error any help would be greatly appreciated:
Code: Select all
void irq_remap(void)
{
outportb(0x20, 0x11);
outportb(0xA0, 0x11);
outportb(0x21, 0x20);
outportb(0xA1, 0x28);
outportb(0x21, 0x04);
outportb(0xA1, 0x02);
outportb(0x21, 0x01);
outportb(0xA1, 0x01);
outportb(0x21, 0x0);
outportb(0xA1, 0x0);
}
Now unless I'm missing something that is exactly what he had and here is the debug in Bochs:
Code: Select all
[BIOS] Booting from 0000:7C00
[CPU0] fetch_raw_descriptor: GDT: index (447)88 > limit (17)
[CPU0] >>PANIC<< fetch_raw_descriptor: LDTR.valid=0
Any Ideas?? I can post more code if it might be something else, but the error happens when I try to run that function
Posted: Sun Oct 21, 2007 4:18 pm
by JAAman
im certainly no bochs expert, but that output looks like you tried to load a segment into one of the segment registers... but the segment number was higher than your current GDT.limit (which if i read it correctly is 17?)
it looks to me like your trying to execute invalid memory (perhaps data or just random memory addresses...) -- make sure all your asm jumps and branches are going to the correct place, and that your code is being linked and/or relocated at the correct addresses
Posted: Sun Oct 21, 2007 5:45 pm
by LordMage
Okay, what does the far jump when loading the GDT do??
Code: Select all
.
.
.
mov ss, ax
jmp 0x08:flush2
flush2:
.
.
Because I can't do it. I just can't figure it out using VC++. I finally got it to far jump but it is to the wrong location. I am using inline asm for everything.
I don't know if that is the problem but it is all I can think. the error actually shows up when I execute the outportb(0x21, 0x20). Here is the code from my outportb() function, might help but I doubt it.
Code: Select all
inline void _cdecl outportb (unsigned short portid, unsigned char value)
{
_asm
{
mov al, [value]
mov dx, [portid]
out dx, al
}
}
Re: Bochs: fetch_raw_descriptor??
Posted: Mon Oct 22, 2007 2:08 am
by JamesM
Now unless I'm missing something that is exactly what he had and here is the debug in Bochs:
Code: Select all
[BIOS] Booting from 0000:7C00
[CPU0] fetch_raw_descriptor: GDT: index (447)88 > limit (17)
[CPU0] >>PANIC<< fetch_raw_descriptor: LDTR.valid=0
Any Ideas?? I can post more code if it might be something else, but the error happens when I try to run that function
That error is to do with the GDT and has nothing to do with remapping the IRQs.
Okay, what does the far jump when loading the GDT do??
Code: Select all
.
.
.
mov ss, ax
jmp 0x08:flush2
flush2:
.
.
With all segment registers except the CS, you can just load a new value in. You cannot do this with the CS. To change it, you must 'far jump' or 'far call', that is, jump or call to a different segment.
In this code snippet a far jump is being done to 'flush2', which is just after the current instruction. The side effect of this is the CS gets changed to 0x08, which is what you want.
Your code will not work without this functionality.
Good luck!
Posted: Mon Oct 22, 2007 4:55 am
by LordMage
okay, I was thinking something along those lines. My next question is how do I do a far jump using VC++ inline asm I tried what I could find on MS Sites and google searches but I am either not doing it right or couldn't find the right procedure. If anyone knows I would appreciate knowing very much
Thanks
Posted: Mon Oct 22, 2007 5:56 am
by JamesM
What syntax does VC++ use? If it's AT&T syntax you want the 'ljmp <addr>, <segment>' pseudoinstruction.
Posted: Tue Oct 23, 2007 9:58 am
by JAAman
JamesM wrote:What syntax does VC++ use? If it's AT&T syntax you want the 'ljmp <addr>, <segment>' pseudoinstruction.
VC++ uses MASM -- that is intel syntax (or something like it -- iirc MASM is a little more complicated than NASM/FASM, but the same code should work essentially the same)
this is standard intel ASM, but MASM might require use of the FAR keyword... (because it does expect to run in flat PMode)
you might want to try it with the FAR keyword (FAR means with segment, near means without segment, and short means as an offset from current eIP):