fix VGA on x86_64

master
WangRunji 6 years ago
parent 0977814d34
commit b304764fb5

2
kernel/Cargo.lock generated

@ -79,7 +79,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bootloader"
version = "0.3.14"
source = "git+https://github.com/wangrunji0408/bootloader#4014546a8655232d87e863b564ae1e4e027f9849"
source = "git+https://github.com/wangrunji0408/bootloader#d19ff0de234a8a54d4f93c355af5399672e026ae"
dependencies = [
"apic 0.1.0 (git+https://github.com/wangrunji0408/APIC-Rust)",
"fixedvec 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",

@ -68,7 +68,8 @@ impl VgaBuffer {
lazy_static! {
pub static ref VGA_WRITER: Mutex<VgaWriter> = Mutex::new(
VgaWriter::new(unsafe{ &mut *((KERNEL_OFFSET + 0xb8000) as *mut VgaBuffer) })
// VGA virtual address is specified at bootloader
VgaWriter::new(unsafe{ &mut *((KERNEL_OFFSET + 0xf0000000) as *mut VgaBuffer) })
);
}

@ -1,4 +1,5 @@
use super::driver::serial::*;
use super::driver::vga::VGA_WRITER;
use core::fmt::{Arguments, Write};
pub fn getchar() -> char {
@ -7,6 +8,14 @@ pub fn getchar() -> char {
}
pub fn putfmt(fmt: Arguments) {
unsafe { COM1.force_unlock(); }
COM1.lock().write_fmt(fmt).unwrap()
#[cfg(feature = "nographic")]
{
unsafe { COM1.force_unlock(); }
COM1.lock().write_fmt(fmt).unwrap();
}
#[cfg(not(feature = "nographic"))]
{
unsafe { VGA_WRITER.force_unlock(); }
VGA_WRITER.lock().write_fmt(fmt).unwrap();
}
}
Loading…
Cancel
Save