Show HN:OSle——一个510字节的x86汇编操作系统
Show HN: OSle – A 510 bytes OS in x86 assembly

原始链接: https://github.com/shikaan/osle

OSle是一个非常小的操作系统,其全部代码都能够容纳在一个引导扇区(510字节)内!它使用x86汇编语言编写,并提供了一个功能 surprisingly 强大的实模式环境。其主要功能包括一个用于执行命令的shell,一个用于管理文件的系统,协作式进程管理,甚至还包括用户态软件。 它还包含一个软件开发工具包(SDK),允许用户创建自己的OSle程序。指南中提供了一个编写第一个程序的教程,详细介绍了必要的工具(NASM, Bochs)以及使用`make`、`sdk/build`和`sdk/pack`的构建过程。编译完成后,你可以使用`make start`或`make osle`,然后运行`qemu-system-i386 -fda osle.img`在Bochs或QEMU中测试OSle和你的程序。 如果使用`dd`将OSle直接写入物理设备,请务必极其小心,因为它可能损坏硬件。该项目是开源的(MIT许可证),欢迎贡献和功能请求。

Shikaan创造了OSle,一个仅510字节的x86汇编语言微型操作系统。它包含文件系统、shell和简单的进程管理,能够运行基本的应用程序。其目标是揭开汇编语言和操作系统开发的神秘面纱。 讨论要点包括汇编语言中高效使用以null结尾的字符串(与Pascal字符串相比),汇编语言中的代码共享策略,以及依赖BIOS中断进行显示输出。为了节省字节,选择使用"tty"中断在一个函数中同时打印和移动光标。OSle的名字来源于南德语的一个指小后缀"-le",表示某物的“小型版本”。 谈话还涉及到如果空间更大可以进行的改进(例如,更强大的API,内存管理),以及在没有分区表的情况下使用AHCI控制器的挑战。Shikaan使用Bosh模拟器调试汇编代码。

原文

logo

A tiny and mighty boot sector OS.

OSle is a real-mode OS that fits in a boot sector.

It's written in x86 assembly and, despite its tiny size (only 510 bytes), it packs essential features like:

  • Shell: Run commands and builtins.
  • File System: Read, write, and find files on the system.
  • Process Management: Cooperatively spawn child processes.
  • Userland Software: Comes with pre-built software and an SDK to write your own.

Check out the online demo to see it in action!

📚 Creating your first OSle program

OSle includes a tiny Software Development Kit (SDK) that includes definitions and a toolchain to create your own OSle programs.

Follow the step-by-step tutorial to write your first program!

To develop OSle and OSle programs you will need the following tools:

Installation instructions

Install dependencies using Homebrew:

brew install nasm
brew install bochs

Install dependencies using your local package manager, e.g., on Debian:

Build and Run OSle locally

These recipes will compile OSle and use the SDK to compile and bundle all the pre-built programs. Using start will also run bochs right away.

# build and run osle on bochs
make start

# or

# build osle
make osle
# use QEMU to run it
qemu-system-i386 -fda osle.img

Build and Run your OSle program

# ensure you have a working OSle image at osle.img
make osle

# compile your source to generate my_file.bin
sdk/build my_file.s

# bundle my_file.bin into the osle.img image
sdk/pack my_file.bin

# run it!
qemu-system-i386 -fda osle.img

Use OSle on a Real Device

Write the built image to a device using dd:

Warning

The following action can damage your hardware. We take no responsibility for any damage OSle might cause.

# generate an OSle image at osle.img
make osle

# write it on a device
sudo dd if=osle.img of=/dev/YOUR_DEVICE bs=512 count=1

Feel free to explore the issues and pull requests to contribute or request features.

MIT

联系我们 contact @ memedata.com