diff options
author | Karthikeyan Ramasubramanian <kramasub@chromium.org> | 2018-11-08 11:57:51 -0700 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2018-11-15 15:26:48 +0000 |
commit | 5ac4b8552a1cc29167181403466b3fb6dc8ff379 (patch) | |
tree | c899072d8c5d4cabc3a2e0d807e6e562e703fc01 | |
parent | 2a244c682e76eaa048fb15a5e1858d7968fca2cf (diff) |
drivers/elog: Add support for early elog
Add support to log events during the preram stages.
BUG=b:117884485
BRANCH=None
TEST=Add an event log from romstage, boot to ChromeOS
Change-Id: Ia69515961da3bc72740f9b048a53d91af79c5b0d
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com>
Reviewed-on: https://review.coreboot.org/29358
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
-rw-r--r-- | src/drivers/elog/Kconfig | 6 | ||||
-rw-r--r-- | src/drivers/elog/Makefile.inc | 4 | ||||
-rw-r--r-- | src/drivers/elog/elog.c | 18 |
3 files changed, 23 insertions, 5 deletions
diff --git a/src/drivers/elog/Kconfig b/src/drivers/elog/Kconfig index c5ff7aeffe..da8a5fa220 100644 --- a/src/drivers/elog/Kconfig +++ b/src/drivers/elog/Kconfig @@ -36,6 +36,12 @@ config ELOG_CBMEM but it means that events added at runtime via the SMI handler will not be reflected in the CBMEM copy of the log. +config ELOG_PRERAM + bool + default n + help + This option will enable event logging from the preram stage. + endif config ELOG_GSMI diff --git a/src/drivers/elog/Makefile.inc b/src/drivers/elog/Makefile.inc index 79a7cc0f7f..cce1c3d6d7 100644 --- a/src/drivers/elog/Makefile.inc +++ b/src/drivers/elog/Makefile.inc @@ -1,3 +1,7 @@ +bootblock-$(CONFIG_ELOG_PRERAM) += elog.c +verstage-$(CONFIG_ELOG_PRERAM) += elog.c +romstage-$(CONFIG_ELOG_PRERAM) += elog.c +postcar-$(CONFIG_ELOG_PRERAM) += elog.c ramstage-$(CONFIG_ELOG) += elog.c smm-$(CONFIG_ELOG_GSMI) += elog.c gsmi.c diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c index e006ded265..0d16b2bed5 100644 --- a/src/drivers/elog/elog.c +++ b/src/drivers/elog/elog.c @@ -70,6 +70,14 @@ struct elog_state { static struct elog_state g_elog_state CAR_GLOBAL; +#define ELOG_SIZE (4 * KiB) +static uint8_t elog_mirror_buf[ELOG_SIZE] CAR_GLOBAL; + +static void *get_elog_mirror_buffer(void) +{ + return car_get_var_ptr(elog_mirror_buf); +} + static inline struct region_device *mirror_dev_get(void) { struct elog_state *es = car_get_var_ptr(&g_elog_state); @@ -706,9 +714,9 @@ static int elog_find_flash(void) return -1; } - if (region_device_sz(rdev) < 4*KiB) { - printk(BIOS_WARNING, "ELOG: Needs a minimum size of 4KiB: %zu\n", - region_device_sz(rdev)); + if (region_device_sz(rdev) < ELOG_SIZE) { + printk(BIOS_WARNING, "ELOG: Needs a minimum size of %dKiB: %zu\n", + ELOG_SIZE / KiB, region_device_sz(rdev)); return -1; } @@ -716,7 +724,7 @@ static int elog_find_flash(void) region_device_offset(rdev), region_device_sz(rdev)); /* Keep 4KiB max size until large malloc()s have been fixed. */ - total_size = MIN(4*KiB, region_device_sz(rdev)); + total_size = MIN(ELOG_SIZE, region_device_sz(rdev)); rdev_chain(rdev, rdev, 0, total_size); es->full_threshold = total_size - reserved_space; @@ -828,7 +836,7 @@ int elog_init(void) return -1; elog_size = region_device_sz(&es->nv_dev); - mirror_buffer = malloc(elog_size); + mirror_buffer = get_elog_mirror_buffer(); if (!mirror_buffer) { printk(BIOS_ERR, "ELOG: Unable to allocate backing store\n"); return -1; |