From d4623419b0be4d2dddad39b9d993a482e890c967 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 17 Jun 2019 17:51:12 +0200 Subject: [PATCH] Try to use Box type in main.rs This causes an allocation error because the Dummy::alloc function always returns a null pointer. --- src/main.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 10b38955..0d3e0df6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,9 +4,12 @@ #![test_runner(blog_os::test_runner)] #![reexport_test_harness_main = "test_main"] +extern crate alloc; + use blog_os::println; use bootloader::{entry_point, BootInfo}; use core::panic::PanicInfo; +use alloc::boxed::Box; entry_point!(kernel_main); @@ -20,13 +23,7 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! { let mut mapper = unsafe { memory::init(boot_info.physical_memory_offset) }; let mut frame_allocator = unsafe { BootInfoFrameAllocator::init(&boot_info.memory_map) }; - // map a previously unmapped page - let page = Page::containing_address(VirtAddr::new(0xdeadbeaf000)); - memory::create_example_mapping(page, &mut mapper, &mut frame_allocator); - - // write the string `New!` to the screen through the new mapping - let page_ptr: *mut u64 = page.start_address().as_mut_ptr(); - unsafe { page_ptr.offset(400).write_volatile(0x_f021_f077_f065_f04e) }; + let x = Box::new(41); #[cfg(test)] test_main();