diff options
author | Aaron Durbin <adurbin@chromium.org> | 2015-03-28 23:56:22 -0500 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2015-05-26 22:33:53 +0200 |
commit | 0424c95a6dafdb65070538d6c5aa394b75eb9850 (patch) | |
tree | f5bd9f485a1a44eece1662a29c1435a44ab5c58a /src/drivers/elog/elog.c | |
parent | b6981c0f9c4ce89c4209c14fb326a414096f2ff1 (diff) |
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 <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/9170
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src/drivers/elog/elog.c')
-rw-r--r-- | src/drivers/elog/elog.c | 49 |
1 files changed, 15 insertions, 34 deletions
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 <pc80/mc146818rtc.h> #endif #include <bcd.h> +#include <fmap.h> #include <rtc.h> #include <smbios.h> #include <spi-generic.h> @@ -35,7 +36,6 @@ #include <elog.h> #include "elog_internal.h" -#include <vendorcode/google/chromeos/fmap.h> #if !IS_ENABLED(CONFIG_CHROMEOS) && CONFIG_ELOG_FLASH_BASE == 0 #error "CONFIG_ELOG_FLASH_BASE is invalid" @@ -86,26 +86,6 @@ static inline u32 get_rom_size(void) } /* - * 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 */ static inline struct event_header* @@ -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, |