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>
This commit is contained in:
Furquan Shaikh 2016-07-15 15:54:36 -07:00
parent d83b0e9ac4
commit e19d9af9ee
1 changed files with 8 additions and 6 deletions

View File

@ -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;