aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--stage2/Cargo.toml2
-rw-r--r--stage2/src/main.rs2
-rw-r--r--stage2/src/vga.rs12
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!");
+ });
}