簡介
關於Bochs的介紹:http://en.wikipedia.org/wiki/Bochs
Bochs的官網:http://bochs.sourceforge.net/
這里記錄如何在Windows系統下使用Bochs,要在Bochs中運行一個操作系統需要准備一些資源:Bochs的執行文件,bios鏡像文件,vga bios鏡像文件,引導啟動磁盤鏡像文件。在使用Bochs時需要做一些系統預設參數,一般將這些參數放在一個配置文件中,文件后綴為bxrc。
配置文件
Bochs使用配置文件中的信息來尋找使用的磁盤鏡像文件,運行環境配置以及其他一些模擬器的配置信息。每個仿真系統都需要一個配置文件,配置文件后綴一般為.bxrc,這類后綴的文件可以直接被Bochs打開,在Windows下安裝Bochs之后會有一個bochsrc-sample文件,在這個文件里對所有可用的參數做了詳細說明。這里以Bochs自帶的dlxlinux為例,看看一些重要參數的含義。
############################################################### # bochsrc.txt file for DLX Linux disk image. ############################################################### # how much memory the emulated machine will have megs: 32 # filename of ROM images romimage: file=../BIOS-bochs-latest vgaromimage: file=../VGABIOS-lgpl-latest # what disk images will be used floppya: 1_44=floppya.img, status=inserted floppyb: 1_44=floppyb.img, status=inserted # hard disk ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 ata0-master: type=disk, path="hd10meg.img", cylinders=306, heads=4, spt=17 # choose the boot disk. boot: c # default config interface is textconfig. #config_interface: textconfig #config_interface: wx #display_library: x # other choices: win32 sdl wx carbon amigaos beos macintosh nogui rfb term svga # where do we send log messages? log: bochsout.txt # disable the mouse, since DLX is text only mouse: enabled=0 # set up IPS value and clock sync cpu: ips=15000000 clock: sync=both # enable key mapping, using US layout as default. # # NOTE: In Bochs 1.4, keyboard mapping is only 100% implemented on X windows. # However, the key mapping tables are used in the paste function, so # in the DLX Linux example I'm enabling keyboard_mapping so that paste # will work. Cut&Paste is currently implemented on win32 and X windows only. keyboard: keymap=../keymaps/x11-pc-us.map #keyboard: keymap=../keymaps/x11-pc-fr.map #keyboard: keymap=../keymaps/x11-pc-de.map #keyboard: keymap=../keymaps/x11-pc-es.map
megs用於設置模擬系統的內存,這里使用的是32MB。
romimage用於控制PC第一次上電后該做些什么,一般可以使用Bochs自帶的BIOS-bochs-latest文件。
vgaromimage要求用戶在C0000載入VGA ROM BIOS,這里可以使用Bochs自帶的VGABIOS-lgpl-latest文件。
floppya和floppyb分別表示第一個軟驅和第二個軟驅,如果需要從一個軟盤上來引導系統則floppya就需要指向一個可引導的磁盤。
ata0用於啟動模擬系統中的ATA通道,對於每個通道必須指明兩個IO基地址和一個中斷請求號。
ata0-master用來指明模擬系統中第一個ATA通道上連接的第一個ATA設備(硬盤等)。
boot用來定義模擬機器中踴躍引導啟動的驅動器,可以為軟盤硬盤或CDROM。
log用於記錄日志信息。
cpu用於指定cpu參數,其中ips表示每秒鍾的仿真命令數。
mouse用於指定模擬鼠標行為的參數。
keyboard用於指定模擬鍵盤行為的參數。
使用Bochs運行dlxlinux
Bochs為用戶制作了一個demo,在Bochs的安裝目錄下有一個dlxlinux目錄,里面有一個bochsrc.brxc的配置文件,雙擊這個文件就能在Bochs中啟動一個模擬的Linux系統。