Page 2 of 2
Posted: Fri May 18, 2007 9:35 pm
by pcmattman
Actually, I can't even get the interrupt code itself to execute when I come from virtual mode.
All the code I posted (irq_common_stub) does not get executed! Any ideas why?
Edit: not even creating an LDT helps. Why doesn't this work? Has anyone got any working code they could point me to, just so I can see where I'm going wrong?
Posted: Sun May 20, 2007 1:20 pm
by Aali
i know you've checked but this must have something to do with the IDT or TSS
did you use the bochs debugger to dump the relevant memory contents just before the crash?
Posted: Sun May 20, 2007 3:25 pm
by pcmattman
I'm guessing it must be my TSS, as I really didn't do much with it, I just set SS0:ESP0 and then installed it into the GDT (also set the IO bitmap).
Posted: Mon May 21, 2007 1:37 am
by Combuster
As hinted before, could you please provide us a hex dump of the IDT, GDT, LDT and TSS(s) involved just before the crash occurs? (including the GDTR IDTR LDTR and TR registers)
A floppy image showing this behaviour reliably will be helpful as well
Posted: Mon May 21, 2007 2:26 am
by pcmattman
<snip>
Posted: Mon May 21, 2007 2:48 am
by Combuster
that doesnt really reproduce your issue - right now your fat driver trips over an unformatted HD:
Code: Select all
[FAT ] Initializing FAT32 structures...
I've been rudely interrupted by the processor with this message for you:
Division By Zero
Registers at time of crash:
Error code: 0
Interrupt number: 0
EAX: 0xffffffff EBX: 0x 0 ECX: 0xffffffff EDX: 0xffffffff
EBP: 0x 328498 ESP: 0x 32824c ESI: 0x 0 EDI: 0x 10d8e2
Segments at time of crash:
CS: 0x 8 DS: 0x 10 ES: 0x 100010
FS: 0x 10 GS: 0x 100010 SS: 0x 0
Running bochs without harddisk sends the code into an infinite loop.
Summarized, I couldn't get to your actual problem. I don't have any bootdisks that allow me to partition the disk image and format it to FAT32. If you can easily disable that code it'd be great, otherwise we'll have to do with the hex dumps
In the meantime, you've got yourself some other bugs to fix
[edit] Why is SS reported to be the null selector? that is bound to give problems [/edit]
Posted: Mon May 21, 2007 2:52 am
by pcmattman
Hmmm... that's my drive detection code gone wrong... It's waiting there forever for IRQ14 or IRQ15 to fire.
The fixed image is in the same place.
Posted: Mon May 21, 2007 3:04 am
by Combuster
As soon as you (Combuster) download it either message me on ICQ or post here so I can remove the link.
Grabbed it. If you do not want everybody seeing that, send me an PM instead.
Right now I got to your bug, but i don't think I can complete the guru meditation before college starts.
Posted: Mon May 21, 2007 3:10 am
by pcmattman
Sounds good.
The bug you got was in my FAT32 initialization code, and it needs a valid FAT32 bootesector (otherwise divide by zero and worse comes). I'm not 100% sure how to tell if the drive is FAT32 or some other filesystem so I didn't check.
I've just committed the version of source that that image works with to my CVS so you can check that when you need to (it's all in the CPP_Kernel folder).
Posted: Mon May 21, 2007 4:10 am
by Combuster
Bochs reports the following tss settings:
GDT[0x05]=32-Bit TSS (Busy) at 0x0000001c, length 0x00067
tr:s=0x0028, dl=0x001c0067, dh=0x00008900, valid=1
In short, your TSS is probably not where you expect it to be. Check your GDT writing functions that it encodes the base of the GDT as expected (it currently seems to encode the base to 0x0000001c instead of 0x001c0000)
Posted: Mon May 21, 2007 4:14 am
by pcmattman
0x0000001c... I never noticed that before.
Out come the Intel manuals, got to figure out what went wrong
Edit:
Code: Select all
GDT[0x05]=32-Bit TSS (Busy) at 0x0010f61c, length 0x00068
Link map:
Now the problem is this:
Code: Select all
00024918077e[CPU0 ] interrupt(): SS selector null
00024918077e[CPU0 ] interrupt(): SS selector null
00024918077e[CPU0 ] interrupt(): SS selector null
At least we're making progress?
Edit: nope, nothing I've done is working... I'm somewhat confused at this error as I'm sure my SS0 and ESP0 values are correct.
Posted: Tue May 22, 2007 1:50 am
by pcmattman
Obviously not:
Code: Select all
tr:s=0x28, base=0x10f61c, valid=1
ss:esp(0): 0x0000:0x00000000
ss:esp(1): 0x0000:0x00000000
ss:esp(2): 0x0000:0x00000000
cr3: 0x00000000
eip: 0x00000000
eflags: 0x00000000
cs: 0x0000 ds: 0x0000 ss: 0x0000
es: 0x0000 fs: 0x0000 gs: 0x0000
eax: 0x00000000 ebx: 0x00000000 ecx: 0x00000000 edx: 0x00000000
esi: 0x00000000 edi: 0x00000000 ebp: 0x00000000 esp: 0x00000000
ldt: 0x0000
i/o map: 0x0000
Posted: Tue May 22, 2007 1:54 am
by pcmattman
Oh my, I fixed it!
It was rather simple... I forgot to set the stuff. Here's why:
I had a function to install the TSS (which also initialized it's SS0:ESP0 values), which I replaced when I found that the TR was in the wrong place.
When I removed it I forgot about the whole 'initialization of TSS' part and so everything in the TSS was NULL. Now, problem solved.
Thankyou so much everyone, I can't believe that I actually have a working virtual mode task now!
Edit: you know, there's something so satisfying looking at a screen like this after about a month of trying to get virtual mode working:
Code: Select all
[GDT ] Installing GDT... Done!
[IDT ] Installing IDT... Done!
[INT ] Installing interrupts (ISR/IRQ)... Done!
[TMR ] Installing timer... Done!
[KBD ] Installing keyboard... Done!
[MEM ] Installing memory manager... Done!
[MTSK] Initializing multitasking... Done!
[MTSK] Creating idle task and enabling tasking... Done!
[NULL] Idle task has started.
I've been rudely interrupted by the processor with this message for you:
General Protection Fault
Crash at 0x 1002 EFLAGS: 0x 33202
Registers at time of crash:
Error code: 26
Interrupt number: 13
EAX: 0x fb EBX: 0x 0 ECX: 0x 0 EDX: 0x 0
EBP: 0x 0 ESP: 0x 10ead0 ESI: 0x 0 EDI: 0x 0
V8086 SS:ESP (checks eflags)
SS: 0x 20 ESP: 0x 2900
<snip>
What I wouldn't have given to see that back then, now all I have to do is figure out how on earth I'm meant to handle this
.