这一次我们开始自己实现一个简单的操作系统,当然自己也是在看别人的视频进行学习,希望自己能从这个实验中学习到操作系统相关的知识
环境配置
环境配置
- VMware
- ArchLinux
- VSCode
- nasm
- bochs
- qemu
- gdb
VSCode远程连接
这个步骤就大家自行百度下把
boot.asm
[org 0x7c00]
; 设置屏幕模式为文本模式,清除屏幕
mov ax, 3
int 0x10
; 初始化段寄存器
mov ax, 0
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7c00
; 0xb8000 文本显示器的内存区域
mov ax, 0xb800
mov ds, ax
mov byte [0], \'H\'
; 阻塞
jmp $
; 填充 0
times 510 - ($ - $$) db 0
; 主引导扇区的最后两个字节必须是 0x55 0xaa
; dw 0xaa55
db 0x55, 0xaa
- 编译
nasm -f bin boot.asm boot.bin
- 创建硬盘镜像
bximage -q -hd=16 -func=create -sectsize=512 -imgmode=flat master.img
- 配置bochsrc
# configuration file generated by Bochs
plugin_ctrl: unmapped=true, biosdev=true, speaker=true, extfpuirq=true, parallel=true, serial=true, iodebug=true, pcidev=false, usb_uhci=false
config_interface: textconfig
display_library: x,options=\"gui_debug\"
memory: host=32, guest=32
romimage: file=\"/usr/share/bochs/BIOS-bochs-latest\", address=0x00000000, options=none
vgaromimage: file=\"/usr/share/bochs/VGABIOS-lgpl-latest\"
boot: disk
floppy_bootsig_check: disabled=0
floppya: type=1_44
# no floppyb
ata0: enabled=true, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=disk, path=\"../build/master.img\", mode=flat
ata0-slave: type=none
ata1: enabled=true, ioaddr1=0x170, ioaddr2=0x370, irq=15
ata1-master: type=none
ata1-slave: type=none
ata2: enabled=false
ata3: enabled=false
optromimage1: file=none
optromimage2: file=none
optromimage3: file=none
optromimage4: file=none
optramimage1: file=none
optramimage2: file=none
optramimage3: file=none
optramimage4: file=none
pci: enabled=1, chipset=i440fx, slot1=none, slot2=none, slot3=none, slot4=none, slot5=none
vga: extension=vbe, update_freq=5, realtime=1, ddc=builtin
cpu: count=1:1:1, ips=4000000, quantum=16, model=bx_generic, reset_on_triple_fault=1, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0
cpuid: level=6, stepping=3, model=3, family=6, vendor_string=\"AuthenticAMD\", brand_string=\"AMD Athlon(tm) processor\"
cpuid: mmx=true, apic=xapic, simd=sse2, sse4a=false, misaligned_sse=false, sep=true
cpuid: movbe=false, adx=false, aes=false, sha=false, xsave=false, xsaveopt=false, avx_f16c=false
cpuid: avx_fma=false, bmi=0, xop=false, fma4=false, tbm=false, x86_64=true, 1g_pages=false
cpuid: pcid=false, fsgsbase=false, smep=false, smap=false, mwait=true
print_timestamps: enabled=0
debugger_log: -
magic_break: enabled=1
port_e9_hack: enabled=0
private_colormap: enabled=0
clock: sync=none, time0=local, rtc_sync=0
# no cmosimage
log: -
logprefix: %t%e%d
debug: action=ignore
info: action=report
error: action=report
panic: action=ask
keyboard: type=mf, serial_delay=250, paste_delay=100000, user_shortcut=none
mouse: type=ps2, enabled=false, toggle=ctrl+mbutton
speaker: enabled=true, mode=system
parport1: enabled=true, file=none
parport2: enabled=false
com1: enabled=true, mode=null
com2: enabled=false
com3: enabled=false
com4: enabled=false
- 将boot.bin写入到主引导扇区
dd if=boot.bin of=master.img bs=512 count=1 conv=notrunc
bochs中运行
bochs -q -f bochsrc
若bochs中显示出一个H
,则表明配置环境成功,下一节,我们将对刚刚那个boot.asm
进行代码讲解
本文由博客一文多发平台 OpenWrite 发布!