diff --git a/Cargo.lock b/Cargo.lock index b62d05029..5ddedfe75 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,27 +64,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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30302dda7a66f8c55932ebf208f7def840743ff64d495e9ceffcd97c18f11d39" -dependencies = [ - "cortex-m", -] - [[package]] name = "atty" version = "0.2.14" @@ -116,15 +95,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "bare-metal" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" -dependencies = [ - "rustc_version", -] - [[package]] name = "base64" version = "0.13.0" @@ -188,12 +158,6 @@ dependencies = [ "which 3.1.1", ] -[[package]] -name = "bitfield" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" - [[package]] name = "bitflags" version = "1.2.1" @@ -222,7 +186,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] @@ -363,7 +327,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] @@ -477,18 +441,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" -[[package]] -name = "cortex-m" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643a210c1bdc23d0db511e2a576082f4ff4dcae9d0c37f50b431b8f8439d6d6b" -dependencies = [ - "bare-metal", - "bitfield", - "embedded-hal", - "volatile-register", -] - [[package]] name = "cpufeatures" version = "0.1.4" @@ -579,7 +531,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] @@ -610,16 +562,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "embedded-hal" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db184d3fa27bc7a2344250394c0264144dfe0bc81a4401801dcb964b8dd172ad" -dependencies = [ - "nb 0.1.3", - "void", -] - [[package]] name = "encoding_rs" version = "0.8.28" @@ -754,7 +696,6 @@ dependencies = [ "content-plugin-api", "enum_dispatch", "graphics-server", - "heapless 0.7.0", "ime-plugin-api", "ime-plugin-shell", "keyboard", @@ -773,24 +714,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" @@ -829,8 +752,6 @@ name = "graphics-server" version = "0.1.0" dependencies = [ "blitstr-ref", - "hash32 0.2.1", - "hash32-derive", "keyboard", "log", "log-server", @@ -846,15 +767,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" @@ -875,29 +787,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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94c13b78b595d2adbd708bce276664f1047f98fc32ddbf463b4c191158334a6" -dependencies = [ - "atomic-polyfill", - "hash32 0.2.1", - "stable_deref_trait", -] - [[package]] name = "hermit-abi" version = "0.1.18" @@ -993,7 +882,6 @@ dependencies = [ name = "ime-plugin-shell" version = "0.1.0" dependencies = [ - "heapless 0.5.6", "ime-plugin-api", "log", "log-server", @@ -1037,7 +925,6 @@ dependencies = [ name = "keyboard" version = "0.1.0" dependencies = [ - "heapless 0.7.0", "llio", "log", "log-server", @@ -1084,7 +971,6 @@ dependencies = [ name = "llio" version = "0.1.0" dependencies = [ - "heapless 0.7.0", "log", "log-server", "num-derive", @@ -1174,21 +1060,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "nb" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" -dependencies = [ - "nb 1.0.0", -] - -[[package]] -name = "nb" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" - [[package]] name = "nix" version = "0.20.0" @@ -1689,15 +1560,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1956f5517128a2b6f23ab2dadf1a976f4f5b27962e7724c2bf3d45e539ec098c" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - [[package]] name = "ryu" version = "1.0.5" @@ -1732,21 +1594,6 @@ dependencies = [ "version-compare", ] -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" version = "1.0.123" @@ -1794,7 +1641,6 @@ dependencies = [ "engine-sha512", "gam", "graphics-server", - "heapless 0.7.0", "hex", "ime-plugin-api", "ime-plugin-shell", @@ -1866,12 +1712,6 @@ dependencies = [ "xous-names", ] -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "status" version = "0.1.0" @@ -2052,7 +1892,6 @@ dependencies = [ name = "ticktimer-server" version = "0.1.0" dependencies = [ - "heapless 0.7.0", "log", "log-server", "num-derive", @@ -2155,12 +1994,6 @@ dependencies = [ "svd2utra", ] -[[package]] -name = "vcell" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" - [[package]] name = "vec_map" version = "0.8.2" @@ -2189,21 +2022,6 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - -[[package]] -name = "volatile-register" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d67cb4616d99b940db1d6bd28844ff97108b498a6ca850e5b6191a532063286" -dependencies = [ - "vcell", -] - [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" @@ -2509,7 +2327,7 @@ dependencies = [ name = "xous-names" version = "0.1.0" dependencies = [ - "hash32 0.2.1", + "hash32", "hash32-derive", "log", "log-server", diff --git a/services/com/Cargo.toml b/services/com/Cargo.toml index 505590ac2..f4f7a5a47 100644 --- a/services/com/Cargo.toml +++ b/services/com/Cargo.toml @@ -7,7 +7,6 @@ version = "0.1.0" [dependencies] com_rs-ref = {path = "../../imports/com_rs-ref"} -#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 00c122cd2..a0b8837f1 100644 --- a/services/com/src/main.rs +++ b/services/com/src/main.rs @@ -76,9 +76,6 @@ mod implementation { ticktimer, workqueue: Vec::new(), busy: false, - //tx_queue: Vec::new(), - //rx_queue: Vec::new(), - //in_progress: false, stby_current: None, }; @@ -148,7 +145,7 @@ mod implementation { pub fn process_queue(&mut self) -> Option { if !self.workqueue.is_empty() && !self.busy { self.busy = true; - let work_descriptor = self.workqueue.swap_remove(0); // not quite FIFO, but Vec does not support FIFO (best we can do with "heapless") + let work_descriptor = self.workqueue.remove(0); let ret = if work_descriptor.work.verb == ComState::STAT.verb { let stats = self.get_battstats(); match return_battstats(work_descriptor.sender, stats) { @@ -204,10 +201,8 @@ mod implementation { use com_rs::*; use log::error; - use heapless::Vec; - pub struct XousCom { - pub workqueue: Vec, + pub workqueue: Vec, busy: bool, } @@ -242,7 +237,7 @@ mod implementation { pub fn process_queue(&mut self) -> Option { if !self.workqueue.is_empty() && !self.busy { self.busy = true; - let work_descriptor = self.workqueue.swap_remove(0); // not quite FIFO, but Vec does not support FIFO (best we can do with "heapless") + let work_descriptor = self.workqueue.remove(0); let ret = if work_descriptor.work.verb == ComState::STAT.verb { let stats = self.get_battstats(); match return_battstats(work_descriptor.sender, stats) { diff --git a/services/gam/Cargo.toml b/services/gam/Cargo.toml index 293535bd3..db4f4dadd 100644 --- a/services/gam/Cargo.toml +++ b/services/gam/Cargo.toml @@ -10,7 +10,6 @@ blitstr-ref = {path = "../../imports/blitstr-ref"} com = {path = "../com"} # used by the backlight setting on the main menu thread content-plugin-api = {path = "../content-plugin-api"} graphics-server = {path = "../graphics-server"} -heapless = "0.7" # used for creating a sortable heap of canvas objects ime-plugin-api = {path = "../ime-plugin-api"} ime-plugin-shell = {path = "../ime-plugin-shell"} keyboard = {path = "../keyboard"} diff --git a/services/gam/src/canvas.rs b/services/gam/src/canvas.rs index ee3ca548d..f5ccf10a8 100644 --- a/services/gam/src/canvas.rs +++ b/services/gam/src/canvas.rs @@ -1,6 +1,7 @@ +use std::collections::HashMap; +use std::collections::BinaryHeap; + use core::cmp::Ordering; -use heapless::binary_heap::{BinaryHeap, Max}; -use heapless::FnvIndexMap; use graphics_server::*; use log::{error, info}; @@ -145,7 +146,7 @@ impl PartialEq for Canvas { impl Eq for Canvas {} -pub fn deface(gfx: &graphics_server::Gfx, trng: &trng::Trng, canvases: &mut FnvIndexMap) -> bool { +pub fn deface(gfx: &graphics_server::Gfx, trng: &trng::Trng, canvases: &mut HashMap) -> bool { // first check if any need defacing, if not, then we're done let mut needs_defacing = false; let mut defaced = false; // this is set if any drawing actually happens @@ -230,19 +231,19 @@ pub fn deface(gfx: &graphics_server::Gfx, trng: &trng::Trng, canvases: &mut FnvI } // we use the "screen" parameter to determine when we can turn off drawing to canvases that are off-screen -pub fn recompute_canvases(canvases: &FnvIndexMap, screen: Rectangle) -> FnvIndexMap { +pub fn recompute_canvases(canvases: &HashMap, screen: Rectangle) -> HashMap { 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 + sorted_clipregions.push(c); // 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);} @@ -271,18 +272,18 @@ pub fn recompute_canvases(canvases: &FnvIndexMap, screen: Recta } } canvas.set_drawable(drawable); - higher_clipregions.push(canvas).unwrap(); + higher_clipregions.push(canvas); } else { break; } } // create a new index map out of the recomputed higher_clipregions - let mut map: FnvIndexMap = FnvIndexMap::new(); + let mut map: HashMap = HashMap::new(); if debug { info!("CANVAS: reconstituting index map");} for &c in higher_clipregions.iter() { if debug { info!(" CANVAS: inserting gid {:?}, canvas {:?}", c.gid(), c);} - map.insert(c.gid(), c).unwrap(); + map.insert(c.gid(), c); } map diff --git a/services/gam/src/layouts.rs b/services/gam/src/layouts.rs index c5da340fb..ad3d388a6 100644 --- a/services/gam/src/layouts.rs +++ b/services/gam/src/layouts.rs @@ -1,6 +1,7 @@ +use std::collections::HashMap; + use crate::Canvas; -use heapless::FnvIndexMap; use blitstr_ref as blitstr; use blitstr::GlyphStyle; use graphics_server::*; @@ -26,7 +27,7 @@ pub(crate) struct ChatLayout { impl ChatLayout { // pass in the status canvas so we can size around it, but we can't draw on it pub fn init(gfx: &graphics_server::Gfx, trng: &trng::Trng, base_trust: u8, - status_canvas: &Canvas, canvases: &mut FnvIndexMap) -> Result { + status_canvas: &Canvas, canvases: &mut HashMap) -> Result { let screensize = gfx.screen_size().expect("Couldn't get screen size"); // get the height of various text regions to compute the layout let small_height: i16 = gfx.glyph_height_hint(GlyphStyle::Small).expect("couldn't get glyph height") as i16; @@ -46,20 +47,20 @@ impl ChatLayout { checked_base_trust - 2, &trng, None ).expect("couldn't create predictive text canvas"); - canvases.insert(predictive_canvas.gid(), predictive_canvas).expect("couldn't store predictive canvas"); + canvases.insert(predictive_canvas.gid(), predictive_canvas); let min_input_height = regular_height + margin*2; let input_canvas = Canvas::new( Rectangle::new_v_stack(predictive_canvas.clip_rect(), -min_input_height), checked_base_trust - 2, &trng, None ).expect("couldn't create input text canvas"); - canvases.insert(input_canvas.gid(), input_canvas).expect("couldn't store input canvas"); + canvases.insert(input_canvas.gid(), input_canvas); let content_canvas = Canvas::new( Rectangle::new_v_span(status_canvas.clip_rect(), input_canvas.clip_rect()), checked_base_trust / 2, &trng, None ).expect("couldn't create content canvas"); - canvases.insert(content_canvas.gid(), content_canvas).expect("can't store content canvas"); + canvases.insert(content_canvas.gid(), content_canvas); Ok(ChatLayout { content: content_canvas.gid(), @@ -78,7 +79,7 @@ impl LayoutApi for ChatLayout { fn behavior(&self) -> LayoutBehavior { LayoutBehavior::App } - fn clear(&self, gfx: &graphics_server::Gfx, canvases: &mut FnvIndexMap) -> Result<(), xous::Error> { + fn clear(&self, gfx: &graphics_server::Gfx, canvases: &mut HashMap) -> 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"); @@ -96,7 +97,7 @@ impl LayoutApi for ChatLayout { gfx.draw_rectangle(rect).expect("can't clear canvas"); Ok(()) } - fn resize_height(&mut self, gfx: &graphics_server::Gfx, new_height: i16, status_canvas: &Canvas, canvases: &mut FnvIndexMap) -> Result { + fn resize_height(&mut self, gfx: &graphics_server::Gfx, new_height: i16, status_canvas: &Canvas, canvases: &mut HashMap) -> 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"); @@ -136,7 +137,7 @@ impl LayoutApi for ChatLayout { fn get_content_canvas(&self) -> Gid { self.content } - fn set_visibility_state(&mut self, onscreen: bool, canvases: &mut FnvIndexMap) { + fn set_visibility_state(&mut self, onscreen: bool, canvases: &mut HashMap) { log::debug!("request modal to onscreen {} from self.visible {}", onscreen, self.visible); if onscreen == self.visible { log::trace!("chatlayout: no change to visibility, moving on"); @@ -179,7 +180,7 @@ pub(crate) struct MenuLayout { visible: bool, } impl MenuLayout { - pub fn init(gfx: &graphics_server::Gfx, trng: &trng::Trng, base_trust: u8, canvases: &mut FnvIndexMap) -> Result { + pub fn init(gfx: &graphics_server::Gfx, trng: &trng::Trng, base_trust: u8, canvases: &mut HashMap) -> Result { let screensize = gfx.screen_size().expect("Couldn't get screen size"); // get the height of various text regions to compute the layout let height: i16 = gfx.glyph_height_hint(GlyphStyle::Regular).expect("couldn't get glyph height") as i16; @@ -198,7 +199,7 @@ impl MenuLayout { Rectangle::new_coords(MENU_X_PAD, MENU_Y_PAD, screensize.x - MENU_X_PAD, MENU_Y_PAD + height), checked_base_trust - 1, &trng, None ).expect("couldn't create menu canvas"); - canvases.insert(menu_canvas.gid(), menu_canvas).expect("can't store menu canvas"); + canvases.insert(menu_canvas.gid(), menu_canvas); Ok(MenuLayout { menu: menu_canvas.gid(), @@ -215,14 +216,14 @@ impl LayoutApi for MenuLayout { fn behavior(&self) -> LayoutBehavior { LayoutBehavior::Alert } - fn clear(&self, gfx: &graphics_server::Gfx, canvases: &mut FnvIndexMap) -> Result<(), xous::Error> { + fn clear(&self, gfx: &graphics_server::Gfx, canvases: &mut HashMap) -> Result<(), xous::Error> { let menu_canvas = canvases.get(&self.menu).expect("couldn't find menu canvas"); let mut rect = menu_canvas.clip_rect(); rect.style = DrawStyle {fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0,}; gfx.draw_rectangle(rect) } - fn resize_height(&mut self, _gfx: &graphics_server::Gfx, new_height: i16, _status_canvas: &Canvas, canvases: &mut FnvIndexMap) -> Result { + fn resize_height(&mut self, _gfx: &graphics_server::Gfx, new_height: i16, _status_canvas: &Canvas, canvases: &mut HashMap) -> Result { let menu_canvas = canvases.get_mut(&self.menu).expect("couldn't find menu canvas"); let orig_rect = menu_canvas.clip_rect(); @@ -243,7 +244,7 @@ impl LayoutApi for MenuLayout { fn get_content_canvas(&self) -> Gid { self.menu } - fn set_visibility_state(&mut self, onscreen: bool, canvases: &mut FnvIndexMap) { + fn set_visibility_state(&mut self, onscreen: bool, canvases: &mut HashMap) { log::debug!("menu entering set_visibilty_state, self.visible {}, onscreen {}", self.visible, onscreen); if onscreen == self.visible { // nothing to do @@ -281,7 +282,7 @@ pub(crate) struct ModalLayout { modal_y_max: i16, } impl ModalLayout { - pub fn init(gfx: &graphics_server::Gfx, trng: &trng::Trng, base_trust: u8, canvases: &mut FnvIndexMap) -> Result { + pub fn init(gfx: &graphics_server::Gfx, trng: &trng::Trng, base_trust: u8, canvases: &mut HashMap) -> Result { let screensize = gfx.screen_size().expect("Couldn't get screen size"); // get the height of various text regions to compute the layout let height: i16 = gfx.glyph_height_hint(GlyphStyle::Regular).expect("couldn't get glyph height") as i16; @@ -299,7 +300,7 @@ impl ModalLayout { Rectangle::new_coords(MODAL_X_PAD, MODAL_Y_PAD, screensize.x - MODAL_X_PAD, crate::api::MODAL_Y_MAX), checked_base_trust, &trng, None ).expect("couldn't create modal canvas"); - canvases.insert(modal_canvas.gid(), modal_canvas).expect("can't store modal canvas"); + canvases.insert(modal_canvas.gid(), modal_canvas); Ok(ModalLayout { modal: modal_canvas.gid(), @@ -317,14 +318,14 @@ impl LayoutApi for ModalLayout { fn behavior(&self) -> LayoutBehavior { LayoutBehavior::Alert } - fn clear(&self, gfx: &graphics_server::Gfx, canvases: &mut FnvIndexMap) -> Result<(), xous::Error> { + fn clear(&self, gfx: &graphics_server::Gfx, canvases: &mut HashMap) -> Result<(), xous::Error> { let modal_canvas = canvases.get(&self.modal).expect("couldn't find modal canvas"); let mut rect = modal_canvas.clip_rect(); rect.style = DrawStyle {fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0,}; gfx.draw_rectangle(rect) } - fn resize_height(&mut self, _gfx: &graphics_server::Gfx, new_height: i16, _status_canvas: &Canvas, canvases: &mut FnvIndexMap) -> Result { + fn resize_height(&mut self, _gfx: &graphics_server::Gfx, new_height: i16, _status_canvas: &Canvas, canvases: &mut HashMap) -> Result { let modal_canvas = canvases.get_mut(&self.modal).expect("couldn't find modal canvas"); let orig_rect = modal_canvas.clip_rect(); @@ -345,7 +346,7 @@ impl LayoutApi for ModalLayout { fn get_content_canvas(&self) -> Gid { self.modal } - fn set_visibility_state(&mut self, onscreen: bool, canvases: &mut FnvIndexMap) { + fn set_visibility_state(&mut self, onscreen: bool, canvases: &mut HashMap) { log::debug!("modal box entering set_visibilty_state, self.visible {}, onscreen {}", self.visible, onscreen); if onscreen == self.visible { // nothing to do diff --git a/services/gam/src/main.rs b/services/gam/src/main.rs index 18d882266..5ab211732 100644 --- a/services/gam/src/main.rs +++ b/services/gam/src/main.rs @@ -16,7 +16,7 @@ use ime_plugin_api::{ImeFrontEndApi, ImefDescriptor}; use log::info; -use heapless::FnvIndexMap; +use std::collections::HashMap; use num_traits::*; use xous_ipc::{Buffer, String}; @@ -40,16 +40,16 @@ pub(crate) enum LayoutBehavior { #[enum_dispatch] pub(crate) trait LayoutApi { - fn clear(&self, gfx: &graphics_server::Gfx, canvases: &mut FnvIndexMap) -> Result<(), xous::Error>; + fn clear(&self, gfx: &graphics_server::Gfx, canvases: &mut HashMap) -> Result<(), xous::Error>; // for Chats, this resizes the height of the input area; for menus, it resizes the overall height - fn resize_height(&mut self, gfx: &graphics_server::Gfx, new_height: i16, status_canvas: &Canvas, canvases: &mut FnvIndexMap) -> Result; + fn resize_height(&mut self, gfx: &graphics_server::Gfx, new_height: i16, status_canvas: &Canvas, canvases: &mut HashMap) -> Result; fn get_input_canvas(&self) -> Option { None } fn get_prediction_canvas(&self) -> Option { None } fn get_content_canvas(&self) -> Gid; // layouts always have a content canvas // when the argument is true, the context is moved "onscreen" by moving the canvases into the screen clipping rectangle // when false, the context is moved "offscreen" by moving the canvases outside the screen clipping rectangle // note that this visibility state is an independent variable from the trust level draw-ability - fn set_visibility_state(&mut self, onscreen: bool, canvases: &mut FnvIndexMap); + fn set_visibility_state(&mut self, onscreen: bool, canvases: &mut HashMap); fn behavior(&self) -> LayoutBehavior; } @@ -147,7 +147,7 @@ impl ContextManager { gfx: &graphics_server::Gfx, trng: &trng::Trng, status_canvas: &Canvas, - canvases: &mut FnvIndexMap, + canvases: &mut HashMap, trust_level: u8, registration: UxRegistration) -> Option<[u32; 4]> { @@ -277,7 +277,7 @@ impl ContextManager { gam_token: [u32; 4], new_height: i16, status_canvas: &Canvas, - canvases: &mut FnvIndexMap) -> Option { + canvases: &mut HashMap) -> Option { for maybe_context in self.contexts.iter_mut() { if let Some(context) = maybe_context { @@ -295,7 +295,7 @@ impl ContextManager { app_token: [u32; 4], new_height: i16, status_canvas: &Canvas, - canvases: &mut FnvIndexMap) -> Option { + canvases: &mut HashMap) -> Option { for maybe_context in self.contexts.iter_mut() { if let Some(context) = maybe_context { @@ -329,7 +329,7 @@ impl ContextManager { } pub(crate) fn activate(&mut self, gfx: &graphics_server::Gfx, - canvases: &mut FnvIndexMap, + canvases: &mut HashMap, token: [u32; 4], clear: bool, ) { @@ -438,7 +438,7 @@ impl ContextManager { } pub(crate) fn revert_focus(&mut self, gfx: &graphics_server::Gfx, - canvases: &mut FnvIndexMap, + canvases: &mut HashMap, ) { if let Some(last) = self.last_context { self.activate(gfx, canvases, last, false); @@ -494,7 +494,7 @@ impl ContextManager { } pub(crate) fn key_event(&mut self, keys: [char; 4], gfx: &graphics_server::Gfx, - canvases: &mut FnvIndexMap, + canvases: &mut HashMap, ) { // only pop up the menu if the primary key hit is the menu key (search just the first entry of keys); reject multi-key hits // only pop up the menu if it isn't already popped up @@ -559,7 +559,7 @@ impl ContextManager { pub(crate) fn raise_menu(&mut self, name: &str, gfx: &graphics_server::Gfx, - canvases: &mut FnvIndexMap, + canvases: &mut HashMap, ) { log::debug!("looking for menu {}", name); if let Some(token) = self.find_app_token_by_name(name) { @@ -607,7 +607,7 @@ fn xmain() -> ! { let mut context_mgr = ContextManager::new(&xns); // a map of canvases accessable by Gid - let mut canvases: FnvIndexMap = FnvIndexMap::new(); + let mut canvases: HashMap = HashMap::new(); let screensize = gfx.screen_size().expect("Couldn't get screen size"); let small_height: i16 = gfx.glyph_height_hint(GlyphStyle::Small).expect("couldn't get glyph height") as i16; @@ -617,7 +617,7 @@ fn xmain() -> ! { Rectangle::new_coords(0, 0, screensize.x, small_height * 2), 255, &trng, None ).expect("couldn't create status canvas"); - canvases.insert(status_canvas.gid(), status_canvas).expect("can't store status canvus"); + canvases.insert(status_canvas.gid(), status_canvas); canvases = recompute_canvases(&canvases, Rectangle::new(Point::new(0, 0), screensize)); // initialize the status bar -- this needs to start late, after the IMEF and most other things are initialized diff --git a/services/graphics-server/Cargo.toml b/services/graphics-server/Cargo.toml index ae0cc8106..2498a576d 100644 --- a/services/graphics-server/Cargo.toml +++ b/services/graphics-server/Cargo.toml @@ -7,8 +7,6 @@ version = "0.1.0" [dependencies] blitstr-ref = {path = "../../imports/blitstr-ref"} -hash32 = "0.2" -hash32-derive = "0.1.0" keyboard = {path = "../keyboard"} log = "0.4" log-server = {path = "../log-server"} diff --git a/services/graphics-server/src/api.rs b/services/graphics-server/src/api.rs index 7e7423cac..9f1d75484 100644 --- a/services/graphics-server/src/api.rs +++ b/services/graphics-server/src/api.rs @@ -24,7 +24,7 @@ pub mod text; pub use text::*; -use hash32::{Hash, Hasher}; +use std::hash::{Hash, Hasher}; //////////////// IPC APIs #[derive(Debug, Copy, Clone, PartialEq, Eq, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] @@ -36,7 +36,7 @@ impl Gid { pub fn new(id: [u32; 4]) -> Self { Gid{gid: id} } pub fn gid(&self) -> [u32; 4] { self.gid } } -impl hash32::Hash for Gid { +impl Hash for Gid { fn hash(&self, state: &mut H) where H: Hasher, diff --git a/services/ime-plugin-shell/Cargo.toml b/services/ime-plugin-shell/Cargo.toml index 00f1991f3..7e09672f8 100644 --- a/services/ime-plugin-shell/Cargo.toml +++ b/services/ime-plugin-shell/Cargo.toml @@ -6,7 +6,6 @@ name = "ime-plugin-shell" version = "0.1.0" [dependencies] -heapless = "0.5.6" 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 2cc548b4b..640d9db06 100644 --- a/services/ime-plugin-shell/src/main.rs +++ b/services/ime-plugin-shell/src/main.rs @@ -4,8 +4,6 @@ use ime_plugin_api::*; use log::{error, info}; -use heapless::spsc::Queue; -use heapless::consts::*; use xous_ipc::{String, Buffer}; use num_traits::FromPrimitive; @@ -21,20 +19,20 @@ fn xmain() -> ! { let ime_sh_sid = xns.register_name(ime_plugin_shell::SERVER_NAME_IME_PLUGIN_SHELL, Some(1)).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: Vec> = Vec::new(); let history_max = 4; if false { // loads defaults into the predictor array to test things use core::fmt::Write as CoreWriter; let mut test1: String::<64> = String::new(); write!(test1, "This〰should overflow the box").unwrap(); - history.enqueue(test1).unwrap(); + history.push(test1); let mut test2: String::<64> = String::new(); write!(test2, "Another string too long").unwrap(); - history.enqueue(test2).unwrap(); + history.push(test2); let mut test3: String::<64> = String::new(); write!(test3, "未雨绸缪").unwrap(); - history.enqueue(test3).unwrap(); + history.push(test3); } let mytriggers = PredictionTriggers { @@ -61,9 +59,9 @@ fn xmain() -> ! { write!(local_s, "{}", s.as_str()).expect("overflowed history variable"); log::trace!("storing history value | {}", s.as_str()); if history.len() == history_max { - history.dequeue().expect("couldn't dequeue history"); + history.remove(0); } - history.enqueue(local_s).expect("couldn't store history"); + history.push(local_s); log::trace!("history has length {}", history.len()); } Some(Opcode::Prediction) => { @@ -108,15 +106,9 @@ fn xmain() -> ! { } Some(Opcode::Unpick) => { if history.len() == 1 { - history.dequeue().expect("couldn't dequeue in Unpick (1)"); + history.remove(0); } else if history.len() > 1 { - // rotate everything around except the last entry - for _ in 0 .. history.len() - 1 { - let s = history.dequeue().expect("couldn't dequee in Unpick (>1)"); - history.enqueue(s).expect("couldn't enqueue in Unpick"); - } - // discard the last entry - history.dequeue().expect("couldn't dequeue in Unpick (>1 last)"); + let _ = history.pop(); // discard the last entry } // in case of 0 length, do nothing } diff --git a/services/keyboard/Cargo.toml b/services/keyboard/Cargo.toml index d8b3f28bb..cb5a6e0f8 100644 --- a/services/keyboard/Cargo.toml +++ b/services/keyboard/Cargo.toml @@ -15,8 +15,6 @@ xous-names = {path = "../xous-names"} llio = {path = "../llio"} susres = {path = "../susres"} -heapless = "0.7" - num-derive = {version = "0.3", default-features = false} num-traits = {version = "0.2", default-features = false} rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]} diff --git a/services/keyboard/src/main.rs b/services/keyboard/src/main.rs index 1e23797b4..774167473 100644 --- a/services/keyboard/src/main.rs +++ b/services/keyboard/src/main.rs @@ -4,8 +4,6 @@ mod api; use api::*; -use heapless::Vec; - use log::info; use num_traits::*; @@ -170,8 +168,6 @@ mod implementation { use num_traits::ToPrimitive; use susres::{RegManager, RegOrField, SuspendResume}; - use heapless::Vec; - /// note: the code is structured to use at most 16 rows or 16 cols const KBD_ROWS: usize = 9; const KBD_COLS: usize = 10; @@ -411,7 +407,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: @@ -430,7 +426,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 { @@ -501,31 +497,31 @@ mod implementation { _ => None, }; if let Some(key) = keychar { - keystates.push(key).unwrap(); + keystates.push(key); } let up = self.chord[6][4]; - if up { keystates.push('↑').unwrap(); } + if up { keystates.push('↑'); } let left = self.chord[8][3]; - if left { keystates.push('←').unwrap(); } + if left { keystates.push('←'); } let right = self.chord[3][6]; - if right { keystates.push('→').unwrap(); } + if right { keystates.push('→'); } let down = self.chord[8][2]; - if down { keystates.push('↓').unwrap(); } + if down { keystates.push('↓'); } let center = self.chord[5][2]; - if center { keystates.push('∴').unwrap(); } + if center { keystates.push('∴'); } let space = self.chord[2][3]; - if space { keystates.push(' ').unwrap(); } + if space { keystates.push(' '); } let esc = self.chord[8][6]; let bs: char = 0x8_u8.into(); // back space - if esc { keystates.push(bs).unwrap(); } + if esc { keystates.push(bs); } let func = self.chord[7][5]; let cr: char = 0xd_u8.into(); // carriage return - if func { keystates.push(cr).unwrap(); } + if func { keystates.push(cr); } log::trace!("up {}, left {}, right {}, down, {}, center, {}, space {}, esc {}, func {}", up, left, right, down, center, space, esc, func); @@ -547,7 +543,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". @@ -558,7 +554,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 { @@ -594,9 +590,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 => { @@ -611,7 +607,7 @@ mod implementation { } self.shift_down = false; } else { - ku_ns.push(RowCol{r: rc.r as _, c: rc.c as _}).unwrap(); + ku_ns.push(RowCol{r: rc.r as _, c: rc.c as _}); } }, _ => { // the rest just have one color of shift @@ -625,7 +621,7 @@ mod implementation { self.shift_down = false; } else { //info!("adding non-shift entry {:?}", rc); - ku_ns.push(RowCol{r: rc.r as _, c: rc.c as _}).unwrap(); + ku_ns.push(RowCol{r: rc.r as _, c: rc.c as _}); } } } @@ -663,8 +659,6 @@ mod implementation { hold = false; } - fn report_ok(k: char) -> Result<(), ()> { log::error!("ran out of space saving char: {}", k); Ok(()) } - if let Some(kus) = &keyups_noshift { for &rc in kus.iter() { // info!("interpreting keyups_noshift entry {:?}", rc); @@ -688,38 +682,38 @@ mod implementation { KeyMap::Azerty => { if self.shift_down || self.shift_up { if let Some(shiftcode) = code.shift { - ks.push(shiftcode).or_else(report_ok).ok(); + ks.push(shiftcode); } else if let Some(keycode) = code.key { - ks.push(keycode).or_else(report_ok).ok(); + ks.push(keycode); } self.shift_down = false; self.shift_up = false; } else if self.alt_down || self.alt_up { if let Some(altcode) = code.alt { - ks.push(altcode).or_else(report_ok).ok(); + ks.push(altcode); } else if let Some(shiftcode) = code.shift { - ks.push(shiftcode).or_else(report_ok).ok(); + ks.push(shiftcode); } else if let Some(keycode) = code.key { - ks.push(keycode).or_else(report_ok).ok(); + ks.push(keycode); } self.alt_down = false; self.alt_up = false; } else if hold { if let Some(holdcode) = code.hold { - ks.push(holdcode).or_else(report_ok).ok(); + ks.push(holdcode); } } else { if let Some(keycode) = code.key { - ks.push(keycode).or_else(report_ok).ok(); + ks.push(keycode); } } }, _ => { if self.shift_down || self.alt_down || self.shift_up || self.alt_up { if let Some(shiftcode) = code.shift { - ks.push(shiftcode).or_else(report_ok).ok(); + ks.push(shiftcode); } else if let Some(keycode) = code.key { - ks.push(keycode).or_else(report_ok).ok(); + ks.push(keycode); } self.shift_down = false; self.alt_down = false; @@ -727,12 +721,12 @@ mod implementation { self.alt_up = false; } else if hold { if let Some(holdcode) = code.hold { - ks.push(holdcode).or_else(report_ok).ok(); + ks.push(holdcode); } } else { if let Some(keycode) = code.key { // info!("appeding normal key '{}'", keycode); - ks.push(keycode).or_else(report_ok).ok(); + ks.push(keycode); } } } @@ -744,7 +738,7 @@ mod implementation { if hold && ((now - self.rate_timestamp) >= self.rate as u64) && self.repeating_key.is_some() { self.rate_timestamp = now; if let Some(repeatkey) = self.repeating_key { - ks.push(repeatkey).or_else(report_ok).ok(); + ks.push(repeatkey); } } @@ -756,7 +750,6 @@ mod implementation { // a stub to try to avoid breaking hosted mode for as long as possible. #[cfg(not(any(target_os = "none", target_os = "xous")))] mod implementation { - use heapless::Vec; use crate::api::*; //use crate::{map_dvorak, map_qwerty}; @@ -793,11 +786,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() } @@ -956,6 +949,8 @@ fn xmain() -> ! { // send rawstates on to rawstate listeners send_rawstates(&mut raw_conns, &rawstates); + ///// TODO: the comment below predates the addition of libstd to Xous. We need to fix this still, + ///// for now we have just refactored out the heapless crate. // GROSS: we copy our IPC-compatible RowColVec type into a heapless::Vec for further processing // this code can probably be cleaned up and improved quite a bit to reduce CPU time. // We don't use heapless::Vec for the IPC because we can't serialize the object with a trait natively @@ -965,16 +960,16 @@ 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(); + keyups_core.push(rc); } } for i in 0..rawstates.keydowns.len() { if let Some(rc) = rawstates.keydowns.get(i) { - keydowns_core.push(rc).unwrap(); + keydowns_core.push(rc); } } let keyups = if keyups_core.len() > 0 { @@ -990,7 +985,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/llio/Cargo.toml b/services/llio/Cargo.toml index dd31938f7..7818d6c80 100644 --- a/services/llio/Cargo.toml +++ b/services/llio/Cargo.toml @@ -18,8 +18,6 @@ num-derive = {version = "0.3", default-features = false} num-traits = {version = "0.2", default-features = false} rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]} -heapless = "0.7" - [target.'cfg(not(any(windows,unix)))'.dependencies] utralib = {path = "../../utralib"} diff --git a/services/llio/src/i2c/hardware.rs b/services/llio/src/i2c/hardware.rs index 37c9f6b5b..68238bcce 100644 --- a/services/llio/src/i2c/hardware.rs +++ b/services/llio/src/i2c/hardware.rs @@ -4,7 +4,6 @@ use utralib::*; use num_traits::ToPrimitive; use susres::{RegManager, RegOrField, SuspendResume}; -use heapless::spsc::Queue; #[derive(Eq, PartialEq)] enum I2cState { @@ -55,7 +54,7 @@ pub(crate) struct I2cStateMachine { listener: Option, error: bool, // set if the interrupt handler encountered some kind of error - workqueue: Queue, + workqueue: Vec, } impl I2cStateMachine { @@ -82,7 +81,7 @@ impl I2cStateMachine { listener: None, error: false, - workqueue: Queue::new(), + workqueue: Vec::new(), }; // disable interrupt, just in case it's enabled from e.g. a warm boot @@ -130,10 +129,8 @@ impl I2cStateMachine { if self.workqueue.is_empty() && self.state == I2cState::Idle && self.listener == None { self.checked_initiate(transaction) } else { - match self.workqueue.enqueue(transaction) { - Ok(_) => return I2cStatus::ResponseInProgress, - _ => return I2cStatus::ResponseBusy, - } + self.workqueue.push(transaction); + I2cStatus::ResponseInProgress } } @@ -219,12 +216,13 @@ impl I2cStateMachine { } else { log::trace!("completed with transaction, but no listener! {:?}", trans); }; - if let Some(work) = self.workqueue.dequeue() { + if self.workqueue.len() > 0 { + let work = self.workqueue.remove(0); if self.checked_initiate(work) != I2cStatus::ResponseInProgress { log::error!("Unable to initiate I2C transaction even though machine should be idle: {:?}.", work); log::error!("Probably, the I2C engine is going off the rails from here..."); } - }; + } Ok(()) } diff --git a/services/shellchat/Cargo.toml b/services/shellchat/Cargo.toml index 7310994da..d5431449e 100644 --- a/services/shellchat/Cargo.toml +++ b/services/shellchat/Cargo.toml @@ -31,7 +31,6 @@ engine-25519 = {path="../engine-25519"} spinor = {path="../spinor"} root-keys = {path="../root-keys"} -heapless = "0.7" trng = {path = "../trng"} num-derive = {version = "0.3", default-features = false} diff --git a/services/shellchat/src/cmds.rs b/services/shellchat/src/cmds.rs index 5bca20bc6..c069dec23 100644 --- a/services/shellchat/src/cmds.rs +++ b/services/shellchat/src/cmds.rs @@ -2,7 +2,7 @@ use xous::{MessageEnvelope}; use xous_ipc::String; use core::fmt::Write; -use heapless::FnvIndexMap; +use std::collections::HashMap; /////////////////////////// Common items to all commands pub trait ShellCmdApi<'a> { // user implemented: @@ -44,7 +44,7 @@ pub struct CommonEnv { com: com::Com, ticktimer: ticktimer_server::Ticktimer, gam: gam::Gam, - cb_registrations: heapless::FnvIndexMap::, 8>, + cb_registrations: HashMap::>, trng: Trng, xns: xous_names::XousNames, } @@ -58,7 +58,7 @@ impl CommonEnv { break; } } - self.cb_registrations.insert(key, verb).unwrap(); + self.cb_registrations.insert(key, verb); key } } @@ -132,7 +132,7 @@ impl CmdEnv { com: com::Com::new(&xns).expect("could't connect to COM"), ticktimer: ticktimer, gam: gam::Gam::new(&xns).expect("couldn't connect to GAM"), - cb_registrations: FnvIndexMap::new(), + cb_registrations: HashMap::new(), trng: Trng::new(&xns).unwrap(), xns: xous_names::XousNames::new().unwrap(), }; diff --git a/services/shellchat/src/main.rs b/services/shellchat/src/main.rs index f1aacf78f..c076d5462 100644 --- a/services/shellchat/src/main.rs +++ b/services/shellchat/src/main.rs @@ -38,8 +38,6 @@ use graphics_server::{Gid, Point, Rectangle, TextBounds, TextView, DrawStyle, Gl use xous::MessageEnvelope; use xous_ipc::{String, Buffer}; -use heapless::spsc::Queue; - #[doc = include_str!("../README.md")] mod cmds; use cmds::*; @@ -61,7 +59,8 @@ struct Repl { msg: Option, // record our input history - history: Queue::, + history: Vec::, + history_len: usize, content: Gid, gam: gam::Gam, @@ -104,7 +103,8 @@ impl Repl{ Repl { input: None, msg: None, - history: Queue::new(), + history: Vec::new(), + history_len: 10, content, gam, screensize, @@ -133,10 +133,10 @@ impl Repl{ } fn circular_push(&mut self, item: History) { - if self.history.len() == self.history.capacity() { - self.history.dequeue().expect("couldn't dequeue historye"); + if self.history.len() >= self.history_len { + self.history.remove(0); } - self.history.enqueue(item).expect("couldn't store input line"); + self.history.push(item); } /// update the loop, in response to various inputs diff --git a/services/ticktimer-server/Cargo.toml b/services/ticktimer-server/Cargo.toml index 8febf5438..70011f0b1 100644 --- a/services/ticktimer-server/Cargo.toml +++ b/services/ticktimer-server/Cargo.toml @@ -6,7 +6,6 @@ name = "ticktimer-server" version = "0.1.0" [dependencies] -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 1ce0e8457..bd6afd847 100644 --- a/services/ticktimer-server/src/main.rs +++ b/services/ticktimer-server/src/main.rs @@ -5,7 +5,8 @@ mod api; -use heapless::binary_heap::{BinaryHeap, Min}; +use std::collections::BinaryHeap; +use std::cmp::Reverse; use log::{error, info}; @@ -449,14 +450,14 @@ use implementation::*; fn recalculate_sleep( ticktimer: &mut XousTickTimer, - sleep_heap: &mut BinaryHeap, + sleep_heap: &mut BinaryHeap>, // min-heap with Reverse new: Option, ) { // If there's a sleep request ongoing now, grab it. if let Some(current) = ticktimer.stop_interrupt() { #[cfg(feature = "debug-print")] info!("Existing request was {:?}", current); - sleep_heap.push(current).expect("couldn't push to heap") + sleep_heap.push(Reverse(current)); } else { #[cfg(feature = "debug-print")] info!("There was no existing request"); @@ -472,15 +473,14 @@ fn recalculate_sleep( #[cfg(feature = "debug-print")] info!("Modified, the request was: {:?}", request); sleep_heap - .push(request) - .expect("couldn't push new sleep to heap"); + .push(Reverse(request)); } else { #[cfg(feature = "debug-print")] info!("No new sleep request"); } // If there are items in the sleep heap, take the next item that will expire. - if let Some(next_response) = sleep_heap.pop() { + if let Some(Reverse(next_response)) = sleep_heap.pop() { #[cfg(feature = "debug-print")] info!( "scheduling a response at {} to {} (heap: {:?})", @@ -492,7 +492,7 @@ fn recalculate_sleep( #[xous::xous_main] fn xmain() -> ! { - let mut sleep_heap: BinaryHeap = BinaryHeap::new(); + let mut sleep_heap: BinaryHeap> = BinaryHeap::new(); // Reverse wrapping makes this a min-heap log_server::init_wait().unwrap(); log::set_max_level(log::LevelFilter::Info);