diff --git a/Cargo.lock b/Cargo.lock
index b3af5a88d..802b81e93 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -654,7 +654,7 @@ dependencies = [
"heapless",
"log",
"log-server",
- "rkyv 0.4.1",
+ "rkyv 0.3.1",
"ticktimer-server",
"utralib",
"xous",
@@ -1589,8 +1589,6 @@ version = "0.1.2"
dependencies = [
"bitflags",
"compiler_builtins",
- "hash32",
- "hash32-derive",
"hex",
"lazy_static",
"log",
diff --git a/emulation/renode.svd b/emulation/renode.svd
index 40cf6f1a9..3ae9e4c40 100644
--- a/emulation/renode.svd
+++ b/emulation/renode.svd
@@ -1328,10 +1328,10 @@ register to disable individual events.]]>
GIT_GITREV
0x0014
- 0xd77dca2f
+ 0x2a2abe5e
32
@@ -1348,7 +1348,7 @@ the exact git version used to build this firmware.]]>
is ``1``, then the repository this was built from has one additional commit
beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]>
0x0018
- 0x0d
+ 0x0e
32
@@ -1957,8 +1957,7 @@ upon the completion of one byte of data transfer.]]>
EV_STATUS
-
+
0x0018
0x00
32
@@ -1970,12 +1969,18 @@ Writes to this register have no effect.]]>
0
+
+ txrx_done
+ 1
+ [1:1]
+ 1
+
+
EV_PENDING
-
+
0x001c
0x00
32
@@ -1985,14 +1990,20 @@ register. To clear the Event, set the corresponding bit in this register.]]>0
[0:0]
0
-
+
+
+
+ txrx_done
+ 1
+ [1:1]
+ 1
+
EV_ENABLE
-
+
0x0020
0x00
32
@@ -2004,6 +2015,13 @@ register to disable individual events.]]>
0
+
+ txrx_done
+ 1
+ [1:1]
+ 1
+
+
@@ -3038,7 +3056,7 @@ again until the interrupt is serviced.]]>
SEED1
0x0000
- 0x48f7dee1
+ 0x1a7a2a66
32
@@ -3053,7 +3071,7 @@ again until the interrupt is serviced.]]>
SEED0
0x0004
- 0xc2db130
+ 0x4b326b1e
32
diff --git a/kernel/src/arch/hosted.rs b/kernel/src/arch/hosted.rs
index e5ace70ca..e6af71273 100644
--- a/kernel/src/arch/hosted.rs
+++ b/kernel/src/arch/hosted.rs
@@ -576,7 +576,12 @@ pub fn idle() -> bool {
crate::arch::process::set_current_pid(pid);
let mut process = Process::current();
- let mut response_vec = Vec::new();
+ let mut capacity = 9 * core::mem::size_of::();
+ if let Some(mem) = response.memory() {
+ capacity += mem.len();
+ }
+ let mut response_vec = Vec::with_capacity(capacity);
+
response_vec.extend_from_slice(&thread_id.to_le_bytes());
for word in response.to_args().iter_mut() {
response_vec.extend_from_slice(&word.to_le_bytes());
diff --git a/loader/src/main.rs b/loader/src/main.rs
index 6781e3c9e..8d8e3e058 100644
--- a/loader/src/main.rs
+++ b/loader/src/main.rs
@@ -21,6 +21,7 @@ const USER_AREA_END: usize = 0xff00_0000;
// and therefore are limited to 4 MB.
const EXCEPTION_STACK_TOP: usize = 0xffff_0000;
const KERNEL_LOAD_OFFSET: usize = 0xffd0_0000;
+const KERNEL_STACK_PAGE_COUNT: usize = 1;
const KERNEL_ARGUMENT_OFFSET: usize = 0xffc0_0000;
const FLG_VALID: usize = 0x1;
@@ -421,7 +422,7 @@ impl ProgramDescription {
allocator.change_owner(pid as XousPid, pt_addr as usize);
// Allocate stack pages.
- for i in 0..STACK_PAGE_COUNT {
+ for i in 0..if is_kernel { KERNEL_STACK_PAGE_COUNT} else { STACK_PAGE_COUNT } {
let sp_page = allocator.alloc() as usize;
allocator.map_page(
satp,
diff --git a/services/llio/Cargo.toml b/services/llio/Cargo.toml
index ccb520313..37aed0c2a 100644
--- a/services/llio/Cargo.toml
+++ b/services/llio/Cargo.toml
@@ -12,11 +12,7 @@ log-server = { path = "../log-server" }
ticktimer-server = { path = "../ticktimer-server" }
xous-names = { path = "../xous-names" }
log = "0.4"
-
-[dependencies.rkyv]
-version = "0.4.1"
-default-features = false
-features = ["const_generics"]
+rkyv = { version = "0.3.1", default_features = false }
[target.'cfg(not(any(windows,unix)))'.dependencies]
utralib = { path = "../../utralib"}
diff --git a/services/llio/src/api.rs b/services/llio/src/api.rs
index 4d95273c2..7658cdf63 100644
--- a/services/llio/src/api.rs
+++ b/services/llio/src/api.rs
@@ -44,7 +44,7 @@ impl Into for UartType {
/////////////////////// I2C
// a small book-keeping struct used to report back to I2C requestors as to the status of a transaction
-#[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
+#[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Eq, PartialEq)]
pub enum I2cStatus {
/// used only as the default, should always be set to one of the below before sending
Uninitialized,
@@ -67,15 +67,15 @@ pub enum I2cStatus {
}
#[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
pub struct I2cTransaction {
- bus_addr: u8,
+ pub bus_addr: u8,
// write address and read address are encoded in the packet field below
- txbuf: Option<[u8; 258]>, // up to 258 bytes total packet length; note cost is "same" b/c these are sent via 4kiB page remaps
- txlen: u32,
- rxbuf: Option<[u8; 258]>,
- rxlen: u32,
- timeout_ms: u32,
+ pub txbuf: Option<[u8; 31]>, // limited by trait types available in Rkyv
+ pub txlen: u32,
+ pub rxbuf: Option<[u8; 31]>,
+ pub rxlen: u32,
+ pub timeout_ms: u32,
// response field to the calling server
- status: I2cStatus,
+ pub status: I2cStatus,
}
impl I2cTransaction {
pub fn new() -> Self {
diff --git a/services/llio/src/i2c.rs b/services/llio/src/i2c.rs
new file mode 100644
index 000000000..cc7f5b332
--- /dev/null
+++ b/services/llio/src/i2c.rs
@@ -0,0 +1,233 @@
+use heapless::Vec;
+use heapless::consts::*;
+
+use llio::api::*;
+use llio::send_i2c_response;
+
+#[cfg(target_os = "none")]
+use utralib::*;
+
+#[derive(Eq, PartialEq)]
+enum I2cState {
+ Idle,
+ Write,
+ Read,
+}
+
+#[cfg(not(target_os = "none"))]
+pub struct I2cStateMachine {
+}
+#[cfg(not(target_os = "none"))]
+impl I2cStateMachine {
+ pub fn new(_ticktimer: xous::CID, _i2c_base: *mut u32) -> Self {
+ I2cStateMachine {}
+ }
+ pub fn initiate(&mut self, _transaction: I2cTransaction ) -> I2cStatus {
+ I2cStatus::ResponseInProgress
+ }
+ pub fn register_listener(&mut self, _listener: xous::CID) -> Result<(), xous::CID> {
+ Ok(())
+ }
+ pub fn handler(&mut self) {
+ }
+}
+#[cfg(target_os = "none")]
+pub struct I2cStateMachine {
+ transaction: I2cTransaction,
+ state: I2cState,
+ index: u32, // index of the current buffer in the state machine
+ timestamp: u64, // timestamp of the last transaction
+ ticktimer: xous::CID, // a connection to the ticktimer so we can measure timeouts
+ i2c_csr: utralib::CSR,
+ listeners: Vec,
+}
+#[cfg(target_os = "none")]
+impl I2cStateMachine {
+ pub fn new(ticktimer: xous::CID, i2c_base: *mut u32) -> Self {
+ I2cStateMachine {
+ transaction: I2cTransaction::new(),
+ state: I2cState::Idle,
+ timestamp: ticktimer_server::elapsed_ms(ticktimer).unwrap(),
+ ticktimer,
+ i2c_csr: CSR::new(i2c_base),
+ index: 0,
+ listeners: Vec::new(),
+ }
+ }
+ pub fn initiate(&mut self, transaction: I2cTransaction ) -> I2cStatus {
+ // sanity-check the bounds limits, currently imposed by trait implementations available in rkyv
+ if transaction.txlen > 31 || transaction.rxlen > 31 {
+ return I2cStatus::ResponseFormatError
+ }
+
+ let now = ticktimer_server::elapsed_ms(self.ticktimer).unwrap();
+ if self.state != I2cState::Idle && ((now - self.timestamp) < self.transaction.timeout_ms as u64) {
+ // we're in a transaction that hadn't timed out, can't accept a new one
+ I2cStatus::ResponseBusy
+ } else {
+ if self.state != I2cState::Idle {
+ // we're in a transaction, but previous transaction had timed out...
+ self.report_timeout();
+ // reset our state parameter
+ self.state = I2cState::Idle;
+ self.index = 0;
+ // now we're ready to move on and try a new transaction. We hope! Maybe the block should be reset?? TBD. Need to understand the nature of the timeouts better, if and when they do happen.
+ }
+ self.timestamp = now;
+ self.transaction = transaction.clone();
+
+ if self.transaction.status == I2cStatus::RequestIncoming {
+ self.transaction.status = I2cStatus::ResponseInProgress;
+ // now do the BusAddr stuff, so that the we can get the irq response
+ if let Some(_txbuf) = self.transaction.txbuf {
+ // initiate bus address with write bit set
+ self.state = I2cState::Write;
+ self.i2c_csr.wfo(utra::i2c::TXR_TXR, (self.transaction.bus_addr << 1 | 0) as u32);
+ self.index = 0;
+ self.i2c_csr.wo(utra::i2c::COMMAND,
+ self.i2c_csr.ms(utra::i2c::COMMAND_WR, 1) |
+ self.i2c_csr.ms(utra::i2c::COMMAND_STA, 1)
+ );
+ I2cStatus::ResponseInProgress
+ } else if let Some(_rxbuf) = self.transaction.rxbuf {
+ // initiate bus address with read bit set
+ self.state = I2cState::Read;
+ self.i2c_csr.wfo(utra::i2c::TXR_TXR, (self.transaction.bus_addr << 1 | 1) as u32);
+ self.index = 0;
+ self.i2c_csr.wo(utra::i2c::COMMAND,
+ self.i2c_csr.ms(utra::i2c::COMMAND_WR, 1) |
+ self.i2c_csr.ms(utra::i2c::COMMAND_STA, 1)
+ );
+ I2cStatus::ResponseInProgress
+ } else {
+ // no buffers specified, erase everything and go to idle
+ self.state = I2cState::Idle;
+ self.transaction = I2cTransaction::new();
+ I2cStatus::ResponseFormatError
+ }
+ } else {
+ I2cStatus::ResponseFormatError // the status field was not formatted correctly to accept the transaction
+ }
+ }
+ }
+ fn report_nack(&mut self) {
+ // report the NACK situation to all the listeners
+ let mut nack = I2cTransaction::new();
+ nack.status = I2cStatus::ResponseNack;
+ for &listener in self.listeners.iter() {
+ send_i2c_response(listener, nack).expect("LLIO|I2C: couldn't send NACK to listeners");
+ }
+ }
+ fn report_timeout(&mut self) {
+ let mut timeout = I2cTransaction::new();
+ timeout.status = I2cStatus::ResponseTimeout;
+ for &listener in self.listeners.iter() {
+ send_i2c_response(listener, timeout).expect("LLIO|I2c: couldn't send timeout error to liseners");
+ }
+ }
+ fn report_write_done(&mut self) {
+ // report the end of a write-only transaction to all the listeners
+ let mut ack = I2cTransaction::new();
+ ack.status = I2cStatus::ResponseWriteOk;
+ for &listener in self.listeners.iter() {
+ send_i2c_response(listener, ack).expect("LLIO|I2C: couldn't send write ACK to listeners");
+ }
+ }
+ fn report_read_done(&mut self) {
+ // report the result of a read transaction to all the listeners
+ self.transaction.status = I2cStatus::ResponseReadOk;
+ for &listener in self.listeners.iter() {
+ send_i2c_response(listener, self.transaction).expect("LLIO|I2C: couldn't send read response to listeners");
+ }
+ }
+ pub fn register_listener(&mut self, listener: xous::CID) -> Result<(), xous::CID> {
+ self.listeners.push(listener)
+ }
+ pub fn handler(&mut self) {
+ // check if the transaction had actually timed out
+ let now = ticktimer_server::elapsed_ms(self.ticktimer).unwrap();
+ if now - self.timestamp > self.transaction.timeout_ms as u64 {
+ // previous transaction had timed out...
+ self.report_timeout();
+ // reset our state parameter
+ self.state = I2cState::Idle;
+ self.index = 0;
+ self.timestamp = now;
+ return;
+ }
+ self.timestamp = now;
+
+ match self.state {
+ I2cState::Write => {
+ if let Some(txbuf) = self.transaction.txbuf {
+ // check ack bit
+ if self.i2c_csr.rf(utra::i2c::STATUS_RXACK) != 1 {
+ self.state = I2cState::Idle;
+ self.transaction = I2cTransaction::new();
+ self.report_nack();
+ }
+ // send next byte if there is one
+ if self.index < self.transaction.txlen {
+ self.i2c_csr.wfo(utra::i2c::TXR_TXR, txbuf[self.index as usize] as u32);
+ if self.index == (self.transaction.txlen - 1) && self.transaction.rxbuf.is_none() {
+ // send a stop bit if this is the very last in the series
+ self.i2c_csr.wo(utra::i2c::COMMAND,
+ self.i2c_csr.ms(utra::i2c::COMMAND_WR, 1) |
+ self.i2c_csr.ms(utra::i2c::COMMAND_STO, 1)
+ );
+ } else {
+ self.i2c_csr.wfo(utra::i2c::COMMAND_WR, 1);
+ }
+ self.index += 1;
+ } else {
+ if let Some(_rxbuf) = self.transaction.rxbuf {
+ // initiate bus address with read bit set
+ self.state = I2cState::Read;
+ self.i2c_csr.wfo(utra::i2c::TXR_TXR, (self.transaction.bus_addr << 1 | 1) as u32);
+ self.index = 0;
+ self.i2c_csr.wo(utra::i2c::COMMAND,
+ self.i2c_csr.ms(utra::i2c::COMMAND_WR, 1) |
+ self.i2c_csr.ms(utra::i2c::COMMAND_STA, 1)
+ );
+ } else {
+ self.report_write_done();
+ self.state = I2cState::Idle;
+ }
+ }
+ } else {
+ // we should never get here, because txbuf was checked as Some() by the setup routine
+ log::error!("LLIO|I2C: illegal write state");
+ }
+ },
+ I2cState::Read => {
+ if let Some(mut rxbuf) = self.transaction.rxbuf {
+ if self.index > 0 {
+ // we are re-entering from a previous call, store the read value from the previous call
+ rxbuf[self.index as usize - 1] = self.i2c_csr.rf(utra::i2c::RXR_RXR) as u8;
+ }
+ if self.index < self.transaction.rxlen {
+ if self.index == (self.transaction.rxlen - 1) {
+ self.i2c_csr.wo(utra::i2c::COMMAND,
+ self.i2c_csr.ms(utra::i2c::COMMAND_RD, 1) |
+ self.i2c_csr.ms(utra::i2c::COMMAND_STO, 1) |
+ self.i2c_csr.ms(utra::i2c::COMMAND_ACK, 1)
+ );
+ } else {
+ self.i2c_csr.wfo(utra::i2c::COMMAND_RD, 1);
+ }
+ self.index += 1;
+ } else {
+ self.report_read_done();
+ self.state = I2cState::Idle;
+ }
+ } else {
+ // we should never get here, because rxbuf was checked as Some() by the setup routine
+ log::error!("LLIO|I2C: illegal read state");
+ }
+ },
+ I2cState::Idle => {
+ log::error!("LLIO|I2C: received interrupt event when no transaciton pending!");
+ }
+ }
+ }
+}
diff --git a/services/llio/src/lib.rs b/services/llio/src/lib.rs
index bf018ddb6..3b225f223 100644
--- a/services/llio/src/lib.rs
+++ b/services/llio/src/lib.rs
@@ -34,9 +34,8 @@ pub fn send_i2c_request(cid: CID, transaction: I2cTransaction) -> Result(buf.as_ref(), pos)};
if let rkyv::Archived::::I2cTxRx(result) = returned {
- use core::ops::DerefMut;
- transaction.deref_mut() = result.as_slice();
- Ok(transaction.status)
+ let transaction = result.deserialise();
+ Ok(transaction.status())
} else {
log::info!("send_i2c_request saw an unhandled return type of {:?}", buf);
Err(xous::Error::InternalError)
diff --git a/services/llio/src/main.rs b/services/llio/src/main.rs
index 2f0e7c03e..9ec5206d2 100644
--- a/services/llio/src/main.rs
+++ b/services/llio/src/main.rs
@@ -2,22 +2,23 @@
#![cfg_attr(target_os = "none", no_main)]
mod api;
-use api::*;
+use llio::api::*;
mod i2c;
use i2c::*;
use core::convert::TryFrom;
+use core::pin::Pin;
+use rkyv::archived_value;
+use rkyv::Unarchive;
use log::{error, info};
#[cfg(target_os = "none")]
mod implementation {
- use crate::api::*;
+ use llio::api::*;
use log::{error, info};
use utralib::generated::*;
- const STD_TIMEOUT: u32 = 100;
-
pub struct Llio {
reboot_csr: utralib::CSR,
crg_csr: utralib::CSR,
@@ -25,7 +26,7 @@ mod implementation {
info_csr: utralib::CSR,
identifier_csr: utralib::CSR,
i2c_csr: utralib::CSR,
- handler_conn: xous::CID,
+ handler_conn: Option,
event_csr: utralib::CSR,
power_csr: utralib::CSR,
seed_csr: utralib::CSR,
@@ -49,8 +50,8 @@ mod implementation {
// ASSUME: we are only ever handling txrx done interrupts. If implementing ARB interrupts, this needs to be refactored to read the source and dispatch accordingly.
fn handle_i2c_irq(_irq_no: usize, arg: *mut usize) {
let xl = unsafe { &mut *(arg as *mut Llio) };
- if let Some(conn) = xl.i2c_conn {
- xous::try_send_message(xl.handler_conn, Opcode::IrqI2cTxrxDone.into()).map(|_| ()).unwrap();
+ if let Some(conn) = xl.handler_conn {
+ xous::try_send_message(conn, Opcode::IrqI2cTxrxDone.into()).map(|_| ()).unwrap();
} else {
log::error!("LLIO|handle_i2c_irq: TXRX done interrupt, but no connection for notification!");
}
@@ -59,7 +60,9 @@ mod implementation {
}
impl Llio {
- pub fn new(local_conn: xous::CID) -> Llio {
+ pub fn get_i2c_base(&self) -> *mut u32 { self.i2c_csr.base }
+
+ pub fn new(handler_conn: xous::CID) -> Llio {
let reboot_csr = xous::syscall::map_memory(
xous::MemoryAddress::new(utra::reboot::HW_REBOOT_BASE),
None,
@@ -102,7 +105,6 @@ mod implementation {
xous::MemoryFlags::R | xous::MemoryFlags::W,
)
.expect("couldn't map I2C CSR range");
- let i2c_sid = xous::create_server_id().expect("LLIO: couldn't get random server ID for I2C");
let event_csr = xous::syscall::map_memory(
xous::MemoryAddress::new(utra::btevents::HW_BTEVENTS_BASE),
None,
@@ -142,7 +144,7 @@ mod implementation {
info_csr: CSR::new(info_csr.as_mut_ptr() as *mut u32),
identifier_csr: CSR::new(identifier_csr.as_mut_ptr() as *mut u32),
i2c_csr: CSR::new(i2c_csr.as_mut_ptr() as *mut u32),
- handler_conn, // connection for messages from IRQ handler
+ handler_conn: Some(handler_conn), // connection for messages from IRQ handler
event_csr: CSR::new(event_csr.as_mut_ptr() as *mut u32),
power_csr: CSR::new(power_csr.as_mut_ptr() as *mut u32),
seed_csr: CSR::new(seed_csr.as_mut_ptr() as *mut u32),
@@ -176,8 +178,12 @@ mod implementation {
)
.expect("couldn't claim I2C irq");
- // initialize i2c
- i2c_init(&mut xl, utralib::LITEX_CONFIG_CLOCK_FREQUENCY);
+ // initialize i2c clocks
+ // set the prescale assuming 100MHz cpu operation: 100MHz / ( 5 * 100kHz ) - 1 = 199
+ let clkcode = (utralib::LITEX_CONFIG_CLOCK_FREQUENCY as u32) / (5 * 100_000) - 1;
+ xl.i2c_csr.wfo(utra::i2c::PRESCALE_PRESCALE, clkcode & 0xFFFF);
+ // enable the block
+ xl.i2c_csr.rmwf(utra::i2c::CONTROL_EN, 1);
// clear any interrupts pending, just in case something went pear-shaped during initialization
xl.i2c_csr.wo(utra::i2c::EV_PENDING, xl.i2c_csr.r(utra::i2c::EV_PENDING));
// now enable interrupts
@@ -348,33 +354,24 @@ mod implementation {
pub fn xadc_gpio2(&self) -> u16 {
self.xadc_csr.rf(utra::trng::XADC_GPIO2_XADC_GPIO2) as u16
}
-
-
- fn i2c_init(&mut self, clock_hz: u32) {
- // set the prescale assuming 100MHz cpu operation: 100MHz / ( 5 * 100kHz ) - 1 = 199
- let clkcode: u32 = clock_hz / (5 * 100_000) - 1;
- self.i2c_csr.wfo(utra::i2c::PRESCALE_PRESCALE, clkcode & 0xFFFF);
-
- // enable the block
- self.i2c_csr.rmwf(utra::i2c::CONTROL_EN, 1);
- }
}
}
// a stub to try to avoid breaking hosted mode for as long as possible.
#[cfg(not(target_os = "none"))]
mod implementation {
- use crate::api::*;
+ use llio::api::*;
use log::{error, info};
pub struct Llio {
}
impl Llio {
- pub fn new() -> Llio {
+ pub fn new(_handler_conn: xous::CID) -> Llio {
Llio {
}
}
+ pub fn get_i2c_base(&self) -> *mut u32 { 0 as *mut u32 }
pub fn reboot(&self, _reboot_soc: bool) {}
pub fn set_reboot_vector(&self, _vector: u32) {}
@@ -435,8 +432,6 @@ mod implementation {
fn xmain() -> ! {
let debug1 = false;
use crate::implementation::Llio;
- //use heapless::Vec;
- //use heapless::consts::*;
log_server::init_wait().unwrap();
info!("LLIO: my PID is {}", xous::process::id());
@@ -452,7 +447,7 @@ fn xmain() -> ! {
let ticktimer_server_id = xous::SID::from_bytes(b"ticktimer-server").unwrap();
let ticktimer_conn = xous::connect(ticktimer_server_id).unwrap();
// create an i2c state machine handler
- let mut i2c_machine = I2cStateMachine::new(ticktimer_conn, llio.i2c_csr);
+ let mut i2c_machine = I2cStateMachine::new(ticktimer_conn, llio.get_i2c_base());
if debug1{info!("LLIO: starting main loop");}
let mut reboot_requested: bool = false;
@@ -590,7 +585,7 @@ fn xmain() -> ! {
},
Opcode::IrqI2cTxrxDone => {
// I2C state machine handler irq received
- ic2_machine.handler();
+ i2c_machine.handler();
},
_ => error!("LLIO: no handler for opcode"),
}
@@ -602,7 +597,7 @@ fn xmain() -> ! {
};
match &*value {
rkyv::Archived::::I2cTxRx(rkyv_i2c) => {
- let i2c_txrx: I2cTransaction = rkyv_i2c.deserialize();
+ let mut i2c_txrx: I2cTransaction = rkyv_i2c.deserialize();
let status = i2c_machine.initiate(i2c_txrx);
@@ -610,19 +605,20 @@ fn xmain() -> ! {
// pack our data back into the buffer to return
use rkyv::Write;
let mut writer = rkyv::ArchiveBuffer::new(buf);
- writer.archive(&api::Opcode::I2cTxRx(i2c_txrx)).expect("LLIO: couldn't re-archive return value to I2cTxRx");
+ writer.archive(&Opcode::I2cTxRx(i2c_txrx)).expect("LLIO: couldn't re-archive return value to I2cTxRx");
},
_ => panic!("LLIO: invalid MutableBorrow memory message")
};
} else if let xous::Message::Borrow(m) = &envelope.body {
- let buf = unsafe { buffer::XousBuffer::from_memory_message(m) };
+ let buf = unsafe { xous::XousBuffer::from_memory_message(m) };
let bytes = Pin::new(buf.as_ref());
let value = unsafe {
archived_value::(&bytes, m.id as usize)
};
match &*value {
rkyv::Archived::::I2cSubscribe(registration) => {
- let cid = xous_names::request_connection_blocking(registration.as_str()).expect("KBD: can't connect to requested listener for reporting events");
+ let reg: xous::String::<64> = registration.unarchive();
+ let cid = xous_names::request_connection_blocking(reg.to_str()).expect("KBD: can't connect to requested listener for reporting events");
i2c_machine.register_listener(cid).expect("LLIO: probably ran out of slots for I2C event reporting");
},
_ => panic!("LLIO: invalid Borrow memory message"),
diff --git a/services/shellchat/src/cmds.rs b/services/shellchat/src/cmds.rs
index 0f54633cc..b21da8449 100644
--- a/services/shellchat/src/cmds.rs
+++ b/services/shellchat/src/cmds.rs
@@ -1,15 +1,10 @@
-use xous::{String, MessageEnvelope};
+use xous::String;
use core::fmt::Write;
/////////////////////////// Common items to all commands
pub trait ShellCmdApi<'a> {
// user implemented:
// called to process the command with the remainder of the string attached
fn process(&mut self, args: String::<1024>, env: &mut CommonEnv) -> Result
+
+ txrx_done
+ 1
+ [1:1]
+ 1
+
+
EV_PENDING
-
+
0x001c
0x00
32
@@ -1985,14 +1990,20 @@ register. To clear the Event, set the corresponding bit in this register.]]>0
[0:0]
0
-
+
+
+
+ txrx_done
+ 1
+ [1:1]
+ 1
+
EV_ENABLE
-
+
0x0020
0x00
32
@@ -2004,6 +2015,13 @@ register to disable individual events.]]>
0
+
+ txrx_done
+ 1
+ [1:1]
+ 1
+
+
@@ -3038,7 +3056,7 @@ again until the interrupt is serviced.]]>
SEED1
0x0000
- 0x48f7dee1
+ 0x1a7a2a66
32
@@ -3053,7 +3071,7 @@ again until the interrupt is serviced.]]>
SEED0
0x0004
- 0xc2db130
+ 0x4b326b1e
32
diff --git a/xous-rs/Cargo.toml b/xous-rs/Cargo.toml
index 3885fcb49..7a4d907b3 100644
--- a/xous-rs/Cargo.toml
+++ b/xous-rs/Cargo.toml
@@ -13,9 +13,6 @@ log = { version = "0.4", optional = true }
core = { version = '1.0.0', optional = true, package = 'rustc-std-workspace-core' }
compiler_builtins = { version = '0.1.0', optional = true }
-# for allowing strings to be used as indexes in hash maps
-hash32 = "0.1.0"
-hash32-derive = "0.1.0"
# for sending strings
[dependencies.rkyv]
version = "0.4.1"
diff --git a/xous-rs/src/arch/hosted.rs b/xous-rs/src/arch/hosted.rs
index cf16139dc..aa172951c 100644
--- a/xous-rs/src/arch/hosted.rs
+++ b/xous-rs/src/arch/hosted.rs
@@ -665,7 +665,12 @@ fn _xous_syscall_to(
// );
// Send the packet to the server
- let mut pkt = vec![];
+ let mut capacity = 9 * core::mem::size_of::();
+ if let Some(mem) = call.memory() {
+ capacity += mem.len();
+ }
+
+ let mut pkt = Vec::with_capacity(capacity);
THREAD_ID.with(|tid| pkt.extend_from_slice(&tid.borrow().to_le_bytes()));
for word in &[nr, a1, a2, a3, a4, a5, a6, a7] {
pkt.extend_from_slice(&word.to_le_bytes());
diff --git a/xous-rs/src/string.rs b/xous-rs/src/string.rs
index 744858835..df95a0538 100644
--- a/xous-rs/src/string.rs
+++ b/xous-rs/src/string.rs
@@ -5,7 +5,6 @@ use rkyv::ser::Serializer;
use rkyv::archived_value;
use rkyv::ArchiveUnsized;
use rkyv::SerializeUnsized;
-use hash32::{Hash, Hasher};
#[derive(Copy, Clone)]
pub struct String {
@@ -276,17 +275,6 @@ impl rkyv::Serialize for S
}
}
-
-impl hash32::Hash for String {
- fn hash(&self, state: &mut H)
- where
- H: Hasher,
- {
- Hash::hash(&self.bytes[..self.len as usize], state);
- Hash::hash(&self.len, state)
- }
-}
-
impl PartialEq for String {
fn eq(&self, other: &Self) -> bool {
self.bytes[..self.len as usize] == other.bytes[..other.len as usize]