This commit is contained in:
FantasyPvP
2023-11-10 00:16:33 +00:00
parent 2d30f16b9d
commit 3510210b99
+7 -11
View File
@@ -4,10 +4,10 @@
#![test_runner(CrystalOS::test_runner)] #![test_runner(CrystalOS::test_runner)]
#![reexport_test_harness_main = "test_main"] #![reexport_test_harness_main = "test_main"]
use bootloader::{entry_point, BootInfo};
use core::panic::PanicInfo; use core::panic::PanicInfo;
use CrystalOS::{println, print, println_log, print_log, kernel, printerr}; use CrystalOS::kernel::tasks::{executor::Executor, Task};
use CrystalOS::kernel::tasks::{Task, executor::Executor}; use CrystalOS::{kernel, print, print_log, printerr, println, println_log};
use bootloader::{BootInfo, entry_point};
extern crate alloc; extern crate alloc;
use CrystalOS::user::bin::shell; use CrystalOS::user::bin::shell;
@@ -25,22 +25,21 @@ fn panic(info: &PanicInfo) -> ! {
CrystalOS::test_panic_handler(info) CrystalOS::test_panic_handler(info)
} }
// some comment
entry_point!(main); entry_point!(main);
fn main(boot_info: &'static BootInfo) -> ! { fn main(boot_info: &'static BootInfo) -> ! {
use x86_64::VirtAddr;
use CrystalOS::kernel::allocator; use CrystalOS::kernel::allocator;
use CrystalOS::kernel::memory; use CrystalOS::kernel::memory;
use CrystalOS::kernel::memory::BootInfoFrameAllocator; use CrystalOS::kernel::memory::BootInfoFrameAllocator;
use x86_64::VirtAddr;
CrystalOS::init(); CrystalOS::init();
let physical_memory_offset = VirtAddr::new(boot_info.physical_memory_offset); let physical_memory_offset = VirtAddr::new(boot_info.physical_memory_offset);
let mut mapper = unsafe { memory::init(physical_memory_offset) }; let mut mapper = unsafe { memory::init(physical_memory_offset) };
let mut frame_allocator = unsafe { let mut frame_allocator = unsafe { BootInfoFrameAllocator::init(&boot_info.memory_map) };
BootInfoFrameAllocator::init(&boot_info.memory_map)
};
allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialisation failed"); allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialisation failed");
@@ -48,7 +47,6 @@ fn main(boot_info: &'static BootInfo) -> ! {
executor.spawn(Task::new(shell::command_handler())); executor.spawn(Task::new(shell::command_handler()));
loop { loop {
executor.try_run(); executor.try_run();
} }
@@ -58,5 +56,3 @@ fn main(boot_info: &'static BootInfo) -> ! {
loop {} loop {}
} }