From 1fc7a75f8c072098e017104788418aeed0705e93 Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Thu, 20 Mar 2014 20:31:23 -0700 Subject: [PATCH] elog: Isolate some x86-isms This attempts to isolate/fix some x86-isms: - Translate flash offset to memory-mapped address only on x86. - Guard ACPI-dependent line of code - Use a Kconfig variable for SPI bus when probing the flash rather than assuming the bus is always on bus 0. - Zero-out timestamp on non-x86 until we have a better abstraction. (note: this is based off of some of Gabe's earlier work) BUG=none BRANCH=none TEST=needs testing Signed-off-by: David Hendricks Change-Id: I887576d8bcabe374d8684aa5588f738b36170ef7 Reviewed-on: https://chromium-review.googlesource.com/191203 Commit-Queue: David Hendricks Tested-by: David Hendricks Reviewed-by: Gabe Black --- src/drivers/elog/elog.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c index 1d7a5b0e6a..9b9ea9de41 100644 --- a/src/drivers/elog/elog.c +++ b/src/drivers/elog/elog.c @@ -17,10 +17,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA */ +#if CONFIG_HAVE_ACPI_RESUME == 1 #include +#endif #include #include +#if CONFIG_ARCH_X86 #include +#endif #include #include #include @@ -91,6 +95,8 @@ static inline u32 get_rom_size(void) */ 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) @@ -99,6 +105,9 @@ static inline u32 elog_flash_address_to_offset(u8 *address) rom_size = get_rom_size(); return (u32)address - ((u32)~0UL - rom_size + 1); +#else + return (u32)address; +#endif } /* @@ -606,12 +615,18 @@ int elog_init(void) #if !defined(__SMM__) /* Log boot count event except in S3 resume */ - if (CONFIG_ELOG_BOOT_COUNT && acpi_slp_type != 3) +#if CONFIG_ELOG_BOOT_COUNT == 1 +#if CONFIG_HAVE_ACPI_RESUME == 1 + if (acpi_slp_type != 3) +#endif elog_add_event_dword(ELOG_TYPE_BOOT, boot_count_read()); +#endif +#if CONFIG_ARCH_X86 /* Check and log POST codes from previous boot */ if (CONFIG_CMOS_POST) cmos_post_log(); +#endif #endif return 0; @@ -622,12 +637,20 @@ int elog_init(void) */ static void elog_fill_timestamp(struct event_header *event) { +#if CONFIG_ARCH_X86 event->second = cmos_read(RTC_CLK_SECOND); event->minute = cmos_read(RTC_CLK_MINUTE); event->hour = cmos_read(RTC_CLK_HOUR); event->day = cmos_read(RTC_CLK_DAYOFMONTH); event->month = cmos_read(RTC_CLK_MONTH); event->year = cmos_read(RTC_CLK_YEAR); +#else + /* + * FIXME: We need to abstract the CMOS stuff on non-x86 platforms. + * Until then, use bogus data here to force the values to 0. + */ + event->month = 0xff; +#endif /* Basic sanity check of expected ranges */ if (event->month > 0x12 || event->day > 0x31 || event->hour > 0x23 ||