# LiziOS **Repository Path**: lihaohello/LiziOS ## Basic Information - **Project Name**: LiziOS - **Description**: 用尽可能少的代码、尽可能优雅的方式实现一个玩具操作系统,一窥操作系统的奥秘! Implement a toy OS by minimum code and in most elegant style. Let's explore the scretes of OS! - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2022-11-08 - **Last Updated**: 2025-04-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: 基础学习项目 ## README # 项目简介 - LiziOS项目旨在用尽可能少的代码、尽可能优雅的方式实现一个玩具操作系统,一窥操作系统的奥秘! - 作者:李浩(个人博客:lihaohello.top) # 环境搭建 ## Ubuntu 16、Ubuntu 18 ```shell sudo apt install build-essential gcc-multilib nasm bochs bochs-x ``` - build-essential: 开发套件,包括gcc、g++、make等工具 - gcc-multilib: 为gcc提供-m32选项支持,从而在64位平台编译出32位程序 - nasm: NASM汇编器 - bochs、bochs-x: 开源硬件模拟器,用于调试,后者用于界面调试 ## Arch Linux ```shell sudo pacman -S base-devel lib32-gcc-libs nasm yay -S bochs ``` - base-devel: 类似于build-essential - lib32-gcc-libs: 类似于gcc-multilib - 注意:在Arch Linux中需要使用yay安装bochs模拟器,且自带bochs-x ## bochs配置 由于不同版本的bochs,其使用方法有区别(包括bochsrc文件、bximage),所以需要区别对待 ### bochs 2.6 - bochsrc配置文件 ```txt # 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: image="../build/floppya.img", status=inserted # no floppyb ata0: enabled=true, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 ata0-master: type=disk, path="../build/master.img", mode=flat #ata0-slave: type=disk, path="../build/slave.img", mode=flat 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=file, dev=../build/serial.txt com2: enabled=false com3: enabled=false com4: enabled=false ``` - 命令行生成硬盘 ```shell yes | bximage -q -hd -mode=flat -size=16 $@ ``` ### bochs 2.8 - bochsrc配置文件 ```txt # 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: image="../build/floppya.img", status=inserted # no floppyb ata0: enabled=true, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 ata0-master: type=disk, path="../build/master.img", mode=flat #ata0-slave: type=disk, path="../build/slave.img", mode=flat 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=file, dev=../build/serial.txt com2: enabled=false com3: enabled=false com4: enabled=false ``` 其它版本的bochs配置,请根据bximage的帮助手册参照bochs 2.6、bochs 2.8进行设置。 - 命令行生成硬盘 ```shell bximage -func=create -hd=16 -imgmode=flat -q $@ ``` ## qemu配置 - 调试命令行 ```shell qemu-system-i386 -m 32M -boot c -hda master.img ``` - Arch Linux安装x86平台模拟器 ```shell yay -S qemu-desktop ```