Make writer instance global
This commit is contained in:
parent
0c970ef827
commit
bf576f23f1
17
Cargo.lock
generated
17
Cargo.lock
generated
|
@ -7,6 +7,8 @@ name = "KarxOS"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bootloader",
|
||||
"lazy_static",
|
||||
"spin",
|
||||
"volatile",
|
||||
]
|
||||
|
||||
|
@ -16,6 +18,21 @@ version = "0.9.19"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7c452074efc3c0bfb241fb7bc87df04741c7c85e926f6a07c05f8fbd6008240"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
dependencies = [
|
||||
"spin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
||||
|
||||
[[package]]
|
||||
name = "volatile"
|
||||
version = "0.2.7"
|
||||
|
|
|
@ -8,3 +8,8 @@ edition = "2018"
|
|||
[dependencies]
|
||||
bootloader = "0.9.8"
|
||||
volatile = "0.2.6"
|
||||
spin = "0.5.2"
|
||||
|
||||
[dependencies.lazy_static]
|
||||
version = "1.0"
|
||||
features = ["spin_no_std"]
|
||||
|
|
|
@ -12,7 +12,9 @@ fn panic(_info: &PanicInfo) -> ! {
|
|||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn _start() -> ! {
|
||||
vga_buffer::print_something();
|
||||
use core::fmt::Write;
|
||||
vga_buffer::WRITER.lock().write_str("Hello there\n").unwrap();
|
||||
writeln!(vga_buffer::WRITER.lock(), "General Kenobi").unwrap();
|
||||
|
||||
loop {}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use volatile::Volatile;
|
||||
use core::fmt;
|
||||
use lazy_static::lazy_static;
|
||||
use spin::Mutex;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
|
@ -118,16 +120,11 @@ impl fmt::Write for Writer {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn print_something() {
|
||||
use core::fmt::Write;
|
||||
let mut writer = Writer {
|
||||
lazy_static! {
|
||||
pub static ref WRITER: Mutex<Writer> = Mutex::new(Writer {
|
||||
column_position: 0,
|
||||
color_code: ColorCode::new(Color::White, Color::Black),
|
||||
buffer: unsafe { &mut *(0xb8000 as *mut Buffer) }
|
||||
};
|
||||
|
||||
writeln!(writer, "Hello world!").unwrap();
|
||||
writeln!(writer, "Hello again!").unwrap();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue