aboutsummaryrefslogtreecommitdiff
path: root/src/vendorcode
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2012-10-15 14:30:28 -0700
committerRonald G. Minnich <rminnich@gmail.com>2012-11-12 17:11:53 +0100
commitad6779138238dc34e8f9da47730229b5891b5fe1 (patch)
treec92f05257aef5f6072402459452e1753ed8ef014 /src/vendorcode
parent08067ba9cbf9904f6637775fe64c8b43229896b6 (diff)
Avoid using hardcoded values in MRC cache code
The MRC cache code, as implemented, in some cases uses configuration settings for MRC cache region, and in some cases - the values read from FMAP. These do not necessarily match, the code should use FMAP across the board. This change also refactors mrccache.c to limit number of iterations through the cache area and number of fmap area searches. Change-Id: Idb9cb70ead4baa3601aa244afc326d5be0d06446 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: http://review.coreboot.org/1788 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'src/vendorcode')
-rw-r--r--src/vendorcode/google/chromeos/fmap.c50
1 files changed, 20 insertions, 30 deletions
diff --git a/src/vendorcode/google/chromeos/fmap.c b/src/vendorcode/google/chromeos/fmap.c
index 0871529a75..538b8c359c 100644
--- a/src/vendorcode/google/chromeos/fmap.c
+++ b/src/vendorcode/google/chromeos/fmap.c
@@ -23,44 +23,32 @@
#include <console/console.h>
#include "fmap.h"
-static int fmap_try_find(void *fmap)
-{
- if (!memcmp(fmap, FMAP_SIGNATURE,
- sizeof(FMAP_SIGNATURE)-1))
- return 1;
- 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)
{
- const struct fmap *fmap = NULL;
-
/* 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.
- * FIXME: Use CONFIG_ROMSIZE instead of CONFIG_MRC_CACHE_BASE
- * (and get rid of CONFIG_MRC_CACHE_BASE), once we are building
- * coreboot images with ME firmware etc built in instead of just
- * the CBFS part.
*/
- if (fmap_try_find((void *)CONFIG_MRC_CACHE_BASE +
- CONFIG_FLASHMAP_OFFSET))
- fmap = (const struct fmap *)(CONFIG_MRC_CACHE_BASE +
- CONFIG_FLASHMAP_OFFSET);
- if (fmap) {
- 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);
- } else
- printk(BIOS_DEBUG, "No FMAP found.\n");
+
+ /* wrapping around 0x100000000 */
+ const struct fmap *fmap = (void *)
+ (CONFIG_FLASHMAP_OFFSET - CONFIG_ROM_SIZE);
+
+ if (memcmp(fmap, FMAP_SIGNATURE, sizeof(FMAP_SIGNATURE)-1)) {
+ printk(BIOS_DEBUG, "No FMAP found at %p.\n", fmap);
+ return NULL;
+ }
+
+ 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 fmap;
}
@@ -114,13 +102,15 @@ int find_fmap_entry(const char name[], void **pointer)
*/
if (fmap->base) {
base = (void *)(unsigned long)fmap->base;
+ printk(BIOS_DEBUG, "FMAP: %s base at %p\n", name, base);
} else {
+ base = (void *)(0 - CONFIG_ROM_SIZE);
printk(BIOS_WARNING, "FMAP: No valid base address, using"
- " 0x%08x\n", CONFIG_MRC_CACHE_BASE);
- base = (void *)CONFIG_MRC_CACHE_BASE;
+ " 0x%p\n", base);
}
- *pointer = base + area->offset;
-
+ *pointer = (void*) ((u32)base + area->offset);
+ printk(BIOS_DEBUG, "FMAP: %s at %p (offset %x)\n",
+ name, *pointer, area->offset);
return area->size;
}