mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Try to use Box type in main.rs
This causes an allocation error because the Dummy::alloc function always returns a null pointer.
This commit is contained in:
11
src/main.rs
11
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();
|
||||
|
||||
Reference in New Issue
Block a user