mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
kernel: fix clippy warnings in mem/server
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
059fc18850
commit
76953985fe
2 changed files with 29 additions and 35 deletions
|
|
@ -386,7 +386,7 @@ impl MemoryManager {
|
||||||
// FIXME: Un-reserve addresses if we encounter an error here
|
// FIXME: Un-reserve addresses if we encounter an error here
|
||||||
mm.reserve_address(self, virt, flags)?;
|
mm.reserve_address(self, virt, flags)?;
|
||||||
}
|
}
|
||||||
Ok(unsafe { xous_kernel::MemoryRange::new(virt_ptr as usize, size) }?)
|
unsafe { xous_kernel::MemoryRange::new(virt_ptr as usize, size) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempt to allocate a single page from the default section.
|
/// Attempt to allocate a single page from the default section.
|
||||||
|
|
@ -490,7 +490,7 @@ impl MemoryManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(unsafe { MemoryRange::new(virt as usize, size) }?)
|
unsafe { MemoryRange::new(virt as usize, size) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempt to map the given physical address into the virtual address space
|
/// Attempt to map the given physical address into the virtual address space
|
||||||
|
|
@ -520,10 +520,10 @@ impl MemoryManager {
|
||||||
let phys_addr = crate::arch::mem::virt_to_phys(src_addr as usize)?;
|
let phys_addr = crate::arch::mem::virt_to_phys(src_addr as usize)?;
|
||||||
crate::arch::mem::move_page_inner(
|
crate::arch::mem::move_page_inner(
|
||||||
self,
|
self,
|
||||||
&src_mapping,
|
src_mapping,
|
||||||
src_addr,
|
src_addr,
|
||||||
dest_pid,
|
dest_pid,
|
||||||
&dest_mapping,
|
dest_mapping,
|
||||||
dest_addr,
|
dest_addr,
|
||||||
)?;
|
)?;
|
||||||
self.claim_release_move(
|
self.claim_release_move(
|
||||||
|
|
@ -552,10 +552,10 @@ impl MemoryManager {
|
||||||
// the page while it's borrowed.
|
// the page while it's borrowed.
|
||||||
crate::arch::mem::lend_page_inner(
|
crate::arch::mem::lend_page_inner(
|
||||||
self,
|
self,
|
||||||
&src_mapping,
|
src_mapping,
|
||||||
src_addr as _,
|
src_addr as _,
|
||||||
dest_pid,
|
dest_pid,
|
||||||
&dest_mapping,
|
dest_mapping,
|
||||||
dest_addr as _,
|
dest_addr as _,
|
||||||
mutable,
|
mutable,
|
||||||
)
|
)
|
||||||
|
|
@ -576,10 +576,10 @@ impl MemoryManager {
|
||||||
// the page while it's borrowed.
|
// the page while it's borrowed.
|
||||||
crate::arch::mem::return_page_inner(
|
crate::arch::mem::return_page_inner(
|
||||||
self,
|
self,
|
||||||
&src_mapping,
|
src_mapping,
|
||||||
src_addr,
|
src_addr,
|
||||||
dest_pid,
|
dest_pid,
|
||||||
&dest_mapping,
|
dest_mapping,
|
||||||
dest_addr,
|
dest_addr,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -647,10 +647,8 @@ impl MemoryManager {
|
||||||
let addr = addr as usize;
|
let addr = addr as usize;
|
||||||
|
|
||||||
// Ensure the address lies on a page boundary
|
// Ensure the address lies on a page boundary
|
||||||
if cfg!(baremetal) {
|
if cfg!(baremetal) && addr & 0xfff != 0 {
|
||||||
if addr & 0xfff != 0 {
|
return Err(xous_kernel::Error::BadAlignment);
|
||||||
return Err(xous_kernel::Error::BadAlignment);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut offset = 0;
|
let mut offset = 0;
|
||||||
|
|
|
||||||
|
|
@ -64,11 +64,11 @@ impl From<usize> for SenderID {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<usize> for SenderID {
|
impl From<SenderID> for usize {
|
||||||
fn into(self) -> usize {
|
fn from(val: SenderID) -> Self {
|
||||||
(self.pid.map(|x| x.get() as usize).unwrap_or(0) << 24)
|
(val.pid.map(|x| x.get() as usize).unwrap_or(0) << 24)
|
||||||
| ((self.sidx << 16) & 0x00ff0000)
|
| ((val.sidx << 16) & 0x00ff0000)
|
||||||
| (self.idx & 0xffff)
|
| (val.idx & 0xffff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,9 +78,9 @@ impl From<MessageSender> for SenderID {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<MessageSender> for SenderID {
|
impl From<SenderID> for MessageSender {
|
||||||
fn into(self) -> MessageSender {
|
fn from(val: SenderID) -> Self {
|
||||||
MessageSender::from_usize(self.into())
|
MessageSender::from_usize(val.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,12 +247,12 @@ impl QueuedMessage {
|
||||||
/// not yet been responded to -- Messages that have not yet been seen by the
|
/// not yet been responded to -- Messages that have not yet been seen by the
|
||||||
/// Server will return `false`.
|
/// Server will return `false`.
|
||||||
fn is_in_server(&self) -> bool {
|
fn is_in_server(&self) -> bool {
|
||||||
match self {
|
matches!(
|
||||||
|
self,
|
||||||
&QueuedMessage::WaitingForget(_, _, _, _, _, _)
|
&QueuedMessage::WaitingForget(_, _, _, _, _, _)
|
||||||
| &QueuedMessage::WaitingReturnMemory(_, _, _, _, _, _)
|
| &QueuedMessage::WaitingReturnMemory(_, _, _, _, _, _)
|
||||||
| &QueuedMessage::WaitingReturnScalar(_, _, _, _) => true,
|
| &QueuedMessage::WaitingReturnScalar(_, _, _, _)
|
||||||
_ => false,
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -331,9 +331,7 @@ impl Server {
|
||||||
// For `Empty` and `Scalar` messages, all we have to do is ignore them.
|
// For `Empty` and `Scalar` messages, all we have to do is ignore them.
|
||||||
// The sending process will not be blocked. These messages will be dropped,
|
// The sending process will not be blocked. These messages will be dropped,
|
||||||
// and the server will never see them.
|
// and the server will never see them.
|
||||||
QueuedMessage::Empty | QueuedMessage::ScalarMessage(_, _, _, _, _, _, _, _, _) => {
|
QueuedMessage::Empty | QueuedMessage::ScalarMessage(_, _, _, _, _, _, _, _, _) => {}
|
||||||
()
|
|
||||||
}
|
|
||||||
|
|
||||||
// For `Send` messages, the Server has not yet seen these messages. Simply
|
// For `Send` messages, the Server has not yet seen these messages. Simply
|
||||||
// prevent this memory from getting mapped into the Server and free it.
|
// prevent this memory from getting mapped into the Server and free it.
|
||||||
|
|
@ -352,10 +350,8 @@ impl Server {
|
||||||
let mut result = Ok(xous_kernel::Result::Ok);
|
let mut result = Ok(xous_kernel::Result::Ok);
|
||||||
let virt = server_memory_addr;
|
let virt = server_memory_addr;
|
||||||
let size = memory_length;
|
let size = memory_length;
|
||||||
if !cfg!(baremetal) {
|
if !cfg!(baremetal) && virt & 0xfff != 0 {
|
||||||
if virt & 0xfff != 0 {
|
return Err(xous_kernel::Error::BadAlignment);
|
||||||
return Err(xous_kernel::Error::BadAlignment);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for addr in (virt..(virt + size)).step_by(crate::mem::PAGE_SIZE) {
|
for addr in (virt..(virt + size)).step_by(crate::mem::PAGE_SIZE) {
|
||||||
if let Err(e) = mm.unmap_page(addr as *mut usize) {
|
if let Err(e) = mm.unmap_page(addr as *mut usize) {
|
||||||
|
|
@ -597,7 +593,7 @@ impl Server {
|
||||||
let buf = buf.expect("memory message expected but no buffer passed!");
|
let buf = buf.expect("memory message expected but no buffer passed!");
|
||||||
if server_addr != buf.as_ptr() as usize || len != buf.len() {
|
if server_addr != buf.as_ptr() as usize || len != buf.len() {
|
||||||
// klog!("Memory is attached but the returned buffer doesn't match (len: {} vs {}), buf addr: {:08x} vs {:08x}", len, buf.len(), server_addr, buf.as_ptr() as usize);
|
// klog!("Memory is attached but the returned buffer doesn't match (len: {} vs {}), buf addr: {:08x} vs {:08x}", len, buf.len(), server_addr, buf.as_ptr() as usize);
|
||||||
Err(xous_kernel::Error::BadAddress)?;
|
return Err(xous_kernel::Error::BadAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*current_val = QueuedMessage::Empty;
|
*current_val = QueuedMessage::Empty;
|
||||||
|
|
@ -988,7 +984,7 @@ impl Server {
|
||||||
// If the head and the tail generations will end up the same, then
|
// If the head and the tail generations will end up the same, then
|
||||||
// the queue is full.
|
// the queue is full.
|
||||||
if self.tail_generation == self.head_generation.wrapping_sub(1) {
|
if self.tail_generation == self.head_generation.wrapping_sub(1) {
|
||||||
Err(xous_kernel::Error::ServerQueueFull)?;
|
return Err(xous_kernel::Error::ServerQueueFull);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look through the queue, beginning at the queue head, for an empty slot.
|
// Look through the queue, beginning at the queue head, for an empty slot.
|
||||||
|
|
@ -1008,7 +1004,7 @@ impl Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if discovered_index.is_none() {
|
if discovered_index.is_none() {
|
||||||
Err(xous_kernel::Error::ServerQueueFull)?;
|
return Err(xous_kernel::Error::ServerQueueFull);
|
||||||
}
|
}
|
||||||
let queue_idx = discovered_index.unwrap();
|
let queue_idx = discovered_index.unwrap();
|
||||||
let queue_entry = &mut self.queue[queue_idx];
|
let queue_entry = &mut self.queue[queue_idx];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue