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
start:
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_cpuid

@ -11,9 +11,15 @@ pub mod idt;
pub mod smp;
pub mod memory;
pub fn init(multiboot_information_address: usize) {
pub fn 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();
memory::init(boot_info);
// Now heap is available

@ -76,32 +76,16 @@ mod arch;
#[path = "arch/riscv32/mod.rs"]
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
#[no_mangle]
#[cfg(target_arch = "x86_64")]
pub extern "C" fn rust_main(multiboot_information_address: usize) -> ! {
pub extern "C" fn rust_main() -> ! {
// ATTENTION: we have a very small stack and no guard page
println!("Hello World{}", "!");
logging::init();
arch::init(multiboot_information_address);
arch::init();
process::init();
fs::load_sfs();
unsafe { arch::interrupt::enable(); }
// thread::test::local_key();

Loading…
Cancel
Save