From d63aeb4c3f8389e458c0c5e580f11a98ac962c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Tue, 9 Apr 2024 11:15:34 +0200 Subject: [PATCH] fix(arch): output whole slices of bytes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- src/arch/aarch64/mod.rs | 8 +++++--- src/arch/riscv64/mod.rs | 6 +++++- src/arch/x86_64/mod.rs | 6 ++++-- src/console.rs | 4 +--- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/arch/aarch64/mod.rs b/src/arch/aarch64/mod.rs index fa7a147b..1aa6b98d 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 50db3055..ea08dfca 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(()) } }