operation system experiment 000

2023-12-15 05:36:34

Ubuntu18.04 bochs install

zlf@ubuntu:~/Documents/operation_system_experiment/000$ uname -a
Linux ubuntu 5.4.0-150-generic #167~18.04.1-Ubuntu SMP Wed May 24 00:51:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
zlf@ubuntu:~/Documents/operation_system_experiment/000$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.6 LTS
Release:	18.04
Codename:	bionic
zlf@ubuntu:~/Documents/operation_system_experiment/000$ 

zlf@ubuntu:~/Documents/operation_system_experiment/000$ wget https://nchc.dl.sourceforge.net/project/bochs/bochs/2.6.8/bochs-2.6.8.tar.gz
--2023-12-15 02:10:58--  https://nchc.dl.sourceforge.net/project/bochs/bochs/2.6.8/bochs-2.6.8.tar.gz
正在连接 127.0.0.1:7890... 已连接。
已发出 Proxy 请求,正在等待回应... 200 OK
长度: 5075617 (4.8M) [application/x-gzip]
正在保存至: “bochs-2.6.8.tar.gz”

bochs-2.6.8.tar.gz                                                   100%[=====================================================================================================================================================================>]   4.84M  7.71MB/s    用时 0.6s  

2023-12-15 02:10:59 (7.71 MB/s) - 已保存 “bochs-2.6.8.tar.gz” [5075617/5075617])

zlf@ubuntu:~/Documents/operation_system_experiment/000$ ll
总用量 4968
drwxrwxr-x 2 zlf zlf    4096 12月 15 02:10 ./
drwxrwxr-x 4 zlf zlf    4096 12月 15 02:04 ../
-rw-rw-r-- 1 zlf zlf 5075617 5月   3  2015 bochs-2.6.8.tar.gz
zlf@ubuntu:~/Documents/operation_system_experiment/000$ tar -zxf bochs-2.6.8.tar.gz
zlf@ubuntu:~/Documents/operation_system_experiment/000$ ll
总用量 4972
drwxrwxr-x  3 zlf zlf    4096 12月 15 02:11 ./
drwxrwxr-x  4 zlf zlf    4096 12月 15 02:04 ../
drwxr-xr-x 16 zlf zlf    4096 5月   3  2015 bochs-2.6.8/
-rw-rw-r--  1 zlf zlf 5075617 5月   3  2015 bochs-2.6.8.tar.gz
zlf@ubuntu:~/Documents/operation_system_experiment/000$ 
zlf@ubuntu:~/Documents/operation_system_experiment/000$ cd bochs-2.6.8/

./configure --with-x11 \
--with-x \
--enable-debugger \
--enable-disasm \
--enable-all-optimizations \
--enable-readline \
--enable-long-phy-address \
--enable-ltdl-install \
--enable-idle-hack \
--enable-a20-pin \
--enable-x86-64 \
--enable-smp \
--enable-cpu-level=6 \
--enable-large-ramfile \
--enable-repeat-speedups \
--enable-fast-function-calls \
--enable-handlers-chaining \
--enable-trace-linking \
--enable-configurable-msrs \
--enable-show-ips --enable-cpp \
--enable-debugger-gui \
--enable-iodebug \
--enable-logging \
--enable-assert-checks \
--enable-fpu \
--enable-vmx=2 \
--enable-svm \
--enable-3dnow \
--enable-alignment-check \
--enable-monitor-mwait \
--enable-avx \
--enable-evex \
--enable-x86-debugger \
--enable-pci \
--enable-usb \
--enable-voodoo
make -j`nproc`
make: *** 没有规则可制作目标“misc/bximage.cc”,由“misc/bximage.o” 需求。 停止。
cp misc/bximage.cpp misc/bximage.cc
cp iodev/hdimage/hdimage.cpp iodev/hdimage/hdimage.cc
cp iodev/hdimage/vmware3.cpp iodev/hdimage/vmware3.cc
cp iodev/hdimage/vmware4.cpp iodev/hdimage/vmware4.cc
cp iodev/hdimage/vpc-img.cpp iodev/hdimage/vpc-img.cc
cp iodev/hdimage/vbox.cpp iodev/hdimage/vbox.cc
sudo make install

验证完成安装

type bochs

//

zlf@ubuntu:~/Documents/operation_system_experiment/001$ ll
总用量 1460
drwxrwxr-x 2 zlf zlf    4096 12月 15 02:04 ./
drwxrwxr-x 4 zlf zlf    4096 12月 15 02:04 ../
-rw-rw---- 1 zlf zlf 1474560 12月 15 00:25 a.img
-rw-rw-r-- 1 zlf zlf    1821 12月 13 22:35 bochsrc.txt
-rw-rw-r-- 1 zlf zlf     809 12月 15 01:59 test.asm
-rw-rw-r-- 1 zlf zlf     512 12月 15 00:25 test.bin
zlf@ubuntu:~/Documents/operation_system_experiment/001$ 
zlf@ubuntu:~/Documents/operation_system_experiment/001$ 
zlf@ubuntu:~/Documents/operation_system_experiment/001$ 
zlf@ubuntu:~/Documents/operation_system_experiment/001$ cat bochsrc.txt 
plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1, iodebug=1
config_interface: textconfig
#使用GUI调试
display_library: x, options="gui_debug"
cpu: model=core2_penryn_t9600, count=1, ips=50000000, reset_on_triple_fault=1, ignore_bad_msrs=1, msrs="msrs.def"
cpu: cpuid_limit_winnt=0
cpuid: x86_64=1, mmx=1, sep=1, simd=sse4_2, apic=xapic, aes=1, movbe=1, xsave=1
cpuid: family=6, model=0x1a, stepping=5
romimage: file=$BXSHARE/BIOS-bochs-latest 
vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
vga: extension=vbe, update_freq=5
keyboard: type=mf, serial_delay=250, paste_delay=100000, user_shortcut=none
mouse: type=ps2, enabled=0, toggle=ctrl+mbutton
pci: enabled=1, chipset=i440fx
clock: sync=none, time0=local, rtc_sync=0
private_colormap: enabled=0
 
#软盘启动的配置,a.img为软盘名
floppya: type=1_44, 1_44=a.img, status=inserted, write_protected=0
 
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata1: enabled=0, ioaddr1=0x170, ioaddr2=0x370, irq=15
ata2: enabled=0, ioaddr1=0x1e8, ioaddr2=0x3e0, irq=11
ata3: enabled=0, ioaddr1=0x168, ioaddr2=0x360, irq=9
 
# 硬盘启动配置,a.img为硬盘名,根据硬盘大小不同需改变后三个参数的值
#ata0-master: type=disk, mode=flat, path=a.img, cylinders=130, heads=16, spt=63
#ata0-slave: type=none
#ata0-master: type=none
#ata1-slave: type=none
 
# 软盘启动/硬盘启动
boot: floppy
# boot: disk
 
floppy_bootsig_check: disabled=0
log: -
logprefix: %t%e%d
panic: action=ask
error: action=report
info: action=report
debug: action=ignore
debugger_log: -
com1: enabled=1, mode=null
com2: enabled=0
com3: enabled=0
com4: enabled=0
parport1: enabled=1, file=none
parport2: enabled=0
speaker: enabled=1, mode=system
magic_break: enabled=0
print_timestamps: enabled=0
port_e9_hack: enabled=0
megs: 2048
zlf@ubuntu:~/Documents/operation_system_experiment/001$ 
zlf@ubuntu:~/Documents/operation_system_experiment/001$ cat test.asm 
; hello_bochs.asm    
    xchg bx,bx
    org 07c00h                      ;The physics address of variables in memory = The offset of variables in this bin file + 0x7c00
    mov ax, cs
    mov ds, ax
    mov es, ax

    ;BIOS interrupt 0x10: print information 
    mov bp, MessageDisp         ; string address,es:bp
    mov cx, MessageDispLen      ; string length
    mov ah, 13h                 ; function code 13h
    mov al, 1                   ; display mode 1
    mov bl, 0ch                 ; display property:background color(black),string color(red)
    mov bh, 0                   ; page number
    mov dx, 1800h               ; row:18(row start from 0)
    int 10h

    jmp $

MessageDisp:          db  "Hello bochs!"
MessageDispLen        equ $ - MessageDisp

times 510-($-$$)    db 0
dw 0xaa55
zlf@ubuntu:~/Documents/operation_system_experiment/001$ 
zlf@ubuntu:~/Documents/operation_system_experiment/001$ nasm test.asm -o test.bin


利用bximage创建一个软盘镜像。bximage是安装bochs时顺带安装的软件。

zlf@ubuntu:~/Documents/operation_system_experiment/001$ 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] 

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

The disk image 'a.img' already exists.  Are you sure you want to replace it?
Please type yes or no. [no] yes

Creating floppy image 'a.img' with 2880 sectors

The following line should appear in your bochsrc:
  floppya: image="a.img", status=inserted
zlf@ubuntu:~/Documents/operation_system_experiment/001$ 
zlf@ubuntu:~/Documents/operation_system_experiment/001$ dd if=test.bin of=a.img bs=512 count=1 conv=notrunc
记录了1+0 的读入
记录了1+0 的写出
512 bytes copied, 8.9538e-05 s, 5.7 MB/s
zlf@ubuntu:~/Documents/operation_system_experiment/001$ 
zlf@ubuntu:~/Documents/operation_system_experiment/001$ 
zlf@ubuntu:~/Documents/operation_system_experiment/001$ bochs -q -f bochsrc.txt 


在上图下方输入框中,依次键入以下指令并回车

0x7c00+回车

c+回车

程序自动跳到源码处。

文章来源:https://blog.csdn.net/zlf19910726/article/details/135007492
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。