Skip to content

Commit

Permalink
[fix] set MAX_RW_SIZE in riscv console read and write
Browse files Browse the repository at this point in the history
  • Loading branch information
hky1999 committed Oct 28, 2024
1 parent 41024da commit 6e915d9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/axhal/src/platform/riscv64_qemu_virt/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use memory_addr::VirtAddr;
use crate::mem::virt_to_phys;

/// The maximum number of bytes that can be read at once.
const MAX_READ_SIZE: usize = 256;
const MAX_RW_SIZE: usize = 256;

/// Writes a byte to the console.
pub fn putchar(c: u8) {
Expand All @@ -13,7 +13,7 @@ pub fn putchar(c: u8) {
/// Writes bytes to the console from input u8 slice.
pub fn write_bytes(bytes: &[u8]) {
sbi_rt::console_write(sbi_rt::Physical::new(
bytes.len(),
bytes.len().min(MAX_RW_SIZE),
virt_to_phys(VirtAddr::from_ptr_of(bytes.as_ptr())).as_usize(),
0,
));
Expand All @@ -23,7 +23,7 @@ pub fn write_bytes(bytes: &[u8]) {
/// Returns the number of bytes read.
pub fn read_bytes(bytes: &mut [u8]) -> usize {
sbi_rt::console_read(sbi_rt::Physical::new(
bytes.len().min(MAX_READ_SIZE),
bytes.len().min(MAX_RW_SIZE),
virt_to_phys(VirtAddr::from_mut_ptr_of(bytes.as_mut_ptr())).as_usize(),
0,
))
Expand Down

0 comments on commit 6e915d9

Please sign in to comment.