diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2022-09-18 18:49:37 +0200 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2022-09-18 18:49:37 +0200 |
commit | fe4c3320fc0626c864d1a622f508c2cf6b8fa1ae (patch) | |
tree | 1f396e5873c101c3149da0c0875c39923be4f83b | |
parent | dc1654c3134e644bae51939d5cd65d74a2a4f853 (diff) |
Global vga::Writer
-rw-r--r-- | stage2/Cargo.toml | 2 | ||||
-rw-r--r-- | stage2/src/main.rs | 2 | ||||
-rw-r--r-- | stage2/src/vga.rs | 12 |
3 files changed, 9 insertions, 7 deletions
diff --git a/stage2/Cargo.toml b/stage2/Cargo.toml index 730ba62..4add51d 100644 --- a/stage2/Cargo.toml +++ b/stage2/Cargo.toml @@ -16,4 +16,6 @@ lto = true codegen-units = 1 [dependencies] +lazy_static = { version = "1.0", features = ["spin_no_std"] } volatile = "0.4.5" +spin = "0.9.4" diff --git a/stage2/src/main.rs b/stage2/src/main.rs index 5e519f7..d05e3b2 100644 --- a/stage2/src/main.rs +++ b/stage2/src/main.rs @@ -14,7 +14,7 @@ fn panic(_info: &PanicInfo) -> ! { #[no_mangle] pub extern "C" fn _start() -> ! { - vga::test_print(); + vga::WRITER.lock().write_string("Hello Stage2!"); unsafe { loop { diff --git a/stage2/src/vga.rs b/stage2/src/vga.rs index 901b91a..f20dec7 100644 --- a/stage2/src/vga.rs +++ b/stage2/src/vga.rs @@ -1,6 +1,8 @@ use core::ops::{AddAssign, Deref, DerefMut, Shl, Sub}; +use lazy_static::lazy_static; use volatile::Volatile; +use spin::Mutex; #[allow(dead_code)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -135,13 +137,11 @@ impl Writer { } } -pub fn test_print() { - let mut writer = Writer { +lazy_static! { + pub static ref WRITER: Mutex<Writer> = Mutex::new(Writer { row_position: 1, column_position: 0, - color_code: ColorCode::new(Color::Yellow, Color::Black), + color_code: ColorCode::new(Color::LightGray, Color::Black), buffer: unsafe { &mut *(0xb8000 as *mut Buffer) }, - }; - - writer.write_string("Hello Stage2!"); + }); } |