OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Oct 28, 2020 8:22 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Virtualbox issues
PostPosted: Tue Apr 28, 2020 8:33 am 
Offline

Joined: Tue Apr 28, 2020 8:25 am
Posts: 1
I’m working on developing my own OS for a class. The OS boots fine on qemu and real hardware. However, I cannot for the life of me make it work on Virtualbox or DOSBox, which I need for Soundblaster 16 direct mode (QEMU only supports DMA transfers). I’m running the OS with:
Code:
qemu-system-i386                                 \           
  -cpu "SandyBridge-v2"                          \
  -m 256M                                        \
  -no-reboot                                     \
  -drive format=raw,file=usb.image               \
  -serial stdio                                  \
  -smp 1                                         \
  -usb                                           \
  -vga std                                       \
  -soundhw sb16


DOSBox can work with the .img file natively, for Virtualbox I’m using the following command to link a VMDK to the img. I’ve tried selecting the DOS preset, Other preset, and Other 64 bit preset:
Code:
VBoxManage internalcommands createrawvmdk -filename OS.vmdk -rawdisk os.img


We were given a boot loader and it seems to always fail here:
Code:
/*
** Read one complete program block into memory.
**
**   ax: number of sectors to read
**   es:bx = starting address for the block
*/
readprog:
   pushw   %ax      /* save sector count */

   movw   $3,%cx      /* initial retry count is 3 */
retry:
   pushw   %cx      /* push the retry count on the stack. */

   movw   sec,%cx      /* get sector number */
   movw   head,%dx   /* get head number */
   movb   drive, %dl

   movw   $0x0201,%ax   /* read 1 sector */
   int   $0x13
   jnc   readcont   /* jmp if it worked ok */

   movw   $err_diskread,%si /* report the error */
   call   dispMsg
   popw   %cx      /* get the retry count back */
   loop   retry      /*   and go try again. */
   movw   $err_diskfail,%si /* can't proceed, */
   call   dispMsg      /* print message and freeze. */
   jmp   .


In Virtualbox and DOSBox, the OS just spits out "Read failed" 3 times and "Can’t proceed” before halting (those strings are constants in the boot loader). I haven’t had luck with getting Bochs to even attempt to start. My guess is some offset is wrong and the boot loader is failing to calculate where it’s supposed to be reading from, or interrupt 0x13 isn’t working properly due to the virtual motherboard being configured incorrectly. I’m just confused as to why it works on real hardware and qemu but not Virtualbox nor DOSBox.


Top
 Profile  
 
 Post subject: Re: Virtualbox issues
PostPosted: Fri May 01, 2020 1:45 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 2415
You haven't included enough information to say exactly what's wrong, but the most common mistake in legacy BIOS bootloader development is using uninitialized registers. It could also be a problem in how the CHS address is being calculated.


Top
 Profile  
 
 Post subject: Re: Virtualbox issues
PostPosted: Fri May 01, 2020 3:25 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3975
Location: Chichester, UK
Have a look here for suggestions as to how to use a raw disk image with VirtualBox.

https://lira.epac.to/MyPublicWiki/VBox: ... alBox.html


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group