[][src]Crate rustos

Writing an OS in Rust

Examples

Example _start() function and the panic handler.

#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![test_runner(rustos::test_runner)]
#![reexport_test_harness_main = "test_main"]
extern crate rustos;
extern crate x86_64;
use core::panic::PanicInfo;
use rustos::println;

#[no_mangle]
pub extern "C" fn _start() -> ! {
    println!("Welcome to the real world!");
    rustos::init();
    use x86_64::registers::control::Cr3;
    let (level_4_page_table, _) = Cr3::read();
    println!("Level 4 page table at: {:?}", level_4_page_table);
    #[cfg(test)]
    test_main();
    println!("It did not crash!!!");
    rustos::hlt_loop();
}

#[cfg(not(test))]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
    println!("{}", info);
    rustos::hlt_loop();
}

#[cfg(test)]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
    rustos::test_panic_handler(info)
}

Modules

serial

Serial driver

vga

VGA driver

Macros

print

Print out the message on the VGA console.

println

Print out the message on the VGA console.

serial_print

Print out the message to the serial port.

serial_println

Print out the message to the serial port.

Enums

QemuExitCode

Qemu exit codes.

Functions

exit_qemu

Qemu exit function.

hlt_loop

hlt instruction based kernel loop.

init

Kernel initialization function.

test_panic_handler

Unit and the integration test panic handler.

test_runner

Unit and the integration test runner.