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:
Sean Cross 2021-01-07 18:51:14 +08:00 committed by bunnie
parent 147100fa38
commit 6ccbacf65f
7 changed files with 51 additions and 25 deletions

1
Cargo.lock generated
View file

@ -151,6 +151,7 @@ dependencies = [
"typenum",
"utralib",
"xous",
"xous-names",
]
[[package]]

View file

@ -10,6 +10,7 @@ xous = { path = "../../xous-rs" }
heapless = "0.5"
log-server = { path = "../log-server" }
ticktimer-server = { path = "../ticktimer-server" }
xous-names = { path = "../xous-names" }
log = "0.4"
com_rs = { git = "https://github.com/betrusted-io/com_rs.git", rev = "a9e05f414accef08348b77be6fc0f668b319e6ff" }
#com_rs = { path = "../../../betrusted-ec/sw/com_rs" }

View file

@ -237,22 +237,17 @@ fn xmain() -> ! {
log_server::init_wait().unwrap();
xous_names::register_name("COM manager to EC");
let 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_conn = xous::connect(shell_id).unwrap();
/*
info!("Test NS registration");
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 testconn = xous_names::request_connection("COM manager to EC");
info!("testconn result: {:?}", testconn);
let agent_conn: usize;
if cfg!(feature = "fccagent") {
let agent_id = xous::SID::from_bytes(b"fcc-agent-server").unwrap();

View file

@ -357,7 +357,7 @@ fn shell_main() -> ! {
info!("memtest: iter {}", iter);
iter += 1;
}
// Periodic tasks
if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) {
if elapsed_time - last_time > 500 {

View file

@ -2,17 +2,41 @@
pub mod api;
/*
Calls are made using the xous::ipc::Sendable IPC wrapper, for example:
use xous::ipc::*;
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)
.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)
}
}
}

View file

@ -58,17 +58,19 @@ fn xmain() -> ! {
let lookup: &mut Lookup = unsafe {
&mut *(m.buf.as_mut_ptr() as *mut Lookup)
};
/*
info!("NS: Lookup request for {}", lookup.name);
if let Ok(server_sid) = name_table.get(lookup) {
lookup.success = true;
let sender_pid = &envelope.sender.pid()?;
let connection_id = xous::connect_for_process(sender_pid, server_sid).expect("NS: can't broker connection");
lookup.cid = connection_id;
if let Some(server_sid) = name_table.get(&lookup.name) {
let sender_pid = envelope.sender.pid().expect("NS: can't extract sender PID on Lookup");
match xous::connect_for_process(sender_pid, *server_sid).expect("NS: can't broker connection") {
xous::Result::ConnectionID(connection_id) => {
lookup.cid = connection_id;
lookup.success = true},
_ => lookup.success = false
}
} else {
lookup.success = false;
// no authenticate remedy currently supported, but we'd put that code somewhere around here eventually.
}*/
}
} else {
error!("NS: unknown message ID received");
}

View file

@ -154,6 +154,7 @@ pub enum Error {
InvalidThread = 20,
InvalidPID = 21,
UnknownError = 22,
AccessDenied = 23,
}
impl Error {
@ -182,6 +183,7 @@ impl Error {
19 => ShareViolation,
20 => InvalidThread,
21 => InvalidPID,
23 => AccessDenied,
_ => UnknownError,
}
}
@ -210,6 +212,7 @@ impl Error {
ShareViolation => 19,
InvalidThread => 20,
InvalidPID => 21,
AccessDenied => 23,
UnknownError => usize::MAX,
}
}