Second attempt at making an OS
Make sure you have following programs installed:
- meson
- ninja
- clang/clang++ (version >= 17)
- lld
- llvm
- xorriso
- tar
- xbstrap
- qemu-system-x86_64
- qemu-system-aarch64
Note: you may need more packages to build the sysroot, such as flex bison automake autoconf autopoint gperf help2man texinfo libgmp-dev libmpc-dev libmpfr-dev
etc
On debian based systems, I recommend installing llvm, clang and lld from here: https://apt.llvm.org
If you are on a up-to-date Debian based system (Ubuntu, linux mint, Pop_os!, etc) you can install most of them with this command:
sudo apt install clang lld llvm xorriso tar qemu-system-x86 qemu-system-arm
For meson, ninja and xbstrap, first make sure you have python and python-pip installed and then run:
python -m pip install meson ninja xbstrap
Follow these steps to build and run the os:
-
Clone this repo with:
git clone --depth=1 https://github.com/ilobilo/ilobilix
-
Currently you have to manually build the sysroot:
- Set the architecture in
boostrap.yml
mkdir build-sysroot
pushd build-sysroot
xbstrap init ..
xbstrap install base
- If symlink named
sysroot
does not exist in ilobilix source that links tobuild-sysroot/system-root
, then create it with:
ln -s $BUILD_SYSROOT_DIR$/system-root $KERNEL_DIR$/sysroot
For example:
ln -s build-sysroot/system-root ../sysroot
popd
-
Set up the build system:
meson setup builddir --cross-file cross-files/meson-kernel-clang-(x86_64/aarch64)(-ccache).cross-file -Doptions=values
-
Build and run the kernel:
ninja -C builddir <see Ninja Targets>
Target Name | Description |
---|---|
run_bios | Run with legacy BIOS (only on x86_64) |
run_bios_debug | Same but with debugging enabled |
run_uefi | Run with UEFI |
run_uefi_debug | Same but with debugging enabled |
norun | Do not run the OS |
Notes:
- run_(bios/uefi)_debug: Runs QEMU with
-d int
and-monitor telnet:127.0.0.1:12345
. Ifgdb
option is enabled, adds-s -S
- If target is not specified and architecture supports bios mode,
run_bios
will be used, otherwiserun_uefi
.
Project options | Default Value | Description |
---|---|---|
kernel_cflags | Extra c compiler arguments for kernel | |
kernel_cxxflags | Extra cpp compiler arguments for kernel | |
modules_cflags | Extra c compiler arguments for modules | |
modules_cxxflags | Extra cpp compiler arguments for modules | |
kernel_ubsan | false | Enable ubsanitizer in kernel |
modules_ubsan | false | Enable ubsanitizer in modules |
5lvl_paging | false | Enable 5 level paging in kernel |
syscall_debug | false | Print syscall log in serial console |
gdb | false | Add -s -S to QEMU when debugging |
noaccel | false | Disable QEMU accelerators |
vnc | false | Start QEMU VNC server on 127.0.0.1:5901 |
- meson: https://mesonbuild.com
- osdev wiki: https://wiki.osdev.org
- osdev discord server: https://discord.gg/RnCtsqD
- managarm: https://github.com/managarm/managarm
- tart: https://github.com/qookei/tart
- toaruOS: https://github.com/klange/toaruos
- LemonOS: https://github.com/LemonOSProject/LemonOS
- Sigma: https://github.com/sigma-os/Sigma
- Luna: https://github.com/thomtl/Luna
- vinix: https://github.com/vlang/vinix
- lyre: https://github.com/lyre-os/lyre
- limine: https://github.com/limine-bootloader/limine
- unifont: https://ftp.gnu.org/gnu/unifont/unifont-14.0.02
- uACPI: https://github.com/UltraOS/uACPI
- frigg: https://github.com/managarm/frigg
- mlibc: https://github.com/managarm/mlibc
- magic_enum: https://github.com/Neargye/magic_enum
- frozen: https://github.com/serge-sans-paille/frozen
- fmt: https://github.com/fmtlib/fmt
- printf: https://github.com/eyalroz/printf
- cwalk: https://github.com/likle/cwalk
- hashmap: https://github.com/ilobilo/parallel-hashmap
- smart_ptr: https://github.com/ilobilo/smart_ptr
- veque: https://github.com/ilobilo/veque
- terminal: https://github.com/ilobilo/limine-terminal
- demangler: https://github.com/ilobilo/demangler
- ilar: https://github.com/ilobilo/ilar
- ovmf: https://github.com/ilobilo/ovmf-binaries
- compiler-rt: https://github.com/ilobilo/compiler-rt-builtins
- libstdc++: https://github.com/ilobilo/libstdcxx-headers
- Serial
- GDT
- IDT
- TSS
- PCI
- PCIe
- MSI
- MSI-X
- Modules x86_64
- Modules aarch64
- DTB
- PS/2
- PMM
- VMM (5 and 4 level)
- Heap
- ACPI
- LAPIC
- IOAPIC
- uACPI
- VFS
- TMPFS
- DEVTMPFS
- PROCFS
- SYSFS
- USTAR
- ILAR
- AHCI
- NVME
- Block Device Interface
- EchFS
- EXT2
- FAT32
- HPET
- PIT
- RTC
- LAPIC Timer
- Generic Timer
- SMP
- Scheduler x86_64
- Scheduler aarch64
- System calls x86_64
- System calls aarch64
- Permissions
- MMAP
- FDs
- CDEV
- FBDEV
- TTY
- PTY
- ELF
- Userspace
- Signals
- mlibc
- RTL8139
- RTL8169
- E1000 (100E 153A and 10EA)
- Ethernet
- ARP
- IPv4
- ICMPv4
- TCP
- UDP
- libiconv
- libintl
- zlib
- file
- ncurses
- readline
- bash
- coreutils
- nano