Address: http://blog.csdn.net/ariesjzj/article/details/8604335
Bochs is a simulator that provides debugging functions. Because all commands are simulated, it is slow. Virtualbox is a virtual machine (providing hardware and software virtualization, but the startup part is running on a qemu-based simulator). virtualbox also provides simple debugging functions.
This article is based on ubuntu12.04 lts (64 bits), but all functions have corresponding versions in windows. Here, we will take the example in "writing an operating system by yourself" as an example to introduce how to run IMG and COM files through virtualbox and bochs.
Virtualbox:
1. Install virtualbox
# Apt-Get install virtualbox
2. Download The MS-DOS installation disk (such as the http://download.csdn.net/detail/ariesjzj/5082584), then create the virtual machine, install dos.
To run the imgfile, insert the virtual disk to floppy in virtualbox. For example, after tinix. IMG is put into the example of "write your own operating system", it is displayed after startup:
If the executable file is compiled into a COM file, you must first complete the communication between the host and guest to copy the COM file. There are several methods, one is the network or share folder (see https://www.virtualbox.org/wiki/Sharing_files_with_DOS), but this method has to install a piece of software, it is more troublesome.
Another method is to make the file ISO, insert a virtual disc into virtualbox, and then dos access the disc. For example, to allow DOS to access the content under/home/jzj/CDROM in the host, create an ISO image first:
$ Mkisofs-r-o myiso. ISO/home/jzj/CDROM
Then add the Virtual Disk myiso. ISO to the storage of virtualbox. The dos installation disk above contains the CD-Rom driver, so you can access the optical drive without any additional operations (automatically mounted to the D disk ). However, if the downloaded DOS file is not supported by the CD by default, refer /.
In order to run the real-mode program, you also need to disable emm386. In config. sys of drive C, note out the lines with emm386.exe, for example:
Rem device = c: \ dos71 \ emm386.exe noems
Otherwise, an error occurs in the COM file in the running example. Now you can run the example in the book, for example:
Bochs:
1. Install bochs
# Apt-Get install bochs-SDL vgabios bochsbios
2. If you want to run tinix. IMG, first compile the bochs configuration file:
################################################################ bochsrc.bxrc file for Tinix.################################################################ how much memory the emulated machine will havemegs: 32# filename of ROM imagesromimage: file=$BXSHARE/BIOS-bochs-latestvgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest# what disk images will be usedfloppya: 1_44=TINIX.IMG, status=inserted# choose the boot disk.boot: a# where do we send log messages?log: bochsout.txtdisplay_library:sdl# disable the mouse, since Tinix is text onlymouse: enabled=0# enable key mapping, using US layout as default.keyboard_mapping: enabled=1, map=$BXSHARE/keymaps/sdl-pc-us.map
Bochs supports multiple front-ends. Here the SDL front-ends are used.
3. Start bochs
$ Bochs-F bochsrc. bxrc
As mentioned above, bochscomes with functions, bochsdbg.exe is available in windows, and binary is not available in Ubuntu, but can be compiled and generated by source code.
# Apt-Get source bochs
# Apt-Get install libsdl1.2-Dev
# Apt-Get build-dep bochs
$ Bochs-2.4.6 CD
$. /Configure -- With-SDL -- enable-debugger -- enable-disasm -- enable-all-optimizations -- enable-Readline -- enable-Long-phy-address -- enable-debugger-Gui -- enable -Long-phy-address -- enable-SMP -- enable-x86-64 -- enable-PCI -- enable-vmx -- enable-logging -- enable-FPU
-- Enable-CDROM -- enable-iodebug -- enable-3dnow
$ Make
$ Sudo CP bochs/usr/bin/bochsdbg
Then you can use
$ Bochsdbg-F bochsrc. bxrc
Debugging.
Other related materials:
Fully installed bochs2.3.7: http://blog.csdn.net/lating/article/details/5465221
Bochs startup problem solution: http://www.cnblogs.com/soli/archive/2009/09/21/1571466.html
Run the. com file in dos7.1 under virtual PC 5.2 problems: http://blog.csdn.net/terryhml/article/details/5469538
Java-written GUI bochs Debugger: http://code.google.com/p/peter-bochs/
Freedos networking with virtualbox 4.x( this freedos version is already configured with a network and can be used for communication between guest and host .) : Http://lazybrowndog.net/freedos/virtualbox/
Bochsdbg Method for debugging Protection Mode Program: http://blog.csdn.net/aliec/article/details/6982095