From 0424c95a6dafdb65070538d6c5aa394b75eb9850 Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Sat, 28 Mar 2015 23:56:22 -0500 Subject: 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 Reviewed-on: http://review.coreboot.org/9170 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- src/mainboard/google/butterfly/mainboard.c | 41 +++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'src/mainboard/google/butterfly/mainboard.c') diff --git a/src/mainboard/google/butterfly/mainboard.c b/src/mainboard/google/butterfly/mainboard.c index bd2fbd5218..e09336d675 100644 --- a/src/mainboard/google/butterfly/mainboard.c +++ b/src/mainboard/google/butterfly/mainboard.c @@ -20,11 +20,13 @@ #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -36,11 +38,6 @@ #include #include #include -#if CONFIG_CHROMEOS -#include -#else -#include -#endif static unsigned int search(char *p, char *a, unsigned int lengthp, unsigned int lengtha) @@ -200,20 +197,30 @@ static void mainboard_init(device_t dev) size_t search_length = -1; u16 io_base = 0; struct device *ethernet_dev = NULL; -#if CONFIG_CHROMEOS - char **vpd_region_ptr = NULL; - search_length = find_fmap_entry("RO_VPD", (void **)vpd_region_ptr); - search_address = (unsigned long)(*vpd_region_ptr); -#else - void *vpd_file = cbfs_get_file_content(CBFS_DEFAULT_MEDIA, "vpd.bin", - CBFS_TYPE_RAW, &search_length); - if (vpd_file) { - search_address = (unsigned long)vpd_file; + void *vpd_file; + + if (IS_ENABLED(CONFIG_CHROMEOS)) { + struct region_device rdev; + + if (fmap_locate_area_as_rdev("RO_VPD", &rdev) == 0) { + vpd_file = rdev_mmap_full(&rdev); + + if (vpd_file != NULL) { + search_length = region_device_sz(&rdev); + search_address = (uintptr_t)vpd_file; + } + } } else { - search_length = -1; - search_address = 0; + vpd_file = cbfs_get_file_content(CBFS_DEFAULT_MEDIA, + "vpd.bin", CBFS_TYPE_RAW, + &search_length); + if (vpd_file) { + search_address = (unsigned long)vpd_file; + } else { + search_length = -1; + search_address = 0; + } } -#endif /* Initialize the Embedded Controller */ butterfly_ec_init(); -- cgit v1.2.3