V8086 mode hell...

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.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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?
Aali
Member
Member
Posts: 58
Joined: Sat Apr 14, 2007 12:13 pm

Post 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?
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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).
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

<snip>
Last edited by pcmattman on Mon May 21, 2007 3:06 am, edited 1 time in total.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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 :wink:

[edit] Why is SS reported to be the null selector? that is bound to give problems [/edit]
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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).
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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:

Code: Select all

                0x0010f61c                _global_tss
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.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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
Last edited by pcmattman on Sun Jul 19, 2009 5:56 pm, edited 1 time in total.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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 :D.
Post Reply