sim: Use simulated flash configuration
There are some instances of hard-coded offsets, which break if the
simulated device doesn't have the same configuration. Query these
from the flash descriptor rather than hard-coding them.
diff --git a/sim/src/area.rs b/sim/src/area.rs
index 9b844d0..4b85912 100644
--- a/sim/src/area.rs
+++ b/sim/src/area.rs
@@ -101,6 +101,17 @@
});
}
+ // Look for the image with the given ID, and return its base and size. Panics if the area is
+ // not present.
+ pub fn find(&self, id: FlashId) -> (usize, usize) {
+ for area in &self.whole {
+ if area.flash_id == id {
+ return (area.off as usize, area.size as usize);
+ }
+ }
+ panic!("Requesting area that is not present in flash");
+ }
+
pub fn get_c(&self) -> CAreaDesc {
let mut areas: CAreaDesc = Default::default();