Skip to content

Commit

Permalink
fix(arch): output whole slices of bytes
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Apr 9, 2024
1 parent 0b0789c commit dd74455
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/arch/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/arch/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down
6 changes: 4 additions & 2 deletions src/arch/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
4 changes: 1 addition & 3 deletions src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}
Expand Down

0 comments on commit dd74455

Please sign in to comment.