1 boot.asm
org 07c00h
mov ax, cs
mov ds, ax
mov es, ax
call DispStr
jmp $
DispStr:
mov ax, BootMessage
mov bp, ax
mov cx, 16
mov ax, 01301h
mov bx, 000ch
mov dl, 0
int 10h
ret
BootMessage: db "Hello OS world!"
times 510-($-$$) db 0
dw 0xaa55
- compile
nasm boot.asm -o boot.bin
2 bochs
2.1 bochs installation
- 下载bochs(.tar.gz的压缩包)
tar -zxvf bochs-2.7.tar.gz
- 在bochs-2.7目录下执行
sudo ./configure --with-x11 --with-x --enable-all-optimizations --enable-readline --enable-debugger-gui --enable-x86-debugger --enable-a20-pin --enable-fast-function-calls --enable-debugger
sudo make all-clean
sudo make
sudo make install
2.2 Create floppy disk
- 创建软盘
dutura@ubuntu:~$ bximage
========================================================================
bximage
Disk Image Creation / Conversion / Resize and Commit Tool for Bochs
$Id: bximage.cc 14091 2021-01-30 17:37:42Z sshwarts $
========================================================================
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.
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]
Creating floppy image 'a.img' with 2880 sectors
The following line should appear in your bochsrc:
floppya: image="a.img", status=inserted
创建完成,当前目录下会多出一个磁盘映像(a.img)
- 将引导扇区写入软盘
dutura@ubuntu:~/Desktop/OS$ dd if=boot.bin of=a.img bs=512 count=1 conv=notrunc
1+0 records in
1+0 records out
512 bytes copied, 9.5893e-05 s, 5.3 MB/s
2.3 configuration & test
reference1
reference2
reference3
- problem 1
dutura@ubuntu:~/Desktop/OS/bochs-2.7$ bochs
========================================================================
Bochs x86 Emulator 2.7
Built from SVN snapshot on August 1, 2021
Timestamp: Sun Aug 1 10:07:00 CEST 2021
========================================================================
00000000000i[ ] BXSHARE not set. using compile time default '/usr/local/share/bochs'
00000000000i[ ] reading configuration from .bochsrc
00000000000e[ ] .bochsrc:197: wrong value for parameter 'model'
00000000000p[ ] >>PANIC<< .bochsrc:197: cpu directive malformed.
00000000000e[SIM ] notify called, but no bxevent_callback function is registered
00000000000e[SIM ] notify called, but no bxevent_callback function is registered
========================================================================
Bochs is exiting with the following message:
[ ] .bochsrc:197: cpu directive malformed.
========================================================================
- 设置model值为bx_generic
cpu: model=bx_generic, count=1, ips=50000000, reset_on_triple_fault=1, ignore_bad_msrs=1, msrs="msrs.def"
- problem 2
Bochs is exiting with the following message:
[ ] .bochsrc:955: Bochs is not compiled with lowlevel sound support
- 注释掉955行附近的sound及speaker两行
-
problem 3
- 调整romimage和vgaromimage两个参数为/home/dutura/Desktop/OS/bochs-2.7/bios/…-latest
romimage: file=/home/dutura/Desktop/OS/bochs-2.7/bios/BIOS-bochs-latest, options=fastboot
vgaromimage: file=/home/dutura/Desktop/OS/bochs-2.7/bios/VGABIOS-lgpl-latest
- 注释掉
#ata0-master: type=disk, mode=flat, path="30M.sample"
#boot: disk
- 开启
boot: floppy
4.设置.bochsrc中floppya参数为 a.img 的路径
floppya: 1_44=../mine/a.img, status=inserted