summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2016-07-15 15:54:36 -0700
committerFurquan Shaikh <furquan@google.com>2016-07-18 08:12:12 +0200
commite19d9af9eed7540f52d39d746314877ab6e0bfe5 (patch)
tree130177f722a54fe1a257ac126e0aa03f2022680f /src/drivers
parentd83b0e9ac4174cca92ac2c3b83a7e8491a9a1ff4 (diff)
downloadcoreboot-e19d9af9eed7540f52d39d746314877ab6e0bfe5.tar.xz
elog: Use rdev_mmap to find offset of ELOG
In case of elog not being stored in CBMEM, calculate flash offset by using rdev_mmap instead of assuming that the entire flash is mapped just below 4GiB. This allows custom mappings of flash to correctly convert the flash offset to mmap address. BUG=chrome-os-partner:54186 TEST=Verified behavior on reef. mosys able to read out the elog correctly. Change-Id: I3eacd2c9266ecc3da1bd45c86ff9d0e8153ca3f2 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/15722 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/elog/elog.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c
index 71eaad207b..d05ce48368 100644
--- a/src/drivers/elog/elog.c
+++ b/src/drivers/elog/elog.c
@@ -22,6 +22,8 @@
#include <pc80/mc146818rtc.h>
#endif
#include <bcd.h>
+#include <boot_device.h>
+#include <commonlib/region.h>
#include <fmap.h>
#include <rtc.h>
#include <smbios.h>
@@ -411,16 +413,16 @@ static int elog_shrink(void)
/*
* Convert a flash offset into a memory mapped flash address
*/
-static inline u8 *elog_flash_offset_to_address(u32 offset)
+static inline u8 *elog_flash_offset_to_address(void)
{
- u32 rom_size;
+ /* Only support memory-mapped SPI devices. */
+ if (!IS_ENABLED(CONFIG_SPI_FLASH_MEMORY_MAPPED))
+ return NULL;
if (!elog_spi)
return NULL;
- rom_size = get_rom_size();
-
- return (u8 *)((u32)~0UL - rom_size + 1 + offset);
+ return rdev_mmap(boot_device_ro(), flash_base, total_size);
}
/*
@@ -453,7 +455,7 @@ int elog_smbios_write_type15(unsigned long *current, int handle)
#if CONFIG_ELOG_CBMEM
t->address = (u32)cbmem;
#else
- t->address = (u32)elog_flash_offset_to_address(flash_base);
+ t->address = (u32)elog_flash_offset_to_address();
#endif
t->header_format = ELOG_HEADER_TYPE_OEM;
t->log_type_descriptors = 0;