Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 5 additions & 26 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![no_std]
#![no_main]
#![no_main] // overwriting rusts' entry point
#![feature(custom_test_frameworks)]
#![test_runner(orust_os::test_runner)]
#![reexport_test_harness_main = "test_main"]
Expand All @@ -18,24 +18,11 @@ pub trait Testable {
fn run(&self);
}

entry_point!(kernel_main);

fn kernel_main(boot_info: &'static BootInfo) -> ! {
use orust_os::allocator;
use orust_os::memory::{self, BootInfoFrameAllocator};
use x86_64::VirtAddr;

#[no_mangle]
pub extern "C" fn _start() -> ! {
println!("Hello, Welcome to the ORUST Operating System{}", "!");
orust_os::init();

let phys_mem_offset = VirtAddr::new(boot_info.physical_memory_offset);
let mut mapper = unsafe { memory::init(phys_mem_offset) };
let mut frame_allocator = unsafe {
BootInfoFrameAllocator::init(&boot_info.memory_map)
};

allocator::init_heap(&mut mapper, &mut frame_allocator)
.expect("heap initialization failed");
orust_os::init();

#[cfg(test)]
test_main();
Expand All @@ -55,16 +42,8 @@ fn panic(info: &PanicInfo) -> ! {
}

#[cfg(test)]
// function called on panic.
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
orust_os::test_panic_handler(info)
}

async fn async_number() -> u32 {
42
}

async fn example_task() {
let number = async_number().await;
println!("async number: {}", number);
}
Loading