A toy, monotasking, self-hosted operating system in less than 3300 lines of code. Includes:
- a boot loader (~100 lines),
- a monolithic kernel (~1030 lines),
- a shell (~230 lines),
- a text editor (~220 lines),
- a compiler for a toy, statically-typed language called Toy (~1300 lines).
Toys runs in 192KB of RAM and uses less than 192KB of disk, in a 1MB partition (this includes 48KB of compiled code, and 106KB of source code). The compressed bootable disk image fits in 64KB. This is a port to x86_64 of the original version, which was written for an ARM-v7M micro-controller.
Toys can be run in QEMU or on real hardware. Once it is running, you can try the following commands:
list,list src/, etc to list the content of a "directory"snaketo play a simple snake game (type ESC to exit)edit src/snake/snake.toyto look at its source code (type ESC to exit)shell src/snake/BUILDto recompile this programshell src/toyc/BUILDto recompile the Toy compiler with itselfshell src/toys/BUILDto recompile the Toys kernelrebootto restart with the recompiled kernel- ...
- gcc
- make
- qemu-system-x86_64
On Ubuntu, the latter can be installed with sudo apt-get install qemu-system.
Type make to compile and run Toys from source code.
A computer with a 64 bits Intel or AMD processor, and UEFI support.
Warning: Toys has only been tested on a single personal computer (a 10 years old Gigabyte H110M-S2HP-CF with Intel Core i5 6500), it might not work on yours. In particular, Toys requires a 100x31 console mode.
- Download and uncompress the Toys bootable
disk image,
or build one from source code with
make image(requires gcc and make; the result is inbin/toys-1.0-amd64.img). - Flash this disk image on an USB stick. On Ubuntu, this can be done with
gnome-disks --restore-disk-image. - Reboot your computer and boot from the USB stick (you might need to disable Secure Boot in your UEFI settings).
- simple
- minimal
- readable
- self-hosted
- useful
- efficient
- portable
- text only (no GUI)
- keyboard input only (no mouse support)
- extremely basic, non-hierarchical file system
- monotasking: parent process suspended until a child process terminates
- single address space, identity mapped, shared between kernel and processes
- process isolation via memory page attributes and privilege levels
- basic exception handling: current process killed, parent resumed
- kernel isolation via system calls (open, read, write, close, etc)
- UEFI-based
There is no plan to develop Toys any futher, and in particular to add new features. On the contrary, some features might be removed to make Toys even smaller and simpler (but still self-hosted, with a "high-level" and "readable" language -- i.e., excluding assembly and concatenative languages).
- bin: the build results
- doc: documentation
- src: the Toy source code of all the components of Toys
- boot loader
- kernel
- shell
- text editor
- Toy compiler (toyc)
- command line tools (copy, delete, list, etc)
- test: automated tests to verify the self-hosting property of toyc and Toys
- tools: the tools to build a Toys bootable disk image
- toyc: the Toy compiler ported to ANSI C
- makefatfs: creates a Toys file system image containing all the source and compiled code of Toys
- makebootefi: wraps the boot loader in an UEFI PE32+ executable
- makefatfs: creates a FAT12 partition image containing the boot loader and the Toys file system image
- maketoysimg: creates the disk image by wrapping the FAT12 partition in a GUID partition table
This project is licensed under the GNU GPLv3 - see the LICENSE file for details.
