sim: Pass alignment into `boot_go`
Move the alignment into the `boot_go` wrapper. Instead of relying on
this as a global, pass it around, ultimately setting it in the C
wrapper. This is in preparation to protecting the `boot_go` call with a
mutex to prevent reentrancy.
Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/sim/mcuboot-sys/src/c.rs b/sim/mcuboot-sys/src/c.rs
index ccd853e..f5643ab 100644
--- a/sim/mcuboot-sys/src/c.rs
+++ b/sim/mcuboot-sys/src/c.rs
@@ -6,9 +6,10 @@
use api;
/// Invoke the bootloader on this flash device.
-pub fn boot_go(flash: &mut Flash, areadesc: &AreaDesc, counter: Option<&mut i32>) -> i32 {
+pub fn boot_go(flash: &mut Flash, areadesc: &AreaDesc, counter: Option<&mut i32>, align: u8) -> i32 {
unsafe {
api::set_flash(flash);
+ raw::sim_flash_align = align;
raw::flash_counter = match counter {
None => 0,
Some(ref c) => **c as libc::c_int
@@ -22,16 +23,8 @@
result
}
-pub fn boot_trailer_sz() -> u32 {
- unsafe { raw::boot_slots_trailer_sz(raw::sim_flash_align) }
-}
-
-pub fn get_sim_flash_align() -> u8 {
- unsafe { raw::sim_flash_align }
-}
-
-pub fn set_sim_flash_align(align: u8) {
- unsafe { raw::sim_flash_align = align };
+pub fn boot_trailer_sz(align: u8) -> u32 {
+ unsafe { raw::boot_slots_trailer_sz(align) }
}
pub fn boot_magic_sz() -> usize {