mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-18 18:44:22 +00:00
feat(fwu): modify the check for getting the FWU bank's state
The version 2 of the FWU metadata structure has a field bank_state in the top level of the structure which can be used to check if a given bank is in the either of Trial State, Accepted State, or in an Invalid State. This is different from the binary states of Valid/Accepted States that the bank could be in, as defined in the earlier version of the specification. Replace the fwu_is_trial_run_state() API with fwu_get_active_bank_state() to get the state the current active bank is in. The value returned by this API is then used by the caller to take appropriate action. Change-Id: I764f486840a3713bfe5f8e03d0634bfe09b23590 Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
This commit is contained in:
parent
588b01b5e4
commit
56724d09c2
3 changed files with 20 additions and 21 deletions
|
@ -328,7 +328,6 @@ static int auth_nvctr(const auth_method_param_nv_ctr_t *param,
|
||||||
unsigned int data_len, len, i;
|
unsigned int data_len, len, i;
|
||||||
unsigned int plat_nv_ctr;
|
unsigned int plat_nv_ctr;
|
||||||
int rc;
|
int rc;
|
||||||
bool is_trial_run = false;
|
|
||||||
|
|
||||||
/* Get the counter value from current image. The AM expects the IPM
|
/* Get the counter value from current image. The AM expects the IPM
|
||||||
* to return the counter value as a DER encoded integer */
|
* to return the counter value as a DER encoded integer */
|
||||||
|
@ -388,9 +387,14 @@ static int auth_nvctr(const auth_method_param_nv_ctr_t *param,
|
||||||
return 1;
|
return 1;
|
||||||
} else if (*cert_nv_ctr > plat_nv_ctr) {
|
} else if (*cert_nv_ctr > plat_nv_ctr) {
|
||||||
#if PSA_FWU_SUPPORT && IMAGE_BL2
|
#if PSA_FWU_SUPPORT && IMAGE_BL2
|
||||||
is_trial_run = fwu_is_trial_run_state();
|
if (fwu_get_active_bank_state() == FWU_BANK_STATE_ACCEPTED) {
|
||||||
|
*need_nv_ctr_upgrade = true;
|
||||||
|
} else {
|
||||||
|
*need_nv_ctr_upgrade = false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
*need_nv_ctr_upgrade = true;
|
||||||
#endif /* PSA_FWU_SUPPORT && IMAGE_BL2 */
|
#endif /* PSA_FWU_SUPPORT && IMAGE_BL2 */
|
||||||
*need_nv_ctr_upgrade = !is_trial_run;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -133,28 +133,23 @@ exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* The system runs in the trial run state if any of the images in the active
|
* The platform can be in one of Valid, Invalid or Accepted states.
|
||||||
* firmware bank has not been accepted yet.
|
|
||||||
*
|
*
|
||||||
* Returns true if the system is running in the trial state.
|
* Invalid - One or more images in the bank are corrupted, or partially
|
||||||
|
* overwritten. The bank is not to be used for booting.
|
||||||
|
*
|
||||||
|
* Valid - All images of the bank are valid but at least one image has not
|
||||||
|
* been accepted. This implies that the platform is in Trial State.
|
||||||
|
*
|
||||||
|
* Accepted - All images of the bank are valid and accepted.
|
||||||
|
*
|
||||||
|
* Returns the state of the current active bank
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
bool fwu_is_trial_run_state(void)
|
uint32_t fwu_get_active_bank_state(void)
|
||||||
{
|
{
|
||||||
bool trial_run = false;
|
|
||||||
|
|
||||||
assert(is_metadata_initialized);
|
assert(is_metadata_initialized);
|
||||||
|
|
||||||
for (unsigned int i = 0U; i < NR_OF_IMAGES_IN_FW_BANK; i++) {
|
return metadata.bank_state[metadata.active_index];
|
||||||
struct fwu_image_entry *entry = &metadata.img_entry[i];
|
|
||||||
struct fwu_image_properties *img_props =
|
|
||||||
&entry->img_props[metadata.active_index];
|
|
||||||
if (img_props->accepted == 0) {
|
|
||||||
trial_run = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return trial_run;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct fwu_metadata *fwu_get_metadata(void)
|
const struct fwu_metadata *fwu_get_metadata(void)
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#define FWU_BANK_STATE_INVALID 0xFFU
|
#define FWU_BANK_STATE_INVALID 0xFFU
|
||||||
|
|
||||||
void fwu_init(void);
|
void fwu_init(void);
|
||||||
bool fwu_is_trial_run_state(void);
|
uint32_t fwu_get_active_bank_state(void);
|
||||||
const struct fwu_metadata *fwu_get_metadata(void);
|
const struct fwu_metadata *fwu_get_metadata(void);
|
||||||
|
|
||||||
#endif /* FWU_H */
|
#endif /* FWU_H */
|
||||||
|
|
Loading…
Add table
Reference in a new issue