context works fianlly
This commit is contained in:
parent
edfffc3b13
commit
120292566d
3 changed files with 17 additions and 8 deletions
|
|
@ -8,6 +8,7 @@ crate-type = ["staticlib"]
|
|||
|
||||
[dependencies]
|
||||
rlibc = "1.0"
|
||||
spin = "0.4.5"
|
||||
multiboot2 = { path = "multiboot2-elf64" }
|
||||
|
||||
[dependencies.lazy_static]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use multiboot2;
|
||||
use memory;
|
||||
use vga;
|
||||
use cpuio;
|
||||
|
||||
pub static mut CONTEXT: Option<Context> = 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!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(); }
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue