mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
add some version commands
This commit is contained in:
parent
308cda1af4
commit
f86f295fa5
3 changed files with 79 additions and 0 deletions
|
|
@ -305,6 +305,36 @@ impl Llio {
|
|||
Message::new_scalar(Opcode::PowerAudio.to_usize().unwrap(), arg, 0, 0, 0)
|
||||
).map(|_| ())
|
||||
}
|
||||
pub fn soc_gitrev(&self) -> Result<(u8, u8, u8, u8, u32), xous::Error> {
|
||||
let response = send_message(self.conn,
|
||||
Message::new_blocking_scalar(Opcode::InfoGit.to_usize().unwrap(), 0, 0, 0, 0))?;
|
||||
if let xous::Result::Scalar2(val1, val2) = response {
|
||||
Ok(
|
||||
(
|
||||
((val1 >> 24) as u8), // major
|
||||
((val1 >> 16) as u8), // minor
|
||||
((val1 >> 8) as u8), // rev
|
||||
(val1 >> 0) as u8, // gitextra
|
||||
val2 as u32 // gitrev
|
||||
)
|
||||
)
|
||||
} else {
|
||||
log::error!("LLIO: unexpected return value: {:#?}", response);
|
||||
Err(xous::Error::InternalError)
|
||||
}
|
||||
}
|
||||
pub fn soc_dna(&self) -> Result<u64, xous::Error> {
|
||||
let response = send_message(self.conn,
|
||||
Message::new_blocking_scalar(Opcode::InfoDna.to_usize().unwrap(), 0, 0, 0, 0))?;
|
||||
if let xous::Result::Scalar2(val1, val2) = response {
|
||||
Ok(
|
||||
(val1 as u64) | ((val2 as u64) << 32)
|
||||
)
|
||||
} else {
|
||||
log::error!("LLIO: unexpected return value: {:#?}", response);
|
||||
Err(xous::Error::InternalError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ mod callback; use callback::*;
|
|||
mod rtc_cmd; use rtc_cmd::*;
|
||||
mod vibe; use vibe::*;
|
||||
mod ssid; use ssid::*;
|
||||
mod ver; use ver::*;
|
||||
|
||||
mod fcc; use fcc::*;
|
||||
mod pds; // dependency of the FCC file
|
||||
|
|
@ -113,6 +114,7 @@ impl CmdEnv {
|
|||
let mut ret = String::<1024>::new();
|
||||
|
||||
let mut echo_cmd = Echo {}; // this command has no persistent storage, so we can "create" it every time we call dispatch (but it's a zero-cost absraction so this doesn't actually create any instructions)
|
||||
let mut ver_cmd = Ver{};
|
||||
let commands: &mut [& mut dyn ShellCmdApi] = &mut [
|
||||
///// 4. add your command to this array, so that it can be looked up and dispatched
|
||||
&mut echo_cmd,
|
||||
|
|
@ -123,6 +125,7 @@ impl CmdEnv {
|
|||
&mut self.rtc_cmd,
|
||||
&mut self.vibe_cmd,
|
||||
&mut self.ssid_cmd,
|
||||
&mut ver_cmd,
|
||||
|
||||
&mut self.fcc_cmd,
|
||||
];
|
||||
|
|
|
|||
46
services/shellchat/src/cmds/ver.rs
Normal file
46
services/shellchat/src/cmds/ver.rs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
use crate::{ShellCmdApi, CommonEnv};
|
||||
use xous_ipc::String;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Ver {
|
||||
}
|
||||
|
||||
impl<'a> ShellCmdApi<'a> for Ver {
|
||||
cmd_api!(ver); // inserts boilerplate for command API
|
||||
|
||||
fn process(&mut self, args: String::<1024>, env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> {
|
||||
use core::fmt::Write;
|
||||
let mut ret = String::<1024>::new();
|
||||
let helpstring = "ver options: ec, wf200, soc, dna";
|
||||
|
||||
let mut tokens = args.as_str().unwrap().split(' ');
|
||||
|
||||
if let Some(sub_cmd) = tokens.next() {
|
||||
match sub_cmd {
|
||||
"ec" => {
|
||||
let (rev, dirty) = env.com.get_ec_git_rev().unwrap();
|
||||
let dirtystr = if dirty { "dirty" } else { "clean" };
|
||||
write!(ret, "EC git commit: {:x}, {}", rev, dirtystr).unwrap();
|
||||
}
|
||||
"wf200" => {
|
||||
let (maj, min, rev) = env.com.get_wf200_fw_rev().unwrap();
|
||||
write!(ret, "Wf200 fw rev {}.{}.{}", maj, min, rev).unwrap();
|
||||
}
|
||||
"soc" => {
|
||||
let (maj, min, rev, extra, gitrev) = env.llio.soc_gitrev().unwrap();
|
||||
write!(ret, "SoC git rev {}.{}.{}+{}, commit {:x}", maj, min, rev, extra, gitrev).unwrap();
|
||||
}
|
||||
"dna" => {
|
||||
write!(ret, "SoC silicon DNA: 0x{:x}", env.llio.soc_dna().unwrap()).unwrap();
|
||||
}
|
||||
_ => {
|
||||
write!(ret, "{}", helpstring).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
write!(ret, "{}", helpstring).unwrap();
|
||||
}
|
||||
Ok(Some(ret))
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue