diff --git a/src/arch/aarch64/mod.rs b/src/arch/aarch64/mod.rs index 307e5d0f..693fba6e 100644 --- a/src/arch/aarch64/mod.rs +++ b/src/arch/aarch64/mod.rs @@ -74,9 +74,11 @@ pub fn message_output_init() { } } -pub fn output_message_byte(byte: u8) { - unsafe { - COM1.write_byte(byte); +pub fn write_to_console(bytes: &[u8]) { + for byte in bytes.iter().copied() { + unsafe { + COM1.write_byte(byte); + } } } diff --git a/src/arch/riscv64/mod.rs b/src/arch/riscv64/mod.rs index 4cd5f7e5..42b7295f 100644 --- a/src/arch/riscv64/mod.rs +++ b/src/arch/riscv64/mod.rs @@ -16,7 +16,11 @@ use sptr::Strict; pub fn message_output_init() {} -pub use sbi_rt::console_write_byte as output_message_byte; +pub fn write_to_console(bytes: &[u8]) { + for byte in bytes.iter().copied() { + sbi_rt::console_write_byte(byte); + } +} fn find_kernel_linux(chosen: &FdtNode<'_, '_>) -> Option<&'static [u8]> { let initrd_start = chosen.property("linux,initrd-start")?.as_usize()?; diff --git a/src/arch/x86_64/mod.rs b/src/arch/x86_64/mod.rs index 212fd6cf..e88ce016 100644 --- a/src/arch/x86_64/mod.rs +++ b/src/arch/x86_64/mod.rs @@ -89,8 +89,10 @@ pub fn message_output_init() { unsafe { COM1.init() }; } -pub fn output_message_byte(byte: u8) { - unsafe { COM1.send(byte) }; +pub fn write_to_console(bytes: &[u8]) { + for byte in bytes.iter().copied() { + unsafe { COM1.send(byte) }; + } } #[cfg(target_os = "uefi")] diff --git a/src/console.rs b/src/console.rs index 61dd3e32..a1f0fd8f 100644 --- a/src/console.rs +++ b/src/console.rs @@ -6,9 +6,7 @@ pub struct Console(()); impl fmt::Write for Console { fn write_str(&mut self, s: &str) -> fmt::Result { - for byte in s.bytes() { - crate::arch::output_message_byte(byte); - } + crate::arch::write_to_console(s.as_bytes()); Ok(()) } }