mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
kernel: services: add a page for the queue
Eventually this will be rolled into an existing page. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
77c07f0d79
commit
db87a94960
1 changed files with 26 additions and 1 deletions
|
|
@ -2,7 +2,7 @@ use crate::arch;
|
||||||
use crate::arch::mem::MemoryMapping;
|
use crate::arch::mem::MemoryMapping;
|
||||||
pub use crate::arch::ProcessContext;
|
pub use crate::arch::ProcessContext;
|
||||||
use crate::args::KernelArguments;
|
use crate::args::KernelArguments;
|
||||||
use crate::mem::MemoryManagerHandle;
|
use crate::mem::{MemoryManagerHandle};
|
||||||
use core::slice;
|
use core::slice;
|
||||||
use xous::{MemoryFlags, PID, SID};
|
use xous::{MemoryFlags, PID, SID};
|
||||||
|
|
||||||
|
|
@ -111,6 +111,9 @@ pub struct Server {
|
||||||
|
|
||||||
/// The current state of this slot
|
/// The current state of this slot
|
||||||
state: ServerState,
|
state: ServerState,
|
||||||
|
|
||||||
|
/// Where data will appear
|
||||||
|
queue: *mut usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Server {
|
impl Default for Server {
|
||||||
|
|
@ -119,6 +122,7 @@ impl Default for Server {
|
||||||
sid: (0, 0, 0, 0),
|
sid: (0, 0, 0, 0),
|
||||||
pid: 0,
|
pid: 0,
|
||||||
state: ServerState::Free,
|
state: ServerState::Free,
|
||||||
|
queue: 0 as *mut usize,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -170,6 +174,7 @@ static mut SYSTEM_SERVICES: SystemServices = SystemServices {
|
||||||
sid: (0, 0, 0, 0),
|
sid: (0, 0, 0, 0),
|
||||||
pid: 0,
|
pid: 0,
|
||||||
state: ServerState::Free,
|
state: ServerState::Free,
|
||||||
|
queue: 0 as *mut usize,
|
||||||
}; MAX_SERVER_COUNT],
|
}; MAX_SERVER_COUNT],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -416,6 +421,26 @@ impl SystemServices {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Allocate a new server ID for this process and return the address.
|
||||||
|
/// If the server table is full, return an error.
|
||||||
|
pub fn create_server(&mut self) -> Result<SID, xous::Error> {
|
||||||
|
for entry in self.servers.iter_mut() {
|
||||||
|
if entry.state == ServerState::Free {
|
||||||
|
let pid = self.pid;
|
||||||
|
// Allocate memory for the new server.
|
||||||
|
entry.queue = {
|
||||||
|
let mut mm = MemoryManagerHandle::get();
|
||||||
|
mm.map_page(pid)?
|
||||||
|
};
|
||||||
|
entry.state = ServerState::Ready;
|
||||||
|
entry.pid = self.pid;
|
||||||
|
entry.sid = (pid as usize, pid as usize, pid as usize, pid as usize);
|
||||||
|
return Ok(entry.sid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(xous::Error::OutOfMemory)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// How many people have checked out the handle object.
|
/// How many people have checked out the handle object.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue