From 02ffdd55bd05ba1e2241c2f0295b261f521197e5 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 27 Nov 2015 14:58:55 -0800 Subject: [PATCH] Add multiboot2 rust lib c.f. os.phil-opp.com/allocating-frames.html --- rust_experiments/Cargo.toml | 4 ++++ rust_experiments/src/boot.asm | 4 +++- rust_experiments/src/lib.rs | 9 ++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/rust_experiments/Cargo.toml b/rust_experiments/Cargo.toml index 467346f..22377f1 100644 --- a/rust_experiments/Cargo.toml +++ b/rust_experiments/Cargo.toml @@ -8,3 +8,7 @@ crate-type = ["staticlib"] [dependencies] rlibc = "*" + +[dependencies.multiboot2] +git = "https://github.com/phil-opp/multiboot2-elf64" + diff --git a/rust_experiments/src/boot.asm b/rust_experiments/src/boot.asm index b094e65..83c6f03 100644 --- a/rust_experiments/src/boot.asm +++ b/rust_experiments/src/boot.asm @@ -9,7 +9,7 @@ section .bss p3_table: resb 4096 p2_table: resb 4096 - stack_bottom: resb 64 ;reserve 64 bytes of stack space + stack_bottom: resb 4096 ;reserve 4096 bytes of stack space stack_top: section .text @@ -17,6 +17,8 @@ bits 32 start: mov esp, stack_top + mov edi, ebx ; move multiboot info pointer to edi + call test_multiboot call test_cpuid call use_cpuid diff --git a/rust_experiments/src/lib.rs b/rust_experiments/src/lib.rs index f8d1e9a..f4e94b2 100644 --- a/rust_experiments/src/lib.rs +++ b/rust_experiments/src/lib.rs @@ -7,6 +7,7 @@ extern crate std; extern crate rlibc; +extern crate multiboot2; /* externs */ #[no_mangle] @@ -38,7 +39,7 @@ pub extern fn rust_handle_timer() { } //timer_callback(gtc); - timer_callback2(gtc); + //timer_callback2(gtc); } #[no_mangle] @@ -176,10 +177,12 @@ fn timer_callback(count: u64) { } #[no_mangle] -pub extern fn rust_main() { +pub extern fn rust_main(multiboot_info_header: usize) { use vga_buffer::{clear, checkerboard, Color}; clear(); - //checkerboard(Color::Red); + checkerboard(Color::Red); + + let boot_info = unsafe { multiboot2::load(multiboot_info_header) }; loop {