From 0424c95a6dafdb65070538d6c5aa394b75eb9850 Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Sat, 28 Mar 2015 23:56:22 -0500 Subject: fmap: new API using region_device Instead of being pointer based use the region infrastrucutre. Additionally, this removes the need for arch-specific compilation paths. The users of the new API can use the region APIs to memory map or read the region provided by the new fmap API. Change-Id: Ie36e9ff9cb554234ec394b921f029eeed6845aee Signed-off-by: Aaron Durbin Reviewed-on: http://review.coreboot.org/9170 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- src/drivers/elog/elog.c | 49 +++++++++++++++---------------------------------- 1 file changed, 15 insertions(+), 34 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c index da1f6fa1c0..8dce86b698 100644 --- a/src/drivers/elog/elog.c +++ b/src/drivers/elog/elog.c @@ -26,6 +26,7 @@ #include #endif #include +#include #include #include #include @@ -35,7 +36,6 @@ #include #include "elog_internal.h" -#include #if !IS_ENABLED(CONFIG_CHROMEOS) && CONFIG_ELOG_FLASH_BASE == 0 #error "CONFIG_ELOG_FLASH_BASE is invalid" @@ -85,26 +85,6 @@ static inline u32 get_rom_size(void) return rom_size; } -/* - * Convert a memory mapped flash address into a flash offset - */ -static inline u32 elog_flash_address_to_offset(u8 *address) -{ -#if CONFIG_ARCH_X86 - /* For x86, assume address is memory-mapped near 4GB */ - u32 rom_size; - - if (!elog_spi) - return 0; - - rom_size = get_rom_size(); - - return (u32)address - ((u32)~0UL - rom_size + 1); -#else - return (u32)(uintptr_t)address; -#endif -} - /* * Pointer to an event log header in the event data area */ @@ -517,21 +497,22 @@ static void elog_find_flash(void) { elog_debug("elog_find_flash()\n"); -#if CONFIG_CHROMEOS - /* Find the ELOG base and size in FMAP */ - u8 *flash_base_ptr; - int fmap_size = find_fmap_entry("RW_ELOG", (void **)&flash_base_ptr); - if (fmap_size < 0) { - printk(BIOS_WARNING, "ELOG: Unable to find RW_ELOG in FMAP\n"); - flash_base = total_size = 0; + if (IS_ENABLED(CONFIG_CHROMEOS)) { + /* Find the ELOG base and size in FMAP */ + struct region r; + + if (fmap_locate_area("RW_ELOG", &r) < 0) { + printk(BIOS_WARNING, + "ELOG: Unable to find RW_ELOG in FMAP\n"); + flash_base = total_size = 0; + } else { + flash_base = region_offset(&r); + total_size = MIN(region_sz(&r), CONFIG_ELOG_AREA_SIZE); + } } else { - flash_base = elog_flash_address_to_offset(flash_base_ptr); - total_size = MIN(fmap_size, CONFIG_ELOG_AREA_SIZE); + flash_base = CONFIG_ELOG_FLASH_BASE; + total_size = CONFIG_ELOG_AREA_SIZE; } -#else - flash_base = CONFIG_ELOG_FLASH_BASE; - total_size = CONFIG_ELOG_AREA_SIZE; -#endif log_size = total_size - sizeof(struct elog_header); full_threshold = log_size - ELOG_MIN_AVAILABLE_ENTRIES * MAX_EVENT_SIZE; shrink_size = MIN(total_size * ELOG_SHRINK_PERCENTAGE / 100, -- cgit v1.2.3