Change BOOT_MAX_ALIGN to #define
BOOT_MAX_ALIGN is defined as extern const uint32_t BOOT_MAX_ALIGN; and is assigned a value in a single file. This causes extra work when this is used as the size of a local variable in a function. The value was made a constant in order for the simulator to be able to access the value. Instead of making it a "real" constant, keep it as a define, unifying the value of FLASH_MAX_ALIGN and this one, and provide an accessor function for the test code to be able to access this value. This causes a minor improvement in the code generated in `boot_write_status`, but more importantly, eliminates a VLA from the code, which increases the possible compilers supported by MCUboot. Signed-off-by: David Brown <david.brown@linaro.org>
This commit is contained in:
parent
510fddb8e0
commit
e0bb1f956f
|
@ -50,8 +50,7 @@ extern "C" {
|
||||||
/** Swapping encountered an unrecoverable error */
|
/** Swapping encountered an unrecoverable error */
|
||||||
#define BOOT_SWAP_TYPE_PANIC 0xff
|
#define BOOT_SWAP_TYPE_PANIC 0xff
|
||||||
|
|
||||||
#define MAX_FLASH_ALIGN 8
|
#define BOOT_MAX_ALIGN 8
|
||||||
extern const uint32_t BOOT_MAX_ALIGN;
|
|
||||||
|
|
||||||
struct image_header;
|
struct image_header;
|
||||||
/**
|
/**
|
||||||
|
@ -75,11 +74,11 @@ struct boot_rsp {
|
||||||
*/
|
*/
|
||||||
struct image_trailer {
|
struct image_trailer {
|
||||||
uint8_t swap_type;
|
uint8_t swap_type;
|
||||||
uint8_t pad1[MAX_FLASH_ALIGN - 1];
|
uint8_t pad1[BOOT_MAX_ALIGN - 1];
|
||||||
uint8_t copy_done;
|
uint8_t copy_done;
|
||||||
uint8_t pad2[MAX_FLASH_ALIGN - 1];
|
uint8_t pad2[BOOT_MAX_ALIGN - 1];
|
||||||
uint8_t image_ok;
|
uint8_t image_ok;
|
||||||
uint8_t pad3[MAX_FLASH_ALIGN - 1];
|
uint8_t pad3[BOOT_MAX_ALIGN - 1];
|
||||||
uint8_t magic[16];
|
uint8_t magic[16];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ const uint32_t boot_img_magic[] = {
|
||||||
(sizeof boot_img_magic / sizeof boot_img_magic[0])
|
(sizeof boot_img_magic / sizeof boot_img_magic[0])
|
||||||
|
|
||||||
const uint32_t BOOT_MAGIC_SZ = sizeof boot_img_magic;
|
const uint32_t BOOT_MAGIC_SZ = sizeof boot_img_magic;
|
||||||
const uint32_t BOOT_MAX_ALIGN = MAX_FLASH_ALIGN;
|
|
||||||
|
|
||||||
struct boot_swap_table {
|
struct boot_swap_table {
|
||||||
uint8_t magic_primary_slot;
|
uint8_t magic_primary_slot;
|
||||||
|
|
|
@ -449,3 +449,8 @@ void sim_assert(int x, const char *assertion, const char *file, unsigned int lin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t boot_max_align(void)
|
||||||
|
{
|
||||||
|
return BOOT_MAX_ALIGN;
|
||||||
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ pub fn boot_magic_sz() -> usize {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn boot_max_align() -> usize {
|
pub fn boot_max_align() -> usize {
|
||||||
unsafe { raw::BOOT_MAX_ALIGN as usize }
|
unsafe { raw::boot_max_align() as usize }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rsa_oaep_encrypt(pubkey: &[u8], seckey: &[u8]) -> Result<[u8; 256], &'static str> {
|
pub fn rsa_oaep_encrypt(pubkey: &[u8], seckey: &[u8]) -> Result<[u8; 256], &'static str> {
|
||||||
|
@ -84,7 +84,7 @@ mod raw {
|
||||||
pub fn boot_trailer_sz(min_write_sz: u8) -> u32;
|
pub fn boot_trailer_sz(min_write_sz: u8) -> u32;
|
||||||
|
|
||||||
pub static BOOT_MAGIC_SZ: u32;
|
pub static BOOT_MAGIC_SZ: u32;
|
||||||
pub static BOOT_MAX_ALIGN: u32;
|
pub fn boot_max_align() -> u32;
|
||||||
|
|
||||||
pub fn rsa_oaep_encrypt_(pubkey: *const u8, pubkey_len: libc::c_uint,
|
pub fn rsa_oaep_encrypt_(pubkey: *const u8, pubkey_len: libc::c_uint,
|
||||||
seckey: *const u8, seckey_len: libc::c_uint,
|
seckey: *const u8, seckey_len: libc::c_uint,
|
||||||
|
|
Loading…
Reference in New Issue