[coreboot-gerrit] New patch to review for coreboot: 7371f0b chromeos: Fix build for the region-based CBFS/FMAP APIs

Sol Boucher (solb@chromium.org) gerrit at coreboot.org
Tue May 5 08:11:11 CEST 2015


Sol Boucher (solb at chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10093

-gerrit

commit 7371f0b3449d61837cda2ff3ab3ad31d0dbee565
Author: Sol Boucher <solb at chromium.org>
Date:   Mon May 4 21:46:03 2015 -0700

    chromeos: Fix build for the region-based CBFS/FMAP APIs
    
    This restores the ability to build with CONFIG_CHROMEOS enabled, which
    was broken by the introduction of the new region-based CBFS and FMAP
    APIs. Note that this does not touch vboot integration, and that builds
    still fail when CONFIG_VBOOT_VERIFY_FIRMWARE and friends are enabled.
    Building panther from this commit using the config file from the
    Chromium OS project[1] (but modified with
    CONFIG_VBOOT_VERIFY_FIRMWARE=n, CONFIG_BUILD_WITH_FAKE_IFD=n, and
    CONFIG_HAVE_ME_BIN=y) results in firmware that successfully gets as
    far as loading depthcharge.
    
    [1] https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/master/sys-boot/coreboot/files/configs/config.panther
    
    Change-Id: I198e2f639a3584deb2b464cf3c237f69d93c1c5f
    Signed-off-by: Sol Boucher <solb at chromium.org>
---
 src/drivers/elog/elog.c                      |  33 +-----
 src/lib/Makefile.inc                         |   4 +-
 src/mainboard/google/butterfly/mainboard.c   |  16 +--
 src/mainboard/google/panther/lan.c           |  10 +-
 src/northbridge/intel/haswell/mrccache.c     |  18 +--
 src/northbridge/intel/sandybridge/mrccache.c |  18 +--
 src/soc/intel/common/mrc_cache.c             |  21 ++--
 src/vendorcode/google/chromeos/Makefile.inc  |   4 -
 src/vendorcode/google/chromeos/cros_vpd.c    |  38 ++++---
 src/vendorcode/google/chromeos/fmap.c        | 157 ---------------------------
 src/vendorcode/google/chromeos/fmap.h        |  46 --------
 11 files changed, 76 insertions(+), 289 deletions(-)

diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c
index d7751c2..e5a99a6 100644
--- a/src/drivers/elog/elog.c
+++ b/src/drivers/elog/elog.c
@@ -26,6 +26,7 @@
 #include <pc80/mc146818rtc.h>
 #endif
 #include <bcd.h>
+#include <fmap.h>
 #include <rtc.h>
 #include <smbios.h>
 #include <spi-generic.h>
@@ -35,8 +36,6 @@
 #include <elog.h>
 #include "elog_internal.h"
 
-#include <vendorcode/google/chromeos/fmap.h>
-
 #if !IS_ENABLED(CONFIG_CHROMEOS) && CONFIG_ELOG_FLASH_BASE == 0
 #error "CONFIG_ELOG_FLASH_BASE is invalid"
 #endif
@@ -86,26 +85,6 @@ static inline u32 get_rom_size(void)
 }
 
 /*
- * Convert a memory mapped flash address into a flash offset
- */
-static inline u32 elog_flash_address_to_offset(u8 *address)
-{
-#if CONFIG_ARCH_X86
-	/* For x86, assume address is memory-mapped near 4GB */
-	u32 rom_size;
-
-	if (!elog_spi)
-		return 0;
-
-	rom_size = get_rom_size();
-
-	return (u32)address - ((u32)~0UL - rom_size + 1);
-#else
-	return (u32)(uintptr_t)address;
-#endif
-}
-
-/*
  * Pointer to an event log header in the event data area
  */
 static inline struct event_header*
@@ -517,16 +496,16 @@ static void elog_find_flash(void)
 {
 	elog_debug("elog_find_flash()\n");
 
+	// TODO: Eliminate the base Kconfig option and always read from FMAP.
 #if CONFIG_CHROMEOS
 	/* Find the ELOG base and size in FMAP */
-	u8 *flash_base_ptr;
-	int fmap_size = find_fmap_entry("RW_ELOG", (void **)&flash_base_ptr);
-	if (fmap_size < 0) {
+	struct region section;
+	if (fmap_locate_area("RW_ELOG", &section) < 0) {
 		printk(BIOS_WARNING, "ELOG: Unable to find RW_ELOG in FMAP\n");
 		flash_base = total_size = 0;
 	} else {
-		flash_base = elog_flash_address_to_offset(flash_base_ptr);
-		total_size = MIN(fmap_size, CONFIG_ELOG_AREA_SIZE);
+		flash_base = section.offset;
+		total_size = MIN(section.size, CONFIG_ELOG_AREA_SIZE);
 	}
 #else
 	flash_base = CONFIG_ELOG_FLASH_BASE;
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 1c69c95..34b31c7 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -140,7 +140,9 @@ ramstage-y += mem_pool.c
 romstage-y += region.c
 ramstage-y += region.c
 
-smm-y += cbfs.c memcmp.c
+smm-y += cbfs.c
+smm-y += fmap.c
+smm-y += memcmp.c
 smm-y += region.c
 smm-y += mem_pool.c
 smm-$(CONFIG_COMPILER_GCC) += gcc.c
diff --git a/src/mainboard/google/butterfly/mainboard.c b/src/mainboard/google/butterfly/mainboard.c
index 5420f72..65debe7 100644
--- a/src/mainboard/google/butterfly/mainboard.c
+++ b/src/mainboard/google/butterfly/mainboard.c
@@ -18,6 +18,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <cbfs.h>
+#include <fmap.h>
 #include <types.h>
 #include <string.h>
 #include <device/device.h>
@@ -36,11 +38,6 @@
 #include <smbios.h>
 #include <device/pci.h>
 #include <ec/quanta/ene_kb3940q/ec.h>
-#if CONFIG_CHROMEOS
-#include <vendorcode/google/chromeos/fmap.h>
-#else
-#include <cbfs.h>
-#endif
 
 static unsigned int search(char *p, char *a, unsigned int lengthp,
 			   unsigned int lengtha)
@@ -201,9 +198,12 @@ static void mainboard_init(device_t dev)
 	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);
+	struct region_device region;
+	if (fmap_locate_area_as_rdev("RO_VPD", &region) >= 0) {
+		search_address = (unsigned long)rdev_mmap(&region, 0,
+							region.region.size);
+		search_length = region.region.size;
+	}
 #else
 	void *vpd_file = cbfs_boot_map_with_leak("vpd.bin", CBFS_TYPE_RAW,
 							&search_length);
diff --git a/src/mainboard/google/panther/lan.c b/src/mainboard/google/panther/lan.c
index 22da881..8500d90 100644
--- a/src/mainboard/google/panther/lan.c
+++ b/src/mainboard/google/panther/lan.c
@@ -18,6 +18,7 @@
  */
 
 #include <cbfs.h>
+#include <fmap.h>
 #include <string.h>
 #include <types.h>
 #include <arch/io.h>
@@ -25,7 +26,6 @@
 #include <device/device.h>
 #include <device/pci.h>
 #include <southbridge/intel/bd82x6x/pch.h>
-#include <vendorcode/google/chromeos/fmap.h>
 #include "onboard.h"
 
 static unsigned int search(char *p, u8 *a, unsigned int lengthp,
@@ -118,14 +118,18 @@ static void program_mac_address(u16 io_base)
 	u32 low_dword = 0x0000AD0B;	/* low word of mac address as a dword */
 
 #if CONFIG_CHROMEOS
-	search_length = find_fmap_entry("RO_VPD", &search_address);
+	struct region_device region;
+	if (fmap_locate_area_as_rdev("RO_VPD", &region) >= 0) {
+		search_address = rdev_mmap(&region, 0, region.region.size);
+		search_length = region.region.size;
+	}
 #else
 	search_address = cbfs_boot_map_with_leak("vpd.bin", CBFS_TYPE_RAW,
 							&search_length);
 #endif
 
 	if (search_length <= 0)
-		printk(BIOS_ERR, "LAN: find_fmap_entry returned -1.\n");
+		printk(BIOS_ERR, "LAN: Unable to find saved MAC address!\n");
 	else
 		get_mac_address(&high_dword, &low_dword, search_address,
 				search_length);
diff --git a/src/northbridge/intel/haswell/mrccache.c b/src/northbridge/intel/haswell/mrccache.c
index d6522a0..15845f8 100644
--- a/src/northbridge/intel/haswell/mrccache.c
+++ b/src/northbridge/intel/haswell/mrccache.c
@@ -22,6 +22,7 @@
 #include <bootstate.h>
 #include <console/console.h>
 #include <cbfs.h>
+#include <fmap.h>
 #include <ip_checksum.h>
 #include <device/device.h>
 #include <cbmem.h>
@@ -30,7 +31,6 @@
 #include <spi-generic.h>
 #include <spi_flash.h>
 #if CONFIG_CHROMEOS
-#include <vendorcode/google/chromeos/fmap.h>
 #endif
 
 /* convert a pointer to flash area into the offset inside the flash */
@@ -58,16 +58,18 @@ static int is_mrc_cache(struct mrc_data_container *mrc_cache)
 	return (!!mrc_cache) && (mrc_cache->mrc_signature == MRC_DATA_SIGNATURE);
 }
 
-/* Right now, the offsets for the MRC cache area are hard-coded in the
- * northbridge Kconfig if CONFIG_CHROMEOS is not set. In order to make
- * this more flexible, there are two of options:
- *  - Have each mainboard Kconfig supply a hard-coded offset
- *  - Use CBFS
- */
 static u32 get_mrc_cache_region(struct mrc_data_container **mrc_region_ptr)
 {
+	// TODO: Eliminate the CBFS access/write and always read from FMAP.
 #if CONFIG_CHROMEOS
-	return find_fmap_entry("RW_MRC_CACHE", (void **)mrc_region_ptr);
+	struct region_device region;
+	if (fmap_locate_area_as_rdev("RW_MRC_CACHE", &region) < 0) {
+		*mrc_region_ptr = NULL;
+		return 0;
+	}
+	*mrc_region_ptr = (struct mrc_data_container *)rdev_mmap(&region, 0,
+							region.region.size);
+	return region.region.size;
 #else
 	size_t region_size;
 	*mrc_region_ptr = cbfs_boot_map_with_leak("mrc.cache",
diff --git a/src/northbridge/intel/sandybridge/mrccache.c b/src/northbridge/intel/sandybridge/mrccache.c
index 6b02c21..60e4b25 100644
--- a/src/northbridge/intel/sandybridge/mrccache.c
+++ b/src/northbridge/intel/sandybridge/mrccache.c
@@ -22,6 +22,7 @@
 #include <bootstate.h>
 #include <console/console.h>
 #include <cbfs.h>
+#include <fmap.h>
 #include <ip_checksum.h>
 #include <device/device.h>
 #include <cbmem.h>
@@ -30,7 +31,6 @@
 #include <spi-generic.h>
 #include <spi_flash.h>
 #if CONFIG_CHROMEOS
-#include <vendorcode/google/chromeos/fmap.h>
 #endif
 
 /* convert a pointer to flash area into the offset inside the flash */
@@ -58,16 +58,18 @@ static int is_mrc_cache(struct mrc_data_container *mrc_cache)
 	return (!!mrc_cache) && (mrc_cache->mrc_signature == MRC_DATA_SIGNATURE);
 }
 
-/* Right now, the offsets for the MRC cache area are hard-coded in the
- * northbridge Kconfig if CONFIG_CHROMEOS is not set. In order to make
- * this more flexible, there are two of options:
- *  - Have each mainboard Kconfig supply a hard-coded offset
- *  - Use CBFS
- */
 static u32 get_mrc_cache_region(struct mrc_data_container **mrc_region_ptr)
 {
+	// TODO: Eliminate the CBFS access/write and always read from FMAP.
 #if CONFIG_CHROMEOS
-	return find_fmap_entry("RW_MRC_CACHE", (void **)mrc_region_ptr);
+	struct region_device region;
+	if (fmap_locate_area_as_rdev("RW_MRC_CACHE", &region) < 0) {
+		*mrc_region_ptr = NULL;
+		return 0;
+	}
+	*mrc_region_ptr = (struct mrc_data_container *)rdev_mmap(&region, 0,
+							region.region.size);
+	return region.region.size;
 #else
 	size_t region_size;
 	*mrc_region_ptr = cbfs_boot_map_with_leak("mrc.cache",
diff --git a/src/soc/intel/common/mrc_cache.c b/src/soc/intel/common/mrc_cache.c
index f854046..3155fae 100644
--- a/src/soc/intel/common/mrc_cache.c
+++ b/src/soc/intel/common/mrc_cache.c
@@ -20,9 +20,9 @@
 #include <string.h>
 #include <console/console.h>
 #include <cbmem.h>
+#include <fmap.h>
 #include <ip_checksum.h>
 #if CONFIG_CHROMEOS
-#include <vendorcode/google/chromeos/fmap.h>
 #endif
 #include "mrc_cache.h"
 
@@ -37,18 +37,19 @@ struct mrc_data_region {
 };
 
 /* common code */
-static int mrc_cache_get_region(struct mrc_data_region *region)
+static int mrc_cache_get_region(struct mrc_data_region *data_region)
 {
+	// TODO: Eliminate the CBFS access/write and always read from FMAP.
 #if CONFIG_CHROMEOS
-	int ret;
-	ret = find_fmap_entry("RW_MRC_CACHE", &region->base);
-	if (ret >= 0) {
-		region->size = ret;
-		return 0;
-	}
+	struct region_device region;
+	if (fmap_locate_area_as_rdev("RW_MRC_CACHE", &region) < 0)
+		return -1;
+	data_region->base = rdev_mmap(&region, 0, region.region.size);
+	data_region->size = region.region.size;
+	return 0;
 #endif
-	region->base = (void *)CONFIG_MRC_SETTINGS_CACHE_BASE;
-	region->size = CONFIG_MRC_SETTINGS_CACHE_SIZE;
+	data_region->base = (void *)CONFIG_MRC_SETTINGS_CACHE_BASE;
+	data_region->size = CONFIG_MRC_SETTINGS_CACHE_SIZE;
 	return 0;
 }
 
diff --git a/src/vendorcode/google/chromeos/Makefile.inc b/src/vendorcode/google/chromeos/Makefile.inc
index 0c66985..87bbc82 100644
--- a/src/vendorcode/google/chromeos/Makefile.inc
+++ b/src/vendorcode/google/chromeos/Makefile.inc
@@ -35,11 +35,7 @@ ramstage-$(CONFIG_CHROMEOS_VBNV_FLASH) += vbnv_flash.c
 romstage-$(CONFIG_ARCH_ROMSTAGE_X86_32) += vboot.c
 ramstage-$(CONFIG_ELOG) += elog.c
 ramstage-$(CONFIG_HAVE_ACPI_TABLES) += gnvs.c
-verstage-y += fmap.c
-romstage-y += fmap.c
-ramstage-y += fmap.c
 ramstage-$(CONFIG_CHROMEOS_RAMOOPS) += ramoops.c
-smm-y += fmap.c
 romstage-y += vpd_decode.c cros_vpd.c
 ramstage-y += vpd_decode.c cros_vpd.c vpd_mac.c vpd_serialno.c vpd_calibration.c
 ifeq ($(CONFIG_ARCH_X86)$(CONFIG_ARCH_MIPS),)
diff --git a/src/vendorcode/google/chromeos/cros_vpd.c b/src/vendorcode/google/chromeos/cros_vpd.c
index c0e4830..bd28e30 100644
--- a/src/vendorcode/google/chromeos/cros_vpd.c
+++ b/src/vendorcode/google/chromeos/cros_vpd.c
@@ -7,11 +7,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"
 
@@ -30,14 +30,14 @@ struct vpd_gets_arg {
 static int cros_vpd_load(uint8_t **vpd_address, int32_t *vpd_size)
 {
 	MAYBE_STATIC int cached = 0;
+	MAYBE_STATIC uint8_t *mapped_address = NULL;
 	MAYBE_STATIC uint8_t *cached_address = NULL;
 	MAYBE_STATIC int32_t cached_size = 0;
 	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 region;
 
 	if (cached) {
 		*vpd_address = cached_address;
@@ -46,32 +46,36 @@ 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", &region) < 0) {
 		printk(BIOS_ERR, "%s: No RO_VPD FMAP section.\n", __func__);
 		return result;
 	}
-	if (area->size <= GOOGLE_VPD_2_0_OFFSET + sizeof(info)) {
+	if (region.region.size <= GOOGLE_VPD_2_0_OFFSET + sizeof(info)) {
 		printk(BIOS_ERR, "%s: Too small (%d) for Google VPD 2.0.\n",
-		       __func__, area->size);
+		       __func__, region.region.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);
+	base = GOOGLE_VPD_2_0_OFFSET;
+	cached_size = region.region.size - GOOGLE_VPD_2_0_OFFSET;
+	mapped_address = rdev_mmap(&region, base, cached_size);
+	if (!mapped_address) {
+		printk(BIOS_ERR, "%s: Couldn't map Google VPD from flash offset %#x.\n",
+			__func__, region.region.offset);
+		return result;
+	}
 
 	/* Try if we can find a google_vpd_info, otherwise read whole VPD. */
-	if (media.read(&media, &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_address = mapped_address;
+	memcpy(&info, cached_address, sizeof(info));
+	if (memcmp(info.header.magic, VPD_INFO_MAGIC, sizeof(info.header.magic))
+	    == 0 && cached_size >= info.size + sizeof(info) &&
+	    sizeof(info) + info.size <= cached_size) {
+		cached_address += sizeof(info);
 		cached_size = info.size;
 	}
+	rdev_munmap(&region, mapped_address);
 
-	cached_address = media.map(&media, base, cached_size);
-	media.close(&media);
 	if (cached_address) {
 		*vpd_address = cached_address;
 		*vpd_size = cached_size;
diff --git a/src/vendorcode/google/chromeos/fmap.c b/src/vendorcode/google/chromeos/fmap.c
deleted file mode 100644
index 21d439e..0000000
--- a/src/vendorcode/google/chromeos/fmap.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2012 The ChromiumOS Authors.  All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdint.h>
-#include <stddef.h>
-#include <string.h>
-#include <console/console.h>
-#include <cbfs.h>
-#include "fmap.h"
-
-static int is_fmap_signature_valid(const struct fmap *fmap)
-{
-	const char reversed_sig[] = FMAP_REVERSED_SIGNATURE;
-	const char *p2 = reversed_sig + sizeof(FMAP_REVERSED_SIGNATURE) - 2;
-	const char *p1 = (char *)fmap;
-
-	while (p2 >= reversed_sig)
-		if (*p1++ != *p2--) {
-			printk(BIOS_ERR, "No FMAP found at %p.\n", fmap);
-			return 1;
-		}
-
-	printk(BIOS_DEBUG, "FMAP: Found \"%s\" version %d.%d at %p.\n",
-	       fmap->name, fmap->ver_major, fmap->ver_minor, fmap);
-	printk(BIOS_DEBUG, "FMAP: base = %llx size = %x #areas = %d\n",
-	       (unsigned long long)fmap->base, fmap->size, fmap->nareas);
-
-	return 0;
-}
-
-/* Find FMAP data structure in ROM.
- * See http://code.google.com/p/flashmap/ for more information on FMAP.
- */
-const struct fmap *fmap_find(void)
-{
-	/* FIXME: Get rid of the hard codes. The "easy" way would be to
-	 * do a binary search, but since ROM accesses are slow, we don't
-	 * want to spend a lot of time looking for the FMAP. An elegant
-	 * solution would be to store a pointer to the FMAP in the CBFS
-	 * master header; that would require some more changes to cbfstool
-	 * and possibly cros_bundle_firmware.
-	 */
-	const struct fmap *fmap;
-	struct cbfs_media media;
-	size_t size;
-
-	if (init_default_cbfs_media(&media)) {
-		printk(BIOS_ERR, "failed to init default cbfs media\n");
-		return NULL;
-	}
-
-	media.open(&media);
-	fmap = media.map(&media, CONFIG_FLASHMAP_OFFSET, sizeof(*fmap));
-
-	if (fmap == CBFS_MEDIA_INVALID_MAP_ADDRESS) {
-		printk(BIOS_ERR, "failed to map FMAP header\n");
-		media.close(&media);
-		return NULL;
-	}
-
-	if (is_fmap_signature_valid(fmap)) {
-		media.unmap(&media, fmap);
-		media.close(&media);
-		return NULL;
-	}
-
-	size = sizeof(*fmap) + sizeof(struct fmap_area) * fmap->nareas;
-	media.unmap(&media, fmap);
-	fmap = media.map(&media, CONFIG_FLASHMAP_OFFSET, size);
-
-	if (fmap == CBFS_MEDIA_INVALID_MAP_ADDRESS) {
-		printk(BIOS_ERR, "failed to map FMAP (size=%zu)\n", size);
-		media.unmap(&media, fmap);
-		media.close(&media);
-		return NULL;
-	}
-
-	media.close(&media);
-	return fmap;
-}
-
-const struct fmap_area *find_fmap_area(const struct fmap *fmap,
-							const char name[])
-{
-	const struct fmap_area *area = NULL;
-
-	if (fmap) {
-		int i;
-		for (i = 0; i < fmap->nareas; i++) {
-			if (!strcmp((const char *)fmap->areas[i].name, name)) {
-				area = &fmap->areas[i];
-				break;
-			}
-		}
-	}
-
-	if (area) {
-		printk(BIOS_DEBUG, "FMAP: area %s found\n", name);
-		printk(BIOS_DEBUG, "FMAP:   offset: %x\n", area->offset);
-		printk(BIOS_DEBUG, "FMAP:   size:   %d bytes\n", area->size);
-	} else {
-		printk(BIOS_DEBUG, "FMAP: area %s not found\n", name);
-	}
-
-	return area;
-}
-
-int find_fmap_entry(const char name[], void **pointer)
-{
-	MAYBE_STATIC const struct fmap *fmap = NULL;
-	const struct fmap_area *area;
-	void *base = NULL;
-
-	if (!fmap)
-		fmap = fmap_find();
-
-	area = find_fmap_area(fmap, name);
-
-	if (!area)
-		return -1;
-
-	/* Right now cros_bundle_firmware does not write a valid
-	 * base address into the FMAP. Hence, if base is 0, assume
-	 * 4GB-8MB as base address.
-	 */
-	if (fmap->base) {
-		base = (void *)(unsigned long)fmap->base;
-		printk(BIOS_DEBUG, "FMAP: %s base at %p\n", name, base);
-	} else {
-#if CONFIG_ARCH_X86
-		base = (void *)(0 - CONFIG_ROM_SIZE);
-		printk(BIOS_WARNING, "FMAP: No valid base address, using"
-				" 0x%p\n", base);
-#endif
-	}
-
-	*pointer = (void*) ((uintptr_t)base + area->offset);
-	printk(BIOS_DEBUG, "FMAP: %s at %p (offset %x)\n",
-	       name, *pointer, area->offset);
-	return area->size;
-}
diff --git a/src/vendorcode/google/chromeos/fmap.h b/src/vendorcode/google/chromeos/fmap.h
deleted file mode 100644
index fc84f15..0000000
--- a/src/vendorcode/google/chromeos/fmap.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2010, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *    * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *    * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *    * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- */
-
-#ifndef FLASHMAP_LIB_FMAP_H__
-#define FLASHMAP_LIB_FMAP_H__
-
-#include <fmap_serialized.h>
-
-/* coreboot specific function prototypes */
-const struct fmap *fmap_find(void);
-const struct fmap_area *find_fmap_area(const struct fmap *fmap,
-							const char name[]);
-int find_fmap_entry(const char name[], void **pointer);
-#endif	/* FLASHMAP_LIB_FMAP_H__*/



More information about the coreboot-gerrit mailing list