mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
port cramium target to xous-ipc 0.10
This commit is contained in:
parent
7ea1400843
commit
1ec66137be
9 changed files with 21 additions and 23 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use String;
|
||||||
use cram_hal_service::trng;
|
use cram_hal_service::trng;
|
||||||
#[cfg(feature = "shellperf")]
|
#[cfg(feature = "shellperf")]
|
||||||
use utralib::generated::*;
|
use utralib::generated::*;
|
||||||
use xous::MessageEnvelope;
|
use xous::MessageEnvelope;
|
||||||
use String;
|
|
||||||
|
|
||||||
/////////////////////////// Common items to all commands
|
/////////////////////////// Common items to all commands
|
||||||
pub trait ShellCmdApi<'a> {
|
pub trait ShellCmdApi<'a> {
|
||||||
|
|
@ -160,7 +160,7 @@ impl CmdEnv {
|
||||||
|
|
||||||
let mut cmd_ret: Result<Option<String>, xous::Error> = Ok(None);
|
let mut cmd_ret: Result<Option<String>, xous::Error> = Ok(None);
|
||||||
if let Some(verb_string) = maybe_verb {
|
if let Some(verb_string) = maybe_verb {
|
||||||
let verb = verb_string.to_str();
|
let verb = &verb_string;
|
||||||
|
|
||||||
// search through the list of commands linearly until one matches,
|
// search through the list of commands linearly until one matches,
|
||||||
// then run it.
|
// then run it.
|
||||||
|
|
@ -168,7 +168,7 @@ impl CmdEnv {
|
||||||
for cmd in commands.iter_mut() {
|
for cmd in commands.iter_mut() {
|
||||||
if cmd.matches(verb) {
|
if cmd.matches(verb) {
|
||||||
match_found = true;
|
match_found = true;
|
||||||
cmd_ret = cmd.process(*cmdline, &mut self.common_env);
|
cmd_ret = cmd.process(cmdline.to_string(), &mut self.common_env);
|
||||||
self.lastverb.clear();
|
self.lastverb.clear();
|
||||||
write!(self.lastverb, "{}", verb).expect("SHCH: couldn't record last verb");
|
write!(self.lastverb, "{}", verb).expect("SHCH: couldn't record last verb");
|
||||||
};
|
};
|
||||||
|
|
@ -182,7 +182,7 @@ impl CmdEnv {
|
||||||
if !first {
|
if !first {
|
||||||
ret.push_str(", ");
|
ret.push_str(", ");
|
||||||
}
|
}
|
||||||
ret.append(cmd.verb())?;
|
ret.push_str(cmd.verb());
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
Ok(Some(ret))
|
Ok(Some(ret))
|
||||||
|
|
@ -196,8 +196,8 @@ impl CmdEnv {
|
||||||
let mut cmd_ret: Result<Option<String>, xous::Error> = Ok(None);
|
let mut cmd_ret: Result<Option<String>, xous::Error> = Ok(None);
|
||||||
// first check and see if we have a callback registration; if not, just map to the last verb
|
// first check and see if we have a callback registration; if not, just map to the last verb
|
||||||
let verb = match self.common_env.cb_registrations.get(&(callback.body.id() as u32)) {
|
let verb = match self.common_env.cb_registrations.get(&(callback.body.id() as u32)) {
|
||||||
Some(verb) => verb.to_str(),
|
Some(verb) => &verb,
|
||||||
None => self.lastverb.to_str(),
|
None => &self.lastverb,
|
||||||
};
|
};
|
||||||
// now dispatch
|
// now dispatch
|
||||||
let mut verbfound = false;
|
let mut verbfound = false;
|
||||||
|
|
@ -228,13 +228,13 @@ pub fn tokenize(line: &mut String) -> Option<String> {
|
||||||
let mut foundrest = false;
|
let mut foundrest = false;
|
||||||
for ch in lineiter {
|
for ch in lineiter {
|
||||||
if ch != ' ' && !foundspace {
|
if ch != ' ' && !foundspace {
|
||||||
token.push(ch).unwrap();
|
token.push(ch);
|
||||||
} else if foundspace && foundrest {
|
} else if foundspace && foundrest {
|
||||||
retline.push(ch).unwrap();
|
retline.push(ch);
|
||||||
} else if foundspace && ch != ' ' {
|
} else if foundspace && ch != ' ' {
|
||||||
// handle case of multiple spaces in a row
|
// handle case of multiple spaces in a row
|
||||||
foundrest = true;
|
foundrest = true;
|
||||||
retline.push(ch).unwrap();
|
retline.push(ch);
|
||||||
} else {
|
} else {
|
||||||
foundspace = true;
|
foundspace = true;
|
||||||
// consume the space
|
// consume the space
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
use String;
|
||||||
use modals::Modals;
|
use modals::Modals;
|
||||||
use utra::mailbox;
|
use utra::mailbox;
|
||||||
use utralib::generated::*;
|
use utralib::generated::*;
|
||||||
use String;
|
|
||||||
|
|
||||||
use crate::{CommonEnv, ShellCmdApi};
|
use crate::{CommonEnv, ShellCmdApi};
|
||||||
|
|
||||||
|
|
@ -181,7 +181,7 @@ impl<'a> ShellCmdApi<'a> for Mbox {
|
||||||
let mut ret = String::new();
|
let mut ret = String::new();
|
||||||
let helpstring = "mbox [knock]";
|
let helpstring = "mbox [knock]";
|
||||||
|
|
||||||
let mut tokens = &args.split(' ');
|
let mut tokens = args.split(' ');
|
||||||
|
|
||||||
if let Some(sub_cmd) = tokens.next() {
|
if let Some(sub_cmd) = tokens.next() {
|
||||||
match sub_cmd {
|
match sub_cmd {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ impl<'a> ShellCmdApi<'a> for Test {
|
||||||
let mut ret = String::new();
|
let mut ret = String::new();
|
||||||
let helpstring = "Test commands. See code for options.";
|
let helpstring = "Test commands. See code for options.";
|
||||||
|
|
||||||
let mut tokens = &args.split(' ');
|
let mut tokens = args.split(' ');
|
||||||
|
|
||||||
if let Some(sub_cmd) = tokens.next() {
|
if let Some(sub_cmd) = tokens.next() {
|
||||||
match sub_cmd {
|
match sub_cmd {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ impl<'a> ShellCmdApi<'a> for TrngCmd {
|
||||||
let mut ret = String::new();
|
let mut ret = String::new();
|
||||||
let helpstring = "trng [pump]";
|
let helpstring = "trng [pump]";
|
||||||
|
|
||||||
let mut tokens = &args.split(' ');
|
let mut tokens = args.split(' ');
|
||||||
|
|
||||||
if let Some(sub_cmd) = tokens.next() {
|
if let Some(sub_cmd) = tokens.next() {
|
||||||
match sub_cmd {
|
match sub_cmd {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ impl<'a> ShellCmdApi<'a> for Usb {
|
||||||
#[cfg(feature = "mass-storage")]
|
#[cfg(feature = "mass-storage")]
|
||||||
let helpstring = "usb [hid] [fido] [ms] [debug] [send <string>] [status] [leds] [lock] [unlock] [kbdtest] [console] [noconsole]";
|
let helpstring = "usb [hid] [fido] [ms] [debug] [send <string>] [status] [leds] [lock] [unlock] [kbdtest] [console] [noconsole]";
|
||||||
|
|
||||||
let mut tokens = &args.split(' ');
|
let mut tokens = args.split(' ');
|
||||||
|
|
||||||
if let Some(sub_cmd) = tokens.next() {
|
if let Some(sub_cmd) = tokens.next() {
|
||||||
match sub_cmd {
|
match sub_cmd {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ impl<'a> ShellCmdApi<'a> for Ver {
|
||||||
let mut ret = String::new();
|
let mut ret = String::new();
|
||||||
let helpstring = "ver [xous]";
|
let helpstring = "ver [xous]";
|
||||||
|
|
||||||
let mut tokens = &args.split(' ');
|
let mut tokens = args.split(' ');
|
||||||
|
|
||||||
if let Some(sub_cmd) = tokens.next() {
|
if let Some(sub_cmd) = tokens.next() {
|
||||||
match sub_cmd {
|
match sub_cmd {
|
||||||
|
|
|
||||||
|
|
@ -122,11 +122,9 @@ impl Repl {
|
||||||
|
|
||||||
let mut dirty = true;
|
let mut dirty = true;
|
||||||
// take the input and pass it on to the various command parsers, and attach result
|
// take the input and pass it on to the various command parsers, and attach result
|
||||||
if let Some(local) = &self.input {
|
if let Some(local) = &mut self.input {
|
||||||
log::trace!("processing line: {}", local);
|
log::trace!("processing line: {}", local);
|
||||||
if let Some(res) =
|
if let Some(res) = self.env.dispatch(Some(local), None).expect("command dispatch failed") {
|
||||||
self.env.dispatch(Some(&mut String::from(&local)), None).expect("command dispatch failed")
|
|
||||||
{
|
|
||||||
let output_history = History { text: String::from(res.as_str()), is_input: false };
|
let output_history = History { text: String::from(res.as_str()), is_input: false };
|
||||||
self.circular_push(output_history);
|
self.circular_push(output_history);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ pub(crate) enum KeyboardOpcode {
|
||||||
// this structure is used to register a keyboard listener. Currently, we only accept
|
// this structure is used to register a keyboard listener. Currently, we only accept
|
||||||
// one trusted listener (enforced by name server and structurally in the code),
|
// one trusted listener (enforced by name server and structurally in the code),
|
||||||
// which is the GAM.
|
// which is the GAM.
|
||||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Clone)]
|
||||||
pub(crate) struct KeyboardRegistration {
|
pub(crate) struct KeyboardRegistration {
|
||||||
pub server_name: String,
|
pub server_name: String,
|
||||||
pub listener_op_id: usize,
|
pub listener_op_id: usize,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
use xous::{msg_blocking_scalar_unpack, msg_scalar_unpack, MessageSender, CID};
|
use xous::{CID, MessageSender, msg_blocking_scalar_unpack, msg_scalar_unpack};
|
||||||
use xous_ipc::Buffer;
|
use xous_ipc::Buffer;
|
||||||
|
|
||||||
use crate::api;
|
use crate::api;
|
||||||
|
|
@ -65,7 +65,7 @@ fn keyboard_service() {
|
||||||
match xns.request_connection_blocking(kr.server_name.as_str()) {
|
match xns.request_connection_blocking(kr.server_name.as_str()) {
|
||||||
Ok(cid) => {
|
Ok(cid) => {
|
||||||
listener_conn = Some(cid);
|
listener_conn = Some(cid);
|
||||||
listener_op = Some(kr.listener_op_id as usize);
|
listener_op = Some(<u32 as From<u32>>::from(kr.listener_op_id.into()) as usize);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("couldn't connect to listener: {:?}", e);
|
log::error!("couldn't connect to listener: {:?}", e);
|
||||||
|
|
@ -81,7 +81,7 @@ fn keyboard_service() {
|
||||||
match xns.request_connection_blocking(kr.server_name.as_str()) {
|
match xns.request_connection_blocking(kr.server_name.as_str()) {
|
||||||
Ok(cid) => {
|
Ok(cid) => {
|
||||||
observer_conn = Some(cid);
|
observer_conn = Some(cid);
|
||||||
observer_op = Some(kr.listener_op_id as usize);
|
observer_op = Some(<u32 as From<u32>>::from(kr.listener_op_id.into()) as usize);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("couldn't connect to observer: {:?}", e);
|
log::error!("couldn't connect to observer: {:?}", e);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue