32-bit lab operating system built to experiment with cross-platform executable support via dual syscall tables.
(
- π― Project Vision
- π Key Features
- π Project Structure
- π₯οΈ Emulating System Environment
- π οΈ Prerequisites
- π Build and Run
- π Troubleshooting & Common Pitfalls
- π¬ Final Words
- π License
The primary goal of KeiOS is to serve as an experimental lab environment. Its standout feature is the planned implementation of two distinct syscall tables, allowing the OS to natively handle and execute both Windows and Linux binaries within a minimal custom kernel and user space.
- Architecture: 32-bit x86 (
i386) operating on a microkernel architecture. - Dual Syscall Interface: Purpose-built routing system to process system calls from both Windows and Linux executables natively.
- Modular Design: Clean structural separation between the bootloader, kernel, and user space code.
KeiOS/
βββ bin/ # Compiled binary
βββ include/ # Main header directory
β βββ arch/ # Architecture specific header definitions
β β βββ x86/ # 32-bit control registers, segmentations, and offsets
β βββ drivers/ # Peripheral configurations (network, audio, display)
β βββ kernel/ # Microkernel core system
β βββ libkern/ # Mini C standard library implementations for kernel space
β βββ config.h # Static build configuration toggles and hardware constants
βββ src/ # Source implementation directory
β βββ arch/ # Architecture specific setup code
β β βββ x86/ # 32-bit initialization sequences
β β βββ boot/ # Assembly bootstrap logic and multiboot entry points
β β βββ cpu/ # Descriptor table logic and CPU contexts
β β βββ memory/ # Memory layout managers, page routing, and allocation
β βββ drivers/ # Physical/virtual hardware interface drivers
β βββ kernel/ # Main execution pipelines and dual-syscall routing routers
β βββ libkern/ # Kernel support libraries and internal utility logic
βββ .clang-format # Configuration of automatic C coding style format
βββ .gitignore # Build artifacts, and raw log filters
βββ clean.py # Automation script to safely delete build folders and files
βββ grub.cfg # GRUB setup template for the live ISO image
βββ CONTRIBUTING.md # Guidelines for contributing and the contributor license agreement
βββ LICENSE.md # Full legal text for the project's copyleft distribution license
βββ linker.ld # Defining memory section offsets and physical loading bounds
βββ Makefile # GNU Make multi-stage instruction script
βββ menu.lst # Boot options template for direct GRUB configuration
βββ muke.bat # Compilation script for manual Windows builds
βββ README.md # Master repository documentation file
βββ run.py # Master orchestration script handling builds, assets, and QEMU setups
To accurately reproduce the performance, bottlenecks, and hardware constraints of early-2010s netbooks (such as the classic ASUS Eee PC or Acer Aspire One), the virtual machine configuration is intentionally restricted. The profiles below are tailored for QEMU and VirtualBox to replicate the baseline environment of a first-generation Intel Atom device.
| Component | Specification | Emulation Target |
|---|---|---|
| CPU | 1 vCPU | Mimics a single-core Intel Atom |
| Memory | 4GB RAM | Standard capacity for Windows XP |
| Boot mode | SeaBios BIOS | Legacy boot environment |
| Storage | 8GB HDD | Replicates early low-capacity storage |
- C Compiler: A C23-compliant compiler (e.g.,
gccorclang) - Assembler:
nasm(Netwide Assembler, used for low-level assembly routines) - Build System:
make(to parse the Makefile) - Toolchain:
binutils(for linking and binary manipulation) - ISO Utility:
xorriso,grub-mkrescue(essential for generating thekeios.isofile) - Scripting Language:
python 3.13(Required for running automation, build, and validation scripts) - Emulator:
qemu(specificallyqemu-system-i386) orVirtualBox(Alternative for full virtual machine testing)
To build and run KeiOS, select the instructions matching the active development environment below.
Install the required development tools, ISO utilities, Python environment, and emulators via the system package manager:
sudo apt update
sudo apt install build-essential nasm xorriso mtools qemu-system-x86 grub-common grub2-common grub-pc-bin grub-efi-amd64-bin python3(Note: mtools and xorriso are heavily used by tools like grub-mkrescue to build bootable ISO files. Install grub2-common if available on the distribution; otherwise, default to grub-common).
Developing an operating system natively on Windows comes with significant hurdles. Before choosing a setup, review the downsides below.
- The Binary Format Clash: Windows compilers naturally output
PE/COFFbinaries (.exe,.obj). Kernel development strictly requiresELFformat binaries. Compiling natively means a cross-compiler (i686-elf-gcc) must be set up manually, which is highly error-prone. - The Bootloader Nightmare:
grub-mkrescuerelies heavily on POSIX-compliant paths,bash, and internal GNU utilities. Getting GRUB to successfully stitch together a bootable ISO natively on Windows is notoriously difficult. - Line Ending Sabotage: Git on Windows automatically converts line endings from LF
\nto CRLF\r\n. This silent conversion can break linker scripts, assembly files, and Python build scripts without warning.
This bypasses all Windows downsides by running a genuine Linux environment directly inside Windows.
- Open PowerShell as Administrator and install WSL:
wsl --install- Restart the computer if prompted.
- Open the new Linux terminal (e.g., Ubuntu) and run the Linux Prerequisites command listed above.
If a native Windows environment is preferred, MSYS2 provides a reliable Unix-like toolchain.
- Download and install MSYS2.
- Open the MSYS2 MINGW32 terminal window (this targets the 32-bit architecture KeiOS requires).
- Install the compilation toolchain, assembler, Python, and ISO helpers:
pacman -S mingw-w64-i686-gcc mingw-w64-i686-make nasm xorriso python3Only use this option if getting WSL or MSYS2 running is not possible.
- Download the following packages, extract them, and organize them into a dedicated development folder (e.g.,
C:\OperatingSystemTools):
- Assembler: NASM Windows Binaries
- Cross-Compiler Alternative: i686-elf-tools (GitHub) (Essential to output ELF format binaries from Windows)
- ISO Creator: xorriso-exe-for-windows
- Python: Python for Windows (Ensure "Add python.exe to PATH" is ticked during installation)
- Emulators: QEMU Windows Installer and/or VirtualBox Windows Installer
- Bootloader Files: Legacy GRUB 0.97 i386-pc (Note: Use this specific version for manual ISO binding).
- Environment Variables: Add the paths of all extracted binaries to the system PATH variable.
- GRUB Manual Setup: Because
grub-mkrescueis unavailable, the ISO structure must be formatted manually:
- Copy
iso9660_stage1_5andstage2from the extracted GRUB files into the project's boot/root directory. - Rename
iso9660_stage1_5to exactlystage1. - Use the downloaded Windows
xorrisobinary targeting this manual directory structure to buildkeios.iso.
For automatically building and running execute the run.py python script:
python run.pyAlso the --help flag can be passed to view available usage options:
python run.py --helpBuild the kernel and generate the bootable .iso image using the provided Makefile.
On Linux / WSL:
makeOn Native Windows (MSYS2 MINGW32):
mingw32-makeFor Manual Addition (Windows): Run the provided batch script:
muke.batKeiOS can be booted using one of two methods depending on the setup:
If skipping the ISO build entirely is desired (or if on native Windows where grub-mkrescue isn't available), QEMU can be instructed to act as a Multiboot bootloader and load the kernel binary directly:
qemu-system-i386 -kernel bin/keios.binIf a full bootable CD image has been successfully generated and testing the actual bootloader configuration is needed:
qemu-system-i386 keios.isoHowever, executing it via the run.py python script is recommended to get access to all features (such as 4GB memory, 8GB memory disk, network driver, etc.).
If executing the ISO manually is preferred, follow these instructions:
- Build virtual disk
qemu-img create -f qcow2 disk.qcow2 8G- Execute the ISO
qemu-system-i386 \
-cpu n270 \
-m 4G \
-machine pc \
-rtc base=localtime \
-vga std \
-hda disk.qcow2 \
-net nic,model=rtl8139 -net user \
-device intel-hda \
-device hda-duplex \
-d int,cpu_reset -D qemu.log \
-cdrom keios.iso \
-debugcon file:debug.logOS development is a fragile process. If a build fails or QEMU refuses to launch properly, check these common issues first.
- The Symptom: QEMU launches, the window flashes or opens to a black screen, and CPU usage loops endlessly.
- The Cause: The kernel hit a Triple Fault. This usually happens if the Global Descriptor Table (GDT) is misconfigured, an interrupt handler is missing, or the stack overflows before the kernel fully boots.
- The Fix: Check the generated
qemu.loganddebug.logfile in the project root. Look for the last executed instruction or a[FATAL]message.
- The Symptom: Running
makeorrun.pyfails while trying to buildkeios.iso. - The Cause:
grub-mkrescueacts as a compiler frontend and requires external backends to stitch the filesystem format together. - The Fix:
- Ubuntu/Debian/WSL: Run
sudo apt install xorriso mtools. - MSYS2: Run
pacman -S xorriso.
- Ubuntu/Debian/WSL: Run
- The Symptom:
nasmorldthrows cryptic syntax errors on clean code paths. - The Cause: Line Ending Conversions. Git on Windows automatically converts files from LF (
\n) to CRLF (\r\n) during checkouts. This breaks low-level assembly definitions and linker maps. - The Fix: Force Git to preserve line endings by running:
git config --global core.autocrlf falseThen re-clone the repository or fix individual scripts using dos2unix.
- The Symptom: The linker (
ld) rejects compiled.objor.oobjects when linkingkeios.bin. - The Cause: A native Windows compiler target is being used. The host compiler outputs Windows PE/COFF architectures which cannot be mixed into flat binaries or standard ELF multiboot formats.
- The Fix: Use
i686-elf-gccor target the MSYS2 MINGW32 environment strictly to output the correct target architecture formats.
"If fighting is sure to result in victory, then you must fight!"
Sun Tzu said that, and I'd say he knows a little more about fighting than you do, pal, because he invented it, and then he perfected it so that no living man could best him in the ring of honor!
"With enough desire, you can do anything."
Even if it takes some time.
This project is licensed under the GNU General Public License v3.0 (GPLv3). See the LICENSE file for more details.