美文网首页
一. bochs环境

一. bochs环境

作者: wit_yuan | 来源:发表于2017-10-26 11:52 被阅读0次

1 简介

1.1 资源

1.bochs-2.6.8源码下载链接:链接

1.2 环境搭建

1 虚拟机环境

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.5 LTS
Release:    12.04
Codename:   precise

$ file /sbin/init
/sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x7aa29ded613e503fb09fb75d94026f3256f01e7a, stripped
wityuan@ubuntu:~/Downloads$ 

2 安装必要工具

$ sudo apt-get install vgabios bochs-x bximage bochs-sdl xorg-dev nasm bochsbios g++

3 编译,安装

编译,安装bochs.

$ sudo ./configure --enable-debugger --enable-disasm
$ sudo make 
$ sudo make install

4 编写程序,执行程序

a.编写程序,命名为hello.asm:

        org 07c00h
        mov ax,cs
        mov ds,ax

        mov es,ax
        call DispStr
        jmp $
DispStr:
        mov ax,Str
        mov bp,ax
        mov cx,13
        mov ax,01301h
        mov bx,000ch
        mov dl,0
        int 10h
        ret

Str:    db "hello world"
times   510-($-$$) db 0
dw      0xaa55

b.编译程序

$ nasm hello.asm -o hello.bin

c.制作floppy文件
首先制作空test.img磁盘:

$ bximage
bximage
========================================================================
                                bximage
  Disk Image Creation / Conversion / Resize and Commit Tool for Bochs
         $Id: bximage.cc 12690 2015-03-20 18:01:52Z vruppert $
========================================================================

1. Create new floppy or hard disk image
2. Convert hard disk image to other format (mode)
3. Resize hard disk image
4. Commit 'undoable' redolog to base image
5. Disk image info

0. Quit

Please choose one [0] 1

Create image

Do you want to create a floppy disk image or a hard disk image?
Please type hd or fd. [hd] fd

Choose the size of floppy disk image to create, in megabytes.
Please type 160k, 180k, 320k, 360k, 720k, 1.2M, 1.44M, 1.68M, 1.72M, or 2.88M.
 [1.44M] 1.44M

What should be the name of the image?
[a.img] test.img

Creating floppy image 'test.img' with 2880 sectors

The following line should appear in your bochsrc:
  floppya: image="test.img", status=inserted

$ dd if=hello.bin of=test.img bs=512 count=1 conv=notrunc

d.编写bochsrc文件

bochsrc文件内容为:

megs:32

romimage:file=/usr/share/bochs/BIOS-bochs-latest
vgaromimage:file=/usr/share/bochs/VGABIOS-lgpl-latest

floppya:1_44=test.img,status=inserted

boot:floppy

mouse:enabled=0

keyboard:keymap=/usr/share/bochs/keymaps/x11-pc-us.map

e.执行:

$ bochs -f bochsrc

f.启动成功,可以看到如下界面:


bochs启动成功

2 bochs操作系统测试

基于bochs,我们可以测试几个操作系统,以便可以自己去写一个操作系统,来熟悉x86结构。

1 MenuetOS

我也贴一张使用软盘启动后的界面:

MenuetOS启动界面.png

2 ReactOS

官网地址:链接
关于该系统,可以在官网上下载,然后在vmware上进行安装,我安装后,体验的系统效果如下图所示:

系统启动-1.png 系统启动-2.png 系统启动-3.png

相关文章

网友评论

      本文标题:一. bochs环境

      本文链接:https://www.haomeiwen.com/subject/trphpxtx.html