Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

chord233/chord_os

Repository files navigation

ChordOS

A minimal operating system written in Rust, inspired by the "Writing an OS in Rust" tutorial series.

About

ChordOS is a hobby operating system project that demonstrates:

  • Bare metal Rust programming
  • VGA text mode output
  • Interrupt handling
  • Memory management
  • Basic keyboard input
  • Serial port communication for debugging

Author

Features

  • Freestanding Rust binary
  • VGA text buffer for output
  • Serial port for debugging
  • Interrupt descriptor table (IDT)
  • Hardware interrupt handling
  • Keyboard input
  • Memory paging
  • Heap allocation
  • Testing framework

Prerequisites

To build and run ChordOS, you need:

  1. Rust nightly toolchain:

    rustup override set nightly
  2. Required components:

    rustup component add rust-src
    rustup component add llvm-tools-preview
  3. Bootimage tool:

    cargo install bootimage
  4. QEMU (for running the OS):

    # On Ubuntu/Debian
    sudo apt install qemu-system-x86
    
    # On macOS
    brew install qemu
    
    # On Windows
    # Download from https://www.qemu.org/download/

Building

To build the kernel:

cargo build

To create a bootable disk image:

cargo bootimage

Running

To run ChordOS in QEMU:

cargo run

This will:

  1. Build the kernel
  2. Create a bootable disk image
  3. Start QEMU with the disk image

Testing

To run the test suite:

cargo test

Project Structure

chord_os/
├── src/
│   ├── main.rs          # Kernel entry point
│   ├── lib.rs           # Library root and test framework
│   ├── vga_buffer.rs    # VGA text mode driver
│   ├── serial.rs        # Serial port driver
│   ├── interrupts.rs    # Interrupt handling
│   ├── gdt.rs          # Global Descriptor Table
│   ├── memory.rs       # Memory management
│   └── allocator.rs    # Heap allocator
├── .cargo/
│   └── config.toml     # Cargo configuration
├── x86_64-chord_os.json # Target specification
├── Cargo.toml          # Package configuration
└── README.md           # This file

Development

Adding New Features

  1. Create new modules in the src/ directory
  2. Add module declarations to lib.rs
  3. Implement functionality following Rust's safety guidelines
  4. Add tests where appropriate

Debugging

  • Use serial_println! macro for debug output
  • QEMU will display serial output in the terminal
  • Use println! for VGA buffer output (visible in QEMU window)

Memory Layout

  • Kernel is loaded at higher half of virtual memory
  • VGA buffer is mapped at 0xb8000
  • Heap starts at 0x_4444_4444_0000
  • Stack grows downward from high memory

Learning Resources

This project is based on the excellent "Writing an OS in Rust" tutorial series:

License

This project is open source and available under the MIT License.

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

Acknowledgments

  • Philipp Oppermann for the original "Writing an OS in Rust" tutorial
  • The Rust community for excellent documentation and tools
  • The OSDev community for valuable resources

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages