Skip to content

NtinosTheGamer2324/ModuOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

397 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ModuOS

OS Type Architecture License Language

ModuOS is a hobby operating system written in C and x86-64 assembly, designed for learning and experimentation. It features a custom kernel with interrupt handling, memory management (paging, physical memory allocator), multitasking with process management, and support for multiple file systems (FAT32, ISO9660).

โœจ Features

  • Custom 64-bit Kernel: Long mode x86-64 kernel with Multiboot2 support
  • Memory Management: Physical memory allocator, virtual memory with paging, kernel heap
  • Process Management: Multitasking, context switching, ELF executable loading, syscall interface
  • Drivers:
    • Storage: ATA/ATAPI, AHCI/SATA support
    • Graphics: VBE text mode
    • Input: PS/2 keyboard and mouse
    • System: PCI enumeration, ACPI, RTC, PIC/Timer
  • File Systems: FAT32 and ISO9660 (read-only) with virtual file system layer
  • Userland: Basic applications and games (cat, echo, shell, games)
  • Built-in Games: Raycaster FPS, Snake (Eat Fruit), Stack Blocks, Vertical Ping Pong, Mine Sweeper

๐Ÿ“‹ Requirements

Build Environment

  • Docker Desktop - For cross-compilation environment
  • QEMU - For testing and running the OS
  • Windows - Primary tested platform (Linux/macOS may work with modifications)

Optional

  • Visual Studio Code or any code editor for development
  • Git for version control

๐Ÿš€ Quick Start

1. Clone the Repository

git clone https://github.com/NtinosTheGamer2324/ModuOS.git
cd ModuOS

2. Build the Docker Build Environment

The project uses a Docker container with a cross-compiler toolchain. Build the image:

docker build buildenv -t modu-os

This creates a modu-os image containing:

  • x86_64-elf-gcc cross-compiler
  • NASM assembler
  • GRUB bootloader tools
  • xorriso for ISO creation

3. Create a Disk Image

ModuOS requires a 1GB FAT32-formatted disk image named disk.img in the project root.

Option A: Using PowerShell (Windows)

# Create 1GB file
fsutil file createnew disk.img 1073741824

# Use Disk Management or diskpart to format as FAT32

Option B: Using third-party tools

โš ๏ธ Important: The build script does not create disk.img automatically. You must provide it.

4. Build and Run

Simply run the batch script:

run.bat

This will:

  1. โœ… Check if Docker is running (and start it if needed)
  2. ๐Ÿ”จ Build the kernel inside the Docker container
  3. ๐Ÿ“ฆ Create a bootable ISO with GRUB2
  4. ๐Ÿš€ Launch QEMU with the ISO and disk image
  5. ๐Ÿ“„ Open log viewer for com1.log and com2.log

5. Log Viewer Setup (Optional)

To view COM port logs during runtime:

  1. Download Log Viewer v1
  2. Place it at: vendor/NTSoftware/Log Viewer.exe
  3. The run.bat script will automatically open it

๐Ÿ“ Project Structure

ModuOS/
โ”œโ”€โ”€ buildenv/           # Docker build environment configuration
โ”œโ”€โ”€ include/            # Header files
โ”‚   โ””โ”€โ”€ moduos/         # Kernel, driver, and filesystem headers
โ”‚       โ”œโ”€โ”€ arch/       # Architecture-specific (AMD64)
โ”‚       โ”œโ”€โ”€ drivers/    # Hardware driver headers
โ”‚       โ”œโ”€โ”€ fs/         # File system headers
โ”‚       โ””โ”€โ”€ kernel/     # Kernel subsystem headers
โ”œโ”€โ”€ src/                # Source code
โ”‚   โ”œโ”€โ”€ arch/AMD64/     # x86-64 specific code (boot, interrupts, syscalls)
โ”‚   โ”œโ”€โ”€ drivers/        # Hardware drivers (ATA, AHCI, VGA, PCI, etc.)
โ”‚   โ”œโ”€โ”€ fs/             # File system implementations
โ”‚   โ””โ”€โ”€ kernel/         # Core kernel (memory, process, scheduler, etc.)
โ”œโ”€โ”€ targets/AMD64/      # Build target configuration
โ”‚   โ”œโ”€โ”€ iso/            # ISO layout for bootable image
โ”‚   โ””โ”€โ”€ linker.ld       # Linker script
โ”œโ”€โ”€ userland/           # User-space programs
โ”œโ”€โ”€ LICENSES/           # Third-party licenses
โ”œโ”€โ”€ Makefile            # Build system
โ”œโ”€โ”€ run.bat             # Build and test script
โ””โ”€โ”€ LICENSE             # Project license (GPLv2)

๐Ÿ› ๏ธ Manual Build Steps

If you prefer to build manually without run.bat:

# Build the kernel
docker run --rm -it -v "%cd%":/root/env modu-os make clean build-AMD64

# Run in QEMU
qemu-system-x86_64 ^
    -M pc-i440fx-6.2 ^
    -m 1024M ^
    -smp 2 ^
    -serial file:com1.log ^
    -serial file:com2.log ^
    -drive file=dist/AMD64/kernel.iso,format=raw,media=cdrom ^
    -drive id=disk,file=disk.img,if=none,format=raw ^
    -device ahci,id=ahci ^
    -device ide-hd,drive=disk,bus=ahci.0 ^
    -boot d

๐ŸŽฎ Available Applications & Games

Once booted, you can run:

Applications

  • cat <file> - Display file contents
  • echo <text> - Print text to console
  • sh - Simple shell
  • memtest - Memory testing utility
  • neofetch - System information display

Games

  • Raycaster FPS - First-person perspective game
  • Eat Fruit (Snake) - Classic snake game
  • Stack Blocks - Block stacking puzzle
  • Vertical Ping Pong - Pong variant
  • Mine Sweeper - Minesweeper clone

๐Ÿงช Development

Building Userland Programs

cd userland
./build.sh  # Linux/WSL

User programs are compiled separately and placed in targets/AMD64/iso/Apps/.

Debugging

  • Serial Output: Kernel outputs debug information to COM1 and COM2 ports
  • QEMU Monitor: Press Ctrl+Alt+2 in QEMU to access the monitor
  • GDB Debugging: Add -s -S to QEMU args and connect with gdb
qemu-system-x86_64 -cdrom dist/AMD64/kernel.iso -s -S &
gdb dist/AMD64/mdsys.sqr
(gdb) target remote localhost:1234
(gdb) continue

๐Ÿค Contributing

Contributions are welcome! Here's how you can help:

  1. ๐Ÿด Fork the repository
  2. ๐ŸŒฟ Create a feature branch (git checkout -b feature/amazing-feature)
  3. ๐Ÿ’พ Commit your changes (git commit -m 'Add amazing feature')
  4. ๐Ÿ“ค Push to the branch (git push origin feature/amazing-feature)
  5. ๐Ÿ”ƒ Open a Pull Request

Contribution Guidelines

  • Follow existing code style and conventions
  • Comment your code where necessary
  • Test your changes in QEMU before submitting
  • Update documentation if you add new features

๐Ÿ“„ License

This project is licensed under the GNU General Public License v2.0 only - see the LICENSE file for details.

Third-Party Components

ModuOS uses several third-party components:

  • GRUB2 - Bootloader (GPLv3+)
  • Multiboot2 - Boot protocol specification
  • GCC Cross-Compiler - Build toolchain (GPLv3+)

See the LICENSES folder for full license texts of third-party components.


๐Ÿ™ Acknowledgments

  • OSDev Community - Invaluable resources at wiki.osdev.org
  • Multiboot2 Specification - Boot protocol by GNU GRUB
  • randomdude/gcc-cross-x86_64-elf - Docker base image for cross-compilation

๐Ÿ“ž Contact & Links


Made with โค๏ธ for learning and fun

About

ModuOS is a hobby operating system written in C and x86-64 assembly.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors