diff options
author | Aaron Durbin <adurbin@chromium.org> | 2015-03-28 23:56:22 -0500 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2015-05-26 22:33:53 +0200 |
commit | 0424c95a6dafdb65070538d6c5aa394b75eb9850 (patch) | |
tree | f5bd9f485a1a44eece1662a29c1435a44ab5c58a /src/vendorcode/google/chromeos/cros_vpd.c | |
parent | b6981c0f9c4ce89c4209c14fb326a414096f2ff1 (diff) |
fmap: new API using region_device
Instead of being pointer based use the region infrastrucutre.
Additionally, this removes the need for arch-specific compilation
paths. The users of the new API can use the region APIs to memory
map or read the region provided by the new fmap API.
Change-Id: Ie36e9ff9cb554234ec394b921f029eeed6845aee
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/9170
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src/vendorcode/google/chromeos/cros_vpd.c')
-rw-r--r-- | src/vendorcode/google/chromeos/cros_vpd.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/vendorcode/google/chromeos/cros_vpd.c b/src/vendorcode/google/chromeos/cros_vpd.c index c0e483019b..fed1d82344 100644 --- a/src/vendorcode/google/chromeos/cros_vpd.c +++ b/src/vendorcode/google/chromeos/cros_vpd.c @@ -6,12 +6,11 @@ #include <console/console.h> -#include <cbfs.h> +#include <fmap.h> #include <stdlib.h> #include <string.h> #include "cros_vpd.h" -#include "fmap.h" #include "lib_vpd.h" #include "vpd_tables.h" @@ -35,9 +34,7 @@ static int cros_vpd_load(uint8_t **vpd_address, int32_t *vpd_size) MAYBE_STATIC int result = -1; struct google_vpd_info info; int32_t base; - - const struct fmap_area *area; - struct cbfs_media media; + struct region_device vpd; if (cached) { *vpd_address = cached_address; @@ -46,32 +43,31 @@ static int cros_vpd_load(uint8_t **vpd_address, int32_t *vpd_size) } cached = 1; - area = find_fmap_area(fmap_find(), "RO_VPD"); - if (!area) { + if (fmap_locate_area_as_rdev("RO_VPD", &vpd)) { printk(BIOS_ERR, "%s: No RO_VPD FMAP section.\n", __func__); return result; } - if (area->size <= GOOGLE_VPD_2_0_OFFSET + sizeof(info)) { + + base = 0; + cached_size = region_device_sz(&vpd); + + if ((cached_size < GOOGLE_VPD_2_0_OFFSET + sizeof(info)) || + rdev_chain(&vpd, &vpd, GOOGLE_VPD_2_0_OFFSET, + cached_size - GOOGLE_VPD_2_0_OFFSET)) { printk(BIOS_ERR, "%s: Too small (%d) for Google VPD 2.0.\n", - __func__, area->size); + __func__, cached_size); return result; } - base = area->offset + GOOGLE_VPD_2_0_OFFSET; - cached_size = area->size - GOOGLE_VPD_2_0_OFFSET; - init_default_cbfs_media(&media); - media.open(&media); - /* Try if we can find a google_vpd_info, otherwise read whole VPD. */ - if (media.read(&media, &info, base, sizeof(info)) == sizeof(info) && + if (rdev_readat(&vpd, &info, base, sizeof(info)) == sizeof(info) && memcmp(info.header.magic, VPD_INFO_MAGIC, sizeof(info.header.magic)) == 0 && cached_size >= info.size + sizeof(info)) { base += sizeof(info); cached_size = info.size; } - cached_address = media.map(&media, base, cached_size); - media.close(&media); + cached_address = rdev_mmap(&vpd, base, cached_size); if (cached_address) { *vpd_address = cached_address; *vpd_size = cached_size; |