I am pleased to announce an x86_64 port of Toys, a toy, monotasking, self-hosted OS, still in less than 3300 lines of code:
- source code: github.com/ebruneton/toys
- bootable disk image: toys-1.0-amd64.img.gz [64KB]
Disclaimer: I did this port in only 2 weeks, without any prior knowledge of the x86 architecture, instruction set, and system programming interface. The code might thus have bugs, issues or flaws due to my inexperience. Feedback from experts is welcome!
Important Note: to simplify, the UEFI-based bootloader never calls ExitBootServices(). This allows the kernel "drivers" to be really thin wrappers on top of the UEFI protocols. One might argue this is cheating and that Toys is thus not an OS. On the other hand, Toys touches on many topics presented on OSDev:
- making a compiler: Toy compiler
- UEFI: Toys UEFI library
- rolling your own bootloader: Toys boot loader
- file systems: Toys file system
- processes: Toys processes
- paging: Toys process isolation
- system calls: Toys system calls
- GDT, IDT, TSS: Toys kernel initialization
- getting to ring 3: spawning a new Toys process
- PE32, FAT, GPT, disk images: Toys disk image creation tools
Furthermore, the original version, equally small and self-hosted, does not use an UEFI or BIOS firmware (there are no such things on ARM micro-controllers). All this shows that creating a fully self-hosted OS is not so complex after all, if you sacrifice performance and many useful features...