From 28d07da7f1b9741e5c34a6b742861e0ec7e2e6be Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 5 Apr 2024 16:45:24 +0800 Subject: [PATCH] add the flash offset of the swap region in swap args Each platform interprets this differently. On Precursor, it's the offset in FLASH of the swap region. Probably, flags should be added to configure this somehow for each platform, but still figuring a lot of things out. The plan is on Cramium for the swap data to always be at 0 in the external SPI, so, we don't store an offset (field is ignored). --- tools/src/tags/swap.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/src/tags/swap.rs b/tools/src/tags/swap.rs index 83a6b101b..ff313697b 100644 --- a/tools/src/tags/swap.rs +++ b/tools/src/tags/swap.rs @@ -5,10 +5,10 @@ use crate::xous_arguments::{XousArgument, XousArgumentCode, XousSize}; #[derive(Debug, Default, Clone, Copy)] pub struct Swap { - /// Starting offset (in bytes) + /// Starting offset (in bytes) of the swap RAM pub offset: u32, - /// Length (in bytes) + /// Total swap length (in bytes) - not all is usable, as a portion is reserved for the MAC codes pub size: u32, /// Region name (as a type) @@ -18,8 +18,8 @@ pub struct Swap { /// by the device upon completion of the keying ceremony. pub key: [u8; 32], - /// Unused - _padding: u32, + /// Starting offset of swap in FLASH + pub offset_flash: u32, } impl fmt::Display for Swap { @@ -37,7 +37,8 @@ impl Swap { size, name: u32::from_le_bytes(*b"Swap") as XousArgumentCode, key: [0u8; 32], - _padding: 0, + // location for swap offset in FLASH (for precursor) + offset_flash: 0x21200000, } } } @@ -53,7 +54,7 @@ impl XousArgument for Swap { output.write_all(&self.size.to_le_bytes())?; output.write_all(&self.name.to_le_bytes())?; output.write_all(&self.key)?; - output.write_all(&0u32.to_le_bytes())?; + output.write_all(&self.offset_flash.to_le_bytes())?; written += 4 * 4 + 32; Ok(written) }