mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 18:41:11 +00:00
The INFO1 mask field contents serves as input for the rollback
protection mechanism, when the RO decides if an RW is allowed to run
on the device.
The existing code updates INFO1 mask to match the lowest rollback
priority of the two images (RW_A and RW_B) present on the device.
INFO1 mask should be also updated when the current image is endorsed
by the host. In this case the alternative RW is destroyed, so the
INFO1 mask could be set based solely on the currently running image.
This patch refactors the code to allow setting INFO1 mask based on one
or both RW headers' contents.
BRANCH=cr50
BUG=b:62138152
TEST=verified that "normal" INFO1 mask updates still work as before,
the mask is modified to match the image with the lowest rollback
priority.
Also verified that when the VENDOR_CC_INVALIDATE_INACTIVE_RW
command is received the INFO1 mask is updated based on the
currently running image.
Change-Id: I23172388674e1f3a4c2489e139dd197a84029f54
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/541738
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
78 lines
2.2 KiB
C
78 lines
2.2 KiB
C
/* Copyright 2017 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* chip/g-specific system function prototypes */
|
|
|
|
#ifndef __CROS_EC_SYSTEM_CHIP_H
|
|
#define __CROS_EC_SYSTEM_CHIP_H
|
|
|
|
/**
|
|
* On systems with protection from a failing RW update: read the retry counter
|
|
* and act on it.
|
|
*
|
|
* @return EC_SUCCESS if no flash write errors were encounterd.
|
|
*/
|
|
int system_process_retry_counter(void);
|
|
|
|
/**
|
|
* On systems with protection from a failing RW update: reset retry
|
|
* counter, this is used after a new image upload is finished, to make
|
|
* sure that the new image has a chance to run.
|
|
*/
|
|
void system_clear_retry_counter(void);
|
|
|
|
/**
|
|
* A function provided by some platforms to decrement a retry counter.
|
|
*
|
|
* This should be used whenever a system reset is manually triggered.
|
|
*/
|
|
void system_decrement_retry_counter(void);
|
|
|
|
/**
|
|
* A function provided by some platforms to hint that something is going
|
|
* wrong.
|
|
*
|
|
* @return a boolean, set to True if rolling reboot condition is suspected.
|
|
*/
|
|
int system_rolling_reboot_suspected(void);
|
|
|
|
/**
|
|
* Compare the rw headers to check if there was a rollback.
|
|
*
|
|
* @return a boolean, set to True if a rollback is detected.
|
|
*/
|
|
int system_rollback_detected(void);
|
|
|
|
/**
|
|
* Returns non-zero value when firmware is expected to be abe to detect user
|
|
* request to cut off battery supply.
|
|
*/
|
|
int system_battery_cutoff_support_required(void);
|
|
|
|
/**
|
|
* Functions to update INFO1 rollback mask based on one or both RW image
|
|
* headers.
|
|
*/
|
|
void system_update_rollback_mask_with_active_img(void);
|
|
void system_update_rollback_mask_with_both_imgs(void);
|
|
|
|
/**
|
|
* Scan INFO1 rollback map and infomap fields of both RW and RW_B image
|
|
* headers, and return a string showing how many zeros are there at the base
|
|
* of in each of these objects.
|
|
*
|
|
* The passed in parameters are the memory area to put the string in and the
|
|
* size of this memory area.
|
|
*/
|
|
void system_get_rollback_bits(char *value, size_t value_size);
|
|
|
|
/**
|
|
* Set the rollback counter to a value which would ensure a rollback on the
|
|
* next boot.
|
|
*/
|
|
void system_ensure_rollback(void);
|
|
|
|
#endif /* __CROS_EC_SYSTEM_CHIP_H */
|