Skip to content

Commit 9707c4a

Browse files
committed
WIP
1 parent b2b9c04 commit 9707c4a

File tree

3 files changed

+67
-6
lines changed

3 files changed

+67
-6
lines changed

Cargo.lock

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/arch/x86_64/kernel/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,15 @@ pub fn message_output_init() {
191191
#[cfg(target_os = "none")]
192192
pub fn output_message_buf(buf: &[u8]) {
193193
// Output messages to the serial port and VGA screen in unikernel mode.
194+
195+
use alloc::string::String;
194196
COM1.lock().as_mut().unwrap().send(buf);
195197

196198
#[cfg(feature = "vga")]
197-
vga::print(buf);
199+
{
200+
let s = String::from_utf8_lossy(buf);
201+
vga::print(&s);
202+
}
198203
}
199204

200205
#[cfg(not(target_os = "none"))]

src/arch/x86_64/kernel/vga.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use core::alloc::Layout;
22

3+
use core::fmt::Write;
34
use hermit_sync::{InterruptOnceCell, InterruptSpinMutex};
4-
use vga_text_mode::{ VgaScreen, TextBuffer, FrontBuffer};
5+
use vga_text_mode::{ VgaScreen, FrontBuffer, text_buffer::TextBuffer};
56
use x86_64::instructions::port::Port;
67

78
use crate::arch::x86_64::mm::paging::{BasePageSize, PageTableEntryFlags, PageTableEntryFlagsExt};
8-
use crate::arch::x86_64::mm::{paging, PhysAddr, VirtAddr, virtualmem};
9+
use crate::arch::x86_64::mm::{paging, PhysAddr, VirtAddr};
910

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

@@ -35,14 +36,15 @@ pub fn init() {
3536
}
3637

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

3941
VGA_SCREEN
40-
.set(InterruptSpinMutex::new(VgaScreen::new(front_buffer).unwrap()))
42+
.set(InterruptSpinMutex::new(VgaScreen::new(front_buffer)))
4143
.unwrap();
4244
}
4345

44-
pub fn print(buf: &[u8]) {
46+
pub fn print(s: &str) {
4547
if let Some(vga_screen) = VGA_SCREEN.get() {
46-
vga_screen.lock().print(buf);
48+
vga_screen.lock().write_str(s).unwrap();
4749
}
4850
}

0 commit comments

Comments
 (0)