diff --git a/Cargo.lock b/Cargo.lock index 07a1e970b..47a59f569 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,18 +32,6 @@ version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" -[[package]] -name = "as-slice" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45403b49e3954a4b8428a0ac21a4b7afadccf92bfd96273f1a58cd4812496ae0" -dependencies = [ - "generic-array 0.12.4", - "generic-array 0.13.3", - "generic-array 0.14.4", - "stable_deref_trait", -] - [[package]] name = "atomic-polyfill" version = "0.1.2" @@ -193,7 +181,6 @@ name = "cb-test-c1" version = "0.1.0" dependencies = [ "cb-test-srv", - "heapless 0.5.6", "log", "log-server", "num-derive", @@ -211,7 +198,6 @@ name = "cb-test-c2" version = "0.1.0" dependencies = [ "cb-test-srv", - "heapless 0.5.6", "log", "log-server", "num-derive", @@ -320,7 +306,6 @@ dependencies = [ name = "codec" version = "0.1.0" dependencies = [ - "heapless 0.5.6", "llio", "log", "log-server", @@ -341,7 +326,7 @@ name = "com" version = "0.1.0" dependencies = [ "com_rs-ref", - "heapless 0.5.6", + "heapless", "log", "log-server", "num-derive", @@ -530,7 +515,7 @@ dependencies = [ "com", "content-plugin-api", "graphics-server", - "heapless 0.5.6", + "heapless", "ime-plugin-api", "keyboard", "log", @@ -547,34 +532,6 @@ dependencies = [ "xous-names", ] -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - -[[package]] -name = "generic-array" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f797e67af32588215eaaab8327027ee8e71b9dd0b2b26996aedf20c030fce309" -dependencies = [ - "typenum", -] - -[[package]] -name = "generic-array" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" -dependencies = [ - "typenum", - "version_check", -] - [[package]] name = "getrandom" version = "0.2.2" @@ -597,7 +554,7 @@ name = "graphics-server" version = "0.1.0" dependencies = [ "blitstr-ref", - "hash32 0.1.1", + "hash32", "hash32-derive", "keyboard", "log", @@ -613,15 +570,6 @@ dependencies = [ "xous-names", ] -[[package]] -name = "hash32" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4041af86e63ac4298ce40e5cca669066e75b6f1aa3390fe2561ffa5e1d9f4cc" -dependencies = [ - "byteorder", -] - [[package]] name = "hash32" version = "0.2.1" @@ -642,18 +590,6 @@ dependencies = [ "syn 0.13.11", ] -[[package]] -name = "heapless" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74911a68a1658cfcfb61bc0ccfbd536e3b6e906f8c2f7883ee50157e3e2184f1" -dependencies = [ - "as-slice", - "generic-array 0.13.3", - "hash32 0.1.1", - "stable_deref_trait", -] - [[package]] name = "heapless" version = "0.7.0" @@ -661,7 +597,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e94c13b78b595d2adbd708bce276664f1047f98fc32ddbf463b4c191158334a6" dependencies = [ "atomic-polyfill", - "hash32 0.2.1", + "hash32", "stable_deref_trait", ] @@ -734,7 +670,7 @@ dependencies = [ name = "ime-plugin-shell" version = "0.1.0" dependencies = [ - "heapless 0.5.6", + "heapless", "ime-plugin-api", "log", "log-server", @@ -769,7 +705,7 @@ dependencies = [ name = "keyboard" version = "0.1.0" dependencies = [ - "heapless 0.5.6", + "heapless", "llio", "log", "log-server", @@ -816,7 +752,7 @@ dependencies = [ name = "llio" version = "0.1.0" dependencies = [ - "heapless 0.7.0", + "heapless", "log", "log-server", "num-derive", @@ -1304,7 +1240,6 @@ version = "0.1.0" dependencies = [ "bitflags", "chrono", - "heapless 0.5.6", "llio", "log", "log-server", @@ -1403,7 +1338,7 @@ dependencies = [ "content-plugin-api", "gam", "graphics-server", - "heapless 0.7.0", + "heapless", "ime-plugin-api", "keyboard", "llio", @@ -1549,7 +1484,7 @@ dependencies = [ name = "ticktimer-server" version = "0.1.0" dependencies = [ - "heapless 0.5.6", + "heapless", "log", "log-server", "num-derive", @@ -1588,7 +1523,6 @@ dependencies = [ name = "trng" version = "0.1.0" dependencies = [ - "heapless 0.5.6", "log", "log-server", "num-derive", @@ -1910,9 +1844,9 @@ dependencies = [ name = "xous-names" version = "0.1.0" dependencies = [ - "hash32 0.1.1", + "hash32", "hash32-derive", - "heapless 0.5.6", + "heapless", "log", "log-server", "num-derive", diff --git a/services/cb-test-c1/Cargo.toml b/services/cb-test-c1/Cargo.toml index 00cb5be6b..643e866a3 100644 --- a/services/cb-test-c1/Cargo.toml +++ b/services/cb-test-c1/Cargo.toml @@ -7,7 +7,6 @@ description = "Callback Test Client 1" [dependencies] xous = { path = "../../xous-rs" } -heapless = "0.5.6" log-server = { path = "../log-server" } ticktimer-server = { path = "../ticktimer-server" } xous-names = { path = "../xous-names" } diff --git a/services/cb-test-c2/Cargo.toml b/services/cb-test-c2/Cargo.toml index f109ec081..0b3987397 100644 --- a/services/cb-test-c2/Cargo.toml +++ b/services/cb-test-c2/Cargo.toml @@ -7,7 +7,6 @@ description = "Callback Test Client 2" [dependencies] xous = { path = "../../xous-rs" } -heapless = "0.5.6" log-server = { path = "../log-server" } ticktimer-server = { path = "../ticktimer-server" } xous-names = { path = "../xous-names" } diff --git a/services/codec/Cargo.toml b/services/codec/Cargo.toml index 78af9d294..8c0e32e1f 100644 --- a/services/codec/Cargo.toml +++ b/services/codec/Cargo.toml @@ -7,7 +7,6 @@ description = "Audio CODEC server" [dependencies] xous = { path = "../../xous-rs" } -heapless = "0.5.6" log-server = { path = "../log-server" } ticktimer-server = { path = "../ticktimer-server" } xous-names = { path = "../xous-names" } diff --git a/services/com/Cargo.toml b/services/com/Cargo.toml index 29a708a70..6c174d5ab 100644 --- a/services/com/Cargo.toml +++ b/services/com/Cargo.toml @@ -7,7 +7,7 @@ version = "0.1.0" [dependencies] com_rs-ref = {path = "../../imports/com_rs-ref"} -heapless = "0.5" +heapless = "0.7" log = "0.4" log-server = {path = "../log-server"} ticktimer-server = {path = "../ticktimer-server"} diff --git a/services/com/src/main.rs b/services/com/src/main.rs index 460f06e6b..2f7dfef49 100644 --- a/services/com/src/main.rs +++ b/services/com/src/main.rs @@ -41,7 +41,6 @@ mod implementation { use susres::{RegManager, RegOrField, SuspendResume}; use heapless::Vec; - use heapless::consts::U64; const STD_TIMEOUT: u32 = 100; @@ -49,7 +48,7 @@ mod implementation { csr: utralib::CSR, susres: RegManager::<{utra::com::COM_NUMREGS}>, ticktimer: ticktimer_server::Ticktimer, - pub workqueue: Vec, + pub workqueue: Vec, busy: bool, stby_current: Option, } @@ -209,7 +208,7 @@ mod implementation { use heapless::consts::*; pub struct XousCom { - pub workqueue: Vec, + pub workqueue: Vec, busy: bool, } diff --git a/services/gam/Cargo.toml b/services/gam/Cargo.toml index 3b0d4fdb3..93af84092 100644 --- a/services/gam/Cargo.toml +++ b/services/gam/Cargo.toml @@ -11,7 +11,7 @@ blitstr-ref = {path = "../../imports/blitstr-ref"} com = {path = "../com"} content-plugin-api = {path = "../content-plugin-api"} graphics-server = {path = "../graphics-server"} -heapless = "0.5" +heapless = "0.7" ime-plugin-api = {path = "../ime-plugin-api"} keyboard = {path = "../keyboard"} log = "0.4" diff --git a/services/gam/src/canvas.rs b/services/gam/src/canvas.rs index 28e5afaa4..5dcb1459b 100644 --- a/services/gam/src/canvas.rs +++ b/services/gam/src/canvas.rs @@ -1,7 +1,6 @@ use core::cmp::Ordering; use heapless::binary_heap::{BinaryHeap, Max}; use heapless::FnvIndexMap; -use heapless::consts::*; use graphics_server::*; use log::{error, info}; @@ -146,7 +145,7 @@ impl PartialEq for Canvas { impl Eq for Canvas {} -pub fn deface(gfx: &graphics_server::Gfx, canvases: &mut FnvIndexMap) -> Result<(), xous::Error> { +pub fn deface(gfx: &graphics_server::Gfx, canvases: &mut FnvIndexMap) -> Result<(), xous::Error> { // first check if any need defacing, if not, then we're done let mut needs_defacing = false; for (_, c) in canvases.iter() { @@ -179,19 +178,19 @@ pub fn deface(gfx: &graphics_server::Gfx, canvases: &mut FnvIndexMap, screen: Rectangle) -> FnvIndexMap { +pub fn recompute_canvases(canvases: FnvIndexMap, screen: Rectangle) -> FnvIndexMap { let debug = false; // first, sort canvases by trust_level. Canvas implements ord/eq based on the trust_level attribute // so jush pushing it into a max binary heap does the trick. if debug { info!("CANVAS: recompute canvas"); } - let mut sorted_clipregions: BinaryHeap = BinaryHeap::new(); + let mut sorted_clipregions: BinaryHeap = BinaryHeap::new(); for (&k, &c) in canvases.iter() { if debug { info!(" CANVAS: sorting gid {:?}, canvas {:?}", k, c);} sorted_clipregions.push(c).unwrap(); // always succeeds because incoming type is the same size } // now, descend through trust levels and compute intersections, putting the updated drawable states into higher_clipregions - let mut higher_clipregions: BinaryHeap = BinaryHeap::new(); + let mut higher_clipregions: BinaryHeap = BinaryHeap::new(); let mut trust_level: u8 = 255; // sorted_clipregions is a Max heap keyed on trust, so popping the elements off will return them sorted from most to least trusted if debug{info!("CANVAS: received screen argument of {:?}", screen);} @@ -227,7 +226,7 @@ pub fn recompute_canvases(canvases: FnvIndexMap, screen: Recta } // create a new index map out of the recomputed higher_clipregions - let mut map: FnvIndexMap = FnvIndexMap::new(); + let mut map: FnvIndexMap = FnvIndexMap::new(); if debug { info!("CANVAS: reconstituting index map");} for &c in higher_clipregions.iter() { if debug { info!(" CANVAS: inserting gid {:?}, canvas {:?}", c.gid(), c);} diff --git a/services/gam/src/main.rs b/services/gam/src/main.rs index 799e0d5b9..dec9f1346 100644 --- a/services/gam/src/main.rs +++ b/services/gam/src/main.rs @@ -18,7 +18,6 @@ use content_plugin_api::{ContentCanvasConnection, ContentCanvasApi}; use log::info; use heapless::FnvIndexMap; -use heapless::consts::*; use num_traits::FromPrimitive; use xous_ipc::Buffer; @@ -40,7 +39,7 @@ struct ChatLayout { gfx: graphics_server::Gfx, } impl ChatLayout { - pub fn init(xns: &xous_names::XousNames, trng: &trng::Trng, canvases: &mut FnvIndexMap) -> Result { + pub fn init(xns: &xous_names::XousNames, trng: &trng::Trng, canvases: &mut FnvIndexMap) -> Result { let gfx = graphics_server::Gfx::new(&xns).unwrap(); let screensize = gfx.screen_size().expect("Couldn't get screen size"); // get the height of various text regions to compute the layout @@ -85,7 +84,7 @@ impl ChatLayout { gfx, }) } - pub fn clear(&self, canvases: &mut FnvIndexMap) -> Result<(), xous::Error> { + pub fn clear(&self, canvases: &mut FnvIndexMap) -> Result<(), xous::Error> { let input_canvas = canvases.get(&self.input).expect("couldn't find input canvas"); let content_canvas = canvases.get(&self.content).expect("couldn't find content canvas"); let predictive_canvas = canvases.get(&self.predictive).expect("couldn't find predictive canvas"); @@ -108,7 +107,7 @@ impl ChatLayout { self.gfx.draw_rectangle(rect).expect("can't clear canvas"); Ok(()) } - pub fn resize_input(&mut self, new_height: i16, canvases: &mut FnvIndexMap) -> Result { + pub fn resize_input(&mut self, new_height: i16, canvases: &mut FnvIndexMap) -> Result { let input_canvas = canvases.get(&self.input).expect("couldn't find input canvas"); let predictive_canvas = canvases.get(&self.predictive).expect("couldn't find predictive canvas"); let status_canvas = canvases.get(&self.status).expect("couldn't find status canvas"); @@ -149,7 +148,7 @@ struct ModalCanvases { pub alert: Gid, } impl ModalCanvases { - fn init(trng: &trng::Trng, canvases: &mut FnvIndexMap) -> Result { + fn init(trng: &trng::Trng, canvases: &mut FnvIndexMap) -> Result { let password_canvas = Canvas::new( Rectangle::new_coords(-1, -1, -1, -1), 255, &trng, None @@ -196,7 +195,7 @@ fn xmain() -> ! { let screensize = gfx.screen_size().expect("Couldn't get screen size"); // a map of canvases accessable by Gid - let mut canvases: FnvIndexMap = FnvIndexMap::new(); + let mut canvases: FnvIndexMap = FnvIndexMap::new(); // let modallayout = ModalCanvases::init(trng, &mut canvases).expect("can't add modal layouts"); let mut chatlayout = ChatLayout::init(&xns, &trng, &mut canvases).expect("couldn't create chat layout"); chatlayout.clear(&mut canvases).expect("couldn't clear initial chatlayout"); diff --git a/services/graphics-server/Cargo.toml b/services/graphics-server/Cargo.toml index 003ccba6f..633c4bbe1 100644 --- a/services/graphics-server/Cargo.toml +++ b/services/graphics-server/Cargo.toml @@ -7,7 +7,7 @@ version = "0.1.0" [dependencies] blitstr-ref = {path = "../../imports/blitstr-ref"} -hash32 = "0.1.0" +hash32 = "0.2" hash32-derive = "0.1.0" keyboard = {path = "../keyboard"} log = "0.4" diff --git a/services/ime-plugin-shell/Cargo.toml b/services/ime-plugin-shell/Cargo.toml index 00f1991f3..149ebf0b1 100644 --- a/services/ime-plugin-shell/Cargo.toml +++ b/services/ime-plugin-shell/Cargo.toml @@ -6,7 +6,7 @@ name = "ime-plugin-shell" version = "0.1.0" [dependencies] -heapless = "0.5.6" +heapless = "0.7" ime-plugin-api = {path = "../ime-plugin-api"} log = "0.4" log-server = {path = "../log-server"} diff --git a/services/ime-plugin-shell/src/main.rs b/services/ime-plugin-shell/src/main.rs index 03eea077c..eee58d807 100644 --- a/services/ime-plugin-shell/src/main.rs +++ b/services/ime-plugin-shell/src/main.rs @@ -5,7 +5,6 @@ use ime_plugin_api::*; use log::{error, info}; use heapless::spsc::Queue; -use heapless::consts::U4; use xous_ipc::{String, Buffer}; use num_traits::FromPrimitive; @@ -20,7 +19,7 @@ fn xmain() -> ! { let ime_sh_sid = xns.register_name(xous::names::SERVER_NAME_IME_PLUGIN_SHELL).expect("can't register server"); log::trace!("registered with NS -- {:?}", ime_sh_sid); - let mut history: Queue, U4> = Queue::new(); // this has 2^4 elements = 16??? or does it just have 4 elements. + let mut history: Queue, 4> = Queue::new(); // this has 2^4 elements = 16??? or does it just have 4 elements. let history_max = 4; if false { // loads defaults into the predictor array to test things diff --git a/services/keyboard/Cargo.toml b/services/keyboard/Cargo.toml index 4fdc3adc8..d8b3f28bb 100644 --- a/services/keyboard/Cargo.toml +++ b/services/keyboard/Cargo.toml @@ -15,7 +15,7 @@ xous-names = {path = "../xous-names"} llio = {path = "../llio"} susres = {path = "../susres"} -heapless = "0.5.6" +heapless = "0.7" num-derive = {version = "0.3", default-features = false} num-traits = {version = "0.2", default-features = false} diff --git a/services/keyboard/src/main.rs b/services/keyboard/src/main.rs index 307756576..2aa2737f2 100644 --- a/services/keyboard/src/main.rs +++ b/services/keyboard/src/main.rs @@ -5,7 +5,6 @@ mod api; use api::*; use heapless::Vec; -use heapless::consts::*; use log::info; @@ -173,7 +172,6 @@ mod implementation { use susres::{RegManager, RegOrField, SuspendResume}; use heapless::Vec; - use heapless::consts::*; /// note: the code is structured to use at most 16 rows or 16 cols const KBD_ROWS: usize = 9; @@ -401,7 +399,7 @@ mod implementation { krs } - pub fn track_chord(&mut self, keyups: Option>, keydowns: Option>) -> Vec { + pub fn track_chord(&mut self, keyups: Option>, keydowns: Option>) -> Vec { /* Chording algorithm: @@ -420,7 +418,7 @@ mod implementation { } } log::trace!("self.chord: {:?}", self.chord); - let mut keystates: Vec = Vec::new(); + let mut keystates: Vec = Vec::new(); let now = self.ticktimer.elapsed_ms(); if was_idle && self.chord_active != 0 { @@ -537,7 +535,7 @@ mod implementation { keystates } - pub fn track_keys(&mut self, keyups: Option>, keydowns: Option>) -> Vec { + pub fn track_keys(&mut self, keyups: Option>, keydowns: Option>) -> Vec { /* "conventional" keyboard algorithm. The goals of this are to differentiate the cases of "shift", "alt", and "hold". @@ -548,7 +546,7 @@ mod implementation { then for all others, we note the down time, and compare it to the current time to determine if a "hold" modifier applies */ - let mut ks: Vec = Vec::new(); + let mut ks: Vec = Vec::new(); // first check for shift and alt keys if let Some(kds) = &keydowns { @@ -584,9 +582,9 @@ mod implementation { } } } - let keyups_noshift: Option> = + let keyups_noshift: Option> = if let Some(kus) = &keyups { - let mut ku_ns: Vec = Vec::new(); + let mut ku_ns: Vec = Vec::new(); for &rc in kus.iter() { match self.map { KeyMap::Azerty => { @@ -747,7 +745,6 @@ mod implementation { #[cfg(not(target_os = "none"))] mod implementation { use heapless::Vec; - use heapless::consts::*; use crate::api::*; //use crate::{map_dvorak, map_qwerty}; @@ -784,11 +781,11 @@ mod implementation { KeyRawStates::new() } - pub fn track_chord(&mut self, _keyups: Option>, _keydowns: Option>) -> Vec { + pub fn track_chord(&mut self, _keyups: Option>, _keydowns: Option>) -> Vec { Vec::new() } - pub fn track_keys(&mut self, _keyups: Option>, _keydowns: Option>) -> Vec { + pub fn track_keys(&mut self, _keyups: Option>, _keydowns: Option>) -> Vec { Vec::new() } @@ -935,8 +932,8 @@ fn xmain() -> ! { // and push(), len() etc. which doesn't really make sense to re-implement. But, maybe someone much // more clever than I could do extend RowColVec to have these feature and get rid of this ugly copy // step and make the rest of this routine operate natively on RowColVec types.... - let mut keyups_core: Vec = Vec::new(); - let mut keydowns_core: Vec = Vec::new(); + let mut keyups_core: Vec = Vec::new(); + let mut keydowns_core: Vec = Vec::new(); for i in 0..rawstates.keyups.len() { if let Some(rc) = rawstates.keyups.get(i) { keyups_core.push(rc).unwrap(); @@ -960,7 +957,7 @@ fn xmain() -> ! { // interpret scancodes // the track_* functions track the keyup/keydowns to modify keys with shift, hold, and chord state - let kc: Vec = match kbd.get_map() { + let kc: Vec = match kbd.get_map() { KeyMap::Braille => { kbd.track_chord(keyups, keydowns) }, diff --git a/services/rtc/Cargo.toml b/services/rtc/Cargo.toml index 0598e1f32..ae33948d4 100644 --- a/services/rtc/Cargo.toml +++ b/services/rtc/Cargo.toml @@ -7,7 +7,6 @@ description = "RTC server" [dependencies] xous = { path = "../../xous-rs" } -heapless = "0.5.6" log-server = { path = "../log-server" } ticktimer-server = { path = "../ticktimer-server" } xous-names = { path = "../xous-names" } diff --git a/services/shellchat/Cargo.toml b/services/shellchat/Cargo.toml index eeecc747b..73ea805e2 100644 --- a/services/shellchat/Cargo.toml +++ b/services/shellchat/Cargo.toml @@ -23,7 +23,7 @@ keyboard = {path = "../keyboard"} susres = {path = "../susres"} codec = {path = "../codec"} -heapless = "0.7.0" +heapless = "0.7" trng = {path = "../trng"} num-derive = {version = "0.3", default-features = false} diff --git a/services/shellchat/src/cmds/audio.rs b/services/shellchat/src/cmds/audio.rs index 1516b6403..da891b147 100644 --- a/services/shellchat/src/cmds/audio.rs +++ b/services/shellchat/src/cmds/audio.rs @@ -116,7 +116,7 @@ impl<'a> ShellCmdApi<'a> for Audio { } "info" => { write!(ret, "Loaded sample is {}kHz, {} channels, {} format, {} bytes", self.header.sampling_rate, self.header.channel_count, self.header.audio_format, self.raw_len_bytes).unwrap(); - } + }/* "dump" => { let mut temp = String::<9>::new(); for i in 0..8 { @@ -131,7 +131,7 @@ impl<'a> ShellCmdApi<'a> for Audio { ret.append(temp.to_str()).unwrap(); temp.clear(); } - } + }*/ _ => write!(ret, "{}", helpstring).unwrap(), } } else { diff --git a/services/skeleton/Cargo.toml b/services/skeleton/Cargo.toml index 4f3cd99d7..16ba81284 100644 --- a/services/skeleton/Cargo.toml +++ b/services/skeleton/Cargo.toml @@ -7,7 +7,6 @@ description = "Audio CODEC server" [dependencies] xous = { path = "../../xous-rs" } -heapless = "0.5.6" log-server = { path = "../log-server" } ticktimer-server = { path = "../ticktimer-server" } xous-names = { path = "../xous-names" } diff --git a/services/ticktimer-server/Cargo.toml b/services/ticktimer-server/Cargo.toml index be5572a2e..8febf5438 100644 --- a/services/ticktimer-server/Cargo.toml +++ b/services/ticktimer-server/Cargo.toml @@ -6,7 +6,7 @@ name = "ticktimer-server" version = "0.1.0" [dependencies] -heapless = "0.5" +heapless = "0.7" log = "0.4" log-server = {path = "../log-server"} xous = {path = "../../xous-rs"} diff --git a/services/ticktimer-server/src/main.rs b/services/ticktimer-server/src/main.rs index c4969cad3..6893ad146 100644 --- a/services/ticktimer-server/src/main.rs +++ b/services/ticktimer-server/src/main.rs @@ -4,7 +4,6 @@ mod api; use heapless::binary_heap::{BinaryHeap, Min}; -use heapless::consts::*; use log::{error, info}; @@ -447,7 +446,7 @@ use implementation::*; fn recalculate_sleep( ticktimer: &mut XousTickTimer, - sleep_heap: &mut BinaryHeap, + sleep_heap: &mut BinaryHeap, new: Option, ) { // If there's a sleep request ongoing now, grab it. @@ -490,7 +489,7 @@ fn recalculate_sleep( #[xous::xous_main] fn xmain() -> ! { - let mut sleep_heap: BinaryHeap = BinaryHeap::new(); + let mut sleep_heap: BinaryHeap = BinaryHeap::new(); log_server::init_wait().unwrap(); log::set_max_level(log::LevelFilter::Info); diff --git a/services/trng/Cargo.toml b/services/trng/Cargo.toml index 3d3e726da..6b76f6d26 100644 --- a/services/trng/Cargo.toml +++ b/services/trng/Cargo.toml @@ -7,7 +7,6 @@ description = "TRNG server" [dependencies] xous = { path = "../../xous-rs" } -heapless = "0.5.6" log-server = { path = "../log-server" } ticktimer-server = { path = "../ticktimer-server" } xous-names = { path = "../xous-names" } diff --git a/services/xous-names/Cargo.toml b/services/xous-names/Cargo.toml index 3fd193d41..0980607fe 100644 --- a/services/xous-names/Cargo.toml +++ b/services/xous-names/Cargo.toml @@ -6,9 +6,9 @@ name = "xous-names" version = "0.1.0" [dependencies] -hash32 = "0.1.0" +hash32 = "0.2" hash32-derive = "0.1.0" -heapless = "0.5" +heapless = "0.7" num-derive = {version = "0.3", default-features = false} num-traits = {version = "0.2", default-features = false} log = "0.4" diff --git a/services/xous-names/src/api.rs b/services/xous-names/src/api.rs index 5c1eab1db..374c86db8 100644 --- a/services/xous-names/src/api.rs +++ b/services/xous-names/src/api.rs @@ -49,7 +49,7 @@ pub(crate) struct AuthenticateRequest { #[derive(Debug, Copy, Clone)] pub struct XousServerName { value: [u8; 64], - length: u32, + length: usize, } impl Default for XousServerName { @@ -84,12 +84,13 @@ impl XousServerName { } // Set the string length to the length of the passed-in String, // or the maximum possible length. Which ever is smaller. - s.length = s.value.len().min(src.as_bytes().len()) as u32; + s.length = s.value.len().min(src.as_bytes().len()); // If the string is not valid, set its length to 0. if s.as_str().is_err() { s.length = 0; } + assert!(s.length < s.value.len(), "incorrect length derivation!"); s } @@ -127,7 +128,8 @@ impl core::fmt::Write for XousServerName { if b.len() > self.value.len() { Err(core::fmt::Error)?; } - self.length = b.len() as u32; + self.length = b.len(); + assert!(self.length < self.value.len(), "incorrect length derivation!"); // Copy the string into this variable for (dest, src) in self.value.iter_mut().zip(s.bytes()) { @@ -148,6 +150,7 @@ impl hash32::Hash for XousServerName { where H: Hasher, { + assert!(self.length < self.value.len(), "incorret length on hash!"); Hash::hash(&self.value[..self.length as usize], state); Hash::hash(&self.length, state) } @@ -155,6 +158,8 @@ impl hash32::Hash for XousServerName { impl PartialEq for XousServerName { fn eq(&self, other: &Self) -> bool { + assert!(self.length < self.value.len(), "incorret length on Eq!"); + assert!(other.length < other.value.len(), "incorrect length on Eq (other)!"); self.value[..self.length as usize] == other.value[..other.length as usize] && self.length == other.length } diff --git a/services/xous-names/src/main.rs b/services/xous-names/src/main.rs index 9e04a072d..3acbaec2f 100644 --- a/services/xous-names/src/main.rs +++ b/services/xous-names/src/main.rs @@ -6,8 +6,6 @@ extern crate hash32_derive; mod api; use api::*; -// use heapless::String; -use heapless::consts::*; use heapless::FnvIndexMap; use num_traits::FromPrimitive; @@ -61,9 +59,9 @@ mod implementation { #[xous::xous_main] fn xmain() -> ! { use implementation::*; - let debug1 = false; + let debug1 = true; log_server::init_wait().unwrap(); - log::set_max_level(log::LevelFilter::Info); + log::set_max_level(log::LevelFilter::Trace); info!("my PID is {}", xous::process::id()); let name_server = xous::create_server_with_address(b"xous-name-server") @@ -72,7 +70,7 @@ fn xmain() -> ! { let d11ctimeout = D11cTimeout::new(); // this limits the number of available servers to be requested to 128...! - let mut name_table = FnvIndexMap::<_, _, U128>::new(); + let mut name_table = FnvIndexMap::::new(); info!("started"); loop { @@ -82,8 +80,8 @@ fn xmain() -> ! { Some(api::Opcode::Register) => { let mem = msg.body.memory_message_mut().unwrap(); let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) }; - let xous_string = buffer.as_flat::, _>().unwrap(); - let name = XousServerName::from_str(xous_string.as_str()); + let xous_string = buffer.to_original::, _>().unwrap(); + let name = XousServerName::from_str(xous_string.as_str().expect("couldn't convert server name to string")); let response: api::Return; @@ -108,8 +106,8 @@ fn xmain() -> ! { Some(api::Opcode::Lookup) => { let mem = msg.body.memory_message_mut().unwrap(); let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) }; - let name_string = buffer.as_flat::, _>().unwrap(); - let name = XousServerName::from_str(name_string.as_str()); + let name_string = buffer.to_original::, _>().unwrap(); + let name = XousServerName::from_str(name_string.as_str().expect("couldn't convert server name to string")); if debug1{info!("Lookup request for '{}'", name);} let response: api::Return; if let Some(server_sid) = name_table.get(&name) { @@ -146,7 +144,7 @@ fn xmain() -> ! { // no authenticate remedy currently supported, but we'd put that code somewhere around here eventually. let (c1, c2, c3, c4) = xous::create_server_id().unwrap().to_u32(); let auth_request = AuthenticateRequest { - name: String::<64>::from_str(name_string.as_str()), + name: String::<64>::from_str(name_string.as_str().expect("couldn't convert server name to string")), pubkey_id: [0; 20], // placeholder challenge: [c1, c2, c3, c4], };