diff --git a/src/arch/x86_64/memory.rs b/src/arch/x86_64/memory.rs index 1fd8e23..bdc7272 100644 --- a/src/arch/x86_64/memory.rs +++ b/src/arch/x86_64/memory.rs @@ -9,13 +9,12 @@ use ucore_memory::paging::PageTable; // BootInformation may trigger page fault after kernel remap // So just take its ownership -pub fn init(boot_info: BootInformation) -> MemorySet { +pub fn init(boot_info: BootInformation) { assert_has_not_been_called!("memory::init must be called only once"); info!("{:?}", boot_info); init_frame_allocator(&boot_info); - let ms = remap_the_kernel(&boot_info); + remap_the_kernel(&boot_info); init_heap(); - ms } fn init_frame_allocator(boot_info: &BootInformation) { @@ -52,7 +51,7 @@ fn init_frame_allocator(boot_info: &BootInformation) { } } -fn remap_the_kernel(boot_info: &BootInformation) -> MemorySet { +fn remap_the_kernel(boot_info: &BootInformation) { extern { fn stack_bottom(); } extern { fn stack_top(); } let kstack = Stack { @@ -76,7 +75,8 @@ fn remap_the_kernel(boot_info: &BootInformation) -> MemorySet { unsafe { memory_set.activate(); } info!("NEW TABLE!!!"); - memory_set + use core::mem::forget; + forget(memory_set); } fn memory_set_from(sections: ElfSectionsTag, kstack: Stack) -> MemorySet { diff --git a/src/arch/x86_64/mod.rs b/src/arch/x86_64/mod.rs index 269bbcd..5a5f775 100644 --- a/src/arch/x86_64/mod.rs +++ b/src/arch/x86_64/mod.rs @@ -10,16 +10,15 @@ pub mod idt; pub mod smp; pub mod memory; -pub fn init(multiboot_information_address: usize) -> MemorySet { +pub fn init(multiboot_information_address: usize) { idt::init(); let boot_info = unsafe { multiboot2::load(multiboot_information_address) }; let rsdt_addr = boot_info.rsdp_v1_tag().unwrap().rsdt_address(); - let ms = memory::init(boot_info); + memory::init(boot_info); // Now heap is available gdt::init(); let acpi = driver::init(rsdt_addr); smp::start_other_cores(&acpi); - ms } /// The entry point for another processors diff --git a/src/lib.rs b/src/lib.rs index 7f72192..5bdb6ac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -107,9 +107,9 @@ pub extern "C" fn rust_main(multiboot_information_address: usize) -> ! { println!("Hello World{}", "!"); io::init(); - let ms = arch::init(multiboot_information_address); + arch::init(multiboot_information_address); - process::init(ms); + process::init(); fs::load_sfs(); diff --git a/src/process/mod.rs b/src/process/mod.rs index 4bc4b6e..381c22d 100644 --- a/src/process/mod.rs +++ b/src/process/mod.rs @@ -10,10 +10,10 @@ mod processor; mod scheduler; -pub fn init(ms: MemorySet) { +pub fn init() { PROCESSOR.call_once(|| { SpinNoIrqLock::new({ - let initproc = Process::new_init(ms); + let initproc = Process::new_init(); let idleproc = Process::new("idle", idle_thread, 0); let mut processor = Processor::new(); processor.add(initproc); diff --git a/src/process/process.rs b/src/process/process.rs index 4c6028a..7622bc1 100644 --- a/src/process/process.rs +++ b/src/process/process.rs @@ -46,13 +46,13 @@ impl Process { /// Make the first kernel thread `initproc` /// Should be called only once - pub fn new_init(ms: MemorySet) -> Self { + pub fn new_init() -> Self { assert_has_not_been_called!(); Process { pid: 0, parent: 0, name: String::from("init"), - memory_set: ms, + memory_set: MemorySet::new(), status: Status::Running, context: unsafe { Context::null() }, // will be set at first schedule is_user: false,