mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
Merge pull request #456 from Foundation-Devices/wip/misc
xous-rs: miscellaneous impromevements.
This commit is contained in:
commit
05aa899762
7 changed files with 30 additions and 33 deletions
|
|
@ -1,3 +0,0 @@
|
|||
fn main() {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ lazy_static::lazy_static! {
|
|||
|
||||
// Note: &* is required due to how `lazy_static` works behind the scenes:
|
||||
// https://github.com/rust-lang-nursery/lazy-static.rs/issues/119#issuecomment-419595818
|
||||
let mut conn = TcpStream::connect(&*NETWORK_CONNECT_ADDRESS).expect("unable to connect to Xous kernel");
|
||||
let mut conn = TcpStream::connect(*NETWORK_CONNECT_ADDRESS).expect("unable to connect to Xous kernel");
|
||||
|
||||
// Disable Nagel's algorithm, since we're running locally and managing buffers ourselves
|
||||
conn.set_nodelay(true).unwrap();
|
||||
|
|
@ -262,7 +262,7 @@ fn read_next_syscall_result(
|
|||
} else if kind == CallMemoryKind::Borrow || kind == CallMemoryKind::MutableBorrow {
|
||||
// Read the buffer back from the remote host.
|
||||
use core::slice;
|
||||
let mut data = unsafe { slice::from_raw_parts_mut(mem.as_mut_ptr(), mem.len()) };
|
||||
let data = unsafe { slice::from_raw_parts_mut(mem.as_mut_ptr(), mem.len()) };
|
||||
|
||||
// If it's a Borrow, verify the contents haven't changed by saving the previous
|
||||
// buffer in a Vec called `previous_data`.
|
||||
|
|
@ -272,7 +272,7 @@ fn read_next_syscall_result(
|
|||
};
|
||||
|
||||
// Read the incoming data from the network.
|
||||
if let Err(e) = stream.read_exact(&mut data) {
|
||||
if let Err(e) = stream.read_exact(data) {
|
||||
eprintln!("Server shut down: {}", e);
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ impl TryFrom<[usize; 7]> for ProcessInit {
|
|||
type Error = crate::Error;
|
||||
fn try_from(src: [usize; 7]) -> core::result::Result<ProcessInit, crate::Error> {
|
||||
let mut exploded = vec![];
|
||||
for word in src[0..4].into_iter() {
|
||||
for word in src[0..4].iter() {
|
||||
exploded.extend_from_slice(&(*word as u32).to_le_bytes());
|
||||
}
|
||||
let mut key = [0u8; 16];
|
||||
|
|
@ -156,7 +156,7 @@ pub fn create_process_post(
|
|||
|
||||
// println!("Launching process...");
|
||||
Command::new(shell)
|
||||
.args(&args)
|
||||
.args(args)
|
||||
.env("XOUS_SERVER", server_env)
|
||||
.env("XOUS_PID", pid_env)
|
||||
.env("XOUS_PROCESS_NAME", process_name_env)
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ pub const BASE_QUANTA_MS: u32 = 10;
|
|||
// where _|TT|_ and _|TE|_ are bookends around the data to be reported
|
||||
// <ident> is a single-word identifier that routes the data to a given parser
|
||||
// <data> is free-form data, which will be split at comma boundaries by the parser
|
||||
pub const BOOKEND_START: &'static str = "_|TT|_";
|
||||
pub const BOOKEND_END: &'static str = "_|TE|_";
|
||||
pub const BOOKEND_START: &str = "_|TT|_";
|
||||
pub const BOOKEND_END: &str = "_|TE|_";
|
||||
|
||||
#[cfg(not(target_os = "xous"))]
|
||||
use core::sync::atomic::AtomicU64;
|
||||
|
|
@ -425,7 +425,7 @@ impl Result {
|
|||
9, me_enc[0], me_enc[1], me_enc[2], me_enc[3], me_enc[4], me_enc[5], me_enc[6],
|
||||
]
|
||||
}
|
||||
Result::ThreadID(ctx) => [10, *ctx as usize, 0, 0, 0, 0, 0, 0],
|
||||
Result::ThreadID(ctx) => [10, *ctx, 0, 0, 0, 0, 0, 0],
|
||||
Result::ProcessID(pid) => [11, pid.get() as _, 0, 0, 0, 0, 0, 0],
|
||||
Result::Unimplemented => [21, 0, 0, 0, 0, 0, 0, 0],
|
||||
Result::BlockedProcess => [13, 0, 0, 0, 0, 0, 0, 0],
|
||||
|
|
|
|||
|
|
@ -91,10 +91,10 @@ impl Envelope {
|
|||
return Err((ManuallyDrop::into_inner(manual_self), e));
|
||||
}
|
||||
|
||||
return Err((
|
||||
Err((
|
||||
ManuallyDrop::into_inner(manual_self),
|
||||
crate::Error::MemoryInUse,
|
||||
));
|
||||
))
|
||||
}
|
||||
Message::BlockingScalar(_) => {
|
||||
let result = crate::send_message(connection, body);
|
||||
|
|
@ -113,10 +113,10 @@ impl Envelope {
|
|||
}
|
||||
return Ok(());
|
||||
}
|
||||
return Err((
|
||||
Err((
|
||||
ManuallyDrop::into_inner(manual_self),
|
||||
crate::Error::MemoryInUse,
|
||||
));
|
||||
))
|
||||
}
|
||||
|
||||
Message::Borrow(_) | Message::MutableBorrow(_) | Message::Scalar(_) => {
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ impl Message {
|
|||
}
|
||||
|
||||
pub fn to_usize(&self) -> [usize; 6] {
|
||||
let ret = match &*self {
|
||||
let ret = match self {
|
||||
Message::MutableBorrow(m) => (0, m.to_usize()),
|
||||
Message::Borrow(m) => (1, m.to_usize()),
|
||||
Message::Move(m) => (2, m.to_usize()),
|
||||
|
|
|
|||
|
|
@ -728,7 +728,7 @@ impl SysCall {
|
|||
SysCall::ReturnToParent(a1, a2) => [
|
||||
SysCallNumber::ReturnToParent as usize,
|
||||
a1.get() as usize,
|
||||
*a2 as usize,
|
||||
*a2,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
|
@ -751,7 +751,7 @@ impl SysCall {
|
|||
SysCall::SwitchTo(a1, a2) => [
|
||||
SysCallNumber::SwitchTo as usize,
|
||||
a1.get() as usize,
|
||||
*a2 as usize,
|
||||
*a2,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
|
@ -770,7 +770,7 @@ impl SysCall {
|
|||
],
|
||||
SysCall::IncreaseHeap(a1, a2) => [
|
||||
SysCallNumber::IncreaseHeap as usize,
|
||||
*a1 as usize,
|
||||
*a1,
|
||||
a2.bits(),
|
||||
0,
|
||||
0,
|
||||
|
|
@ -780,7 +780,7 @@ impl SysCall {
|
|||
],
|
||||
SysCall::DecreaseHeap(a1) => [
|
||||
SysCallNumber::DecreaseHeap as usize,
|
||||
*a1 as usize,
|
||||
*a1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
|
@ -841,17 +841,17 @@ impl SysCall {
|
|||
SysCallNumber::SendMessage as usize,
|
||||
*a1 as usize,
|
||||
a2.message_type(),
|
||||
mm.id as usize,
|
||||
mm.id,
|
||||
mm.buf.as_ptr() as usize,
|
||||
mm.buf.len(),
|
||||
mm.offset.map(|x| x.get()).unwrap_or(0) as usize,
|
||||
mm.valid.map(|x| x.get()).unwrap_or(0) as usize,
|
||||
mm.offset.map(|x| x.get()).unwrap_or(0),
|
||||
mm.valid.map(|x| x.get()).unwrap_or(0),
|
||||
],
|
||||
Message::Scalar(sc) | Message::BlockingScalar(sc) => [
|
||||
SysCallNumber::SendMessage as usize,
|
||||
*a1 as usize,
|
||||
a2.message_type(),
|
||||
sc.id as usize,
|
||||
sc.id,
|
||||
sc.arg1,
|
||||
sc.arg2,
|
||||
sc.arg3,
|
||||
|
|
@ -914,17 +914,17 @@ impl SysCall {
|
|||
SysCallNumber::TrySendMessage as usize,
|
||||
*a1 as usize,
|
||||
a2.message_type(),
|
||||
mm.id as usize,
|
||||
mm.id,
|
||||
mm.buf.as_ptr() as usize,
|
||||
mm.buf.len(),
|
||||
mm.offset.map(|x| x.get()).unwrap_or(0) as usize,
|
||||
mm.valid.map(|x| x.get()).unwrap_or(0) as usize,
|
||||
mm.offset.map(|x| x.get()).unwrap_or(0),
|
||||
mm.valid.map(|x| x.get()).unwrap_or(0),
|
||||
],
|
||||
Message::Scalar(sc) | Message::BlockingScalar(sc) => [
|
||||
SysCallNumber::TrySendMessage as usize,
|
||||
*a1 as usize,
|
||||
a2.message_type(),
|
||||
sc.id as usize,
|
||||
sc.id,
|
||||
sc.arg1,
|
||||
sc.arg2,
|
||||
sc.arg3,
|
||||
|
|
@ -978,7 +978,7 @@ impl SysCall {
|
|||
],
|
||||
SysCall::JoinThread(tid) => [
|
||||
SysCallNumber::JoinThread as usize,
|
||||
*tid as usize,
|
||||
*tid,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
|
@ -1073,13 +1073,13 @@ impl SysCall {
|
|||
MemoryAddress::new(a3),
|
||||
),
|
||||
SysCallNumber::FreeInterrupt => SysCall::FreeInterrupt(a1),
|
||||
SysCallNumber::SwitchTo => SysCall::SwitchTo(pid_from_usize(a1)?, a2 as usize),
|
||||
SysCallNumber::SwitchTo => SysCall::SwitchTo(pid_from_usize(a1)?, a2),
|
||||
SysCallNumber::ReadyThreads => SysCall::ReadyThreads(pid_from_usize(a1)?),
|
||||
SysCallNumber::IncreaseHeap => SysCall::IncreaseHeap(
|
||||
a1 as usize,
|
||||
a1,
|
||||
crate::MemoryFlags::from_bits(a2).ok_or(Error::InvalidSyscall)?,
|
||||
),
|
||||
SysCallNumber::DecreaseHeap => SysCall::DecreaseHeap(a1 as usize),
|
||||
SysCallNumber::DecreaseHeap => SysCall::DecreaseHeap(a1),
|
||||
SysCallNumber::UpdateMemoryFlags => SysCall::UpdateMemoryFlags(
|
||||
unsafe { MemoryRange::new(a1, a2) }?,
|
||||
crate::MemoryFlags::from_bits(a3).ok_or(Error::InvalidSyscall)?,
|
||||
|
|
@ -1986,7 +1986,7 @@ pub fn reply_and_receive_next(
|
|||
/// ## Arguments
|
||||
///
|
||||
/// * **server**: The SID of the server to receive messages from
|
||||
/// * **msg**: An Option<MessageEnvelope> specifying the message to return.
|
||||
/// * **msg**: An `Option<MessageEnvelope>` specifying the message to return.
|
||||
/// * **return_type**: If 1 or 2, responds to a BlockingScalarMessage
|
||||
/// with a Scalar1 or a Scalar2. Otherwise, will respond
|
||||
/// as normal.
|
||||
|
|
|
|||
Loading…
Reference in a new issue