Skip to content

compiledkernel-idk/barraos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BarraOS - Custom x86 Operating System

A feature-rich 32-bit x86 operating system written in C and Assembly, designed with a comprehensive kernel and userland architecture.

Features

Current Implementation (Phase 1)

  • Bootloader: Multiboot-compliant bootloader with GRUB support
  • Protected Mode: Full 32-bit protected mode operation
  • Memory Segmentation: GDT (Global Descriptor Table) with kernel and user segments
  • Interrupt Handling: IDT (Interrupt Descriptor Table) with ISRs and IRQs
  • Hardware Drivers:
    • VGA text mode driver (80x25 color output)
    • PS/2 keyboard driver (with key buffer)
    • PIT timer driver (programmable interval timer)
  • Shell: Built-in command-line interface with commands:
    • help - Display available commands
    • clear - Clear the screen
    • uptime - Show system uptime
    • about - Display OS information

Planned Features (Phase 2)

  • Memory Management:
    • Physical memory manager
    • Virtual memory manager (paging)
    • Heap allocator (kmalloc/kfree)
  • Process Management:
    • Task structures and process control blocks
    • Preemptive multitasking scheduler
    • Context switching
  • System Calls:
    • Usermode/kernel mode switching
    • System call interface (int 0x80)
  • File System:
    • Virtual File System (VFS) layer
    • Initial RAM filesystem support
  • Userland:
    • Standard C library for applications
    • Init process
    • Shell and utilities (ls, cat, echo, ps, etc.)

Build Requirements

  • GCC: Cross-compiler for i686-elf or native GCC with -m32 support
  • NASM: Netwide Assembler for x86 assembly
  • LD: GNU linker
  • Make: Build automation
  • QEMU: For testing (qemu-system-i386)
  • GRUB (optional): For creating bootable ISOs
  • xorriso (optional): For ISO creation

Installing Dependencies

Arch Linux / Manjaro:

sudo pacman -S gcc nasm qemu-system-x86 grub xorriso

Ubuntu / Debian:

sudo apt install gcc nasm qemu-system-x86 grub-pc-bin xorriso

Fedora:

sudo dnf install gcc nasm qemu-system-x86 grub2 xorriso

Building

# Clean previous builds
make clean

# Build kernel
make kernel.bin

# Build ISO image (requires grub-mkrescue and xorriso)
make iso

Running

Using QEMU (Recommended)

# Run kernel directly in QEMU
make run

# Run with ISO image
make run-iso

# Run in debug mode (GDB server on port 1234)
make debug

Using VirtualBox or VMware

  1. Build the ISO: make iso
  2. Create a new VM with the following settings:
    • Type: Other/Unknown
    • Memory: 128 MB minimum
    • Boot from ISO: barraos.iso

Using Real Hardware

WARNING: Experimental! Test in a VM first.

  1. Build the ISO: make iso
  2. Write to USB: sudo dd if=barraos.iso of=/dev/sdX bs=4M (replace sdX with your USB device)
  3. Boot from USB

Project Structure

barraos/
├── boot/
│   ├── boot.asm          # Boot assembly with multiboot header
│   └── grub.cfg          # GRUB configuration
├── kernel/
│   ├── include/          # Header files
│   │   ├── types.h       # Type definitions
│   │   ├── vga.h         # VGA driver header
│   │   ├── gdt.h         # GDT header
│   │   ├── idt.h         # IDT header
│   │   ├── timer.h       # Timer driver header
│   │   ├── keyboard.h    # Keyboard driver header
│   │   ├── io.h          # Port I/O functions
│   │   └── string.h      # String functions
│   ├── arch/x86/         # Architecture-specific code
│   │   ├── gdt.c         # GDT implementation
│   │   └── idt.c         # IDT implementation
│   ├── drivers/          # Device drivers
│   │   ├── vga.c         # VGA text mode driver
│   │   ├── keyboard.c    # Keyboard driver
│   │   └── timer.c       # Timer driver
│   ├── main.c            # Kernel entry point
│   └── string.c          # String library implementation
├── userland/             # User-space programs (planned)
│   ├── libc/             # Standard C library
│   └── bin/              # User programs
├── linker.ld             # Linker script
├── Makefile              # Build system
└── README.md             # This file

Architecture

Boot Process

  1. GRUB loads the kernel at 1MB in memory
  2. Multiboot header is detected and validated
  3. Kernel entry point (_start) is called
  4. Stack is set up
  5. kernel_main() is invoked with multiboot info

Memory Layout

  • 0x00000000 - 0x000FFFFF: Real mode area (1MB)
  • 0x00100000 - ...: Kernel loaded here (1MB+)
  • 0xB8000: VGA text mode buffer
  • Stack grows downward from top of available memory

Interrupt Handling

  • ISRs 0-31: CPU exceptions (divide by zero, page fault, etc.)
  • IRQs 32-47: Hardware interrupts (remapped from 0-15)
    • IRQ 0 (32): Timer
    • IRQ 1 (33): Keyboard
  • INT 128 (0x80): System call interface (planned)

Development Roadmap

Phase 1: Basic Kernel ✓

  • Bootloader and kernel entry
  • VGA text mode driver
  • GDT setup
  • IDT and interrupt handling
  • Timer driver
  • Keyboard driver
  • Basic shell

Phase 2: Memory Management (In Progress)

  • Physical memory manager
  • Virtual memory (paging)
  • Heap allocator

Phase 3: Process Management

  • Task structures
  • Scheduler
  • Context switching
  • System calls

Phase 4: File System

  • VFS layer
  • Initial RAM filesystem
  • File operations

Phase 5: Userland

  • User mode switching
  • Standard C library
  • Init process
  • Shell and utilities

Testing

The kernel currently boots and provides an interactive shell. Try these commands:

  • Type help to see available commands
  • Type about to see OS information
  • Type uptime to see how long the system has been running
  • Type clear to clear the screen

Debugging

Using GDB with QEMU

# Terminal 1: Start QEMU in debug mode
make debug

# Terminal 2: Connect GDB
gdb kernel.bin
(gdb) target remote localhost:1234
(gdb) break kernel_main
(gdb) continue

Common Issues

"Error: Invalid multiboot magic number!"

  • The bootloader didn't load properly. Ensure GRUB is configured correctly.

Keyboard not responding

  • Check that interrupts are enabled (STI instruction)
  • Verify PIC is remapped correctly

Triple fault / Reboot loop

  • Check GDT and IDT are properly configured
  • Verify stack is set up correctly
  • Enable QEMU debug output: -d int,cpu_reset

Contributing

This is a personal OS development project. Feel free to fork and experiment!

License

MIT

Resources

Contact

For questions or issues, please open a GitHub issue (if hosted on GitHub).


Note: This OS is a work in progress. Features are being actively developed.

About

Source code of barraOS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published