mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-09 05:16:47 +00:00
Fix IoMem read and write bugs
This commit is contained in:
parent
2ad9735eab
commit
f1a7c767d2
@ -17,7 +17,7 @@ impl VmIo for IoMem {
|
||||
self.check_range(offset, buf.len())?;
|
||||
unsafe {
|
||||
core::ptr::copy(
|
||||
self.virtual_address as *const u8,
|
||||
(self.virtual_address + offset) as *const u8,
|
||||
buf.as_mut_ptr(),
|
||||
buf.len(),
|
||||
);
|
||||
@ -28,7 +28,11 @@ impl VmIo for IoMem {
|
||||
fn write_bytes(&self, offset: usize, buf: &[u8]) -> crate::Result<()> {
|
||||
self.check_range(offset, buf.len())?;
|
||||
unsafe {
|
||||
core::ptr::copy(buf.as_ptr(), self.virtual_address as *mut u8, buf.len());
|
||||
core::ptr::copy(
|
||||
buf.as_ptr(),
|
||||
(self.virtual_address + offset) as *mut u8,
|
||||
buf.len(),
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user