Page 1 of 1
Works in Bochs, Not in Virtual PC
Posted: Sat Feb 02, 2008 9:59 am
by neon
Hey everyone,
I do not have much experience with Virtual PC, but am hoping someone here may know something.
My system seems to work fine in Bochs and on real hardware, but Virtual PC does not seem to like it. It executes my bootloader fine, however it outputs an error ("Reboot and select proper boot device") whenever it attempts to execute my Kernel.
I have done some searching, but there does not seem to be a way for Virtual PC to output debugging information.
Does anyone here know where else to look?
Thanks
Posted: Sat Feb 02, 2008 11:03 am
by mathematician
My guess is that there isn't any way of getting debugging information from Virtual PC; it seems to be aimed at a different audience to Bochs. (i.e. somebody who wants to run different OS's without rebooting, but knows little and cares less about PC internals.)
Posted: Sat Feb 02, 2008 1:57 pm
by 01000101
I know you said that you have tested in on real hardware, but have you actually tested in on the machine that you are running VPC on?
Boches only emulates the neccecities, and even then, not to actually emulate the machine iteself... vpc on the other hand tries to emulate exactly what you have and in a most complete way. Also, do you have the correct boot mediums active in vpc? check in the menu to make sure that you have physical control over your cdrom or floppy or whatever you boot off of.
Posted: Sat Feb 02, 2008 2:18 pm
by jerryleecooper
I have some problem sometimes with Virtual PC. Sometimes my kernel works on it and qemu, but not on bochs, sometimes works on bochs and qemu but not on Virtual PC. Ive found the problem.
Your specific problem may be due to your disk image, if it's a floppy image, not being exactly 1440kb, VirtualPC wants exact sizes.
If you use an hard disk image then I don't know, I didn't try it.
Posted: Sat Feb 02, 2008 2:18 pm
by neon
vpc on the other hand tries to emulate exactly what you have and in a most complete way.
Hm... That is interesting.
Every time I start Virtual PC I always get a warning saying that it is running in an unsupported operating system (I am running this in WinXP Home)
I wonder if this has something to do with it?
Also, do you have the correct boot mediums active in vpc?
Yes. I am using a virtual floppy drive, and am having it boot off of it.
It is executing my bootloader fine. The bootloader even loads and executes my 2nd stage loader fine as well.
However, it never seems to get to the kernel...
Posted: Sat Feb 02, 2008 3:12 pm
by neon
Just a little update...
The problem seems to be in my 2nd stage loaders ReadSectors routine. Im not sure why it would work in Bochs and not Virtual PC though...
Posted: Sat Feb 02, 2008 4:05 pm
by 01000101
hmm that is indeed strange. Have you checked the afore mentioned floppy issue (the image needs to be exactly 1.44mb)?
It is also strange that it says you are in an unsupported operating environment. I have only really heard of that issue when it comes to the VirtualServer side of things.
Also, if you think about it, the ReadSectors command that you have, is probably actually trying to read physical floppy sectors. Maybe VPC is not emulating the floppy image correctly and still utilizing the physical floppy drive.
Try to write the floppy image to an actual floppy and then run VPC on the physical drive. maybe this will work.
Posted: Sat Feb 02, 2008 5:05 pm
by neon
hmm that is indeed strange. Have you checked the afore mentioned floppy issue (the image needs to be exactly 1.44mb)?
By "Virtual floppy drive", I mean a virtual floppy driver software. Basically it creates a virtual 1.44 MB floppy disk on drive A:. Windows will take this as if it was a real floppy disk (Which is why it works fine in Bochs. I have bochs boot from drive A - my floppy drive)
It is also strange that it says you are in an unsupported operating environment. I have only really heard of that issue when it comes to the VirtualServer side of things.
Hm... Unless I did not set it up correctly?
Then again, I got the same warning attempting to run the setup program...
After clicking the warning box "Continue" button, everything seems to work... I can post a pic of it, if you want to see it.
Also, if you think about it, the ReadSectors command that you have, is probably actually trying to read physical floppy sectors. Maybe VPC is not emulating the floppy image correctly and still utilizing the physical floppy drive.
I dont have a physical floppy drive, which is why I am emulating it
In any case, it seems to be using it fine as it does load my 1st stage bootloader. The 1st bootloader also correctly loads and executes my 2nd stage bootloader through FAT12 filesystem.
...It seems like it does not like the way I load the kernel image though. It does not even get to the jmp kernel instruction.
At the moment, I found what was causing it to output the original message ("Please insert proper boot media") - int 0x18.
Anywhoo, after commenting that instruction out, it seems to freeze though as if there was an infinity loop with ReadSectors :/
I can test the same system in Bochs and it works fine. In Virtual PC, it just halts.
Try to write the floppy image to an actual floppy and then run VPC on the physical drive. maybe this will work.
Its not quite a floppy image.
VFD contains a real floppy driver and installs it with Windows. This means, by using VFD to create a virtual floppy drive, it acts as a real physical drive.
---
I would like to post my ReadSectors routine, however I am currently testing if the problem actually does lie there. Its hard to tell if it is in ReadSectors or my FAT12 code.
Posted: Sat Feb 02, 2008 5:14 pm
by 01000101
I would suggest putting little "test" print statements ALL over the place to see how far you get exactly and that will narrow it down. Or if you want total assurance of sector to memory placement, try and load your bootsector somewhere in memory, and then test 510 bytes in for the boot-signature at the new memory location. I did that during my bootloader test, I would load a sector, and then use a hex editor to view what that sector contained and test the memory for the contents to ensure proper transport.
Posted: Sat Feb 02, 2008 5:30 pm
by neon
Disclaimer: Please note that the following images are running Windows XP Home Edition, Not Vista. It is installed with a Vista theme. Also note that this is using Virtual PC 7. I have heard of some changes between this and version 6...Perhaps this is where the problem is at?
This is the warning that I received by both the Setup program and when I run VirtualPC 7. Please keep in mind that I am using Windows XP Home, which, I believe is supported. Please correct me if I am mistaken:
Here is Virtual PC booting from my floppy disk. Please note that:
1. The time frame between the text "Loading Sectors" and "All sectors loaded" is the time frame of the LoadSectors routine.
2. LoadSectors, based off the timeframe between displayed text, runs very slow on VirtualPC, and fast on Bochs. I am thinking it is loading much more sectors on VirtualPC then its supposed to.
3. It works fine in bochs booting from the floppy drive. Why would VirtualPC a) never return from LoadSectors (As so it seems) and/or go into an infinity loop? Or can something else (Configuation in VirtualPC, perhaps?) cause this?
Thanks again for everyones help so far.
I am more confused as to why it works in Bochs, but not virtual PC.
Perhaps I am missing something...
*edit: I uploaded a different image. This image displays the large amount of sectors that VirtualPC is trying to load.
Posted: Sat Feb 02, 2008 5:35 pm
by mathematician
01000101 wrote:It is also strange that it says you are in an unsupported operating environment. I have only really heard of that issue when it comes to the VirtualServer side of things.
That bit is fairly easy to answer, because Virtual PC is supposed to need XP Professional or Vista Business on up.
Posted: Sat Feb 02, 2008 5:50 pm
by neon
*Updated.
Please compare the output of the new uploaded image (Shown above) to that of the output from Bochs screen:
Code: Select all
Booting from Floppy...
Loading Boot Image ...................................
Searching for Operating System...
Loading root directory table...
Loading sectors...
Sector Loaded
Sector Loaded
Sector Loaded
Sector Loaded
Sector Loaded
Sector Loaded
Sector Loaded
Sector Loaded
Sector Loaded
Sector Loaded
Sector Loaded
Sector Loaded
Sector Loaded
Sector Loaded
All sectors loaded!
...Loaded!
Root Directory Table Loaded!
Searching for file...
File not found
*** FATAL: MISSING OR CURRUPT KRNL.DLL. Press Any Key to Reboot
Bochs only loads 14 sectors while VirtualPC loads hundreds. :/ Not to mention Bochs gets to where the kernel is. (Please do not mind the fatal error displayed above--It is intentional as krnl.dll has not been built)
I am going to post ReadSectors to see if someone might see a problem with it running in VirtualPC.
Here it is...
Code: Select all
;************************************************;
; Reads a series of sectors
; CX=>Number of sectors to read
; AX=>Starting sector
; ES:EBX=>Buffer to read to
;************************************************;
ReadSectors:
.MAIN
mov di, 0x0005 ; five retries for error
.SECTORLOOP
push ax
push bx
push cx
call LBACHS ; convert starting sector to CHS
mov ah, 0x02 ; BIOS read sector
mov al, 0x01 ; read one sector
mov ch, BYTE [absoluteTrack] ; track
mov cl, BYTE [absoluteSector] ; sector
mov dh, BYTE [absoluteHead] ; head
mov dl, BYTE [bsDriveNumber] ; drive
clc ; clear carry flag
int 0x13 ; invoke BIOS
jnc .SUCCESS ; test for read error
xor eax, eax ; BIOS reset disk
int 0x13 ; invoke BIOS
dec di ; decrement error counter
pop cx
pop bx
pop ax
jnz .SECTORLOOP ; attempt to read again
.SUCCESS
pop cx
pop bx
pop ax
add bx, WORD [bpbBytesPerSector] ; queue next buffer
inc ax ; queue next sector
loop .MAIN ; read next sector
; VirtualPC gets here, but never seems to return where its supposed to.
; Everything works fine in Bochs, so I dont suspect a stack problem...
ret
Thanks for all of your help so far
Posted: Sat Feb 02, 2008 7:09 pm
by neon
*edit:
It seems if I uncomment the floppy read int 0x13 instruction, it works fine... I think I found the problem. Of course, I need that in order to load the sectors off disk.
...Still not sure whats causing it, though.
*edit 2:
I would like to make things more confusing: This is the same routine used in the 1st stage loader and works perfectly in loading stage2. Makes me wonder if the above code is the problem... Perhaps its where I am loading it to?
Hm....
Does Virtual PC have the A20 line automatically enabled at startup?
The Kernel is being loaded at 1MB. Perhaps the problem is indeed *where* specially if my A20 code is the problem... Bochs has it enabled by default, iirc, so cannot fully test that code.
Posted: Sun Feb 03, 2008 2:09 am
by bewing
Easy enough to test whether A20 is set -- especially if you just want to do it one time to check. I gave Zacariaz 3 methods on this thread:
http://www.osdev.org/phpBB2/viewtopic.php?t=16049