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 <dhendrix@chromium.org>

Original-Change-Id: I887576d8bcabe374d8684aa5588f738b36170ef7
Original-Reviewed-on: https://chromium-review.googlesource.com/191203
Original-Commit-Queue: David Hendricks <dhendrix@chromium.org>
Original-Tested-by: David Hendricks <dhendrix@chromium.org>
Original-Reviewed-by: Gabe Black <gabeblack@chromium.org>
(cherry picked from commit 1fc7a75f8c072098e017104788418aeed0705e93)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>

Change-Id: Ida4b211cf21ecdde9745d4dbef6a63ffb9fbba8d
Reviewed-on: http://review.coreboot.org/7832
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
David Hendricks 2014-03-20 20:31:23 -07:00 committed by Marc Jones
parent 9acbd6ff99
commit 259e49a2c7
1 changed files with 25 additions and 2 deletions

View File

@ -17,10 +17,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
*/ */
#if CONFIG_HAVE_ACPI_RESUME == 1
#include <arch/acpi.h> #include <arch/acpi.h>
#endif
#include <cbmem.h> #include <cbmem.h>
#include <console/console.h> #include <console/console.h>
#if CONFIG_ARCH_X86
#include <pc80/mc146818rtc.h> #include <pc80/mc146818rtc.h>
#endif
#include <smbios.h> #include <smbios.h>
#include <spi-generic.h> #include <spi-generic.h>
#include <spi_flash.h> #include <spi_flash.h>
@ -29,12 +33,12 @@
#include <elog.h> #include <elog.h>
#include "elog_internal.h" #include "elog_internal.h"
#if CONFIG_CHROMEOS
#include <vendorcode/google/chromeos/fmap.h> #include <vendorcode/google/chromeos/fmap.h>
#if CONFIG_ELOG_FLASH_BASE == 0 #if CONFIG_ELOG_FLASH_BASE == 0
#error "CONFIG_ELOG_FLASH_BASE is invalid" #error "CONFIG_ELOG_FLASH_BASE is invalid"
#endif #endif
#if CONFIG_ELOG_FULL_THRESHOLD >= CONFIG_ELOG_AREA_SIZE #if CONFIG_ELOG_FULL_THRESHOLD >= CONFIG_ELOG_AREA_SIZE
#error "CONFIG_ELOG_FULL_THRESHOLD is larger than CONFIG_ELOG_AREA_SIZE" #error "CONFIG_ELOG_FULL_THRESHOLD is larger than CONFIG_ELOG_AREA_SIZE"
#endif #endif
@ -92,6 +96,8 @@ static inline u32 get_rom_size(void)
*/ */
static inline u32 elog_flash_address_to_offset(u8 *address) 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; u32 rom_size;
if (!elog_spi) if (!elog_spi)
@ -100,6 +106,9 @@ static inline u32 elog_flash_address_to_offset(u8 *address)
rom_size = get_rom_size(); rom_size = get_rom_size();
return (u32)address - ((u32)~0UL - rom_size + 1); return (u32)address - ((u32)~0UL - rom_size + 1);
#else
return (u32)address;
#endif
} }
/* /*
@ -607,12 +616,18 @@ int elog_init(void)
#if !defined(__SMM__) #if !defined(__SMM__)
/* Log boot count event except in S3 resume */ /* Log boot count event except in S3 resume */
if (CONFIG_ELOG_BOOT_COUNT && !acpi_is_wakeup_s3()) #if CONFIG_ELOG_BOOT_COUNT == 1
#if CONFIG_HAVE_ACPI_RESUME == 1
if (!acpi_is_wakeup_s3())
#endif
elog_add_event_dword(ELOG_TYPE_BOOT, boot_count_read()); elog_add_event_dword(ELOG_TYPE_BOOT, boot_count_read());
#endif
#if CONFIG_ARCH_X86
/* Check and log POST codes from previous boot */ /* Check and log POST codes from previous boot */
if (CONFIG_CMOS_POST) if (CONFIG_CMOS_POST)
cmos_post_log(); cmos_post_log();
#endif
#endif #endif
return 0; return 0;
@ -623,12 +638,20 @@ int elog_init(void)
*/ */
static void elog_fill_timestamp(struct event_header *event) static void elog_fill_timestamp(struct event_header *event)
{ {
#if CONFIG_ARCH_X86
event->second = cmos_read(RTC_CLK_SECOND); event->second = cmos_read(RTC_CLK_SECOND);
event->minute = cmos_read(RTC_CLK_MINUTE); event->minute = cmos_read(RTC_CLK_MINUTE);
event->hour = cmos_read(RTC_CLK_HOUR); event->hour = cmos_read(RTC_CLK_HOUR);
event->day = cmos_read(RTC_CLK_DAYOFMONTH); event->day = cmos_read(RTC_CLK_DAYOFMONTH);
event->month = cmos_read(RTC_CLK_MONTH); event->month = cmos_read(RTC_CLK_MONTH);
event->year = cmos_read(RTC_CLK_YEAR); 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 */ /* Basic sanity check of expected ranges */
if (event->month > 0x12 || event->day > 0x31 || event->hour > 0x23 || if (event->month > 0x12 || event->day > 0x31 || event->hour > 0x23 ||