bochs 調試

bochs

安裝
從http://bochs.sourceforge.net/下載
./configure --with-all-libs --enable-vbe --enable-debugger
make
make install
#需要聲卡加--enable-sb16,需要網卡加--enable-ne2000,
#64位機使用--enable-x86-64,mmx和sse, smp默認不支持

用SLS Linux  測試
下載SLS Linux    從http://bochs.sourceforge.net/cgi-bin/topper.pl?name=Disk+Images&url=http://sourceforge.net/project/showfiles.phpqmrkgroup_ideq12580amppackage_ideq27799
把SLS Linux 解壓縮到一個文件夾

在終端下進到SLS Linux 所在的目錄:sls-0.99pl
然後運行bochs
出現問題:
========================================================================
                        Bochs x86 Emulator 2.3
              Build from CVS snapshot on August 27, 2006
========================================================================
00000000000i[     ] reading configuration from bochsrc
00000000000i[     ] WARNING: syntax has changed, please use 'vgaromimage: file=...' now
00000000000e[     ] bochsrc: unknown parameter for parport1 ignored.
00000000000e[     ] bochsrc: floppy_command_delay is DEPRECATED (now using hardware timing).
00000000000e[     ] bochsrc: ips directive is DEPRECATED (use cpu directive parameter 'ips').
------------------------------
Bochs Configuration: Main Menu
------------------------------

This is the Bochs Configuration Interface, where you can describe the
machine that you want to simulate.  Bochs has already searched for a
configuration file (typically called bochsrc.txt) and loaded it if it
could be found.  When you are satisfied with the configuration, go
ahead and start the simulation.

You can also start bochs with the -q option to skip these menus.

1. Restore factory default configuration
2. Read options from...
3. Edit options
4. Save options to...
5. Begin simulation
6. Quit now

Please choose one: [5]
00000000000i[     ] installing x module as the Bochs GUI
00000000000i[     ] using log file bochsout.txt
========================================================================
Event type: PANIC
Device: [MEM0 ]
Message: ROM: couldn't open ROM image file '/usr/local/share/bochs/bios/BIOS-bochs-latest'.

A PANIC has occurred.  Do you want to:
  cont       - continue execution
  alwayscont - continue execution, and don't ask again.
               This affects only PANIC events from device [MEM0 ]
  die        - stop execution now
  abort      - dump core
Choose one of the actions above: [die]
========================================================================
Bochs is exiting with the following message:
[MEM0 ] ROM: couldn't open ROM image file '/usr/local/share/bochs/bios/BIOS-bochs-latest'.
========================================================================


修改幾個地方就可以了:
romimage: file=$BXSHARE/bios/BIOS-bochs-latest, address=0xf0000
修改爲:romimage: file=$BXSHARE/BIOS-bochs-latest, address=0xf0000
vgaromimage: $BXSHARE/bios/VGABIOS-elpin-2.40
修改爲:vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest

在出現的界面login:輸入root
就進入系統
表示bochs的安裝成功


創建image文件
dd if=/dev/zero of=hdc.img bs=512 count=524160

Bochs 配置文件 bochsrc.bxrc。在 ata0-master 一行下加
入我們的硬盤 Image 文件的配置參數行:
ata0-slave:type=disk, path=hdc.img, cylinders=520, heads=16, spt=63
此處有些不明白,創建的hdc.img是否在/dev/zero路徑?path=hdc.img?


     利用 fdisk 命令在 hdc.img 文件中建立 1 個分區。下面是建立第 1 個分區的命令序列。建立另外 3 個
     分區的過程與此相仿。由於 SLS Linux 默認建立的分區類型是支持 MINIX2.0 文件系統的 81 類型
     (Linux/MINIX)  ,因此需要使用 fdisk 的 t 命令把類型修改成 80(Old MINIX)類型。這裏請注意,
     我們已經把 hdc.img 掛接成 SLS Linux 系統下的第 2 個硬盤。按照 Linux 0.11 對硬盤的命名規則,該
     硬盤整體的設備名應爲/dev/hd5(參見表 14–3)             。但是從 Linux 0.95 版開始硬盤的命名規則已經修改
     成目前使用的規則,因此在 SLS Linux 下第 2 個硬盤整體的設備名稱是/dev/hdb。
[/]# fdisk /dev/hdb
Command (m for help): n
Command action
    e   extended
    p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-520): 1
Last cylinder or +size or +sizeM or +sizeK (1-520): +63M
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): L
  0 Empty              8 AIX            75  PC/IX           b8 BSDI swap
  1 DOS 12-bit FAT     9 AIX bootable   80  Old MINIX       c7 Syrinx
  2 XENIX root         a OPUS           81  Linux/MINIX     db CP/M
  3 XENIX user       40 Venix           82  Linux swap      e1 DOS access
  4 DOS 16-bit <32M 51 Novell?          83  Linux extfs     e3 DOS R/O
  5 Extended         52 Microport       93  Amoeba          f2 DOS secondary
  6 DOS 16-bit >=32 63 GNU HURD         94  Amoeba BBT      ff BBT
  7 OS/2 HPFS        64 Novell          b7  BSDI fs
Hex code (type L to list codes): 80
Command (m for help): p
Disk /dev/hdb: 16 heads, 63 sectors, 520 cylinders
Units = cylinders of 1008 * 512 bytes
    Device Boot Begin    Start     End Blocks Id    System
/dev/hdb1            1       1     129 65015+ 80    Old MINIX
Command (m for help):w
The partition table has been altered.
Please reboot before doing anything else.
[/]#

接着重新啓動:

    再次進入 SLS Linux 模擬系統後,我們使用 mkfs 命令在剛建立的第 1 個分區上創建 MINIX 文件系
    統。命令與信息如下所示。這裏創建了具有 64000 個數據塊的分區(一個數據塊爲 1KB 字節)        。
[/]# mkfs /dev/hdb1 64000
21333 inodes
64000 blocks
Firstdatazone=680 (680)
Zonesize=1024
Maxsize=268966912
[/]#
     至此,我們完成了在 hdc.img 文件的第 1 個分區中創建文件系統的工作。


現在可以開始加載硬盤上的文件系統了。執行下列命令,把新的文件系統加載到/mnt 目錄上。
[/usr/root]# cd /
[/]# mount /dev/hd1 /mnt
[/]#

  在加載了硬盤分區上的文件系統之後,我們就可以把軟盤上的根文件系統複製到硬盤上去了。請執
行以下命令:
[/]# cd /mnt
[/mnt]# for i in bin dev etc usr tmp
> do
> cp +recursive +verbose /$i $i
done

    此時軟盤根文件系統上的所有文件就會被複制到硬盤上的文件系統中。在複製過程中會出現很多類
似下面的信息。
/usr/bin/mv -> usr/bin/mv
/usr/bin/rm -> usr/bin/rm
/usr/bin/rmdir -> usr/bin/rmdir
/usr/bin/tail -> usr/bin/tail
/usr/bin/more -> usr/bin/more
/usr/local -> usr/local
/usr/root -> usr/root
/usr/root/.bash_history -> usr/root/.bash_history
/usr/root/a.out -> usr/root/a.out
/usr/root/hello.c -> usr/root/hello.c
/tmp -> tmp
[/mnt]#
    現在說明你已經在硬盤上建立好了一個基本的根文件系統。你可以在新文件系統中隨處查看一下。
然後卸載硬盤文件系統,並鍵入'logout'或'exit'退出 Linux 0.11 系統。此時會顯示如下信息:


[/mnt]# cd /
[/]# umount /dev/hd1

[/]# logout


原文網址:http://blog.csdn.net/s_ware/article/details/1534854


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章