summaryrefslogtreecommitdiff
path: root/src/vendorcode/google
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2013-05-10 00:42:14 -0500
committerAaron Durbin <adurbin@google.com>2013-05-16 01:30:09 +0200
commit677e1558c32d1c88ade486e5ac42e60a3da1fdcf (patch)
tree768e664dc03605114d4b310ba097783e9504998a /src/vendorcode/google
parentcb997d3710900d5950d244edd607e25bb45ea962 (diff)
downloadcoreboot-677e1558c32d1c88ade486e5ac42e60a3da1fdcf.tar.xz
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. Change-Id: Ia1d8932f98e00def0a44444a1ead0018a59d3d98 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/3234 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/vendorcode/google')
-rw-r--r--src/vendorcode/google/chromeos/vbnv.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/vendorcode/google/chromeos/vbnv.c b/src/vendorcode/google/chromeos/vbnv.c
index 2a2faf9e96..d94203ad6d 100644
--- a/src/vendorcode/google/chromeos/vbnv.c
+++ b/src/vendorcode/google/chromeos/vbnv.c
@@ -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,20 +127,20 @@ 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();
/* FIXME(crosbug.com/p/8789). The following commented-out line does the
@@ -130,6 +148,6 @@ int vboot_wants_oprom(void)
* rebooted if it finds that it's needed but not loaded. At the moment,
* it doesn't yet do that, so we must always say we want it. */
- /* return (vbnv[BOOT_OFFSET] & BOOT_OPROM_NEEDED) ? 1 : 0; */
+ /* return (vbnv_data(BOOT_OFFSET) & BOOT_OPROM_NEEDED) ? 1 : 0; */
return 1;
}