Skip to content

Commit a706317

Browse files
committed
sim: Increase jmpbuf size
Increase the size of the jmpbuf to accomodate other architectures. Unfortunately, the size of this is not available in the libc crate. Increase this so encompass any platforms we wish to support, including aarch64 on both Linux and MacOS. Increasing an array beyond 32 means there is no default offered, so implement this manually. Signed-off-by: David Brown <[email protected]>
1 parent d6a5a73 commit a706317

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

sim/mcuboot-sys/src/api.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl Default for FlashContext {
9090
}
9191

9292
#[repr(C)]
93-
#[derive(Debug, Default)]
93+
#[derive(Debug)]
9494
pub struct CSimContext {
9595
pub flash_counter: libc::c_int,
9696
pub jumped: libc::c_int,
@@ -99,7 +99,19 @@ pub struct CSimContext {
9999
// NOTE: Always leave boot_jmpbuf declaration at the end; this should
100100
// store a "jmp_buf" which is arch specific and not defined by libc crate.
101101
// The size below is enough to store data on a x86_64 machine.
102-
pub boot_jmpbuf: [u64; 16],
102+
pub boot_jmpbuf: [u64; 48],
103+
}
104+
105+
impl Default for CSimContext {
106+
fn default() -> Self {
107+
CSimContext {
108+
flash_counter: 0,
109+
jumped: 0,
110+
c_asserts: 0,
111+
c_catch_asserts: 0,
112+
boot_jmpbuf: [0; 48],
113+
}
114+
}
103115
}
104116

105117
pub struct CSimContextPtr {

sim/mcuboot-sys/src/c.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,8 @@ pub fn boot_go(multiflash: &mut SimMultiFlash, areadesc: &AreaDesc,
8181
None => 0,
8282
Some(ref c) => **c as libc::c_int
8383
},
84-
jumped: 0,
85-
c_asserts: 0,
8684
c_catch_asserts: if catch_asserts { 1 } else { 0 },
87-
boot_jmpbuf: [0; 16],
85+
.. Default::default()
8886
};
8987
let mut rsp = api::BootRsp {
9088
br_hdr: std::ptr::null(),

0 commit comments

Comments
 (0)