Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MagixOS

A complete custom operating system built from scratch in x86 Assembly and C. Not based on any existing Linux distribution - everything from the bootloader to the shell is written from the ground up.

Features

  • Custom Bootloader - Stage 1 (MBR, 16-bit) + Stage 2 (32-bit protected mode)
  • Custom Kernel - Written in C with Assembly routines
  • Custom GDT/IDT - Global Descriptor Table and Interrupt Descriptor Table
  • Physical Memory Manager - Bitmap-based page frame allocator
  • Virtual Memory Manager - Page table management with identity mapping
  • Preemptive Scheduler - Round-robin process scheduling via PIT timer
  • PS/2 Keyboard Driver - Full scancode set 1 support with shift
  • VGA Text Mode - 80x25 color display with cursor
  • Serial Port Debug - COM1 output for kernel debugging
  • System Call Interface - INT 0x80 with 12+ syscalls
  • Custom libc - String, stdio, stdlib, ctype implementations
  • VFS Layer - Virtual filesystem with memory filesystem
  • Shell - Interactive command-line with 20+ commands
  • Userland Utilities - cat, ls, mkdir, rm, touch, clear, reboot, etc.

Quick Start

Prerequisites

# Ubuntu/Debian
sudo apt-get install build-essential nasm gcc-multilib qemu-system-x86

# Fedora
sudo dnf install gcc nasm qemu-system-x86

# Arch Linux
sudo pacman -S base-devel nasm qemu-system-x86

Build & Run

# Clone the repository
git clone https://github.com/itriedcoding/MagixOS.git
cd MagixOS

# Build everything
make all

# Test in QEMU
make test

Build Individual Components

make boot      # Build bootloader only
make kernel    # Build kernel only
make clean     # Clean build artifacts

Project Structure

MagixOS/
├── boot/
│   ├── stage1/boot.asm         # MBR boot sector (16-bit real mode)
│   └── stage2/stage2.asm       # Stage 2 loader (32-bit protected mode)
├── kernel/
│   ├── entry/
│   │   ├── main.c              # Kernel main entry point
│   │   └── entry.asm           # Assembly entry point + multiboot
│   ├── cpu/
│   │   ├── gdt.c               # Global Descriptor Table
│   │   ├── gdt_asm.asm         # GDT flush (assembly)
│   │   ├── idt.c               # Interrupt Descriptor Table
│   │   ├── isr.asm             # ISR/IRQ stubs (assembly)
│   │   └── irq.c               # IRQ handler + PIC
│   ├── drivers/
│   │   ├── vga.c               # VGA text mode (80x25)
│   │   ├── keyboard.c          # PS/2 keyboard (scancode set 1)
│   │   ├── timer.c             # PIT timer (100 Hz)
│   │   └── serial.c            # Serial port (COM1)
│   ├── mm/
│   │   └── mm.c                # PMM (bitmap) + VMM (page tables) + heap
│   ├── sched/
│   │   └── sched.c             # Process scheduler (round-robin)
│   ├── fs/
│   │   └── vfs.c               # Virtual filesystem
│   └── syscall/
│       └── syscall.c           # System calls (INT 0x80)
├── libc/
│   ├── string/string.c         # strlen, strcpy, memcpy, memset, etc.
│   ├── stdio/stdio.c           # printf, puts, fopen, fread, etc.
│   ├── stdlib/stdlib.c         # malloc, free, rand, atoi, etc.
│   └── ctype.c                 # isdigit, isalpha, toupper, etc.
├── userland/
│   ├── bin/
│   │   ├── sh.c                # Interactive shell
│   │   ├── cat.c, ls.c, ...    # File utilities
│   │   └── clear.c, reboot.c   # System utilities
│   └── sbin/
│       └── init.c              # Init process (PID 1)
├── include/
│   ├── kernel/                 # Kernel headers
│   └── libc/                   # Library headers
├── config/
│   └── linker.ld               # Kernel linker script
├── Makefile                    # Build system
└── README.md                   # This file

Architecture

┌──────────────────────────────────────────┐
│            Userland (Ring 3)             │
│    ┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐     │
│    │ sh  │ │ cat │ │ ls  │ │ ... │     │
│    └──┬──┘ └──┬──┘ └──┬──┘ └──┬──┘     │
│       └───────┴───────┴───────┘         │
│              INT 0x80                    │
├──────────────────────────────────────────┤
│            Kernel (Ring 0)               │
│  ┌──────────────────────────────────┐    │
│  │        System Call Interface      │    │
│  ├──────────────────────────────────┤    │
│  │  ┌─────┐ ┌──────┐ ┌─────────┐   │    │
│  │  │ VFS │ │Sched │ │ Memory  │   │    │
│  │  └─────┘ └──────┘ └─────────┘   │    │
│  ├──────────────────────────────────┤    │
│  │  ┌─────┐ ┌──────┐ ┌─────────┐   │    │
│  │  │ VGA │ │ KBD  │ │  Timer  │   │    │
│  │  └─────┘ └──────┘ └─────────┘   │    │
│  ├──────────────────────────────────┤    │
│  │  ┌─────┐ ┌──────┐ ┌─────────┐   │    │
│  │  │GDT  │ │ IDT  │ │  PIC    │   │    │
│  │  └─────┘ └──────┘ └─────────┘   │    │
│  └──────────────────────────────────┘    │
├──────────────────────────────────────────┤
│       Bootloader (Real Mode → PM)        │
│    Stage 1 (MBR) → Stage 2 → Kernel     │
└──────────────────────────────────────────┘

Boot Process

  1. BIOS loads boot sector (512 bytes) to 0x7C00
  2. Stage 1 enables A20, loads Stage 2 from disk, switches to 32-bit
  3. Stage 2 detects memory (E820), loads kernel, jumps to kernel entry
  4. Kernel sets up GDT, IDT, memory manager, drivers, scheduler
  5. Init process starts, launches the shell

System Calls

Number Name Description
0 read Read from file descriptor
1 write Write to file descriptor
2 open Open a file
3 close Close a file descriptor
10 unlink Remove a file
11 exec Execute a program
12 chdir Change directory
15 chmod Change permissions
37 kill Send signal to process
45 sbrk Change data segment size
88 reboot Reboot the system

Shell Commands

help      - Show available commands
about     - About MagixOS
echo      - Echo text to stdout
clear     - Clear the screen
ps        - List running processes
uname     - System information
free      - Memory usage
whoami    - Current user
hostname  - System hostname
cat       - Display file contents
ls        - List directory contents
mkdir     - Create a directory
rm        - Remove a file
touch     - Create an empty file
reboot    - Reboot the system
shutdown  - Shut down the system
top       - Process monitor
dmesg     - Kernel messages
id        - User/group IDs
date      - Current date/time
exit      - Exit the shell

Version History

  • v1.0.0 - Initial release
    • Custom bootloader (Stage 1 + Stage 2)
    • Custom kernel with GDT, IDT, IRQ
    • Physical memory manager (bitmap allocator)
    • Virtual memory manager (page tables)
    • Preemptive round-robin scheduler
    • PS/2 keyboard driver
    • VGA text mode driver
    • Serial port debug output
    • PIT timer at 100 Hz
    • System call interface (INT 0x80)
    • Custom libc (string, stdio, stdlib, ctype)
    • VFS layer with memory filesystem
    • Interactive shell with 20+ commands
    • Userland utilities (cat, ls, mkdir, rm, etc.)

License

MIT License - See LICENSE for details.

Author

Built from scratch by itriedcoding

About

A custom Linux distribution built entirely from source - kernel, userland, and bootloader

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages