mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
loader: assign sections to process ownership
This ensures these addresses aren't re-used and handed out again by memory allocation. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
147100fa38
commit
6ccbacf65f
7 changed files with 51 additions and 25 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -151,6 +151,7 @@ dependencies = [
|
||||||
"typenum",
|
"typenum",
|
||||||
"utralib",
|
"utralib",
|
||||||
"xous",
|
"xous",
|
||||||
|
"xous-names",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ xous = { path = "../../xous-rs" }
|
||||||
heapless = "0.5"
|
heapless = "0.5"
|
||||||
log-server = { path = "../log-server" }
|
log-server = { path = "../log-server" }
|
||||||
ticktimer-server = { path = "../ticktimer-server" }
|
ticktimer-server = { path = "../ticktimer-server" }
|
||||||
|
xous-names = { path = "../xous-names" }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
com_rs = { git = "https://github.com/betrusted-io/com_rs.git", rev = "a9e05f414accef08348b77be6fc0f668b319e6ff" }
|
com_rs = { git = "https://github.com/betrusted-io/com_rs.git", rev = "a9e05f414accef08348b77be6fc0f668b319e6ff" }
|
||||||
#com_rs = { path = "../../../betrusted-ec/sw/com_rs" }
|
#com_rs = { path = "../../../betrusted-ec/sw/com_rs" }
|
||||||
|
|
|
||||||
|
|
@ -237,22 +237,17 @@ fn xmain() -> ! {
|
||||||
|
|
||||||
log_server::init_wait().unwrap();
|
log_server::init_wait().unwrap();
|
||||||
|
|
||||||
|
xous_names::register_name("COM manager to EC");
|
||||||
|
|
||||||
let com_server =
|
let com_server =
|
||||||
xous::create_server_with_address(b"com ").expect("Couldn't create COM server");
|
xous::create_server_with_address(b"com ").expect("Couldn't create COM server");
|
||||||
|
|
||||||
let shell_id = xous::SID::from_bytes(b"shell ").unwrap();
|
let shell_id = xous::SID::from_bytes(b"shell ").unwrap();
|
||||||
let shell_conn = xous::connect(shell_id).unwrap();
|
let shell_conn = xous::connect(shell_id).unwrap();
|
||||||
|
|
||||||
/*
|
let testconn = xous_names::request_connection("COM manager to EC");
|
||||||
info!("Test NS registration");
|
info!("testconn result: {:?}", testconn);
|
||||||
let registration = Registration::new();
|
|
||||||
let mut sendable_registration = Sendable::new(registration)
|
|
||||||
.expect("can't create sendable registration structure");
|
|
||||||
write!(sendable_registration.name, "A test Name!").unwrap();
|
|
||||||
info!("namserver registration input: {:?}", sendable_registration.success);
|
|
||||||
sendable_registration.lend_mut(ns_conn, sendable_registration.mid()).expect("nameserver registration failure!");
|
|
||||||
info!("nameserver registration result: {:?}, {:?}", sendable_registration.success, sendable_registration.sid);
|
|
||||||
*/
|
|
||||||
let agent_conn: usize;
|
let agent_conn: usize;
|
||||||
if cfg!(feature = "fccagent") {
|
if cfg!(feature = "fccagent") {
|
||||||
let agent_id = xous::SID::from_bytes(b"fcc-agent-server").unwrap();
|
let agent_id = xous::SID::from_bytes(b"fcc-agent-server").unwrap();
|
||||||
|
|
|
||||||
|
|
@ -357,7 +357,7 @@ fn shell_main() -> ! {
|
||||||
info!("memtest: iter {}", iter);
|
info!("memtest: iter {}", iter);
|
||||||
iter += 1;
|
iter += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Periodic tasks
|
// Periodic tasks
|
||||||
if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) {
|
if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) {
|
||||||
if elapsed_time - last_time > 500 {
|
if elapsed_time - last_time > 500 {
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,41 @@
|
||||||
|
|
||||||
pub mod api;
|
pub mod api;
|
||||||
|
|
||||||
/*
|
use xous::ipc::*;
|
||||||
Calls are made using the xous::ipc::Sendable IPC wrapper, for example:
|
use api::{Registration, Lookup};
|
||||||
|
use core::fmt::Write;
|
||||||
|
|
||||||
use xous::ipc::*;
|
pub fn register_name(name: &str) -> Result<bool, xous::Error> {
|
||||||
|
let ns_id = xous::SID::from_bytes(b"xous-name-server").unwrap();
|
||||||
|
let ns_conn = xous::connect(ns_id).unwrap();
|
||||||
|
|
||||||
let mut registration = Registration::new();
|
let registration = Registration::new();
|
||||||
let mut sendable_registration = Sendable::new(registration)
|
let mut sendable_registration = Sendable::new(registration)
|
||||||
.expect("can't create sendable registration structure");
|
.expect("can't create sendable registration structure");
|
||||||
|
write!(sendable_registration.name, "{}", name).unwrap();
|
||||||
|
sendable_registration.lend_mut(ns_conn, sendable_registration.mid()).expect("nameserver registration failure!");
|
||||||
|
|
||||||
write!(sendable_registration.name, "I'm a server, please call me Fred!");
|
Ok(sendable_registration.success)
|
||||||
|
}
|
||||||
|
|
||||||
sendable_registration.lend_mut(ns_conn, sendable_registration.mid());
|
/// note: if this throws an AccessDenied error, you can retry with a request_authenticat_connection() call (to be written)
|
||||||
|
pub fn request_connection(name: &str) -> Result<xous::CID, xous::Error> {
|
||||||
|
let ns_id = xous::SID::from_bytes(b"xous-name-server").unwrap();
|
||||||
|
let ns_conn = xous::connect(ns_id).unwrap();
|
||||||
|
|
||||||
*/
|
let lookup = Lookup::new();
|
||||||
|
let mut sendable_lookup = Sendable::new(lookup)
|
||||||
|
.expect("can't create sendable lookup structure");
|
||||||
|
write!(sendable_lookup.name, "{}", name).unwrap();
|
||||||
|
sendable_lookup.lend_mut(ns_conn, sendable_lookup.mid()).expect("nameserver lookup failure!");
|
||||||
|
|
||||||
|
if sendable_lookup.success {
|
||||||
|
Ok(sendable_lookup.cid)
|
||||||
|
} else {
|
||||||
|
if sendable_lookup.authenticate_request {
|
||||||
|
Err(xous::Error::AccessDenied)
|
||||||
|
} else {
|
||||||
|
Err(xous::Error::ServerNotFound)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -58,17 +58,19 @@ fn xmain() -> ! {
|
||||||
let lookup: &mut Lookup = unsafe {
|
let lookup: &mut Lookup = unsafe {
|
||||||
&mut *(m.buf.as_mut_ptr() as *mut Lookup)
|
&mut *(m.buf.as_mut_ptr() as *mut Lookup)
|
||||||
};
|
};
|
||||||
/*
|
|
||||||
info!("NS: Lookup request for {}", lookup.name);
|
info!("NS: Lookup request for {}", lookup.name);
|
||||||
if let Ok(server_sid) = name_table.get(lookup) {
|
if let Some(server_sid) = name_table.get(&lookup.name) {
|
||||||
lookup.success = true;
|
let sender_pid = envelope.sender.pid().expect("NS: can't extract sender PID on Lookup");
|
||||||
let sender_pid = &envelope.sender.pid()?;
|
match xous::connect_for_process(sender_pid, *server_sid).expect("NS: can't broker connection") {
|
||||||
let connection_id = xous::connect_for_process(sender_pid, server_sid).expect("NS: can't broker connection");
|
xous::Result::ConnectionID(connection_id) => {
|
||||||
lookup.cid = connection_id;
|
lookup.cid = connection_id;
|
||||||
|
lookup.success = true},
|
||||||
|
_ => lookup.success = false
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
lookup.success = false;
|
lookup.success = false;
|
||||||
// no authenticate remedy currently supported, but we'd put that code somewhere around here eventually.
|
// no authenticate remedy currently supported, but we'd put that code somewhere around here eventually.
|
||||||
}*/
|
}
|
||||||
} else {
|
} else {
|
||||||
error!("NS: unknown message ID received");
|
error!("NS: unknown message ID received");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,7 @@ pub enum Error {
|
||||||
InvalidThread = 20,
|
InvalidThread = 20,
|
||||||
InvalidPID = 21,
|
InvalidPID = 21,
|
||||||
UnknownError = 22,
|
UnknownError = 22,
|
||||||
|
AccessDenied = 23,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
|
|
@ -182,6 +183,7 @@ impl Error {
|
||||||
19 => ShareViolation,
|
19 => ShareViolation,
|
||||||
20 => InvalidThread,
|
20 => InvalidThread,
|
||||||
21 => InvalidPID,
|
21 => InvalidPID,
|
||||||
|
23 => AccessDenied,
|
||||||
_ => UnknownError,
|
_ => UnknownError,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -210,6 +212,7 @@ impl Error {
|
||||||
ShareViolation => 19,
|
ShareViolation => 19,
|
||||||
InvalidThread => 20,
|
InvalidThread => 20,
|
||||||
InvalidPID => 21,
|
InvalidPID => 21,
|
||||||
|
AccessDenied => 23,
|
||||||
UnknownError => usize::MAX,
|
UnknownError => usize::MAX,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue