重复的*通用操作系统内核

时间:2022-09-01 08:30:41

hello os


环境准备

第一行汇编

boost.asm 在屏幕打印hello os

org 07c00h ;指定代码加载到7c00地址处

mov ax, cs
mov ds, ax
mov es, ax
call DispStr ;显示字符串
jmp $ ;无线循环

DispStr:
mov ax, BootMessage
mov bp, ax ;es:bp 串地址
mov cx, 24 ;字符串长度
mov ax, 01301h ;AH=13, AL=01h
mov bx, 000ch ;BH=0(页号0) BL=0CH(红底黑字高亮)
mov dl, 0
int 10h
ret

BootMessage: db "lxhuster hello os world"
times 510-($-$$) db 0 ;填充剩余空间
dw 0xaa55 ;固定的结束标志数

编译代码

nasm boot.asm –o boot.bin

创建虚拟软驱

bximage 生成lxhuster.img软驱

创建虚拟机配置文件

  • 可以从例子dlxlinux借鉴bochsrc.bxrc
  • 1) 注意路径
  • 2) 注意floppya: 1_44=lxhuster.img 修改为自己创建软驱名称
###############################################################
# bochsrc.txt file for DLX Linux disk image.
###############################################################

# how much memory the emulated machine will have
megs: 32

# filename of ROM images
romimage: file=..\BIOS-bochs-latest
vgaromimage: file=..\VGABIOS-lgpl-latest

# what disk images will be used
floppya: 1_44=lxhuster.img, status=inserted

# hard disk
#ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
#ata0-master: type=disk, path="hd10meg.img", cylinders=306, heads=4, spt=17

# choose the boot disk.
boot: floppy

# default config interface is textconfig.
#config_interface: textconfig
#config_interface: wx

#display_library: x
# other choices: win32 sdl wx carbon amigaos beos macintosh nogui rfb term svga

# where do we send log messages?
log: bochsout.txt

# disable the mouse, since DLX is text only
mouse: enabled=0

# set up IPS value and clock sync
cpu: ips=15000000
clock: sync=both

# enable key mapping, using US layout as default.
#
# NOTE: In Bochs 1.4, keyboard mapping is only 100% implemented on X windows.
# However, the key mapping tables are used in the paste function, so
# in the DLX Linux example I'm enabling keyboard_mapping so that paste
# will work. Cut&Paste is currently implemented on win32 and X windows only.

keyboard: keymap=..\keymaps\x11-pc-us.map

烧写boot.bin

烧写boot.bin 到 lxhuster.img

  • 方法一: 使用二进制编辑器将boot.bin内容复制到lxhuster.img

  • 方法二:编写个小工具,使用二进制模式完成方法一的动作

启动bochs

bochs -q -f bochsrc.bxrc

重复的*通用操作系统内核

hint

  • 为了方便虚拟机的位置在bochs安装目录下

重复的*通用操作系统内核

  • 参考资料
    Orange’S:一个操作系统的实现