BACKPORT: chromeos: use cache-as-ram migration API for vbnv
It's possible that the vbnv global variables may be accessed in romstage after cache-as-ram is torn down. Therefore use the cache-as-ram migration API. Wrappers were written to wrap the API to keep the existing code as close as possible. BUG=chrome-os-partner:19342 BRANCH=none TEST=Built and booted. Noted that CAR values are not read incorrectly. Change-Id: I00fa4128fd2f197f238f38814b158ffc3387ea48 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/51388 Reviewed-by: Stefan Reinauer <reinauer@google.com>
This commit is contained in:
parent
f6563fb9f7
commit
398a704859
1 changed files with 25 additions and 7 deletions
|
|
@ -53,7 +53,25 @@
|
|||
#define CRC_OFFSET 15
|
||||
|
||||
static int vbnv_initialized CAR_GLOBAL;
|
||||
uint8_t vbnv[CONFIG_VBNV_SIZE] CAR_GLOBAL;
|
||||
static uint8_t vbnv[CONFIG_VBNV_SIZE] CAR_GLOBAL;
|
||||
|
||||
/* Wrappers for accessing the variables marked as CAR_GLOBAL. */
|
||||
static inline int is_vbnv_initialized(void)
|
||||
{
|
||||
return car_get_var(vbnv_initialized);
|
||||
}
|
||||
|
||||
static inline uint8_t *vbnv_data_addr(int index)
|
||||
{
|
||||
uint8_t *vbnv_arr = car_get_var_ptr(vbnv);
|
||||
|
||||
return &vbnv_arr[index];
|
||||
}
|
||||
|
||||
static inline uint8_t vbnv_data(int index)
|
||||
{
|
||||
return *vbnv_data_addr(index);
|
||||
}
|
||||
|
||||
/* Return CRC-8 of the data, using x^8 + x^2 + x + 1 polynomial. A
|
||||
* table-based algorithm would be faster, but for only 15 bytes isn't
|
||||
|
|
@ -109,21 +127,21 @@ void save_vbnv(const uint8_t *vbnv_copy)
|
|||
|
||||
static void vbnv_setup(void)
|
||||
{
|
||||
read_vbnv(vbnv);
|
||||
vbnv_initialized = 1;
|
||||
read_vbnv(vbnv_data_addr(0));
|
||||
car_set_var(vbnv_initialized, 1);
|
||||
}
|
||||
|
||||
int get_recovery_mode_from_vbnv(void)
|
||||
{
|
||||
if (!vbnv_initialized)
|
||||
if (!is_vbnv_initialized())
|
||||
vbnv_setup();
|
||||
return vbnv[RECOVERY_OFFSET];
|
||||
return vbnv_data(RECOVERY_OFFSET);
|
||||
}
|
||||
|
||||
int vboot_wants_oprom(void)
|
||||
{
|
||||
if (!vbnv_initialized)
|
||||
if (!is_vbnv_initialized())
|
||||
vbnv_setup();
|
||||
|
||||
return (vbnv[BOOT_OFFSET] & BOOT_OPROM_NEEDED) ? 1 : 0;
|
||||
return (vbnv_data(BOOT_OFFSET) & BOOT_OPROM_NEEDED) ? 1 : 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue