DIOS stands for Desktop-oriented Independent Operating System. It is a minimalistic multi-tasking x86_64 OS written in D language with some small parts in NASM assembly, and it allows to write user applications in D as well. It is tested on a real hardware and emulators like VirtualBox and QEMU.
DIOS is an experimental platform for exploring system software architecture. It does not replicate either Unix or Windows. While some parts of the system are modeled after Unix and others are inspired by Windows, these design choices are primarily intended to maintain familiarity with existing systems and provide a better user experience. DIOS adopts proven concepts where appropriate, but its goal is not to create a complete clone of any existing operating system.
You can use DIOS as a basis for creating your own OS! PRs implementing new features are welcome.
- DIOS uses a monolithic kernel with all device drivers built into the kernel. It is primarily designed for modern computers and does not support legacy hardware.
- DIOS is now x86_64-only; 32-bit x86 support has been dropped.
- DIOS is designed as a graphical OS, but no built-in GUI toolkit is available yet. Graphical features are still under development.
- DIOS is an ELF kernel that requires a bootloader. Currently, only the Limine bootloader is supported.
- The default workflow in this repository assumes booting from a GPT-partitioned USB mass storage device on a UEFI system. CD images are no longer generated. Simply copy the contents of the
bootdiskfolder to a FAT32-formatted USB drive and select it as the first boot device in UEFI settings. - Installing DIOS on a SATA disk is theoretically possible, but this has not been tested on physical hardware, and the installation process is not yet streamlined. DIOS does not have a user-friendly graphical installer. In practice, there is currently little reason to install the system permanently. If you still want to try, see installation.md for details.
- Most userland programs are minimal reference implementations and may not meet everyone's needs. Any program can be replaced with an alternative implementation, including the graphics server.
Kernel:
- DIOS + Limine are compatible with both UEFI and BIOS (but the current build workflow supports only UEFI)
- UEFI GOP (or VESA) framebuffer
- SSE2, AVX
- IDT, GDT
- Bitmap page-frame allocator
- Low-latency HPET-based timer with legacy PIT fallback. Configurable system tick frequency (250 Hz by default)
- Minimal ACPI table reader
- I/O APIC, Local APIC
- CMOS date-time
- PCI enumeration
- Block device interface
- FAT32 (read-write) and exFAT (read-only)
- AHCI driver
- xHCI driver. USB keyboard and mouse; mass storage devices; USB hot-plug support; USB hubs support
- PS/2 keyboard and mouse
- A shell with built-in kernel commands; shell scripts
- Basic multi-tasking userspace in Ring 3; multithreading; system calls; spawning processes from other processes
- Virtual filesystem; multiple mount points; any detected volume can be mounted as the filesystem root
- RAM filesystem image loaded from a TAR archive (
rootfs.tar) provided by the bootloader - SATA disk partitioning and FAT32 formatting
- Standard output channels
Userspace:
- Work-in-progress appliation runtime library (ulib)
- Work-in-progress libc
- Graphics server (GFXD), windowed applications, transparent windows
- Work-in-progress desktop manager with a taskbar
- TTF font rasterization (with subpixel rendering) based on D port of stb_truetype
- UTF-8 support
- A number of basic built-in applications.
After successful initialization, the kernel immediately starts the graphics server and runs its own shell at the background. You can always switch to the shell with Ctrl+F1 and back to graphics with Ctrl+F2. Available shell commands are listed here.
In the graphics mode, you can open a terminal window by pressing a launcher button. Terminal's possibilities are quite limited at the moment, but you already can run built-in programs. For example:
about- prints the information about the systemtime- prints current date and timefile /home/hello.txt- prints a text fileimage /home/lake.tga &- displays a TGA imageblackboard &- a simple sketching appclock- a digital clocktruetype /etc/fonts/LiberationSans-Regular.ttf &- TTF font rasterization demo.
Full list of built-in programs is here.
The repo also contains a number of simple examples of what can be done in DIOS userspace. They are included in the prebuilt ISO image:
hello- "Hello, World!" program that prints its argumentsmemtest- dynamic memory allocation testmath- floating-point math functions testrandom- random number generator test.
Applications are also written in D, but they actually can be written in any language that can make platform-independent ELF64 binaries.
DIOS project consists of a several structural layers, each with its own workflow.
src/kernelcontains the kernel codesrc/ulibcontains the ulib runtime library codesrc/usercontains built-in programssrc/demoscontains sample applications.
ulib stands for "user library". It is a runtime library for DIOS applications written in D.
ulib contains code ported directly from RTLD, so it provides basic building blocks to write GC-free D programs. Because Phobos/druntime are not available under DIOS, some code discipline is required to manage memory properly. Also keep in mind that ulib/RTLD API is not a drop-in Phobos replacement, so porting existing programs may be a challenge.
RTLD module structure is kept, just replace rtld package with ulib in imports. For example, import ulib.core.memory; or import ulib.container.array;.
ulib also provides a micro-subset of libc, a bare minimum necessary for RTLD implementation. libc functions use C calling convention and can be used from non-D programs by static linking with libulib.a. See ulib.libc package.
GFXD is a graphics server and a window manager that allows other applications to create windows and draw graphics. It is a userspace program that must be present as /bin/gfxd.elf in the root filesystem.
When the kernel is started with gfx argument (first boot option in the list), GFXD is launched automatically. If you accidently booted the system in shell mode, you can start GFXD by running gfx start command. Ctrl+F1 switches back to the shell, Ctrl+F2 shows the server, Ctrl+F3 stops it.
import ulib.dios;
void main(string[] args)
{
uprintf("Hello, World!\n");
}ulib is currently statically linked; DIOS doesn't support dynamic linking yet.
DIOS uses its own build system written in Python that compiles the entire system. It does the following:
- Compiles the kernel (by default
bootdisk/kernel64.bin) - Compiles ulib (
bootdisk/lib/libulib.a) - Compiles userspace programs (
bootdisk/bin/*.elf) - Builds the root filesystem image (
bootdisk/boot/rootfs.tar).
Prerequisites:
Run python build.py to build everything.
Run python build.py kernel to build only the kernel.
Run python build.py ulib to build only ulib.
Run python build.py user to build only the userspace.
Userspace and sample programs (src/demos) can be built individually with DUB:
dub build
All *.elf binaries of the demos are automatically copied to bootdisk/bin.
Tianocore's Open Virtual Machine Firmware is required (OVMF.fd).
Create a USB stick image from the contents of bootdisk:
python build.py usb
Then run
qemu-system-x86_64 -cpu max,+rdrand -m 512M -bios OVMF.fd -vga std -device qemu-xhci,id=xhci -device usb-mouse,bus=xhci.0,port=1 -drive if=none,id=usbstick,file=usbstick.img,format=raw -device usb-storage,bus=xhci.0,port=2,drive=usbstick -display sdl,gl=on -d guest_errors
To test the installation, create a disk image:
qemu-img create -f raw disk.img 256M
Then run
qemu-system-x86_64 -cpu max,+rdrand -m 512M -bios OVMF.fd -vga std -device qemu-xhci,id=xhci -device usb-mouse,bus=xhci.0,port=1 -drive if=none,id=usbstick,file=usbstick.img,format=raw -device usb-storage,bus=xhci.0,port=2,drive=usbstick -drive if=none,id=hd0,file=disk.img,format=raw -device ich9-ahci,id=ahci -device ide-hd,drive=hd0,bus=ahci.0 -display sdl,gl=on -d guest_errors
This disk will be seen by the system as sata0.
VirtualBox requires images in VDI format, so you still need QEMU to convert raw *.img to *.vdi:
qemu-img convert -f raw -O vdi usbstick.img usbstick.vdi
Create a new virtual machine named "DIOS". Choose type "Other", version "Other/Unknown (64-bit)". It is recommended to set at least 512M of RAM.
In system settings, enable EFI. Add a USB controller and add a storage device to it. Use usbstick.vdi image.
