[coreboot-gerrit] Patch set updated for coreboot: 3553c04 elog: handle ROM_SIZE differences from detected flash size
Stefan Reinauer (stefan.reinauer@coreboot.org)
gerrit at coreboot.org
Fri Dec 6 00:40:31 CET 2013
Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4332
-gerrit
commit 3553c04f7d66853f3e86f1c584a6fa63ba36ce95
Author: Aaron Durbin <adurbin at chromium.org>
Date: Fri Jun 28 12:30:53 2013 -0700
elog: handle ROM_SIZE differences from detected flash size
The elog code calculates flash offsets and their equivalent
addresses in the memory address space. However, it assumes
the detected flash size is entirely mapped into the address
space. This can lead to incorrect calculations. Add code
to allow ROM_SIZE to be less than detected flash size. The
underlying assumption is that the first ROM_SIZE bytes are
programmed into the larger device.
Change-Id: Id848f136515289b40594b7d3762e26e3e55da62f
Signed-off-by: Aaron Durbin <adurbin at chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60501
Reviewed-by: Duncan Laurie <dlaurie at chromium.org>
---
src/drivers/elog/elog.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c
index cff7886..de34928 100644
--- a/src/drivers/elog/elog.c
+++ b/src/drivers/elog/elog.c
@@ -72,14 +72,33 @@ static u16 event_count;
static int elog_initialized;
static struct spi_flash *elog_spi;
+
+static inline u32 get_rom_size(void)
+{
+ u32 rom_size;
+
+ /* Assume the used space of the ROM image starts from 0. The
+ * physical size of the device may not be completely used. */
+ rom_size = elog_spi->size;
+ if (rom_size > CONFIG_ROM_SIZE)
+ rom_size = CONFIG_ROM_SIZE;
+
+ return rom_size;
+}
+
/*
* Convert a memory mapped flash address into a flash offset
*/
static inline u32 elog_flash_address_to_offset(u8 *address)
{
+ u32 rom_size;
+
if (!elog_spi)
return 0;
- return (u32)address - ((u32)~0UL - elog_spi->size + 1);
+
+ rom_size = get_rom_size();
+
+ return (u32)address - ((u32)~0UL - rom_size + 1);
}
/*
@@ -87,9 +106,14 @@ static inline u32 elog_flash_address_to_offset(u8 *address)
*/
static inline u8* elog_flash_offset_to_address(u32 offset)
{
+ u32 rom_size;
+
if (!elog_spi)
return NULL;
- return (u8*)((u32)~0UL - elog_spi->size + 1 + offset);
+
+ rom_size = get_rom_size();
+
+ return (u8*)((u32)~0UL - rom_size + 1 + offset);
}
/*
More information about the coreboot-gerrit
mailing list