diff --git a/kernel-rs/Cargo.toml b/kernel-rs/Cargo.toml index 8acf6e4c..84dde790 100644 --- a/kernel-rs/Cargo.toml +++ b/kernel-rs/Cargo.toml @@ -8,6 +8,7 @@ crate-type = ["staticlib"] [dependencies] rlibc = "1.0" +spin = "0.4.5" multiboot2 = { path = "multiboot2-elf64" } [dependencies.lazy_static] diff --git a/kernel-rs/src/context.rs b/kernel-rs/src/context.rs index 418b98d5..fddab663 100644 --- a/kernel-rs/src/context.rs +++ b/kernel-rs/src/context.rs @@ -1,7 +1,6 @@ use multiboot2; use memory; use vga; -use cpuio; pub static mut CONTEXT: Option = None; @@ -37,6 +36,9 @@ impl Context kernel_start, kernel_end, multiboot_start, multiboot_end, memory_map_tag.memory_areas()); + let vga1 = vga::Writer::new(); + let vga2 = vga::Writer::new(); + Context { current_term: 0, multiboot_start, @@ -45,11 +47,16 @@ impl Context kernel_end, boot_info, frame_allocator, - vga1: vga::Writer::new(), - vga2: vga::Writer::new(), + vga1, + vga2, } } + pub fn init_screen(&mut self) { + self.vga1.prompt(); + self.vga2.prompt(); + self.vga1.flush(); + } pub fn switch_term(&mut self) { self.current_term = { @@ -67,11 +74,11 @@ impl Context } } -pub fn context() -> Context { +pub fn context() -> &'static mut Context { unsafe { - match CONTEXT.take() { - Some(context) => context, - None => panic!("heeelp"), + match CONTEXT { + Some(ref mut x) => &mut *x, + None => panic!(), } } } diff --git a/kernel-rs/src/lib.rs b/kernel-rs/src/lib.rs index abb9a3b2..bbf6f05c 100644 --- a/kernel-rs/src/lib.rs +++ b/kernel-rs/src/lib.rs @@ -10,6 +10,7 @@ extern crate rlibc; extern crate multiboot2; //slightly modified fork from official 0.3.2 #[macro_use] extern crate lazy_static; +extern crate spin; /// 80x25 screen and simplistic terminal driver #[macro_use] pub mod vga; @@ -34,6 +35,7 @@ use vga::{Color, ColorCode}; pub extern fn kmain(multiboot_info_addr: usize) -> ! { unsafe { CONTEXT = Some(Context::new(multiboot_info_addr)) }; acpi::init().unwrap(); + context().init_screen(); set_color!(White, Cyan); print!("{}{}{}{}{}{}{}{}{}{}{}{}{}{}", @@ -53,7 +55,6 @@ pub extern fn kmain(multiboot_info_addr: usize) -> ! { format_args!("{: ^80}", r#" '--' `---' "#)); set_color!(); - context(); loop { keyboard::kbd_callback(); } }