How nileshgupta1/nilos works
Project Type & Purpose
• NilOS is a lightweight operating system that includes a kernel, a minimal libc (often serving kernel-specific functionalities as libk), boot scripts, and ISO creation tools.
• The project is developed to boot via GRUB, load the kernel (which prints a welcome message), and run on x86 hardware (specifically the i386 architecture).
Main Components
a. Boot Loader & ISO Creation
• GRUB: Although the GRUB configuration is generated as part of the ISO creation process, include it as an external bootloader component that loads NilOS.
• ISO Image (nilos.iso): The product of the build process, prepared by the iso.sh script.
b. Kernel
• Kernel Source (in kernel/): Contains boot code (kernel/arch/i386/boot.S), early initialization (e.g., linker script, crti.S, crtn.S), and the core kernel logic (kernel/kernel/kernel.c).
• Architecture-specific components in kernel/arch/i386 (such as tty.c for terminal output) that highlight the low-level hardware interactions.
c. Minimal C Library (libc)
• libc Source (in libc/): Provides essential functions for stdio, stdlib, and string operations to support the kernel.
• That this minimal library is meant more as a “libk” for the kernel – possibly emphasizing tailored versions of common functions.
d. Build & Configuration Scripts
• Build Scripts (build.sh, iso.sh, clean.sh, qemu.sh, headers.sh, etc.): These scripts orchestrate the build process, header installation, ISO generation, and virtual machine booting.
• Configuration scripts (config.sh, default-host.sh) and makefiles within the kernel and libc also hint at the build pipeline and toolchain integration.
e. External Dependencies & Environment
• Cross-Compiler & Toolchain: The README describes building a cross-compiler (i686-elf-gcc), required for compiling both the kernel and the libraries.
• External tools such as GRUB, QEMU, and Xorriso that are vital for the boot process and for creating a bootable ISO.
Interactions and Data Flow
• Flow from the build output to ISO creation: build scripts generating the nilos.kernel and copying it into a boot directory in the isodir, followed by ISO assembly via grub-mkrescue.
Architectural Patterns & Design Principles
• Separation of Concerns: Clearly separate the “kernel” module (core OS logic and hardware interfacing) from the “libc” (providing standard C library functionalities).
• Modularity: The use of shell scripts to encapsulate build, test, and clean-up processes demonstrates a modular and reproducible build pipeline.
• Cross-Compilation: Emphasize that the system is developed to be compiled with an i686-elf cross-compiler, which isolates the build environment from the host system.
Technologies & Frameworks
• Programming Languages: Primarily C with some Assembly in the boot and architecture-specific components.
• Build Tools: GNU Make via makefiles located in kernel/ and libc/.
• Shell Scripting: Extensive use of bash scripts for configuration, building, and deployment.
• External Tools: GRUB for boot loading, QEMU for emulation, and other Unix-based build tools.