[−][src]Crate rustos
Examples
Here is the current entry point, start_kernel()
, and panic handlers,
and async task.
#![no_std] #![no_main] #![feature(custom_test_frameworks)] #![test_runner(rustos::test_runner)] #![reexport_test_harness_main = "test_main"] extern crate bootloader; extern crate rustos; use bootloader::{entry_point, BootInfo}; use core::panic::PanicInfo; use rustos::{println, task}; entry_point!(start_kernel); fn start_kernel(boot_info: &'static BootInfo) -> ! { println!("Welcome to the real world!"); // Initialize the kernel. rustos::init(); rustos::memory::init(boot_info); // Spawn async task(s). let mut executor = task::Executor::new(); executor.spawn(task::Task::new(example_task())); #[cfg(test)] test_main(); println!("It did not crash!!!"); // This won't return now because of the keyboard task. executor.run(); 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) } async fn example_task() { let number = async_number().await; println!("async number: {}", number); } async fn async_number() -> u32 { 42 }
Modules
memory | Memory mapper and the frame allocator |
serial | Serial driver |
task | Task manager |
vga | VGA driver |
Macros
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. |
Constants
HEAP_SIZE | Kernel heap size. |
HEAP_START | Kernel heap start address. |
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. |