refactor of COM

this was much harder than I liked.
This commit is contained in:
bunnie 2021-04-02 05:43:47 +08:00
parent 5a6ce66d7e
commit d21c0fa3e7
7 changed files with 251 additions and 228 deletions

2
Cargo.lock generated
View file

@ -241,6 +241,8 @@ dependencies = [
"heapless", "heapless",
"log", "log",
"log-server", "log-server",
"num-derive",
"num-traits",
"rkyv 0.4.3", "rkyv 0.4.3",
"ticktimer-server", "ticktimer-server",
"typenum", "typenum",

View file

@ -9,17 +9,15 @@ version = "0.1.0"
com_rs-ref = {path = "../../imports/com_rs-ref"} com_rs-ref = {path = "../../imports/com_rs-ref"}
heapless = "0.5" heapless = "0.5"
log = "0.4" log = "0.4"
num-derive = {version = "0.3", default-features = false}
num-traits = {version = "0.2", default-features = false}
log-server = {path = "../log-server"} log-server = {path = "../log-server"}
ticktimer-server = {path = "../ticktimer-server"} ticktimer-server = {path = "../ticktimer-server"}
typenum = "1.12" typenum = "1.12"
xous = {path = "../../xous-rs"} xous = {path = "../../xous-rs"}
xous-ipc = {path = "../../xous-ipc"} xous-ipc = {path = "../../xous-ipc"}
xous-names = {path = "../xous-names"} xous-names = {path = "../xous-names"}
rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]}
[dependencies.rkyv]
default-features = false
features = ["const_generics"]
version = "0.4.1"
[target.'cfg(not(any(windows,unix)))'.dependencies] [target.'cfg(not(any(windows,unix)))'.dependencies]
utralib = {path = "../../utralib"} utralib = {path = "../../utralib"}

View file

@ -7,6 +7,8 @@ use xous_ipc::String;
use com_rs::*; use com_rs::*;
use com_rs_ref as com_rs; use com_rs_ref as com_rs;
pub(crate) const SERVER_NAME_COM: &str = "_COM manager_";
#[derive(Debug, Default, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] #[derive(Debug, Default, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
pub struct BattStats { pub struct BattStats {
/// instantaneous voltage in mV /// instantaneous voltage in mV
@ -40,55 +42,52 @@ impl Into<[usize; 2]> for BattStats {
} }
} }
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] #[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
pub enum Opcode { pub(crate) enum Opcode {
/// Battery stats /// Battery stats
BattStats, BattStats,
/// Battery stats, non-blocking /// Battery stats, non-blocking
BattStatsNb, BattStatsNb,
/// Battery stats return
BattStatsEvent(BattStats),
/// Query Full charge capacity of the battery /// Query Full charge capacity of the battery
BattFullCapacity, //BattFullCapacity,
/// Turn Boost Mode On /// Turn Boost Mode On
BoostOn, //BoostOn,
/// Turn Boost Mode Off /// Turn Boost Mode Off
BoostOff, //BoostOff,
/// Read the current accelerations off the IMU /// Read the current accelerations off the IMU
ImuAccelRead, //ImuAccelRead,
/// Power off the SoC /// Power off the SoC
PowerOffSoc, PowerOffSoc,
/// Ship mode (battery disconnect) /// Ship mode (battery disconnect)
ShipMode, //ShipMode,
/// Is the battery charging? /// Is the battery charging?
IsCharging, //IsCharging,
/// Set the backlight brightness /// Set the backlight brightness
SetBackLight, //SetBackLight,
/// Request charging /// Request charging
RequestCharging, //RequestCharging,
/// Erase a region of EC FLASH /// Erase a region of EC FLASH
FlashErase, //FlashErase,
/// Program a page of FLASH /// Program a page of FLASH
//FlashProgram(&'a [u8]), //FlashProgram(&'a [u8]),
/// Update the SSID list /// Update the SSID list
SsidScan, //SsidScan,
/// Return the latest SSID list /// Return the latest SSID list
SsidFetch, //SsidFetch,
/// Fetch the git ID of the EC /// Fetch the git ID of the EC
EcGitRev, EcGitRev,
@ -97,15 +96,20 @@ pub enum Opcode {
Wf200Rev, Wf200Rev,
/// Send a line of PDS data /// Send a line of PDS data
Wf200PdsLine(String<512>), Wf200PdsLine, //String<512>
/// Send Rx stats to fcc-agent
RxStatsAgent,
/// request for a listener to BattStats events /// request for a listener to BattStats events
RegisterBattStatsListener(String<64>), RegisterBattStatsListener, //String<64>
} }
/// These enums indicate what kind of callback type we're sending.
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
pub(crate) enum CallbackType {
/// Battery status
BattStats,
}
/*
impl core::convert::TryFrom<&Message> for Opcode { impl core::convert::TryFrom<&Message> for Opcode {
type Error = &'static str; type Error = &'static str;
fn try_from(message: &Message) -> Result<Self, Self::Error> { fn try_from(message: &Message) -> Result<Self, Self::Error> {
@ -144,7 +148,7 @@ impl core::convert::TryFrom<&Message> for Opcode {
} }
} }
_ => Err("unhandled message type"), _ => Err("unhandled message type"),
} }let registration_name = buffer.as_flat::<
} }
} }
@ -236,3 +240,4 @@ impl Into<Message> for Opcode {
} }
} }
} }
*/

View file

@ -7,85 +7,124 @@ use core::convert::TryInto;
pub mod api; pub mod api;
use api::BattStats; use api::BattStats;
use xous::{send_message, Error, CID}; use api::Opcode;
use xous_ipc::String; use xous::{send_message, Error, CID, Message};
use xous_ipc::{String, Buffer};
use num_traits::{ToPrimitive, FromPrimitive};
pub fn power_off_soc(cid: CID) -> Result<(), xous::Error> { /// mapping of the callback function to the library user
send_message(cid, api::Opcode::PowerOffSoc.into()).map(|_| ()) /// this exists in the library user's memory space, so we can have up to one
} /// callback per library user.
static mut BATTSTATS_CB: Option<fn(BattStats)> = None;
pub fn get_batt_stats(cid: CID) -> Result<BattStats, xous::Error> { /// handles callback messages from the COM server, in the library user's process space.
let response = send_message(cid, api::Opcode::BattStats.into())?; fn battstats_server(sid0: usize, sid1: usize, sid2: usize, sid3: usize) {
if let xous::Result::Scalar2(upper, lower) = response { let sid = xous::SID::from_u32(sid0 as u32, sid1 as u32, sid2 as u32, sid3 as u32);
let raw_stats: [usize; 2] = [lower, upper]; loop {
Ok(raw_stats.into()) let msg = xous::receive_message(sid).unwrap();
} else { match FromPrimitive::from_usize(msg.body.id()) {
panic!("unexpected return value: {:#?}", response); Some(api::CallbackType::BattStats) => {
} if let xous::Message::Scalar(xous::ScalarMessage {
} id: _, arg1: lo, arg2: hi, arg3: _, arg4: _
}) = msg.body {
pub fn get_batt_stats_nb(cid: CID) -> Result<(), xous::Error> { let bs: BattStats = [lo, hi].into();
send_message(cid, api::Opcode::BattStatsNb.into()).map(|_| ()) unsafe {
} if let Some(cb) = BATTSTATS_CB {
cb(bs)
pub fn get_wf200_fw_rev(cid: CID) -> Result<(u8, u8, u8), xous::Error> { }
let response = send_message(cid, api::Opcode::Wf200Rev.into())?; }
if let xous::Result::Scalar1(rev) = response { }
Ok(((rev >> 16) as u8, (rev >> 8) as u8, rev as u8)) }
} else { _ => (),
panic!("unexpected return value: {:#?}", response);
}
}
pub fn get_ec_git_rev(cid: CID) -> Result<(u32, bool), Error> {
let response = send_message(cid, api::Opcode::EcGitRev.into())?;
if let xous::Result::Scalar2(rev, dirty) = response {
let dirtybool: bool;
if dirty == 0 {
dirtybool = false;
} else {
dirtybool = true;
} }
Ok((rev as u32, dirtybool))
} else {
panic!("unexpected return value: {:#?}", response);
} }
} }
pub fn send_pds_line(cid: CID, s: &String<512>) -> Result<(), Error> { pub struct Com {
use core::fmt::Write; conn: CID,
let mut clone_s: String<512> = String::new(); battstats_sid: Option<xous::SID>,
write!(clone_s, "{}", s.as_str().unwrap()).map_err(|_| xous::Error::AccessDenied)?;
let request = api::Opcode::Wf200PdsLine(clone_s);
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
let pos = {
use rkyv::ser::Serializer;
writer.serialize_value(&request).expect("COM: couldn't archive PDS line request")
};
let xous_buffer = writer.into_inner();
xous_buffer.lend(cid, pos as u32).expect("COM: PDS line request failure");
Ok(())
} }
impl Com {
pub fn new(xns: xous_names::XousNames) -> Result<Self, xous::Error> {
let conn = xns.request_connection_blocking(api::SERVER_NAME_COM).expect("Can't connect to TRNG server");
Ok(Com {
conn,
battstats_sid: None,
})
}
pub fn get_rx_stats_agent(cid: CID) -> Result<(), Error> { pub fn power_off_soc(&self) -> Result<(), xous::Error> {
send_message(cid, api::Opcode::RxStatsAgent.into()).map(|_| ()) send_message(self.conn,
Message::new_scalar(Opcode::PowerOffSoc.to_usize().unwrap(), 0, 0, 0, 0)
).map(|_| ())
}
pub fn hook_batt_stats(&mut self, cb: fn(BattStats)) -> Result<(), xous::Error> {
if unsafe{BATTSTATS_CB}.is_some() {
return Err(xous::Error::MemoryInUse)
}
unsafe{BATTSTATS_CB = Some(cb)};
if self.battstats_sid.is_none() {
let sid = xous::create_server().unwrap();
self.battstats_sid = Some(sid);
let sid_tuple = sid.to_u32();
xous::create_thread_4(battstats_server, sid_tuple.0 as usize, sid_tuple.1 as usize, sid_tuple.2 as usize, sid_tuple.3 as usize).unwrap();
xous::send_message(self.conn,
Message::new_scalar(Opcode::RegisterBattStatsListener.to_usize().unwrap(),
sid_tuple.0 as usize, sid_tuple.1 as usize, sid_tuple.2 as usize, sid_tuple.3 as usize
)).unwrap();
}
Ok(())
}
pub fn get_batt_stats_nb(&self) -> Result<(), xous::Error> {
send_message(self.conn, Message::new_scalar(Opcode::BattStatsNb.to_usize().unwrap(), 0, 0, 0, 0,)).map(|_| ())
}
pub fn get_wf200_fw_rev(&self) -> Result<(u8, u8, u8), xous::Error> {
let response = send_message(self.conn,
Message::new_blocking_scalar(Opcode::Wf200Rev.to_usize().unwrap(), 0, 0, 0, 0))?;
if let xous::Result::Scalar1(rev) = response {
Ok(((rev >> 16) as u8, (rev >> 8) as u8, rev as u8))
} else {
panic!("unexpected return value: {:#?}", response);
}
}
pub fn get_ec_git_rev(&self) -> Result<(u32, bool), Error> {
let response = send_message(self.conn,
Message::new_blocking_scalar(Opcode::EcGitRev.to_usize().unwrap(), 0, 0, 0, 0))?;
if let xous::Result::Scalar2(rev, dirty) = response {
let dirtybool: bool;
if dirty == 0 {
dirtybool = false;
} else {
dirtybool = true;
}
Ok((rev as u32, dirtybool))
} else {
panic!("unexpected return value: {:#?}", response);
}
}
pub fn send_pds_line(&self, s: &String<512>) -> Result<(), Error> {
use core::fmt::Write;
let mut clone_s: String<512> = String::new();
write!(clone_s, "{}", s.as_str().unwrap()).map_err(|_| xous::Error::AccessDenied)?;
let buf = Buffer::into_buf(clone_s).or(Err(xous::Error::InternalError))?;
buf.lend(
self.conn,
Opcode::Wf200PdsLine.to_u32().unwrap()
).map(|_| ())
}
// event relay request API
pub fn request_battstat_events(&self, name: &str) -> Result<xous::Result, xous::Error> {
let s = String::<64>::from_str(name);
let buf = Buffer::into_buf(s).or(Err(xous::Error::InternalError))?;
buf.lend(self.conn, Opcode::RegisterBattStatsListener.to_u32().unwrap())
}
// note to future self: add other event listener registrations (such as network events) here
} }
// event relay request API
pub fn request_battstat_events(name: &str, com_conn: xous::CID) -> Result<xous::Result, xous::Error> {
let s = String::<64>::from_str(name);
let request = api::Opcode::RegisterBattStatsListener(s);
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
let pos = {
use rkyv::ser::Serializer;
writer.serialize_value(&request).expect("COM: couldn't archive battstat request")
};
let xous_buffer = writer.into_inner();
xous_buffer
.lend(com_conn, pos.try_into().unwrap())
}
// note to future self: add other event listener registrations (such as network events) here

View file

@ -5,13 +5,15 @@ mod api;
use api::Opcode; use api::Opcode;
use core::convert::TryFrom; use core::convert::TryFrom;
use num_traits::{ToPrimitive, FromPrimitive};
use log::{error, info}; use log::{error, info, trace};
use com_rs_ref as com_rs; use com_rs_ref as com_rs;
use com_rs::*; use com_rs::*;
use xous::CID; use xous::CID;
use xous_ipc::{Buffer, String};
const STD_TIMEOUT: u32 = 100; const STD_TIMEOUT: u32 = 100;
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
@ -21,7 +23,11 @@ pub struct WorkRequest {
} }
fn return_battstats(cid: CID, stats: api::BattStats) -> Result<(), xous::Error> { fn return_battstats(cid: CID, stats: api::BattStats) -> Result<(), xous::Error> {
xous::send_message(cid, crate::api::Opcode::BattStatsEvent(stats).into()).map(|_| ()) let rawstats: [usize; 2] = stats.into();
xous::send_message(cid,
xous::Message::new_scalar(api::CallbackType::BattStats.to_usize().unwrap(),
rawstats[0], rawstats[1], 0, 0)
).map(|_| ())
} }
#[cfg(target_os = "none")] #[cfg(target_os = "none")]
@ -36,18 +42,13 @@ mod implementation {
use xous::CID; use xous::CID;
use heapless::Vec; use heapless::Vec;
use heapless::consts::*; use heapless::consts::U64;
/*
use typenum::{UInt, UTerm};
use typenum::bit::{B0, B1};
type U1280 = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>;
*/
const STD_TIMEOUT: u32 = 100; const STD_TIMEOUT: u32 = 100;
pub struct XousCom { pub struct XousCom {
csr: utralib::CSR<u32>, csr: utralib::CSR<u32>,
ticktimer: CID, ticktimer: ticktimer_server::Ticktimer,
pub workqueue: Vec<WorkRequest, U64>, pub workqueue: Vec<WorkRequest, U64>,
busy: bool, busy: bool,
} }
@ -73,7 +74,7 @@ mod implementation {
let mut xc = XousCom { let mut xc = XousCom {
csr: CSR::new(csr.as_mut_ptr() as *mut u32), csr: CSR::new(csr.as_mut_ptr() as *mut u32),
ticktimer: ticktimer_conn, ticktimer,
workqueue: Vec::new(), workqueue: Vec::new(),
busy: false, busy: false,
//tx_queue: Vec::new(), //tx_queue: Vec::new(),
@ -231,90 +232,88 @@ mod implementation {
#[xous::xous_main] #[xous::xous_main]
fn xmain() -> ! { fn xmain() -> ! {
use crate::implementation::XousCom; use crate::implementation::XousCom;
use heapless::Vec;
use heapless::consts::*;
use core::pin::Pin; use core::pin::Pin;
use xous::buffer; use xous::buffer;
use rkyv::archived_value_mut; use rkyv::archived_value_mut;
log_server::init_wait().unwrap(); log_server::init_wait().unwrap();
info!("COM: my PID is {}", xous::process::id()); info!("my PID is {}", xous::process::id());
let xns = xous_names::XousNames::new().unwrap(); let xns = xous_names::XousNames::new().unwrap();
let com_sid = xns.register_name(xous::names::SERVER_NAME_COM).expect("COM: can't register server"); let com_sid = xns.register_name(api::SERVER_NAME_COM).expect("can't register server");
info!("COM: registered with NS -- {:?}", com_sid); info!("registered with NS -- {:?}", com_sid);
/* // get rid of this feature for now, it doesn't work, we don't use it, and it potentially causes troubles
let agent_conn= if cfg!(feature = "fccagent") {
xns.request_connection_blocking(xous::names::SERVER_NAME_FCCAGENT).expect("FCCAGENT: can't connect to COM")
} else {
0 // bogus value
}; */
// Create a new com object // Create a new com object
let mut com = XousCom::new(); let mut com = XousCom::new();
// create a Vec to track return connections for battery stats // create an array to track return connections for battery stats
let mut battstats_conns: Vec<xous::CID, U64> = Vec::new(); let mut battstats_conns: [Option<xous::CID>; 32] = [None; 32];
// other future notification vectors shall go here // other future notification vectors shall go here
info!("COM: starting main loop"); info!("starting main loop");
loop { loop {
let envelope = xous::receive_message(com_sid).unwrap(); let msg = xous::receive_message(com_sid).unwrap();
// info!("COM: Message: {:?}", envelope); trace!("Message: {:?}", msg);
if let xous::Message::Borrow(m) = &envelope.body { match FromPrimitive::from_usize(msg.body.id()) {
let mut buf = unsafe { buffer::XousBuffer::from_memory_message(m) }; Some(Opcode::RegisterBattStatsListener) => {
let value = unsafe { if let xous::Message::Scalar(xous::ScalarMessage {
archived_value_mut::<api::Opcode>(Pin::new(buf.as_mut()), m.id as usize) id: _id, arg1: sid0, arg2: sid1, arg3: sid2, arg4: sid3
}; }) = msg.body {
match &*value { let sid = xous::SID::from_u32(sid0 as _, sid1 as _, sid2 as _, sid3 as _);
rkyv::Archived::<api::Opcode>::RegisterBattStatsListener(registration_name) => { let cid = Some(xous::connect(sid).unwrap());
let cid = xns.request_connection_blocking(registration_name.as_str()).expect("COM: can't connect to requested listener for reporting events"); let mut found = false;
battstats_conns.push(cid).expect("COM: probably ran out of slots for battstats event reporting"); for entry in battstats_conns.iter_mut() {
}, if *entry == None {
rkyv::Archived::<api::Opcode>::Wf200PdsLine(rkyv_l) => { *entry = cid;
let l = xous::String::<512>::from_str(rkyv_l.as_str()); found = true;
info!("COM: Wf200PdsLine got line {}", l); break;
let line = l.as_bytes();
let length = (l.len() + 0) as u16;
//info!("COM: 0x{:04x}", ComState::WFX_PDS_LINE_SET.verb);
com.txrx(ComState::WFX_PDS_LINE_SET.verb);
//info!("COM: 0x{:04x}", length);
com.txrx(length);
//for i in 0..(ComState::WFX_PDS_LINE_SET.w_words as usize - 1) {
for i in 0..128 {
let word: u16;
if (i * 2 + 1) == length as usize { // odd last element
word = line[i * 2] as u16;
} else if i * 2 < length as usize {
word = (line[i*2] as u16) | ((line[i*2+1] as u16) << 8);
} else {
word = 0;
} }
com.txrx(word); }
//info!("COM: 0x{:04x}", word); if !found {
error!("RegisterBattStatsListener ran out of space registering callback");
} }
} }
_ => panic!("Invalid memory message response -- corruption occurred"), }
}; Some(Opcode::Wf200PdsLine) => {
} else if let Ok(opcode) = Opcode::try_from(&envelope.body) { let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
// info!("COM: Opcode: {:?}", opcode); let l = buffer.to_original::<String::<512>, _>().unwrap();
match opcode { info!("Wf200PdsLine got line {}", l);
Opcode::PowerOffSoc => { let line = l.as_bytes();
info!("COM: power off called"); let length = (l.len() + 0) as u16;
com.txrx(ComState::POWER_OFF.verb); //info!("0x{:04x}", ComState::WFX_PDS_LINE_SET.verb);
com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)); // consume the obligatory return value, even if not used com.txrx(ComState::WFX_PDS_LINE_SET.verb);
//info!("0x{:04x}", length);
com.txrx(length);
//for i in 0..(ComState::WFX_PDS_LINE_SET.w_words as usize - 1) {
for i in 0..128 {
let word: u16;
if (i * 2 + 1) == length as usize { // odd last element
word = line[i * 2] as u16;
} else if i * 2 < length as usize {
word = (line[i*2] as u16) | ((line[i*2+1] as u16) << 8);
} else {
word = 0;
}
com.txrx(word);
//info!("0x{:04x}", word);
} }
Opcode::BattStats => { }
info!("COM: batt stats request received"); Some(Opcode::PowerOffSoc) => {
let stats = com.get_battstats(); info!("power off called");
let raw_stats: [usize; 2] = stats.into(); com.txrx(ComState::POWER_OFF.verb);
xous::return_scalar2(envelope.sender, raw_stats[1], raw_stats[0]) com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)); // consume the obligatory return value, even if not used
.expect("COM: couldn't return batt stats request"); }
info!("COM: done returning batt stats request"); Some(Opcode::BattStats) => {
} info!("batt stats request received");
Opcode::BattStatsNb => { let stats = com.get_battstats();
for &conn in battstats_conns.iter() { let raw_stats: [usize; 2] = stats.into();
xous::return_scalar2(msg.sender, raw_stats[1], raw_stats[0])
.expect("couldn't return batt stats request");
info!("done returning batt stats request");
}
Some(Opcode::BattStatsNb) => {
for &maybe_conn in battstats_conns.iter() {
if let Some(conn) = maybe_conn {
com.workqueue com.workqueue
.push(WorkRequest { .push(WorkRequest {
work: ComState::STAT, work: ComState::STAT,
@ -323,50 +322,31 @@ fn xmain() -> ! {
.unwrap(); .unwrap();
} }
} }
Opcode::Wf200Rev => {
com.txrx(ComState::WFX_FW_REV_GET.verb);
let major = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)) as u8;
let minor = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)) as u8;
let build = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)) as u8;
xous::return_scalar(
envelope.sender,
((major as usize) << 16) | ((minor as usize) << 8) | (build as usize)
)
.expect("COM: couldn't return WF200 firmware rev");
}
Opcode::EcGitRev => {
com.txrx(ComState::EC_GIT_REV.verb);
let rev_msb = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)) as u16;
let rev_lsb = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)) as u16;
let dirty = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)) as u8;
xous::return_scalar2(
envelope.sender,
((rev_msb as usize) << 16) | (rev_lsb as usize),
dirty as usize
)
.expect("COM: couldn't return WF200 firmware rev");
}
/* // excised because it doesn't work
Opcode::RxStatsAgent => {
if cfg!(feature = "fccagent") {
// note -- this code never worked, but wasn't needed. just hanging out as bread crumbs for future work in case this is needed.
let mut stats: [u8; (ComState::WFX_RXSTAT_GET.r_words*2) as usize] = [0; (ComState::WFX_RXSTAT_GET.r_words*2) as usize];
com.txrx(ComState::WFX_RXSTAT_GET.verb);
for i in 0..ComState::WFX_RXSTAT_GET.r_words as usize {
let data = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT));
stats[i*2] = data as u8;
stats[i*2+1] = (data >> 8) as u8;
}
// hard-coded from fccagent to break circular dependency of fcc agent on com on agent on com on...
let data = xous::carton::Carton::from_bytes(&stats);
let m = xous::Message::Borrow(data.into_message(2));
xous::send_message(agent_conn, m).expect("Can't send RxStat message to FCC agent!");
}
}*/
_ => error!("unknown opcode"),
} }
} else { Some(Opcode::Wf200Rev) => {
error!("couldn't convert opcode"); com.txrx(ComState::WFX_FW_REV_GET.verb);
let major = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)) as u8;
let minor = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)) as u8;
let build = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)) as u8;
xous::return_scalar(
msg.sender,
((major as usize) << 16) | ((minor as usize) << 8) | (build as usize)
)
.expect("couldn't return WF200 firmware rev");
}
Some(Opcode::EcGitRev) => {
com.txrx(ComState::EC_GIT_REV.verb);
let rev_msb = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)) as u16;
let rev_lsb = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)) as u16;
let dirty = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)) as u8;
xous::return_scalar2(
msg.sender,
((rev_msb as usize) << 16) | (rev_lsb as usize),
dirty as usize
)
.expect("couldn't return WF200 firmware rev");
}
None => error!("unknown opcode"),
} }
com.process_queue(); com.process_queue();

View file

@ -5,7 +5,6 @@ A list of descriptions of servers ("names") that are used as keys by the xous-na
for the core set of kernel services. for the core set of kernel services.
*/ */
pub const SERVER_NAME_COM: &str = "_COM manager_";
pub const SERVER_NAME_LLIO: &str = "_Low Level I/O manager_"; pub const SERVER_NAME_LLIO: &str = "_Low Level I/O manager_";
pub const SERVER_NAME_SHELL: &str = "_Shell_"; pub const SERVER_NAME_SHELL: &str = "_Shell_";
pub const SERVER_NAME_GFX: &str = "_Graphics_"; pub const SERVER_NAME_GFX: &str = "_Graphics_";

View file

@ -37,20 +37,20 @@ fn main() {
fn try_main() -> Result<(), DynError> { fn try_main() -> Result<(), DynError> {
let hw_pkgs = [ let hw_pkgs = [
"gam", //"gam",
//"shell", //"shellchat",
"shellchat", //"ime-frontend",
"ime-frontend", //"ime-plugin-shell",
"ime-plugin-shell", //"graphics-server",
"graphics-server",
"ticktimer-server", "ticktimer-server",
"log-server", "log-server",
"com", "com",
"xous-names", "xous-names",
"keyboard", //"keyboard",
"trng", "trng",
"llio", "llio",
//"kernel-test", "rkyv-test-client",
"rkyv-test-server",
]; ];
let fcc_pkgs = [ let fcc_pkgs = [
"shell", "shell",