mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
com: don't use internal xous_names register api
This API is now private. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
8ba7496f64
commit
704c0f47bf
3 changed files with 17 additions and 13 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
use xous::{Message, ScalarMessage};
|
use xous::{Message, ScalarMessage, MemoryMessage};
|
||||||
|
|
||||||
// NOTE: the use of ComState "verbs" as commands is not meant as a 1:1 mapping of commands
|
// NOTE: the use of ComState "verbs" as commands is not meant as a 1:1 mapping of commands
|
||||||
// It's just a convenient abuse of already-defined constants. However, it's intended that
|
// It's just a convenient abuse of already-defined constants. However, it's intended that
|
||||||
|
|
@ -7,7 +7,8 @@ use com_rs_ref as com_rs;
|
||||||
use com_rs::*;
|
use com_rs::*;
|
||||||
|
|
||||||
// subtype constants for registering service listeners from the COM
|
// subtype constants for registering service listeners from the COM
|
||||||
pub const SUBTYPE_REGISTER_BATTSTATS_LISTENER: u16 = 0;
|
// pub const SUBTYPE_REGISTER_BATTSTATS_LISTENER: u16 = 0;
|
||||||
|
pub const REGISTER_BATTSTATS_LISTENER: u32 = 0x0022_0000;
|
||||||
|
|
||||||
#[derive(Debug, Default, Copy, Clone)]
|
#[derive(Debug, Default, Copy, Clone)]
|
||||||
pub struct BattStats {
|
pub struct BattStats {
|
||||||
|
|
@ -105,7 +106,7 @@ pub enum Opcode<'a> {
|
||||||
RxStatsAgent,
|
RxStatsAgent,
|
||||||
|
|
||||||
/// request for a listener to BattStats events
|
/// request for a listener to BattStats events
|
||||||
RegisterBattStatsListener(xous_names::api::Registration),
|
RegisterBattStatsListener(xous_names::api::XousServerName),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> core::convert::TryFrom<&'a Message> for Opcode<'a> {
|
impl<'a> core::convert::TryFrom<&'a Message> for Opcode<'a> {
|
||||||
|
|
@ -154,9 +155,9 @@ impl<'a> core::convert::TryFrom<&'a Message> for Opcode<'a> {
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
Ok(Opcode::Wf200PdsLine(core::str::from_utf8(s).unwrap()))
|
Ok(Opcode::Wf200PdsLine(core::str::from_utf8(s).unwrap()))
|
||||||
} else if xous_names::api::Registration::match_subtype(m.id, SUBTYPE_REGISTER_BATTSTATS_LISTENER) {
|
} else if m.id as u32 == REGISTER_BATTSTATS_LISTENER {
|
||||||
Ok(Opcode::RegisterBattStatsListener({
|
Ok(Opcode::RegisterBattStatsListener({
|
||||||
unsafe { *( (m.buf.as_mut_ptr()) as *mut xous_names::api::Registration) }
|
unsafe { *( (m.buf.as_mut_ptr()) as *mut xous_names::api::XousServerName) }
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
Err("COM: unknown borrow ID")
|
Err("COM: unknown borrow ID")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#![cfg_attr(target_os = "none", no_std)]
|
#![cfg_attr(target_os = "none", no_std)]
|
||||||
|
|
||||||
|
use core::convert::TryInto;
|
||||||
|
|
||||||
/// This is the API that other servers use to call the COM. Read this code as if you
|
/// This is the API that other servers use to call the COM. Read this code as if you
|
||||||
/// are calling these functions inside a different process.
|
/// are calling these functions inside a different process.
|
||||||
pub mod api;
|
pub mod api;
|
||||||
|
|
@ -63,7 +65,9 @@ pub fn get_rx_stats_agent(cid: CID) -> Result<(), Error> {
|
||||||
|
|
||||||
// event relay request API
|
// event relay request API
|
||||||
pub fn request_battstat_events(name: &str, com_conn: xous::CID) -> Result<xous::Result, xous::Error> {
|
pub fn request_battstat_events(name: &str, com_conn: xous::CID) -> Result<xous::Result, xous::Error> {
|
||||||
xous_names::request_core(name, com_conn, api::SUBTYPE_REGISTER_BATTSTATS_LISTENER)
|
let s: xous_names::api::XousServerName = name.try_into()?;
|
||||||
|
let sendable = xous::ipc::Sendable::new(s)?;
|
||||||
|
sendable.lend(com_conn, api::REGISTER_BATTSTATS_LISTENER)
|
||||||
}
|
}
|
||||||
|
|
||||||
// note to future self: add other event listener registrations (such as network events) here
|
// note to future self: add other event listener registrations (such as network events) here
|
||||||
|
|
|
||||||
|
|
@ -245,12 +245,11 @@ fn xmain() -> ! {
|
||||||
let com_sid = xous_names::register_name(xous::names::SERVER_NAME_COM).expect("COM: can't register server");
|
let com_sid = xous_names::register_name(xous::names::SERVER_NAME_COM).expect("COM: can't register server");
|
||||||
info!("COM: registered with NS -- {:?}", com_sid);
|
info!("COM: registered with NS -- {:?}", com_sid);
|
||||||
|
|
||||||
let agent_conn: usize;
|
let agent_conn= if cfg!(feature = "fccagent") {
|
||||||
if cfg!(feature = "fccagent") {
|
xous_names::request_connection_blocking(xous::names::SERVER_NAME_FCCAGENT).expect("FCCAGENT: can't connect to COM")
|
||||||
agent_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_FCCAGENT).expect("FCCAGENT: can't connect to COM");
|
|
||||||
} else {
|
} else {
|
||||||
agent_conn = 0; // bogus value
|
0 // bogus value
|
||||||
}
|
};
|
||||||
|
|
||||||
// Create a new com object
|
// Create a new com object
|
||||||
let mut com = XousCom::new();
|
let mut com = XousCom::new();
|
||||||
|
|
@ -351,7 +350,7 @@ fn xmain() -> ! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Opcode::RegisterBattStatsListener(registration) => {
|
Opcode::RegisterBattStatsListener(registration) => {
|
||||||
let cid = xous_names::request_connection_blocking(registration.name.to_str()).expect("COM: can't connect to requested listener for reporting events");
|
let cid = xous_names::request_connection_blocking(registration.to_str()).expect("COM: can't connect to requested listener for reporting events");
|
||||||
battstats_conns.push(cid).expect("COM: probably ran out of slots for battstats event reporting");
|
battstats_conns.push(cid).expect("COM: probably ran out of slots for battstats event reporting");
|
||||||
}
|
}
|
||||||
_ => error!("unknown opcode"),
|
_ => error!("unknown opcode"),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue