Page 1 of 1

Crash on VMWare but not on real computer...

Posted: Wed May 18, 2005 7:19 am
by ChrML
This is kinda funny, but in VMWare my OS it can run fine (it starts from a floppy), as long as I don't have any harddrive device added. If I have a harddrive added, it crashes already on the bootloader (simple FAT12 loader using int 13). My floppy FAT12 loader does this:
- Copy itself from 0x7C00 to 0x6000
- Jump to 0:0x6000
- Load the second loader from the floppy to 0:0x7C00
- Jump to 0:0x7C00
- The second loader loads the kernel to 1MB mark
- Maps 1-4MB to the 2GB mark, maps the first 16MB 1:1, and the primary stack just before the 3GB mark
- Jumps to 2GB

Everything works fine on mum's computer (my kernel is big and well made). On VMWare it doesn't even get the second loader loaded, it simply freezes. Are there any common problems causing this kind of problems? It uses int 13 to load sectors from the boot drive (I keep the dl value the BIOS gives me), and it's sort of funny that an added empty harddrive can cause that kind of lockup, and it still works perfectly on mum's real computer. This sort of pisses me off, as I've worked a lot on my kernel (it has a good working memory manager, interrupts, driver + irq system, filesystem support etc...), and currently I can only test it on a physical computer over 6 meters away from this one, and that VMWare refuses to boot it while a harddrive is added sort of makes me feel that some parts that obviously should be working doesn't. In Bochs it always crashes.

My question basically is, what are the common causes when an OS crashes in an emulator but not on a real computer? I know I should paste some code, but my loaders are big, and won't be a too interesting reading.

Re:Crash on VMWare but not on real computer...

Posted: Wed May 18, 2005 7:42 am
by Brendan
Hi,
ChrML wrote:My question basically is, what are the common causes when an OS crashes in an emulator but not on a real computer? I know I should paste some code, but my loaders are big, and won't be a too interesting reading.
Does your code work on all real computers, or does it crash on some of them (perhaps your mum's computer is the only computer it actually works on!)? :)

I'd start by figuring out why it crashes on Bochs - chances are it's the same problem you're getting elsewhere, and it's easier to find the bug when your can use a debugger (the "out 0xE9,al" thing is also very handy to figure out how far it gets before crashing).


Cheers,

Brendan

Re:Crash on VMWare but not on real computer...

Posted: Wed May 18, 2005 7:58 am
by Pype.Clicker
we might help more with a more complete description of Bochs' crash. chances are that you're facing a 0:0x7c00 / 0x7c0:0 problem...

Re:Crash on VMWare but not on real computer...

Posted: Wed May 18, 2005 9:01 am
by ChrML
Debugging this was very easy compared to earlier. It stops at the call to the BIOS interrupt to reset the drive:

resetdrive:
   push   ax
   xor   ah, ah
   int   13h
   jnz   resetdrive
   pop   ax
   ret

It only happens in VMWare when a HD is added to the VMWare virtual machine. You think this is a (weird) problem with VMWare? Atleast other OS-es like Windows and Linux start up with harddrives, and I'm always supposed to blame my OS before I blame my emulator.

Re:Crash on VMWare but not on real computer...

Posted: Wed May 18, 2005 9:02 am
by Chrml
ADDED: I just made it safe from the 0:0x7C00 / 0x7C0:0 thingy:

_begin:
jmp 0:begin
begin:
;blablalba

Re:Crash on VMWare but not on real computer...

Posted: Thu May 19, 2005 4:14 am
by ChrML
Sorry, the problem was simply me making a fool out of myself :). I did a jnz without comparing first (making the result depend on the previous comparison done by the BIOS), instead of a jc.

Re:Crash on VMWare but not on real computer...

Posted: Thu May 19, 2005 6:44 am
by pkd
Another bug that may cause other problems is your push ax inside the loop, you may in effect be pushing 3 or 4 values onto the stack but are poping only one after the loop

resetdrive:
push ax <<<<<
xor ah, ah
int 13h
jnz resetdrive
pop ax
ret

easily fixed by removing the push from the loop eg

resetdrive:
push ax
resetdrive1:
xor ah, ah
int 13h
jnz resetdrive1
pop ax
ret

Re:Crash on VMWare but not on real computer...

Posted: Thu May 19, 2005 6:55 am
by ChrML
Another thing I didn't think of, thank you :).