fix some minor bugs in hosted mode

memory is not page-aligned so `if !cfg()`-out the alignment
checks in hosted mode
This commit is contained in:
bunnie 2021-04-09 17:31:36 +08:00
parent 8b93dd0c63
commit aed2325f68
5 changed files with 14 additions and 8 deletions

View file

@ -620,8 +620,10 @@ impl MemoryManager {
let addr = addr as usize;
// Ensure the address lies on a page boundary
if addr & 0xfff != 0 {
return Err(xous_kernel::Error::BadAlignment);
if cfg!(baremetal) {
if addr & 0xfff != 0 {
return Err(xous_kernel::Error::BadAlignment);
}
}
let mut offset = 0;

View file

@ -356,8 +356,10 @@ impl Server {
let mut result = Ok(xous_kernel::Result::Ok);
let virt = server_memory_addr;
let size = memory_length;
if virt & 0xfff != 0 {
return Err(xous_kernel::Error::BadAlignment);
if !cfg!(baremetal) {
if virt & 0xfff != 0 {
return Err(xous_kernel::Error::BadAlignment);
}
}
for addr in (virt..(virt + size)).step_by(crate::mem::PAGE_SIZE) {
if let Err(e) = mm.unmap_page(addr as *mut usize) {

View file

@ -657,8 +657,10 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
let mut result = Ok(xous_kernel::Result::Ok);
let virt = range.as_ptr() as usize;
let size = range.len();
if virt & 0xfff != 0 {
return Err(xous_kernel::Error::BadAlignment);
if cfg!(baremetal) {
if virt & 0xfff != 0 {
return Err(xous_kernel::Error::BadAlignment);
}
}
for addr in (virt..(virt + size)).step_by(PAGE_SIZE) {
if let Err(e) = mm.unmap_page(addr as *mut usize) {

View file

@ -36,7 +36,7 @@ pub fn dt_callback(dt: rtc::DateTime) {
//log::trace!("dt_callback received with {:?}", dt);
if let Some(cb_to_main_conn) = unsafe{CB_TO_MAIN_CONN} {
let buf = xous_ipc::Buffer::into_buf(dt).or(Err(xous::Error::InternalError)).unwrap();
buf.lend(cb_to_main_conn, StatusOpcode::DateTime.to_u32().unwrap()).unwrap();
buf.send(cb_to_main_conn, StatusOpcode::DateTime.to_u32().unwrap()).unwrap();
}
}

View file

@ -81,7 +81,7 @@ impl Llio {
}
pub fn allow_power_off(&self, allow: bool) -> Result<(), xous::Error> {
let arg = if allow { 1 } else { 0 };
let arg = if allow { 0 } else { 1 };
send_message(self.conn,
Message::new_scalar(Opcode::PowerSelf.to_usize().unwrap(), arg, 0, 0, 0)
).map(|_| ())