Merge remote-tracking branch 'betrusted/master' into bunnie-dev

This commit is contained in:
bunnie 2021-05-16 02:28:02 +08:00
commit d7b64972e9
6 changed files with 59 additions and 6 deletions

1
Cargo.lock generated
View file

@ -524,6 +524,7 @@ version = "0.1.0"
dependencies = [
"bitflags",
"blitstr-ref",
"chrono",
"com",
"content-plugin-api",
"graphics-server",

10
buildpush.bat Normal file
View file

@ -0,0 +1,10 @@
REM a crappy starter script to help with builds under Windows environments. ymmv.
cargo xtask hw-image precursors/soc.svd
CertUtil -hashfile precursors/soc_csr.bin MD5
CertUtil -hashfile target/riscv32imac-unknown-none-elf/release/loader.bin MD5
CertUtil -hashfile target/riscv32imac-unknown-none-elf/release/xous.img MD5
scp -i c:/users/bunnie/.ssh/id_pi target/riscv32imac-unknown-none-elf/release/xous.img target/riscv32imac-unknown-none-elf/release/loader.bin precursors/soc_csr.bin pi@10.0.245.90:code/precursors/
REM wishbone-tool --load-name target/riscv32imac-unknown-none-elf/release/xous.img --load-address 0x980000 --load-flash

View file

@ -30,6 +30,10 @@ rkyv = {version = "0.4.3", default-features = false, features = ["const_generics
[target.'cfg(not(any(windows,unix)))'.dependencies]
utralib = {path = "../../utralib"}
# short circuit the datetime call on hosted mode
[target.'cfg(any(windows,unix))'.dependencies]
chrono = "0.4"
[features]
debugprint = []
slowstatus = [] # used for braille mode, so console isn't overwhelmed with status

View file

@ -33,7 +33,7 @@ fn battstats_cb(stats: BattStats) {
}
pub fn dt_callback(dt: rtc::DateTime) {
//log::trace!("dt_callback received with {:?}", dt);
//log::info!("dt_callback received with {:?}", dt);
if let Some(cb_to_main_conn) = unsafe{CB_TO_MAIN_CONN} {
let buf = xous_ipc::Buffer::into_buf(dt).or(Err(xous::Error::InternalError)).unwrap();
buf.send(cb_to_main_conn, StatusOpcode::DateTime.to_u32().unwrap()).unwrap();
@ -158,7 +158,33 @@ pub fn status_thread(canvas_gid_0: usize, canvas_gid_1: usize, canvas_gid_2: usi
dt_pump_modulus += 1;
if dt_pump_modulus > 15 {
dt_pump_modulus = 0;
#[cfg(target_os = "none")]
rtc.request_datetime().expect("|status: can't request datetime from RTC");
#[cfg(not(target_os = "none"))]
{
log::trace!("hosted request of date time - short circuiting server call");
use chrono::prelude::*;
use rtc::Weekday;
let now = Local::now();
let wday: Weekday = match now.weekday() {
chrono::Weekday::Mon => Weekday::Monday,
chrono::Weekday::Tue => Weekday::Tuesday,
chrono::Weekday::Wed => Weekday::Wednesday,
chrono::Weekday::Thu => Weekday::Thursday,
chrono::Weekday::Fri => Weekday::Friday,
chrono::Weekday::Sat => Weekday::Saturday,
chrono::Weekday::Sun => Weekday::Sunday,
};
datetime = Some(rtc::DateTime {
seconds: now.second() as u8,
minutes: now.minute() as u8,
hours: now.hour() as u8,
months: now.month() as u8,
days: now.day() as u8,
years: (now.year() - 2000) as u8,
weekday: wday,
});
}
}
last_seconds = now_seconds;
uptime_tv.clear_str();
@ -192,7 +218,7 @@ pub fn status_thread(canvas_gid_0: usize, canvas_gid_1: usize, canvas_gid_2: usi
}
}
Some(StatusOpcode::DateTime) => {
//log::trace!("got DateTime update");
//log::info!("got DateTime update");
let buffer = unsafe { xous_ipc::Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
let dt = buffer.to_original::<rtc::DateTime, _>().unwrap();
datetime = Some(dt);

View file

@ -38,6 +38,12 @@ mod implementation {
xous::yield_slice();
}
}
pub fn hosted_delay(&self) {
// this is a delay used in hosted mode to prevent threads from thrashing. We don't need this on
// raw hardware because we aren't multi-core, and thus a yield_slice() will always schedule
// a different process to run, whereas a yield_slice() on hosted/emulation can immediately return
// and cause troubles for other processes.
}
}
}
@ -51,6 +57,9 @@ mod implementation {
pub fn deterministic_busy_wait(&self) {
// don't do anything for hosted mode
}
pub fn hosted_delay(&self) {
std::thread::sleep(std::time::Duration::from_millis(10));
}
}
}
@ -179,26 +188,27 @@ fn xmain() -> ! {
response = api::Return::CID(connection_id)
}
_ => {
info!(
log::debug!(
"Can't find request '{}' in table, dumping table:",
name
);
for kv_tuple in name_table.map.iter() {
if let Some((key, val)) = kv_tuple {
info!("name: '{}', sid: '{:?}'", key, val);
log::debug!("name: '{}', sid: '{:?}'", key, val);
}
}
d11ctimeout.hosted_delay();
response = api::Return::Failure
}
}
} else {
info!(
log::debug!(
"Can't find request '{}' in table, dumping table:",
name
);
for kv_tuple in name_table.map.iter() {
if let Some((key, val)) = kv_tuple {
info!("name: '{}', sid: '{:?}'", key, val);
log::debug!("name: '{}', sid: '{:?}'", key, val);
}
}
// no authenticate remedy currently supported, but we'd put that code somewhere around here eventually.
@ -208,6 +218,7 @@ fn xmain() -> ! {
pubkey_id: [0; 20], // placeholder
challenge: [c1, c2, c3, c4],
};
d11ctimeout.hosted_delay();
response = api::Return::AuthenticateRequest(auth_request) // this code just exists to exercise the return path
}
buffer.replace(response).expect("Lookup can't serialize return value");

View file

@ -63,6 +63,7 @@ fn try_main() -> Result<(), DynError> {
"keyboard",
"trng",
"susres",
"llio",
];
let minimal_pkgs = [
"ticktimer-server",