• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            斜樹的空間

            集中精力,放棄一切的去做一件事情,只要盡力了,即使失敗了,你也不會(huì)后悔!

              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              47 隨筆 :: 0 文章 :: 12 評(píng)論 :: 0 Trackbacks
            作者:王聰

            引言

                 最近在做操作系統(tǒng)方面的研究,不得不去下一個(gè)虛擬機(jī) 來用。由于我不使用Windows,所以選擇很少了。因?yàn)樵贚inux上,差不多就只有兩款好的 虛擬機(jī)——Bochs和Qemu。這兩個(gè)之中,Bochs是用C++編寫,能在很多平臺(tái)上使用,而且不論什么平臺(tái), 它都不倚賴主機(jī)的指令系統(tǒng),總是模擬x86。所以我選擇了Bochs。但是,我驚訝地發(fā)現(xiàn) 關(guān)于如何在Linux上使用Bochs的資料很少。Bochs自帶的文檔中講得也不很明確,而且還 是英文的。所以我寫了這篇文章。

            安裝

                 到Bochs的主頁: http://bochs.sourceforge.net 上下載最新的Bochs RPM安裝包。(寫這篇文章時(shí),最新的版本是2.2.1。)以root的身份安裝:

            #rpm -ivh bochs-2.2.1-1.i586.rpm
            其實(shí)RPM安裝包給你裝上了四個(gè)新程序:bochs,bochs-dlx,bximage,bxcommit, 以及相關(guān)文檔。安裝完畢后,你可以先試試bochs-dlx,它是DLX Linux的一個(gè)demo。
            $ bochs-dlx
            ---------------------------------------------------------------
                         DLX Linux Demo, for Bochs x86 Emulator
            ---------------------------------------------------------------
            Checking for bochs binary...ok
            Checking for DLX linux directory...ok
            Checking for /usr/bin/gzip...ok
            Checking for /home/wangcong/.bochsdlx directory...ok
            Entering /home/wangcong/.bochsdlx
            Running bochs
            00000000000i[APIC?] local apic in initializing
            ========================================================================
                                     Bochs x86 Emulator 2.2.1
                             Build from CVS snapshot on July 8, 2005
            ========================================================================
            00000000000i[ ] LTDL_LIBRARY_PATH not set. using compile time default '/usr/lib/bochs/plugins'
            00000000000i[ ] BXSHARE not set. using compile time default '/usr/share/bochs'
            00000000000i[ ] reading configuration from bochsrc.txt
            00000000000i[ ] lt_dlhandle is 0x8bac490
            00000000000i[PLGIN] loaded plugin libbx_x.la
            00000000000i[ ] installing x module as the Bochs GUI
            00000000000i[ ] using log file bochsout.txt

            馬上,你就會(huì)看到一個(gè)X11窗口。



            顯示的是VGA BIOS信息,然后是加載Linux的信息。以root身份登錄,試試DLX Linux。安裝成功。

            使用

                 下面是一些重要的文件:

            /usr/bin/bochs Bochs啟動(dòng)程序
            /usr/bin/bximage Bochs帶的制作磁盤鏡像文件的工具
            /usr/bin/bxcommit 把redolog放進(jìn)flat磁盤鏡像文件中去的交互工具
            /usr/share/doc/bochs/bochsrc-sample.txt Bochs配置文件的例子
            /usr/share/bochs/BIOS-bochs-* ROM BIOS鏡像文件
            /usr/share/bochs/VGABIOS-* 與VGA BIOS鏡像文件相關(guān)的文件
            /usr/bin/bochs-dlx 啟動(dòng)Bochs中DLX linux的程序
            /usr/share/bochs/dlxlinux/ DLX Linux的目錄,包含它的磁盤鏡像文件和配置文件
            /usr/share/bochs/keymaps/*.map X11和SDL的keymap列表

                 命令bohcs可以接受4個(gè)參數(shù):-q 加載配置文件后跳過開始菜單;-f configfile 識(shí)別指定的配制文件;-n 不加載配置文件;-h 打印幫助信息;-qf configfile 相當(dāng)于同時(shí)使用-q和-f兩個(gè)選項(xiàng)。使用Bochs,你必須有一個(gè)配置文件,或者你通 過-f參數(shù)指定,或者讓Bochs自己搜索。配置文件的作用是告訴Bochs到哪里尋找鏡像 文件,模擬層如何工作等。Bochs搜索配置文件的順序是:


            1. bochsrc 在當(dāng)前目錄中


            2. .bochsrc 在用戶的主目錄中

            3. bochsrc /etc 目錄中

            以dlx-linux的配置文件為例,講一下如何定制你需要的配置文件。dlx-linux的 配置文件是/usr/share/doc/bochs目錄中的bochsrc-sample.txt。它的內(nèi)容 如下:
            ###############################################################
            # bochsrc.txt file for DLX Linux disk image.
            ###############################################################

            # how much memory the emulated machine will have
            megs: 32

            # filename of ROM images
            romimage: file=$BXSHARE/BIOS-bochs-latest, address=0xf0000
            vgaromimage: file=$BXSHARE/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

            # 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_mapping: enabled=1, map=$BXSHARE/keymaps/x11-pc-us.map
            #keyboard_mapping: enabled=1, map=$BXSHARE/keymaps/x11-pc-fr.map
            #keyboard_mapping: enabled=1, map=$BXSHARE/keymaps/x11-pc-de.map
            #keyboard_mapping: enabled=1, map=$BXSHARE/keymaps/x11-pc-es.map
            以#開頭的每一行都是注釋。注釋寫得很明白。
            megs: 32
            指明想要模擬32M的內(nèi)存。注意:后面的數(shù)字最大為2048,但是因?yàn)橹鳈C(jī)系統(tǒng)的限制,在 大多數(shù)系統(tǒng)上,Bochs甚至不能支持1024M。
            romimage: file=$BXSHARE/BIOS-bochs-latest, address=0xf0000
            指明ROM的鏡像文件在哪,開機(jī)時(shí)ROM BIOS被加載到哪里。$BXSHARE是環(huán)境變量,指明 Bochs的share目錄,在Linux上為/usr/share/bochs。這一般不用改動(dòng)。下面的vgaromimage 指明VGA ROM的鏡像文件位置。
            floppya: 1_44=floppya.img, status=inserted
            floppyb: 1_44=floppyb.img, status=inserted
            floppya是第一軟驅(qū),floppyb是第二軟驅(qū)。后面標(biāo)明的是軟驅(qū)鏡像文件的位置,軟盤 是否插入。可以根據(jù)你的需要做適當(dāng)?shù)男薷摹?
            ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
            ata0-master: type=disk, path="hd10meg.img", cylinders=306, heads=4, spt=17
            打開ata0通道,另外還有ata1,ata2,ata3。對(duì)于每一個(gè)通道,都必須指明兩個(gè)IO地址和IRQ。 ata0是默認(rèn)被打開的,它的ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14。ata0-master 是主ata0通道,后面指明它附帶的設(shè)備是硬盤,硬盤鏡像文件路徑,硬盤柱面數(shù),磁頭數(shù)等參數(shù)。
            boot: c
            指明啟動(dòng)次序,可以是cdrom,floppy,disk。不過由于歷史的原因a和c也能被接受。 也可以這樣來寫:
            boot: cdrom, floppy, disk
            mouse: enabled=0
            指明鼠標(biāo)是否可見。
            keyboard_mapping: enabled=1, map=$BXSHARE/keymaps/x11-pc-us.map
            打開對(duì)虛擬US鍵盤的重映射,keymap必須被指明。
                 更多的配置文件選項(xiàng)說明見/usr/share/doc/bochs/user/bochsrc.html。 如何編寫鍵盤的keymap列表見/usr/share/doc/bochs/user/keymap.html。

            制作磁盤鏡像

                 bximage是Bochs自帶的制作磁盤鏡像的工具,具有 良好的交互性,使用很方便。運(yùn)行bximage,你會(huì)看到:

            ========================================================================
                                             bximage
                               Disk Image Creation Tool for Bochs
                   $Id: bximage.c,v 1.25.2.1 2005/07/06 20:40:00 vruppert Exp $
            ========================================================================

            Do you want to create a floppy disk image or a hard disk image?
            Please type hd or fd. [hd]
            詢問我們是建立一個(gè)軟盤鏡像還是硬盤鏡像,默認(rèn)的是硬盤。我們直接按回車,選擇硬盤 鏡像。
            What kind of image should I create?
            Please type flat, sparse or growing. [flat]
            我們想建立一個(gè)簡單的鏡像,選擇默認(rèn)的flat。回車。
            Enter the hard disk size in megabytes, between 1 and 32255
            [10]
            想要多少M(fèi)byte的大小?鍵入你想要的大小。
            I will create a 'flat' hard disk image with
               cyl=2
               heads=16
               sectors per track=63
               total sectors=2016
               total size=0.98 megabytes

            What should I name the image?
            [c.img]
            在上一步中輸入“1”后,顯示相關(guān)的硬盤信息。詢問想要什么鏡像文件名字?默認(rèn)的是 c.img。輸入hd.img回車。
            Writing: [] Done.

            I wrote 1032192 bytes to hd.img.

            The following line should appear in your bochsrc:
               ata0-master: type=disk, path="hd.img", mode=flat, cylinders=2, heads=16, spt=63
            建立完畢。然后你就可以使用這個(gè)鏡像,用Bochs做實(shí)驗(yàn)了。

                 另外Bochs還有強(qiáng)大的調(diào)試功能,詳細(xì)請(qǐng)參閱用戶 手冊(cè)第8章。Bochs主頁上還有一些做好的系統(tǒng)鏡像,比如:OpenBSD,F(xiàn)reeDOS等。 不妨下載一個(gè)來試試。 Bochs的確是一款優(yōu)秀的工具,我推薦給每一位做操作系統(tǒng)研究的朋友。


            posted on 2010-10-16 18:12 張貴川 閱讀(705) 評(píng)論(0)  編輯 收藏 引用 所屬分類: 自己動(dòng)手些操作系統(tǒng)
            伊人 久久 精品| 欧美国产成人久久精品| 久久精品国产亚洲AV高清热 | 久久精品人人做人人爽电影| 国产婷婷成人久久Av免费高清| 国内精品久久久久| 久久人人爽人人精品视频| 三上悠亚久久精品| 国产综合成人久久大片91| 亚洲国产成人精品女人久久久| 色偷偷88888欧美精品久久久| 日本久久久久久中文字幕| 污污内射久久一区二区欧美日韩| 亚洲精品乱码久久久久久蜜桃不卡| 7国产欧美日韩综合天堂中文久久久久| 久久精品国产亚洲AV不卡| 久久国产精品99精品国产| 久久久久久久国产免费看| 久久不射电影网| 久久精品国产网红主播| 中文字幕久久精品| 久久久久国产日韩精品网站| 国产精品久久久久久影院| 7777久久久国产精品消防器材| 精品国产热久久久福利| 日本免费一区二区久久人人澡| 五月丁香综合激情六月久久| 中文字幕无码久久久| 久久99久久无码毛片一区二区| 久久精品国产影库免费看 | 久久精品国产精品国产精品污| 人妻无码αv中文字幕久久琪琪布| 久久高清一级毛片| 久久精品18| 久久99精品久久久久久噜噜| 伊人色综合久久天天| 久久综合九色综合久99| 91精品国产91久久久久久蜜臀| 99国产欧美久久久精品蜜芽| av无码久久久久不卡免费网站 | 久久久久久久久久久|