From 4f2506f00902eeddfc6a6538bc2a575cdd0c14c9 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 27 Sep 2022 17:50:32 +0800 Subject: [PATCH] some housekeeping; remove bit-rotted test targets these targets are so old they would need to be completely re-written to be relevant, so just cull them. --- Cargo.lock | 22 +-- services/benchmark-target/Cargo.toml | 26 --- services/benchmark-target/src/api.rs | 19 --- services/benchmark-target/src/lib.rs | 48 ------ services/benchmark-target/src/main.rs | 53 ------- services/benchmark/Cargo.toml | 29 ---- services/benchmark/src/main.rs | 213 ------------------------- services/rkyv-test-client/Cargo.toml | 22 --- services/rkyv-test-client/README.md | 5 - services/rkyv-test-client/build.rs | 17 -- services/rkyv-test-client/src/main.rs | 95 ----------- services/rkyv-test-server/Cargo.toml | 21 --- services/rkyv-test-server/README.md | 5 - services/rkyv-test-server/build.rs | 17 -- services/rkyv-test-server/src/api.rs | 70 -------- services/rkyv-test-server/src/lib.rs | 220 -------------------------- services/rkyv-test-server/src/main.rs | 182 --------------------- xtask/src/main.rs | 138 ++-------------- 18 files changed, 23 insertions(+), 1179 deletions(-) delete mode 100644 services/benchmark-target/Cargo.toml delete mode 100644 services/benchmark-target/src/api.rs delete mode 100644 services/benchmark-target/src/lib.rs delete mode 100644 services/benchmark-target/src/main.rs delete mode 100644 services/benchmark/Cargo.toml delete mode 100644 services/benchmark/src/main.rs delete mode 100644 services/rkyv-test-client/Cargo.toml delete mode 100644 services/rkyv-test-client/README.md delete mode 100644 services/rkyv-test-client/build.rs delete mode 100644 services/rkyv-test-client/src/main.rs delete mode 100644 services/rkyv-test-server/Cargo.toml delete mode 100644 services/rkyv-test-server/README.md delete mode 100644 services/rkyv-test-server/build.rs delete mode 100644 services/rkyv-test-server/src/api.rs delete mode 100644 services/rkyv-test-server/src/lib.rs delete mode 100644 services/rkyv-test-server/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 15d94b85e..83765e0c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -705,7 +705,7 @@ dependencies = [ "bare-metal 1.0.0", "cfg-if", "cortex-m", - "riscv 0.7.0", + "riscv", ] [[package]] @@ -3052,14 +3052,6 @@ dependencies = [ "xous-names", ] -[[package]] -name = "riscv" -version = "0.5.6" -dependencies = [ - "bare-metal 0.2.4", - "bit_field 0.9.0", -] - [[package]] name = "riscv" version = "0.7.0" @@ -4806,10 +4798,10 @@ dependencies = [ "lazy_static", "rand 0.7.3", "rand_chacha 0.3.1", - "riscv 0.5.6", "stats_alloc", "utralib 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "xous 0.9.9 (registry+https://github.com/rust-lang/crates.io-index)", + "xous-riscv", ] [[package]] @@ -4826,6 +4818,16 @@ dependencies = [ "xous-ipc 0.9.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "xous-riscv" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63ec51bd5669f944bc375cc2c8ba93e28d7e697d13605a3454c331ea5f0b461a" +dependencies = [ + "bare-metal 0.2.4", + "bit_field 0.9.0", +] + [[package]] name = "xous-semver" version = "0.1.2" diff --git a/services/benchmark-target/Cargo.toml b/services/benchmark-target/Cargo.toml deleted file mode 100644 index c7e110c29..000000000 --- a/services/benchmark-target/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "benchmark-target" -version = "0.1.0" -authors = ["bunnie "] -edition = "2018" -description = "Benchmark target for Xous" - -# Dependency versions enforced by Cargo.lock. -[dependencies] -xous = "0.9.9" -xous-names = { path = "../xous-names" } -log-server = { version = "0.1.2", package = "xous-api-log-server" } -log = "0.4.14" - -xous-ipc = "0.9.9" -num-derive = {version = "0.3.3", default-features = false} -num-traits = {version = "0.2.14", default-features = false} -rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]} - -[target.'cfg(not(any(windows,unix)))'.dependencies] -utralib = { path = "../../utralib", default-features = false } - -[features] -debugprint = [] -# default = ["debugprint"] # "debugprint" -default = [] diff --git a/services/benchmark-target/src/api.rs b/services/benchmark-target/src/api.rs deleted file mode 100644 index d133e84dc..000000000 --- a/services/benchmark-target/src/api.rs +++ /dev/null @@ -1,19 +0,0 @@ -#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] -pub struct TestStruct { - pub challenge: [u32; 8], -} -impl TestStruct { - pub fn new() -> Self { - TestStruct { challenge: [0; 8] } - } -} - -pub const SERVER_NAME_BENCHMARK: &str = "_Benchmark target_"; - -#[allow(dead_code)] -#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)] -pub enum Opcode { - TestScalar, //(u32), - TestMemory, //(TestStruct), - TestMemorySend, -} diff --git a/services/benchmark-target/src/lib.rs b/services/benchmark-target/src/lib.rs deleted file mode 100644 index 8ed546d97..000000000 --- a/services/benchmark-target/src/lib.rs +++ /dev/null @@ -1,48 +0,0 @@ -#![cfg_attr(target_os = "none", no_std)] - -pub mod api; -use api::*; - -use num_traits::ToPrimitive; -use xous::{send_message, CID}; -use xous_ipc::Buffer; - -pub fn test_scalar(cid: CID, testvar: u32) -> Result { - let response = send_message( - cid, - xous::Message::new_blocking_scalar( - Opcode::TestScalar.to_usize().unwrap(), - testvar as usize, - 0, - 0, - 0, - ), - )?; - if let xous::Result::Scalar1(r) = response { - Ok(r as u32) - } else { - panic!("unexpected return value: {:#?}", response); - } -} - -pub fn test_memory(cid: CID, testvar: u32) -> Result { - let mut reg = TestStruct::new(); - reg.challenge[0] = testvar; - - let mut buf = Buffer::into_buf(reg).or(Err(xous::Error::InternalError))?; - buf.lend_mut(cid, Opcode::TestMemory.to_u32().unwrap()) - .or(Err(xous::Error::InternalError))?; - - let result = buf.as_flat::().unwrap(); - Ok(result.challenge[0]) -} - -pub fn test_memory_send(cid: CID, testvar: u32) -> Result { - let mut reg = TestStruct::new(); - reg.challenge[0] = testvar; - - let mut buf = Buffer::into_buf(reg).or(Err(xous::Error::InternalError))?; - buf.send(cid, Opcode::TestMemorySend.to_u32().unwrap()) - .or(Err(xous::Error::InternalError))?; - Ok(testvar + 2) -} diff --git a/services/benchmark-target/src/main.rs b/services/benchmark-target/src/main.rs deleted file mode 100644 index 89347ed76..000000000 --- a/services/benchmark-target/src/main.rs +++ /dev/null @@ -1,53 +0,0 @@ -#![cfg_attr(target_os = "none", no_std)] -#![cfg_attr(target_os = "none", no_main)] - -mod api; -use api::*; -use xous::msg_blocking_scalar_unpack; - -use log::{error, info}; - -use num_traits::FromPrimitive; -use xous_ipc::Buffer; - -fn main() -> ! { - log_server::init_wait().unwrap(); - info!("BENCHTARGET: my PID is {}", xous::process::id()); - - let xns = xous_names::XousNames::new().unwrap(); - let bench_sid = xns - .register_name(api::SERVER_NAME_BENCHMARK, None) - .expect("BENCHTARGET: can't register server"); - info!("BENCHTARGET: registered with NS -- {:?}", bench_sid); - - let mut state: u32 = 0; - loop { - let mut envelope = xous::receive_message(bench_sid).unwrap(); - match FromPrimitive::from_usize(envelope.body.id()) { - Some(Opcode::TestScalar) => msg_blocking_scalar_unpack!(envelope, val, _, _, _, { - xous::return_scalar(envelope.sender, (val + 1) as usize) - .expect("BENCHTARGET: couldn't return TestScalar request"); - }), - Some(Opcode::TestMemory) => { - let mut buffer = unsafe { - Buffer::from_memory_message_mut(envelope.body.memory_message_mut().unwrap()) - }; - let reg = buffer.to_original::().unwrap(); - - let mut ret = TestStruct::new(); - ret.challenge[0] = reg.challenge[0] + 1; - buffer.replace(ret).unwrap(); - } - Some(Opcode::TestMemorySend) => { - let mut buffer = unsafe { - Buffer::from_memory_message_mut(envelope.body.memory_message_mut().unwrap()) - }; - let reg = buffer.to_original::().unwrap(); - state += reg.challenge[0]; - } - None => { - error!("BENCHTARGET: couldn't convert opcode"); - } - } - } -} diff --git a/services/benchmark/Cargo.toml b/services/benchmark/Cargo.toml deleted file mode 100644 index 31eb3bc4d..000000000 --- a/services/benchmark/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "benchmark" -version = "0.1.0" -authors = ["bunnie "] -edition = "2018" -description = "Benchmarks for Xous" - -# Dependency versions enforced by Cargo.lock. -[dependencies] -xous = "0.9.9" -graphics-server = { path = "../graphics-server" } -ticktimer-server = { path = "../ticktimer-server" } -xous-names = { path = "../xous-names" } -log-server = { version = "0.1.2", package = "xous-api-log-server" } -log = "0.4.14" -benchmark-target = { path = "../benchmark-target" } - -xous-ipc = "0.9.9" -num-derive = {version = "0.3.3", default-features = false} -num-traits = {version = "0.2.14", default-features = false} -rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]} - -[target.'cfg(not(any(windows,unix)))'.dependencies] -utralib = { path = "../../utralib", default-features = false } - -[features] -debugprint = [] -# default = ["debugprint"] # "debugprint" -default = [] diff --git a/services/benchmark/src/main.rs b/services/benchmark/src/main.rs deleted file mode 100644 index 804e78358..000000000 --- a/services/benchmark/src/main.rs +++ /dev/null @@ -1,213 +0,0 @@ -#![cfg_attr(target_os = "none", no_std)] -#![cfg_attr(target_os = "none", no_main)] - -/*************** -NOTE: this assumes that you turn off the watchdog timer. This code does not include enough sleeps to reset the WDT -Do this by removing the watchdog feature in the ticktimer-server Cargo.toml crate -****************/ -use blitstr::GlyphStyle; -use blitstr_ref as blitstr; -use core::fmt::Write; -use graphics_server::{DrawStyle, PixelColor, Point, Rectangle, TextBounds, TextOp, TextView}; - -use log::{error, info}; -use num_traits::{FromPrimitive, ToPrimitive}; - -#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)] -pub enum Opcode { - Start, - Stop, -} - -const SERVER_NAME_SHELL: &str = "_Shell_"; - -fn stopwatch_thread() { - info!("BENCHMARK|stopwatch: starting"); - - let ticktimer = ticktimer_server::Ticktimer::new().expect("Couldn't connect to Ticktimer"); - - let xns = xous_names::XousNames::new().unwrap(); - let shell_conn = xns - .request_connection_blocking(SERVER_NAME_SHELL) - .expect("BENCHMARK|stopwatch: can't connect to main program"); - let mut last_time: u64 = ticktimer.elapsed_ms(); - let mut start_sent = false; - loop { - let elapsed_time = ticktimer.elapsed_ms(); - if false { - if elapsed_time - last_time > 500 && !start_sent { - last_time = elapsed_time; - xous::send_message( - shell_conn, - xous::Message::new_scalar(Opcode::Start.to_usize().unwrap(), 0, 0, 0, 0), - ) - .expect("BENCHMARK|stopwatch: couldn't send Start message"); - start_sent = true; - } else if elapsed_time - last_time > 10_000 && start_sent { - last_time = elapsed_time; - start_sent = false; - xous::send_message( - shell_conn, - xous::Message::new_scalar(Opcode::Stop.to_usize().unwrap(), 0, 0, 0, 0), - ) - .expect("BENCHMARK|stopwatch: couldn't send Start message"); - } - } else { - // send a start loop message - xous::send_message( - shell_conn, - xous::Message::new_scalar(Opcode::Start.to_usize().unwrap(), 0, 0, 0, 0), - ) - .expect("BENCHMARK|stopwatch: couldn't send Start message"); - ticktimer.sleep_ms(10_000).expect("couldn't sleep"); - // send a stop loop message - xous::send_message( - shell_conn, - xous::Message::new_scalar(Opcode::Stop.to_usize().unwrap(), 0, 0, 0, 0), - ) - .expect("BENCHMARK|stopwatch: couldn't send Start message"); - // give a moment for the result to update - ticktimer.sleep_ms(500).expect("couldn't sleep"); - } - xous::yield_slice(); - } -} - -fn main() -> ! { - log_server::init_wait().unwrap(); - info!("BENCHMARK: my PID is {}", xous::process::id()); - - info!("BENCHMARK: ticktimer"); - let ticktimer = ticktimer_server::Ticktimer::new().expect("Couldn't connect to Ticktimer"); - - let xns = xous_names::XousNames::new().unwrap(); - let shell_server = xns - .register_name(SERVER_NAME_SHELL, None) - .expect("BENCHMARK: can't register server"); - - let gfx = graphics_server::Gfx::new(&xns).unwrap(); - let target_conn = xns - .request_connection_blocking(benchmark_target::api::SERVER_NAME_BENCHMARK) - .expect("BENCHMARK: can't connect to COM"); - - xous::create_thread_0(stopwatch_thread).unwrap(); - info!("BENCHMARK: stopwatch thread started"); - - let screensize = gfx.screen_size().expect("Couldn't get screen size"); - - let font_h: i16 = gfx - .glyph_height_hint(GlyphStyle::Regular) - .expect("couldn't get glyph height") as i16; - - let status_clipregion = Rectangle::new_coords_with_style( - 4, - 0, - screensize.x, - font_h as i16 * 4, - DrawStyle::new(PixelColor::Light, PixelColor::Light, 1), - ); - - gfx.draw_rectangle(Rectangle::new_with_style( - Point::new(0, 0), - screensize, - DrawStyle::new(PixelColor::Light, PixelColor::Light, 0), - )) - .expect("unable to clear region"); - - let mut result_tv = TextView::new( - graphics_server::Gid::new([0, 0, 0, 0]), - TextBounds::BoundingBox(Rectangle::new( - Point::new(0, 0), - Point::new(screensize.x, screensize.y - 1), - )), - ); - result_tv.set_op(TextOp::Render); - result_tv.clip_rect = Some(status_clipregion.into()); - result_tv.untrusted = false; - result_tv.style = blitstr::GlyphStyle::Regular; - result_tv.draw_border = false; - result_tv.margin = Point::new(3, 0); - write!(result_tv, "Initializing...").expect("couldn't init text"); - gfx.draw_textview(&mut result_tv).unwrap(); - - gfx.flush().expect("unable to draw to screen"); - - let mut start_time: u64 = 0; - let mut stop_time: u64 = 0; - let mut update_result: bool = false; - let mut count: u32 = 0; - let mut check_count: u32 = 0; - loop { - let maybe_env = xous::try_receive_message(shell_server).unwrap(); - match maybe_env { - Some(envelope) => { - info!("BENCHMARK: Message: {:?}", envelope); - match FromPrimitive::from_usize(envelope.body.id()) { - Some(Opcode::Start) => { - start_time = ticktimer.elapsed_ms(); - } - Some(Opcode::Stop) => { - stop_time = ticktimer.elapsed_ms(); - update_result = true; - } - None => { - error!("BENCHMARK: couldn't convert opcode"); - } - } - } - None => (), // don't yield, we are trying to run the loop as fast as we can... - } - - // actual benchmark - // get a scalar message - if false { - // measured at 1479.2 iterations per second in this loop (hardware); 55/s (hosted) - - // xous v0.8 - // 29729 per 10s = 2972.9/s (hardware) - // 485 per 10s = 48.5/s (hosted) - count = benchmark_target::test_scalar(target_conn, count) - .expect("BENCHMARK: couldn't send test message"); - check_count = check_count + 1; - } else { - if false { - // works on hosted mode, 35/s (hosted) - // measured at 762.6 iterations per second (hardware) - - // xous v0.8 - // 9,928 per 10s = 992.8/s (hardware) - // 243 per 10s = 24.3/s (hosted) - count = benchmark_target::test_memory(target_conn, count) - .expect("BENCHMARK: couldn't send test message"); - check_count = check_count + 1; - } else { - // simple send benchmark, instead of lend - count = benchmark_target::test_memory_send(target_conn, count) - .expect("BENCHMARK: couldn't send test message"); - check_count = check_count + 1; - } - } - - if update_result { - update_result = false; - - gfx.draw_rectangle(status_clipregion) - .expect("unable to clear region"); - - result_tv.clear_str(); - write!( - &mut result_tv, - "Elapsed: {}, count: {}, check: {}", - stop_time - start_time, - count, - check_count - ) - .unwrap(); - gfx.draw_textview(&mut result_tv).unwrap(); - gfx.flush().expect("unable to draw to screen"); - - count = 0; - check_count = 0; - } - } -} diff --git a/services/rkyv-test-client/Cargo.toml b/services/rkyv-test-client/Cargo.toml deleted file mode 100644 index fd0a22e9f..000000000 --- a/services/rkyv-test-client/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -authors = ["Sean Cross "] -description = "Program to test various aspects of the kernel" -edition = "2018" -name = "rkyv-test-client" -version = "0.1.0" - -# Dependency versions enforced by Cargo.lock. -[dependencies] -log = "0.4.14" -log-server = {version = "0.1.2", package = "xous-api-log-server"} -rkyv-test-server = {path = "../rkyv-test-server"} -ticktimer-server = {path = "../ticktimer-server"} -xous = "0.9.9" -com = {path = "../com"} -xous-names = {path="../xous-names"} -susres = {path = "../susres"} - -keyboard = {path="../keyboard"} - -[features] -default = [] diff --git a/services/rkyv-test-client/README.md b/services/rkyv-test-client/README.md deleted file mode 100644 index f1d1ca67f..000000000 --- a/services/rkyv-test-client/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Kernel Test - -Run various tests inside the kernel. - -This is supposed to be the only program running. diff --git a/services/rkyv-test-client/build.rs b/services/rkyv-test-client/build.rs deleted file mode 100644 index 43c3deb4f..000000000 --- a/services/rkyv-test-client/build.rs +++ /dev/null @@ -1,17 +0,0 @@ -// NOTE: Adapted from cortex-m/build.rs -use std::env; - -fn main() { - let target = env::var("TARGET").unwrap(); - - let target_os = target.split('-').nth(2).unwrap_or("none"); - - // If we're not running on a desktop-class operating system, emit the "baremetal" - // config setting. This will enable software to do tasks such as - // managing memory. - if target_os == "none" { - println!("cargo:rustc-cfg=baremetal"); - } - - println!("cargo:rerun-if-changed=build.rs"); -} diff --git a/services/rkyv-test-client/src/main.rs b/services/rkyv-test-client/src/main.rs deleted file mode 100644 index aa751ebb4..000000000 --- a/services/rkyv-test-client/src/main.rs +++ /dev/null @@ -1,95 +0,0 @@ -#![cfg_attr(target_os = "none", no_std)] -#![cfg_attr(target_os = "none", no_main)] - -use core::fmt::Write; - -fn print_log_messages(log_message: &str, prefix: &str) { - log::info!( - "Got a message hook! Message: [{}], prefix: [{}]", - log_message, - prefix - ); -} - -fn handle_battstats(bs: com::BattStats) { - log::info!("battstats: {:?}", bs); - // note: at this point to repatriate data into the core main loop, you have two options: - // 1. send a new message to the server, using your own private API. This feels "wasteful" - // as you're bouncing a message twice but it keeps the API spaces strictly on crate boundaries - // 2. use an Atomic type to transfer primitive data types from the handler thread to the main thread -} - -fn handle_keyevents(keys: [char; 4]) { - for &k in keys.iter() { - if k != '\u{0000}' { - log::info!("KEYEVENT: {}", k); - } - } -} - -fn main() -> ! { - log_server::init_wait().unwrap(); - log::info!( - "Hello, world! This is the client, PID {}", - xous::current_pid().unwrap().get() - ); - let ticktimer = ticktimer_server::Ticktimer::new().expect("couldn't create ticktimer object"); - - rkyv_test_server::hook_log_messages(print_log_messages); - - let mut idx = 0; - - // This is just some number. It should change width, ensuring our padding - // is working and we're not overwriting the buffer weirdly. - let mut some_number = 98653i32; - let mut double_src = xous::String::<256>::new(); - - let mut message_string = xous::String::<64>::new(); - - let xns = xous_names::XousNames::new().unwrap(); - - let mut susres = susres::Susres::new_without_hook(&xns).unwrap(); - let mut com = com::Com::new(&xns).unwrap(); - com.hook_batt_stats(handle_battstats).unwrap(); - /* - let mut kbd = keyboard::Keyboard::new(&xns).unwrap(); - kbd.hook_keyboard_events(handle_keyevents).unwrap();*/ - loop { - log::info!("2 + {} = {}", idx, rkyv_test_server::add(2, idx).unwrap()); - ticktimer.sleep_ms(3000).ok(); - - message_string.clear(); - write!( - message_string, - "I'm at loop # {:^4} (some numer: {})", - idx, some_number - ) - .unwrap(); - some_number = some_number.wrapping_mul(53); - rkyv_test_server::log_message("prefix", message_string); - - double_src.clear(); - write!(double_src, "12345678 Loop {} 🎉 你好", idx).unwrap(); - log::info!("Doubling string {}", double_src); - log::info!( - "Doubled string: {}", - rkyv_test_server::double_string(&double_src) - ); - - let sent_str = xous::String::<32>::from_str("This got moved"); - log::info!("Sending a string \"{}\"", sent_str); - rkyv_test_server::log_message("prefix", sent_str); - - if (idx % 2) == 0 { - com.req_batt_stats().unwrap(); - } - - // let the loop run a bit, then try a suspend - if idx == 3 { - // TODO: add a self-wakeup RTC alarm once we're beyond the touch-and-go phase - susres.initiate_suspend().unwrap(); - } - - idx += 1; - } -} diff --git a/services/rkyv-test-server/Cargo.toml b/services/rkyv-test-server/Cargo.toml deleted file mode 100644 index 30e0f2785..000000000 --- a/services/rkyv-test-server/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -authors = ["Sean Cross "] -description = "Program to test various aspects of the kernel" -edition = "2018" -name = "rkyv-test-server" -version = "0.1.0" - -# Dependency versions enforced by Cargo.lock. -[dependencies] -log = "0.4.14" -log-server = {version = "0.1.2", package = "xous-api-log-server"} -num-derive = {version = "0.3.3", default-features = false} -num-traits = {version = "0.2.14", default-features = false} -rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]} -ticktimer-server = {path = "../ticktimer-server"} -xous = "0.9.9" -xous-ipc = "0.9.9" -xous-names = {path = "../xous-names"} - -[features] -default = [] diff --git a/services/rkyv-test-server/README.md b/services/rkyv-test-server/README.md deleted file mode 100644 index f1d1ca67f..000000000 --- a/services/rkyv-test-server/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Kernel Test - -Run various tests inside the kernel. - -This is supposed to be the only program running. diff --git a/services/rkyv-test-server/build.rs b/services/rkyv-test-server/build.rs deleted file mode 100644 index 43c3deb4f..000000000 --- a/services/rkyv-test-server/build.rs +++ /dev/null @@ -1,17 +0,0 @@ -// NOTE: Adapted from cortex-m/build.rs -use std::env; - -fn main() { - let target = env::var("TARGET").unwrap(); - - let target_os = target.split('-').nth(2).unwrap_or("none"); - - // If we're not running on a desktop-class operating system, emit the "baremetal" - // config setting. This will enable software to do tasks such as - // managing memory. - if target_os == "none" { - println!("cargo:rustc-cfg=baremetal"); - } - - println!("cargo:rerun-if-changed=build.rs"); -} diff --git a/services/rkyv-test-server/src/api.rs b/services/rkyv-test-server/src/api.rs deleted file mode 100644 index 84e65fc83..000000000 --- a/services/rkyv-test-server/src/api.rs +++ /dev/null @@ -1,70 +0,0 @@ -use xous_ipc::String; -pub(crate) const SERVER_NAME: &str = "Rkyv Test Server 1"; -/// A `usize` value that gets set as the `id` for every message handled -/// by our server. -#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive)] -pub(crate) enum Opcode { - /// Perform a mathematical function - Mathematics = 0, - - /// Log the string to the log server with the given prefix - LogString = 1, - - /// Callback with log string - AddLogStringCallback = 2, - - /// Double the string - DoubleString = 3, -} - -/// These enums indicate what kind of callback type we're sending. -#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive)] -pub(crate) enum CallbackType { - /// A log message was sent - LogString, -} - -/// A rich structure that contains multiple values. -#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] -pub(crate) enum MathOperation { - /// Add two numbers together and return the result. - Add(i32, i32), - - /// Subtract two numbers and return the result. - Subtract(i32, i32), - - /// Multiply the two numbers - Multiply(i32, i32), - - /// Divide the two numbers - Divide(i32, i32), -} - -#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] -pub(crate) struct LogString { - pub(crate) prefix: String<32>, - pub(crate) message: String<5200>, -} - -#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] -pub(crate) struct StringDoubler { - pub(crate) value: String<512>, -} - -#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Debug)] -pub enum Error { - InternalError, - Overflow, - Underflow, -} - -#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] -pub(crate) enum MathResult { - Value(i32), - Error(Error), -} - -#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] -pub(crate) struct RegisterCallback { - server: (u32, u32, u32, u32), -} diff --git a/services/rkyv-test-server/src/lib.rs b/services/rkyv-test-server/src/lib.rs deleted file mode 100644 index 070f9a53e..000000000 --- a/services/rkyv-test-server/src/lib.rs +++ /dev/null @@ -1,220 +0,0 @@ -#![cfg_attr(target_os = "none", no_std)] - -mod api; - -use core::sync::atomic::{AtomicU32, Ordering}; -use num_traits::{FromPrimitive, ToPrimitive}; - -use xous_ipc::{Buffer, String}; - -// Note that connection IDs are never 0, so this is invalid, and could map to `None`. -static SERVER_CID: AtomicU32 = AtomicU32::new(0); - -/// Ensure we have a connection to our own server. If a connection does not exist, -/// have the nameserver create one for us. -fn ensure_connection() -> xous::CID { - let mut cid = SERVER_CID.load(Ordering::Relaxed); - if cid == 0 { - let ns = xous_names::XousNames::new().unwrap(); - cid = ns.request_connection_blocking(api::SERVER_NAME).unwrap(); - SERVER_CID.store(cid, Ordering::Relaxed); - } - cid -} - -/// Add two numbers to gether, and return the result. Returns -/// an Error if one is detected. -pub fn add(arg1: i32, arg2: i32) -> Result { - // Create an opcode variant. This can be a rich structure. - let op = api::MathOperation::Add(arg1, arg2); - - // Convert the opcode into a serialized buffer. This consumes the opcode, which will - // exist on the heap in its own page. Furthermore, this will be in a flattened format - // suitable for passing around as a message. - let mut buf = Buffer::into_buf(op).or(Err(api::Error::InternalError))?; - - // Mutably lend our op to the server, specifying the `api::Opcode::Mathematics` opcode. - // This will return a structure that we can deserialize back into something we - // can verify. - buf.lend_mut( - ensure_connection(), - api::Opcode::Mathematics.to_u32().unwrap(), - ) - .or(Err(api::Error::InternalError))?; - - // Turn the result of the response into a friendly value that can be understood - // by the caller. - match buf.to_original().unwrap() { - api::MathResult::Value(v) => Ok(v), - api::MathResult::Error(val) => Err(val), - } -} - -/// Condensed form of the operation, that allows for reuse among other operations. -fn do_op(op: api::MathOperation) -> Result { - // Convert the opcode into a serialized buffer. This consumes the opcode, which will - // exist on the heap in its own page. Furthermore, this will be in a flattened format - // suitable for passing around as a message. - let mut buf = Buffer::into_buf(op).or(Err(api::Error::InternalError))?; - - // Lend our op to the server, specifying the `api::Opcode::Mathematics` opcode. - // This will return a structure that we can deserialize back into something we - // can verify. - buf.lend_mut( - ensure_connection(), - api::Opcode::Mathematics.to_u32().unwrap(), - ) - .or(Err(api::Error::InternalError))?; - - // Don't deserialize it -- use the archived version - match *buf.as_flat::().unwrap() { - api::ArchivedMathResult::Value(v) => Ok(v), - api::ArchivedMathResult::Error(api::ArchivedError::InternalError) => { - Err(api::Error::InternalError) - } - api::ArchivedMathResult::Error(api::ArchivedError::Overflow) => Err(api::Error::Overflow), - api::ArchivedMathResult::Error(api::ArchivedError::Underflow) => Err(api::Error::Underflow), - } -} - -pub fn subtract(arg1: i32, arg2: i32) -> Result { - do_op(api::MathOperation::Subtract(arg1, arg2)) -} - -pub fn multiply(arg1: i32, arg2: i32) -> Result { - do_op(api::MathOperation::Multiply(arg1, arg2)) -} - -pub fn divide(arg1: i32, arg2: i32) -> Result { - do_op(api::MathOperation::Divide(arg1, arg2)) -} - -/// Log the given message to the server. -/// We accept any two parameters that can be treated as strings. -pub fn log_message, T: AsRef>(prefix: S, message: T) { - let op = api::LogString { - prefix: String::from_str(prefix.as_ref()), - message: String::from_str(message.as_ref()), - }; - - // Convert the opcode into a serialized buffer. This consumes the opcode, which will - // exist on the heap in its own page. Furthermore, this will be in a flattened format - // suitable for passing around as a message. - let buf = Buffer::into_buf(op).unwrap(); - - // Send the message to the server. - buf.lend( - ensure_connection(), - api::Opcode::LogString.to_u32().unwrap(), - ) - .unwrap(); -} - -/// Log the given message to the server. -/// We accept any two parameters that can be treated as strings. -pub fn log_message_send, T: AsRef>(prefix: S, message: T) { - let op = api::LogString { - prefix: String::from_str(prefix.as_ref()), - message: String::from_str(message.as_ref()), - }; - - // Convert the opcode into a serialized buffer. This consumes the opcode, which will - // exist on the heap in its own page. Furthermore, this will be in a flattened format - // suitable for passing around as a message. - let buf = Buffer::into_buf(op).unwrap(); - - // Send the message to the server. - buf.send( - ensure_connection(), - api::Opcode::LogString.to_u32().unwrap(), - ) - .unwrap(); -} - -// Callback messages will be sent to this private server. -// Ideally it would be held in a Mutex. -static mut CALLBACK_SID: Option = None; -static mut CALLBACK_ARRAY: [Option; 8] = [None; 8]; - -// This callback server runs in its own thread. -fn callback_server() { - let sid = unsafe { CALLBACK_SID }.unwrap(); - loop { - let msg = xous::receive_message(sid).unwrap(); - match FromPrimitive::from_usize(msg.body.id()) { - Some(api::CallbackType::LogString) => { - let mem = msg.body.memory_message().unwrap(); - let buffer = unsafe { Buffer::from_memory_message(mem) }; - let log_string = buffer.as_flat::().unwrap(); - unsafe { - for entry in CALLBACK_ARRAY.iter() { - if let Some(cb) = entry { - cb(log_string.message.as_str(), log_string.prefix.as_str()); - } - } - } - } - _ => (), - } - } -} - -pub fn hook_log_messages(cb: fn(&str, &str)) { - // Add this entry to the callback array - unsafe { - for entry in CALLBACK_ARRAY.iter_mut() { - if entry.is_none() { - *entry = Some(cb); - break; - } - } - } - - // If no thread exists to handle callbacks, create one. - // Publish this server with the main thread so it can call us as necessary. - if unsafe { CALLBACK_SID }.is_none() { - let sid = xous::create_server().unwrap(); - unsafe { CALLBACK_SID = Some(sid) }; - xous::create_thread_0(callback_server).unwrap(); - let sid = sid.to_u32(); - xous::send_message( - ensure_connection(), - xous::Message::Scalar(xous::ScalarMessage { - id: api::Opcode::AddLogStringCallback.to_usize().unwrap(), - arg1: sid.0 as _, - arg2: sid.1 as _, - arg3: sid.2 as _, - arg4: sid.3 as _, - }), - ) - .unwrap(); - } -} - -pub fn double_string(value: &T) -> String<512> -where - T: AsRef, -{ - let op = api::StringDoubler { - value: String::from_str(value.as_ref()), - }; - - // Convert the opcode into a serialized buffer. This consumes the opcode, which will - // exist on the heap in its own page. Furthermore, this will be in a flattened format - // suitable for passing around as a message. - let mut buf = Buffer::into_buf(op).unwrap(); - - // Send the message to the server. - buf.lend_mut( - ensure_connection(), - api::Opcode::DoubleString.to_u32().unwrap(), - ) - .unwrap(); - - String::from_str( - buf.as_flat::() - .unwrap() - .value - .as_str(), - ) -} diff --git a/services/rkyv-test-server/src/main.rs b/services/rkyv-test-server/src/main.rs deleted file mode 100644 index 422cf3f52..000000000 --- a/services/rkyv-test-server/src/main.rs +++ /dev/null @@ -1,182 +0,0 @@ -#![cfg_attr(target_os = "none", no_std)] -#![cfg_attr(target_os = "none", no_main)] - -mod api; -use num_traits::{FromPrimitive, ToPrimitive}; -use xous_ipc::{Buffer, String}; - -fn value_or(val: Option, default: api::MathResult) -> api::MathResult { - val.map(|v| api::MathResult::Value(v)).unwrap_or(default) -} - -fn handle_math_withcopy(mem: &mut xous::MemoryMessage) { - let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) }; - let response = { - use api::MathOperation::*; - match buffer.to_original().unwrap() { - Add(a, b) => value_or( - a.checked_add(b), - api::MathResult::Error(api::Error::Overflow), - ), - Subtract(a, b) => value_or( - a.checked_sub(b), - api::MathResult::Error(api::Error::Underflow), - ), - Multiply(a, b) => value_or( - a.checked_mul(b), - api::MathResult::Error(api::Error::Overflow), - ), - Divide(a, b) => value_or( - a.checked_div(b), - api::MathResult::Error(api::Error::Underflow), - ), - } - }; - buffer.replace(response).unwrap(); -} - -// This doesn't deserialize the struct, and therefore operates entirely -// on the archived data. This saves a copy step. -fn handle_math_zerocopy(mem: &mut xous::MemoryMessage) { - let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) }; - let response = { - use api::ArchivedMathOperation::*; - match *buffer.as_flat::().unwrap() { - Add(a, b) => value_or( - a.checked_add(b), - api::MathResult::Error(api::Error::Overflow), - ), - Subtract(a, b) => value_or( - a.checked_sub(b), - api::MathResult::Error(api::Error::Underflow), - ), - Multiply(a, b) => value_or( - a.checked_mul(b), - api::MathResult::Error(api::Error::Overflow), - ), - Divide(a, b) => value_or( - a.checked_div(b), - api::MathResult::Error(api::Error::Underflow), - ), - } - }; - buffer.replace(response).unwrap(); -} - -fn handle_log_string(mem: &xous::MemoryMessage) { - let buffer = unsafe { Buffer::from_memory_message(mem) }; - let log_string = buffer.as_flat::().unwrap(); - log::info!( - "Prefix: {} Message: {}", - log_string.prefix.as_str(), - log_string.message.as_str() - ); -} - -/// Take the given string and double each character in an output string. -fn double_string(mem: &mut xous::MemoryMessage) { - use core::fmt::Write; - let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) }; - let mut response = api::StringDoubler { - value: String::new(), - }; - for ch in buffer - .as_flat::() - .unwrap() - .value - .as_str() - .chars() - { - write!(response.value, "{}{}", ch, ch).ok(); - } - buffer.replace(response).unwrap(); -} - -fn local_lender() { - use core::fmt::Write; - - let ticktimer = ticktimer_server::Ticktimer::new().unwrap(); - let mut message_string = xous::String::<64>::new(); - - let mut idx: usize = 0; - loop { - message_string.clear(); - write!(message_string, "LOCAL loop # {:^4}", idx).unwrap(); - idx += 1; - rkyv_test_server::log_message("LOCAL LENDER", message_string); - ticktimer.sleep_ms(500).unwrap(); - } -} - -fn main() -> ! { - log_server::init_wait().unwrap(); - - log::info!( - "Hello, world! This is the server, PID {}", - xous::current_pid().unwrap() - ); - let xns = xous_names::XousNames::new().unwrap(); - let sid = xns.register_name(api::SERVER_NAME).unwrap(); - - let mut logstring_callback_connections = [None; 32]; - - xous::create_thread_0(local_lender); - - loop { - let mut msg = xous::receive_message(sid).unwrap(); - match FromPrimitive::from_usize(msg.body.id()) { - Some(api::Opcode::Mathematics) => { - handle_math_withcopy(msg.body.memory_message_mut().unwrap()) - } - Some(api::Opcode::DoubleString) => { - double_string(msg.body.memory_message_mut().unwrap()) - } - Some(api::Opcode::LogString) => { - let memory = msg.body.memory_message().unwrap(); - // If a callback exists, first pass this message to the callback server. - for callback_conn in logstring_callback_connections.iter() { - if let Some(callback_sid) = callback_conn { - let buffer = unsafe { Buffer::from_memory_message(memory) }; - buffer - .lend( - *callback_sid, - api::CallbackType::LogString.to_u32().unwrap(), - ) - .unwrap(); - } - } - handle_log_string(msg.body.memory_message().unwrap()) - } - Some(api::Opcode::AddLogStringCallback) => { - // The Log String Callback provides us a SID. Connect to that SID - // and add it to the list of connections available. - if let xous::Message::Scalar(xous::ScalarMessage { - id: _id, - arg1, - arg2, - arg3, - arg4, - }) = msg.body - { - let sid = xous::SID::from_u32(arg1 as _, arg2 as _, arg3 as _, arg4 as _); - let cb_conn = Some(xous::connect(sid).unwrap()); - // Add this callback connection to the list of callbacks. If `AddLogStringCallback` - // is called multiple times, then it will receive multiple callbacks. - for entry in logstring_callback_connections.iter_mut() { - if *entry == None { - *entry = cb_conn; - break; - } - } - } - } - None => break, - } - } - // clean up our program - log::trace!("main loop exit, destroying servers"); - xns.unregister_server(sid).unwrap(); - xous::destroy_server(sid).unwrap(); - log::trace!("quitting"); - xous::terminate_process(0) -} diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 01424bc08..c84c607f7 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -14,8 +14,6 @@ use std::{ // updated every time the SoC version is bumped. const SOC_SVD_VERSION: &str = "precursor-c809403"; -///// TODO: BRING BACK THE UTRA SWAP BUILD TARGET - // This is the minimum Xous version required to read a PDDB backup generated // by the current kernel revision. const MIN_XOUS_VERSION: &str = "v0.9.8-791"; @@ -95,18 +93,6 @@ fn main() -> Result<(), Box> { // "standard" demo apps "ball", "repl", ]; - let benchmark_pkgs = [ - "benchmark", - "benchmark-target", - "graphics-server", - "ticktimer-server", - "log-server", - "xous-names", - "keyboard", - "trng", - "susres", - "llio", - ]; let minimal_pkgs = [ "ticktimer-server", "log-server", @@ -125,28 +111,6 @@ fn main() -> Result<(), Box> { "xous-names", "trng", ]; - let cbtest_pkgs = [ - "ticktimer-server", - "log-server", - "xous-names", - "trng", - "llio", - "cb-test-srv", - "cb-test-c1", - "cb-test-c2", - "susres", - ]; - let sr_pkgs = [ - "ticktimer-server", - "log-server", - "xous-names", - "trng", - "llio", - "rkyv-test-client", - "rkyv-test-server", - "com", - "susres", - ]; let pddb_dev_pkgs = [ // just for checking compilation "ticktimer-server", @@ -182,8 +146,8 @@ fn main() -> Result<(), Box> { "keyboard", "spinor", ]; - let aestest_pkgs = ["ticktimer-server", "log-server", "aes-test"]; + let mut args = env::args(); let task = args.nth(1); // extract lkey/kkey args only after a "--" separator @@ -249,7 +213,7 @@ fn main() -> Result<(), Box> { pkgs.push(app); } generate_app_menus(&apps); - renode_image(false, &cbtest_pkgs, &[], None, None)? + renode_image(false, &minimal_pkgs, &[], None, None)? } Some("tts") => { let tmp_dir = tempfile::Builder::new().prefix("bins").tempdir()?; @@ -417,33 +381,6 @@ fn main() -> Result<(), Box> { Some(&["--features", "renode-bypass"]), )?; } - Some("pddb-flamegraph") => { - let mut args = env::args(); - args.nth(1); - let mut pkgs = pddb_dev_pkgs.to_vec(); - // add pkgs required for functional testing. Quite a bit. :-/ - pkgs.push("llio"); - pkgs.push("root-keys"); - pkgs.push("jtag"); - pkgs.push("com"); - pkgs.push("gam"); - pkgs.push("net"); - pkgs.push("dns"); - pkgs.push("graphics-server"); - pkgs.push("modals"); - pkgs.push("keyboard"); - pkgs.push("ime-frontend"); - pkgs.push("ime-plugin-shell"); - pkgs.push("status"); - pkgs.push("usb-device-xous"); - generate_app_menus(&vec![]); - run(false, &pkgs, - Some(&[ - "--features", "pddbtest", - "--features", "pddb-flamegraph", - ]), false)? - - } Some("renode-aes-test") => { generate_app_menus(&Vec::::new()); renode_image(false, &aestest_pkgs, &[], None, None)? @@ -541,6 +478,7 @@ fn main() -> Result<(), Box> { lkey, kkey, None, + // Some(&["--features", "ditherpunk"]), // swap for extra_args if you want ditherpunk in the app-image &[], None, None, )? @@ -577,28 +515,6 @@ fn main() -> Result<(), Box> { ]), )? } - Some("ditherpunk-image") => { - let mut args = env::args(); - args.nth(1); - let mut pkgs = hw_pkgs.to_vec(); - let apps = get_packages(); - for app in &apps { - pkgs.push(app); - } - generate_app_menus(&apps); - build_hw_image( - false, - None, - &pkgs, - lkey, - kkey, - Some(&[ - "--features", "ditherpunk", - ]), - &[], - None, None, - )? - } Some("hw-image") => { let mut pkgs = vec![]; for pkg in hw_pkgs { @@ -640,16 +556,6 @@ fn main() -> Result<(), Box> { None, None, )?, Some("pddb-hosted") => run(false, &pddb_dev_pkgs, None, false)?, - Some("benchmark") => build_hw_image( - false, - env::args().nth(2), - &benchmark_pkgs, - lkey, - kkey, - None, - &[], - None, None, - )?, Some("minimal") => build_hw_image( false, env::args().nth(2), @@ -660,16 +566,6 @@ fn main() -> Result<(), Box> { &[], None, None, )?, - Some("cbtest") => build_hw_image( - false, - env::args().nth(2), - &cbtest_pkgs, - lkey, - kkey, - None, - &[], - None, None, - )?, Some("trng-test") => { generate_app_menus(&Vec::::new()); build_hw_image( @@ -709,16 +605,6 @@ fn main() -> Result<(), Box> { None, None, )? } - Some("sr-test") => build_hw_image( - false, - env::args().nth(2), - &sr_pkgs, - lkey, - kkey, - None, - &[], - None, None, - )?, Some("generate-locales") => generate_locales()?, Some("wycheproof-import") => whycheproof_import()?, _ => print_help(), @@ -751,21 +637,19 @@ Locale (re-)generation: generate-locales (re)generate the locales include for the language selected in xous-rs/src/locale.rs Various debug configurations (high chance of bitrot): - debug runs a debug build using a hosted environment - benchmark builds a benchmarking image for real hardware - minimal builds a minimal image for API testing - cbtest builds an image for callback testing - trng-test builds an image for TRNG testing - urandom source seeded by TRNG+AV - ro-test builds an image for ring oscillator only TRNG testing - av-test builds an image for avalanche generater only TRNG testing - sr-test builds the suspend/resume testing image + tts builds an image with text to speech support via externally linked C executable wycheproof-import generate binary test vectors for engine-25519 from whycheproof-import/x25519.json + debug runs a debug build using a hosted environment + minimal builds a minimal image for API testing + ffi-test builds an image for testing C-FFI bindings and integration + gfx-dev minimal configuration for graphics primitive testing pddb-dev PDDB testing only for live hardware pddb-hosted PDDB testing in a hosted environment pddb-ci PDDB config for CI testing (eg: TRNG->deterministic for reproducible errors) - ffi-test builds an image for testing C-FFI bindings and integration - tts builds an image with text to speech support via externally linked C executable usbdev minimal, insecure build for new USB core bringup + trng-test builds an image for TRNG testing - urandom source seeded by TRNG+AV + ro-test builds an image for ring oscillator only TRNG testing + av-test builds an image for avalanche generater only TRNG testing install-toolkit installs Xous toolkit with no prompt, useful in CI. Specify `--force` to remove existing toolchains Note: By default, the `ticktimer` will get rebuilt every time. You can skip this by appending `--no-timestamp` to the command.