diff options
author | Aaron Durbin <adurbin@chromium.org> | 2015-05-15 23:25:46 -0500 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2015-05-26 22:34:23 +0200 |
commit | 4e50cdd979c03a0d64cc1b4c9ada45822aa6d346 (patch) | |
tree | ea3dd5b45f7bb56d68a07ad94421e6cd7bd0b99c /src/vendorcode/google/chromeos/vbnv_flash.c | |
parent | 0424c95a6dafdb65070538d6c5aa394b75eb9850 (diff) |
vboot: move to region_devices
Now that vboot is using offsets for everything remove the
pass through vboot_get_region() and use region_devices
as first class citizens.
Change-Id: I1a86f3725e5bce38e6ca31e9641b1a8f4ac50e96
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/10225
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src/vendorcode/google/chromeos/vbnv_flash.c')
-rw-r--r-- | src/vendorcode/google/chromeos/vbnv_flash.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/vendorcode/google/chromeos/vbnv_flash.c b/src/vendorcode/google/chromeos/vbnv_flash.c index 976793a6a7..656c3ea2a2 100644 --- a/src/vendorcode/google/chromeos/vbnv_flash.c +++ b/src/vendorcode/google/chromeos/vbnv_flash.c @@ -19,8 +19,6 @@ * TODO: Make this CAR-friendly in case we use it on x86 some day. */ -#include <cbfs.h> -#include <cbfs_core.h> #include <console/console.h> #include <spi_flash.h> #include <string.h> @@ -32,7 +30,7 @@ #define BLOB_SIZE VB2_NVDATA_SIZE /* FMAP descriptor of the NVRAM area */ -static struct region nvram_region; +static struct region_device nvram_region; /* offset of the current nvdata in SPI flash */ static int blob_offset = -1; @@ -73,8 +71,8 @@ static int init_vbnv(void) int offset; int i; - vboot_locate_region("RW_NVRAM", &nvram_region); - if (region_sz(&nvram_region) < BLOB_SIZE) { + if (vboot_named_region_device("RW_NVRAM", &nvram_region) || + region_device_sz(&nvram_region) < BLOB_SIZE) { printk(BIOS_ERR, "%s: failed to locate NVRAM\n", __func__); return 1; } @@ -83,8 +81,8 @@ static int init_vbnv(void) for (i = 0; i < BLOB_SIZE; i++) empty_blob[i] = erase_value(); - offset = region_offset(&nvram_region); - top_offset = offset + region_sz(&nvram_region) - BLOB_SIZE; + offset = 0; + top_offset = region_device_sz(&nvram_region) - BLOB_SIZE; /* * after the loop, offset is supposed to point the blob right before @@ -92,8 +90,8 @@ static int init_vbnv(void) * empty blob, or the base of the region if the nvram has never been * used. */ - for (i = offset; i <= top_offset; i += BLOB_SIZE) { - if (vboot_get_region(i, BLOB_SIZE, buf) == NULL) { + for (i = 0; i <= top_offset; i += BLOB_SIZE) { + if (rdev_readat(&nvram_region, buf, i, BLOB_SIZE) < 0) { printk(BIOS_ERR, "failed to read nvdata\n"); return 1; } @@ -103,7 +101,7 @@ static int init_vbnv(void) } /* reread the nvdata and write it to the cache */ - if (vboot_get_region(offset, BLOB_SIZE, cache) == NULL) { + if (rdev_readat(&nvram_region, cache, offset, BLOB_SIZE) < 0) { printk(BIOS_ERR, "failed to read nvdata\n"); return 1; } @@ -130,8 +128,8 @@ static int erase_nvram(void) if (vbnv_flash_probe()) return 1; - if (spi_flash->erase(spi_flash, region_offset(&nvram_region), - region_sz(&nvram_region))) { + if (spi_flash->erase(spi_flash, region_device_offset(&nvram_region), + region_device_sz(&nvram_region))) { printk(BIOS_ERR, "failed to erase nvram\n"); return 1; } @@ -171,14 +169,16 @@ void save_vbnv(const uint8_t *vbnv_copy) if (new_offset > top_offset) { if (erase_nvram()) return; /* error */ - new_offset = region_offset(&nvram_region); + new_offset = 0; } break; } } if (!vbnv_flash_probe() && - !spi_flash->write(spi_flash, new_offset, BLOB_SIZE, vbnv_copy)) { + !spi_flash->write(spi_flash, + region_device_offset(&nvram_region) + new_offset, + BLOB_SIZE, vbnv_copy)) { /* write was successful. safely move pointer forward */ blob_offset = new_offset; memcpy(cache, vbnv_copy, BLOB_SIZE); |