Skip to content

kevinWangSheng/kevin_os

Repository files navigation

Kevin OS

License Rust Version Build Status

A minimalist operating system kernel written in Rust, following the blog_os tutorial series.

Features

  • Bare metal Rust environment
  • VGA text mode output
  • Interrupt handling
  • Memory management with paging
  • Heap allocation
  • Async/await support
  • Keyboard input handling
  • Multitasking

Prerequisites

  • Rust nightly toolchain
  • QEMU for x86_64 architecture
  • bootimage tool
  • For WSL users: VcXsrv X Server

Building and Running

# Build the kernel
cargo build

# Run in QEMU
cargo run

WSL Setup Guide

For Windows Subsystem for Linux users, follow these steps to set up a graphical environment:

  1. Install VcXsrv on Windows:

  2. Configure VcXsrv:

    • Launch XLaunch from the Start menu
    • Select "Multiple windows"
    • Set Display number to 0
    • Choose "Start no client"
    • Check "Disable access control" in Extra settings
    • Click "Finish"
  3. Configure WSL environment:

    # Set display variable
    export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0
    
    # Verify DISPLAY setting
    echo $DISPLAY
    
    # Allow connections
    xhost +local:
  4. Run QEMU:

    qemu-system-x86_64 \
        -drive format=raw,file=target/x86_64_kevin_os/debug/bootimage-kevin_os.bin \
        -serial stdio \
        -display sdl

    QEMU Screenshot

Cargo Configuration

To simplify development, add this to your .cargo/config.toml:

[target.'cfg(target_os = "none")']
runner = "bootimage runner"

[unstable]
build-std = ["core", "compiler_builtins"]
build-std-features = ["compiler-builtins-mem"]

[build]
target = "x86_64_kevin_os.json"

[target.x86_64-kevin_os]
runner = """
bootimage runner --timeout 300
qemu-system-x86_64 \
    -drive format=raw,file=target/x86_64-kevin_os/debug/bootimage-kevin_os.bin \
    -serial stdio \
    -display sdl \
"""

Implementation Details

This OS kernel includes implementations of:

  • Custom interrupt descriptor table (IDT)
  • Memory paging and frame allocation
  • Multiple heap allocator designs (bump, linked list, fixed-size block)
  • Async/await task executor with waker support
  • VGA text buffer driver for output
  • PS/2 keyboard driver with scancode handling
  • Simple multitasking system

Project Structure

kevin_os/
├── src/
│   ├── main.rs           # Kernel entry point
│   ├── vga_buffer.rs     # Text mode display driver
│   ├── interrupts/       # Interrupt handling code
│   │   ├── mod.rs
│   │   └── gdt.rs        # Global Descriptor Table
│   ├── memory/           # Memory management
│   │   ├── mod.rs
│   │   ├── paging.rs
│   │   └── frame.rs
│   ├── allocator/        # Heap allocators
│   │   ├── mod.rs
│   │   ├── bump.rs
│   │   ├── linked_list.rs
│   │   └── fixed_size_block.rs
│   └── task/             # Async task system
│       ├── mod.rs
│       ├── executor.rs
│       ├── keyboard.rs   # Keyboard input handling
│       └── simple_executor.rs
├── Cargo.toml
└── x86_64_kevin_os.json  # Target specification

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

About

A reference to https://os.phil-opp.com/ for an operating system implemented in rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages