Orange‘s 一个操作系统的实现 chapter 1&2 记录

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

reference

  • 下载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
    problem3

    1. 调整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
  1. 注释掉
    #ata0-master: type=disk, mode=flat, path="30M.sample"
    #boot: disk
  1. 开启
boot: floppy

4.设置.bochsrc中floppya参数为 a.img 的路径

floppya: 1_44=../mine/a.img, status=inserted
2.4 Run

run

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
orange's个操作系统实现》是一本关于操作系统实现的书籍,其中第六章无法运行可能有以下几个原因。 首先,书中的代码可能存在错误。编写代码时,一些细节的失误可能导致程序无法正确运行。这可能是作者在编写书籍时出现的问题,或者是影响到第六章的代码遗漏或错误。在实际操作中,我们应该检查在书中提供的代码并尝试找到错误。 第二,缺少必要的软件或工具。在开发操作系统时,通常需要使用一些特定的软件和工具,例如汇编器、编译器、链接器等。如果这些软件或工具没有正确安装或配置,可能会导致第六章中的代码无法运行。 第三,硬件环境不符合要求。在实际操作系统的开发中,硬件环境的要求可能较高。如果硬件配置不符合第六章中所述的要求,例如内存容量过低或者缺少某些关键的硬件设备,那么无法保证代码能够正确运行。 最后,操作系统开发环境的设置可能有问题。正确设置开发环境是操作系统开发的关键。如果遗漏了某些设置步骤,例如环境变量的配置或者文件路径的设置等,那么第六章的代码可能无法正常运行。 针对以上可能的原因,我们可以先检查书中代码的正确性,然后逐步检查所需软件和工具的安装与配置,以及硬件环境是否符合要求。如果仍然无法解决问题,我们可以尝试在相关的开发社区或论坛上寻求帮助,与其他开发者交流并寻找解决方案。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值