Merge `rust_main`. Change the way to pass multiboot info address.

toolchain_update
WangRunji 7 years ago
parent c768ec3e1e
commit 76f5af7d30

@ -7,7 +7,7 @@ section .text
bits 32 bits 32
start: start:
mov esp, stack_top mov esp, stack_top
mov edi, ebx ; move Multiboot info pointer to edi push ebx ; push Multiboot info pointer to stack_top
call check_multiboot call check_multiboot
call check_cpuid call check_cpuid

@ -11,9 +11,15 @@ pub mod idt;
pub mod smp; pub mod smp;
pub mod memory; pub mod memory;
pub fn init(multiboot_information_address: usize) { pub fn init() {
idt::init(); idt::init();
let boot_info = unsafe { multiboot2::load(multiboot_information_address) }; // Load boot info address from stack_top.
// See `boot.asm`
extern {
fn stack_top();
}
let boot_info_addr = unsafe { *(stack_top as *const u32).offset(-1) } as usize;
let boot_info = unsafe { multiboot2::load(boot_info_addr) };
let rsdt_addr = boot_info.rsdp_v1_tag().unwrap().rsdt_address(); let rsdt_addr = boot_info.rsdp_v1_tag().unwrap().rsdt_address();
memory::init(boot_info); memory::init(boot_info);
// Now heap is available // Now heap is available

@ -76,32 +76,16 @@ mod arch;
#[path = "arch/riscv32/mod.rs"] #[path = "arch/riscv32/mod.rs"]
mod arch; mod arch;
#[no_mangle]
#[cfg(target_arch = "riscv")]
pub extern fn rust_main() -> ! {
logging::init();
arch::init();
info!("RISCV init end");
process::init();
fs::load_sfs();
unsafe { arch::interrupt::enable(); }
loop {}
}
/// The entry point of Rust kernel /// The entry point of Rust kernel
#[no_mangle] #[no_mangle]
#[cfg(target_arch = "x86_64")] pub extern "C" fn rust_main() -> ! {
pub extern "C" fn rust_main(multiboot_information_address: usize) -> ! {
// ATTENTION: we have a very small stack and no guard page // ATTENTION: we have a very small stack and no guard page
println!("Hello World{}", "!"); println!("Hello World{}", "!");
logging::init(); logging::init();
arch::init(multiboot_information_address); arch::init();
process::init(); process::init();
fs::load_sfs(); fs::load_sfs();
unsafe { arch::interrupt::enable(); } unsafe { arch::interrupt::enable(); }
// thread::test::local_key(); // thread::test::local_key();

Loading…
Cancel
Save