mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
hosted: fix MemoryRange refactor
This fixes the MemoryRange refactor where `.addr` and `.size` are now private fields. Previously it had only been tested on baremetal mode. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
a99839ecd6
commit
7b7be0fe9e
3 changed files with 15 additions and 18 deletions
|
|
@ -228,14 +228,13 @@ fn handle_connection(
|
|||
sliced_data.len(),
|
||||
msg.buf.len()
|
||||
);
|
||||
msg.buf.addr =
|
||||
match MemoryAddress::new(Box::into_raw(sliced_data)
|
||||
as *mut u8
|
||||
as usize)
|
||||
{
|
||||
Some(a) => a,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
msg.buf = unsafe {
|
||||
xous_kernel::MemoryRange::new(
|
||||
Box::into_raw(sliced_data) as *mut u8 as usize,
|
||||
msg.buf.len(),
|
||||
)
|
||||
.unwrap()
|
||||
};
|
||||
}
|
||||
xous_kernel::Message::Scalar(_)
|
||||
| xous_kernel::Message::BlockingScalar(_) => (),
|
||||
|
|
@ -255,12 +254,12 @@ fn handle_connection(
|
|||
sliced_data.len(),
|
||||
buf.len()
|
||||
);
|
||||
buf.addr = match MemoryAddress::new(Box::into_raw(sliced_data)
|
||||
as *mut u8
|
||||
as usize)
|
||||
{
|
||||
Some(a) => a,
|
||||
_ => unreachable!(),
|
||||
*buf = unsafe {
|
||||
xous_kernel::MemoryRange::new(
|
||||
Box::into_raw(sliced_data) as *mut u8 as usize,
|
||||
buf.len(),
|
||||
)
|
||||
.unwrap()
|
||||
};
|
||||
}
|
||||
_ => panic!("unsupported message type"),
|
||||
|
|
|
|||
|
|
@ -691,8 +691,7 @@ fn _xous_syscall_result(ret: &mut Result, thread_id: TID, server_connection: &Se
|
|||
assert_eq!(data.len(), data.capacity());
|
||||
let len = data.len();
|
||||
let addr = data.as_mut_ptr();
|
||||
memory_message.buf.addr = crate::MemoryAddress::new(addr as _).unwrap();
|
||||
memory_message.buf.size = crate::MemorySize::new(len).unwrap();
|
||||
memory_message.buf = unsafe { crate::MemoryRange::new(addr as _, len).unwrap() };
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ pub fn map_memory_post(
|
|||
) -> core::result::Result<MemoryRange, Error> {
|
||||
let layout = Layout::from_size_align(range.len(), 4096).unwrap();
|
||||
let new_mem = MemoryAddress::new(unsafe { alloc(layout) } as usize).ok_or(Error::BadAddress)?;
|
||||
range.addr = new_mem;
|
||||
Ok(range)
|
||||
Ok(unsafe { MemoryRange::new(new_mem.get(), range.len()).unwrap() })
|
||||
}
|
||||
|
||||
pub fn unmap_memory_pre(_range: &MemoryRange) -> core::result::Result<(), Error> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue