Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mkroening committed Jan 3, 2023
1 parent b2b9c04 commit 9707c4a
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 6 deletions.
54 changes: 54 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/arch/x86_64/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,15 @@ pub fn message_output_init() {
#[cfg(target_os = "none")]
pub fn output_message_buf(buf: &[u8]) {
// Output messages to the serial port and VGA screen in unikernel mode.

use alloc::string::String;
COM1.lock().as_mut().unwrap().send(buf);

#[cfg(feature = "vga")]
vga::print(buf);
{
let s = String::from_utf8_lossy(buf);
vga::print(&s);
}
}

#[cfg(not(target_os = "none"))]
Expand Down
12 changes: 7 additions & 5 deletions src/arch/x86_64/kernel/vga.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use core::alloc::Layout;

use core::fmt::Write;
use hermit_sync::{InterruptOnceCell, InterruptSpinMutex};
use vga_text_mode::{ VgaScreen, TextBuffer, FrontBuffer};
use vga_text_mode::{ VgaScreen, FrontBuffer, text_buffer::TextBuffer};
use x86_64::instructions::port::Port;

use crate::arch::x86_64::mm::paging::{BasePageSize, PageTableEntryFlags, PageTableEntryFlagsExt};
use crate::arch::x86_64::mm::{paging, PhysAddr, VirtAddr, virtualmem};
use crate::arch::x86_64::mm::{paging, PhysAddr, VirtAddr};

static VGA_SCREEN: InterruptOnceCell<InterruptSpinMutex<VgaScreen<'static>>> = InterruptOnceCell::new();

Expand Down Expand Up @@ -35,14 +36,15 @@ pub fn init() {
}

let front_buffer = unsafe { &mut *(virt_addr as *mut TextBuffer) };
let front_buffer = FrontBuffer::new(front_buffer);

VGA_SCREEN
.set(InterruptSpinMutex::new(VgaScreen::new(front_buffer).unwrap()))
.set(InterruptSpinMutex::new(VgaScreen::new(front_buffer)))
.unwrap();
}

pub fn print(buf: &[u8]) {
pub fn print(s: &str) {
if let Some(vga_screen) = VGA_SCREEN.get() {
vga_screen.lock().print(buf);
vga_screen.lock().write_str(s).unwrap();
}
}

0 comments on commit 9707c4a

Please sign in to comment.