Convert Figma logo to code with AI

intermezzOS logokernel

A hobby operating system, in Rust

1,394
91
1,394
15

Top Related Projects

14,568

Writing an OS in Rust

2,851

Theseus is a modern OS written from scratch in Rust that explores 𝐢𝐧𝐭𝐫𝐚𝐥𝐢𝐧𝐠𝐮𝐚𝐥 𝐝𝐞𝐬𝐢𝐠𝐧: closing the semantic gap between compiler and hardware by maximally leveraging the power of language safety and affine types. Theseus aims to shift OS responsibilities like resource management into the compiler.

:books: Learn to write an embedded OS in Rust :crab:

3,421

Rust version of THU uCore OS. Linux compatible.

15,144

Mirror of https://gitlab.redox-os.org/redox-os/redox

3,332

A new operating system kernel with Linux binary compatibility written in Rust.

Quick Overview

intermezzOS/kernel is an educational operating system kernel project written in Rust. It aims to teach OS development concepts while leveraging Rust's safety features. The project is part of the larger intermezzOS initiative, which includes documentation and tutorials for learning OS development.

Pros

  • Written in Rust, providing memory safety and preventing common low-level programming errors
  • Educational focus with accompanying documentation and tutorials
  • Open-source project, encouraging community contributions and learning
  • Demonstrates practical application of Rust in systems programming

Cons

  • Limited functionality compared to production-ready kernels
  • May not cover all advanced OS concepts or optimizations
  • Primarily focused on x86_64 architecture, limiting portability
  • Development progress may be slower due to its educational nature

Code Examples

Here are a few code examples from the intermezzOS kernel:

  1. Initializing the Global Descriptor Table (GDT):
lazy_static! {
    static ref GDT: (GlobalDescriptorTable, Selectors) = {
        let mut gdt = GlobalDescriptorTable::new();
        let code_selector = gdt.add_entry(Descriptor::kernel_code_segment());
        let data_selector = gdt.add_entry(Descriptor::kernel_data_segment());
        (gdt, Selectors { code_selector, data_selector })
    };
}

This code initializes the GDT, which is crucial for memory segmentation in x86 architectures.

  1. Handling interrupts:
lazy_static! {
    static ref IDT: InterruptDescriptorTable = {
        let mut idt = InterruptDescriptorTable::new();
        idt.breakpoint.set_handler_fn(breakpoint_handler);
        idt
    };
}

pub fn init_idt() {
    IDT.load();
}

This code sets up the Interrupt Descriptor Table (IDT) and defines a handler for the breakpoint interrupt.

  1. Implementing a simple keyboard driver:
pub fn read_scancode() -> u8 {
    unsafe {
        while (inb(0x64) & 1) == 0 {}
        inb(0x60)
    }
}

This function reads a scancode from the keyboard controller, demonstrating low-level I/O operations.

Getting Started

To get started with intermezzOS/kernel:

  1. Clone the repository:

    git clone https://github.com/intermezzOS/kernel.git
    cd kernel
    
  2. Install Rust and required tools:

    curl https://sh.rustup.rs -sSf | sh
    rustup override set nightly
    cargo install bootimage
    
  3. Build and run the kernel:

    cargo xrun
    

This will compile the kernel and run it in QEMU. For more detailed instructions and explanations, refer to the project's documentation and accompanying tutorials.

Competitor Comparisons

14,568

Writing an OS in Rust

Pros of blog_os

  • More comprehensive documentation and detailed explanations
  • Regular updates and active community engagement
  • Broader coverage of OS development topics

Cons of blog_os

  • Slower development pace compared to intermezzOS
  • Less focus on specific architectural choices

Code Comparison

blog_os:

#[no_mangle]
pub extern "C" fn _start() -> ! {
    println!("Hello World{}", "!");
    loop {}
}

intermezzOS:

#[no_mangle]
pub extern fn kmain() -> ! {
    let hello = b"Hello World!";
    let color_byte = 0x1f; // white foreground, blue background

    let mut hello_color = [color_byte; 24];

    for (i, char_byte) in hello.into_iter().enumerate() {
        hello_color[i * 2] = *char_byte;
    }

    let buffer_ptr = (0xb8000 + 1988) as *mut _;
    unsafe { *buffer_ptr = hello_color };

    loop { }
}

Both projects aim to create operating systems in Rust, but they differ in their approach and focus. blog_os provides a more educational experience with detailed explanations, while intermezzOS offers a more hands-on approach with less documentation. The code comparison shows that blog_os uses a higher-level abstraction for printing, while intermezzOS demonstrates low-level memory manipulation for displaying text.

2,851

Theseus is a modern OS written from scratch in Rust that explores 𝐢𝐧𝐭𝐫𝐚𝐥𝐢𝐧𝐠𝐮𝐚𝐥 𝐝𝐞𝐬𝐢𝐠𝐧: closing the semantic gap between compiler and hardware by maximally leveraging the power of language safety and affine types. Theseus aims to shift OS responsibilities like resource management into the compiler.

Pros of Theseus

  • More active development with recent commits and releases
  • Extensive documentation and research papers available
  • Larger community and contributor base

Cons of Theseus

  • More complex architecture and steeper learning curve
  • Requires more system resources due to its advanced features
  • Less beginner-friendly compared to intermezzOS

Code Comparison

intermezzOS kernel:

#[no_mangle]
pub extern fn kmain() -> ! {
    vga::clear_screen();
    println!("Hello, world!");
    loop { }
}

Theseus:

#[no_mangle]
pub extern "C" fn kernel_main() -> ! {
    println!("Hello from Theseus!");
    scheduler::schedule();
    loop { }
}

Both kernels use Rust and have similar entry points, but Theseus demonstrates more advanced features like a scheduler right from the start.

:books: Learn to write an embedded OS in Rust :crab:

Pros of rust-raspberrypi-OS-tutorials

  • More comprehensive and structured learning path for OS development on Raspberry Pi
  • Regularly updated with new tutorials and improvements
  • Focuses on practical, hands-on experience with real hardware

Cons of rust-raspberrypi-OS-tutorials

  • Specific to Raspberry Pi architecture, limiting broader OS development concepts
  • May be overwhelming for absolute beginners due to its depth and complexity
  • Requires physical Raspberry Pi hardware for full experience

Code Comparison

rust-raspberrypi-OS-tutorials:

#[no_mangle]
pub extern "C" fn kernel_main() -> ! {
    // Initialization code
    loop {
        cortex_a::asm::wfe()
    }
}

intermezzOS/kernel:

#[no_mangle]
pub extern fn kmain() -> ! {
    // Initialization code
    loop {
        unsafe { asm!("hlt"); }
    }
}

Both projects use Rust for OS development, but rust-raspberrypi-OS-tutorials is tailored for Raspberry Pi, while intermezzOS/kernel is more generic. The code snippets show similar kernel entry points, but with platform-specific differences in the main loop implementation.

rust-raspberrypi-OS-tutorials offers a more structured learning experience with a focus on practical, hardware-specific knowledge. intermezzOS/kernel provides a more general approach to OS development, potentially offering broader conceptual understanding but with less hands-on application for specific hardware.

3,421

Rust version of THU uCore OS. Linux compatible.

Pros of rCore

  • Written in Rust, providing memory safety and concurrency benefits
  • More comprehensive OS implementation with support for multiple architectures
  • Active development with regular updates and contributions

Cons of rCore

  • Higher complexity and steeper learning curve for beginners
  • Larger codebase, which may be overwhelming for those new to OS development
  • Requires more resources to build and run compared to simpler kernels

Code Comparison

rCore (main.rs):

#[no_mangle]
pub extern "C" fn rust_main() -> ! {
    println!("Hello, rCore!");
    panic!("Shutdown machine!");
}

intermezzOS (src/arch/x86_64/boot.asm):

global start
extern long_mode_start

section .text
bits 32
start:
    mov esp, stack_top
    call check_multiboot
    call check_cpuid
    call check_long_mode

Summary

rCore is a more feature-rich and actively developed OS project written in Rust, offering better safety guarantees and multi-architecture support. However, it may be more challenging for beginners due to its complexity. intermezzOS, while simpler and potentially easier to understand, has a more limited scope and fewer features. The choice between the two depends on the developer's goals and experience level in OS development.

15,144

Mirror of https://gitlab.redox-os.org/redox-os/redox

Pros of Redox

  • More mature and feature-rich operating system project
  • Written in Rust, offering memory safety and concurrency benefits
  • Active community with regular updates and contributions

Cons of Redox

  • Larger codebase, potentially more complex for newcomers
  • Steeper learning curve due to its more comprehensive nature
  • May require more resources to build and run

Code Comparison

Redox (syscall handling):

pub fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -> usize {
    let mut ret: usize;
    unsafe {
        asm!("int 0x80"
             : "={rax}"(ret)
             : "{rax}"(a), "{rbx}"(b), "{rcx}"(c), "{rdx}"(d), "{rsi}"(e), "{rdi}"(f)
             : "memory", "cc"
             : "intel", "volatile");
    }
    ret
}

intermezzOS (basic kernel entry):

#[no_mangle]
pub extern fn kmain() -> ! {
    vga::clear_screen();
    vga::print_hello();
    loop { }
}

The code snippets showcase the difference in complexity and focus between the two projects. Redox demonstrates a more advanced syscall handling mechanism, while intermezzOS presents a simpler kernel entry point, reflecting its educational nature.

3,332

A new operating system kernel with Linux binary compatibility written in Rust.

Pros of Kerla

  • Written in Rust, providing memory safety and modern language features
  • More actively maintained with recent commits and updates
  • Includes a broader range of kernel features and device support

Cons of Kerla

  • More complex codebase, potentially harder for beginners to understand
  • Requires more system resources due to its comprehensive feature set
  • Less focused on educational purposes compared to intermezzOS

Code Comparison

Kerla (memory management):

pub fn alloc_pages(order: usize) -> Option<PhysAddr> {
    FRAME_ALLOCATOR.lock().alloc_pages(order)
}

intermezzOS (memory management):

pub fn allocate_frame() -> Option<Frame> {
    FRAME_ALLOCATOR.lock().allocate_frame()
}

Both projects use Rust for memory management, but Kerla's implementation appears more flexible with the order parameter for allocating multiple pages.

Summary

Kerla is a more feature-rich and actively maintained kernel project, while intermezzOS focuses on simplicity and education. Kerla may be better suited for advanced users or those interested in a more complete kernel implementation, whereas intermezzOS could be more appropriate for beginners or educational purposes.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

intermezzOS: kernel

Build Status Build status

intermezzOS is a hobby operating system. This repository is for its kernel. See the website for more.

License

This project is dual licensed under Apache2/MIT. See the two LICENSE-* files for details.

Code of conduct

The intermezzOS project has a Code of Conduct, please observe it.