From e19d9af9eed7540f52d39d746314877ab6e0bfe5 Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Fri, 15 Jul 2016 15:54:36 -0700 Subject: 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 Reviewed-on: https://review.coreboot.org/15722 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/drivers/elog/elog.c | 14 ++++++++------ 1 file 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 #endif #include +#include +#include #include #include #include @@ -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; -- cgit v1.2.3