summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorShannon Chen <shannc@google.com>2019-08-02 17:48:58 +0800
committerCommit Bot <commit-bot@chromium.org>2019-08-21 04:58:22 +0000
commit2fb1836646a1f4edcea1f22408535872b833d14e (patch)
tree3fead01aba3c47b18c85f462e88cf505fb4f4464 /include
parent10d0ea416eac754b94858c491efdd56cf1ef2476 (diff)
downloadchrome-ec-2fb1836646a1f4edcea1f22408535872b833d14e.tar.gz
log: Preserve Kukui EC reset logs across every EC reboot on SRAM.
On Kukui, we need to put console logs and reset reasons at fixed addresses on SRAM to save the information across each EC resets. Otherwise, EC will lose console logs and reset reasons after resetting EC. This CL ensures that the contents of reset and console logs will not be clobbered or cleared by putting mandatory symbols at a fixed location on SRAM. The values will only be reset when checksum or sanity check fails. BUG=b:133795403 TEST=1. On Kukui, shutdown AP, reboot AP, or sysjump, and see the previous logs before reboot will be kept on /var/log/croc_ec.log 2. Reset reasons can be viewed with ectool uptimeinfo BRANCH=master Change-Id: I19db49101fda1675dc2fdc047b7f14af77cdb6e6 Signed-off-by: Shannon Chen <shannc@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1716671 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Shannon Chen <shannc@chromium.org> Tested-by: Shannon Chen <shannc@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/chipset.h5
-rw-r--r--include/config.h9
-rw-r--r--include/link_defs.h7
-rw-r--r--include/uart.h5
-rw-r--r--include/util.h3
5 files changed, 29 insertions, 0 deletions
diff --git a/include/chipset.h b/include/chipset.h
index bb0d7b4943..05eeb844a1 100644
--- a/include/chipset.h
+++ b/include/chipset.h
@@ -263,3 +263,8 @@ static inline void report_ap_reset(enum chipset_shutdown_reason reason) { }
#endif /* !CONFIG_CMD_AP_RESET_LOG */
#endif /* __CROS_EC_CHIPSET_H */
+
+/**
+ * Initialize reset logs and next reset log.
+ */
+void init_reset_log(void);
diff --git a/include/config.h b/include/config.h
index 377f89d603..5bb89a7a46 100644
--- a/include/config.h
+++ b/include/config.h
@@ -3525,6 +3525,15 @@
*/
#undef CONFIG_UART_PAD_SWITCH
+/**
+ * This will only be used for Kukui and cortex-m0. Preserve EC reset logs and
+ * console logs on SRAM so that the logs will be preserved after EC shutting
+ * down or sysjumped. It will keep the contents across EC resets, so we have
+ * more information about system states. The contents on SRAM will be cleared
+ * when checksum or sanity check fails.
+ */
+#undef CONFIG_PRESERVE_LOGS
+
/*
* UART receive buffer size in bytes. Must be a power of 2 for macros in
* common/uart_buffering.c to work properly. Must be larger than
diff --git a/include/link_defs.h b/include/link_defs.h
index 28ea0113e1..5ea500516f 100644
--- a/include/link_defs.h
+++ b/include/link_defs.h
@@ -134,3 +134,10 @@ extern void *__dram_bss_end;
#endif
#endif /* __CROS_EC_LINK_DEFS_H */
+
+#ifdef CONFIG_PRESERVE_LOGS
+#define __preserved_logs(name) \
+ __attribute__((section(".preserved_logs." STRINGIFY(name))))
+#else
+#define __preserved_logs(name)
+#endif
diff --git a/include/uart.h b/include/uart.h
index d5493544c2..66561b09a7 100644
--- a/include/uart.h
+++ b/include/uart.h
@@ -352,3 +352,8 @@ int uart_console_read_buffer(uint8_t type,
uint16_t *write_count);
#endif /* __CROS_EC_UART_H */
+
+/**
+ * Initialize tx buffer head and tail
+ */
+void uart_init_buffer(void);
diff --git a/include/util.h b/include/util.h
index 04acffd988..60bb00510a 100644
--- a/include/util.h
+++ b/include/util.h
@@ -55,6 +55,9 @@ extern "C" {
/* True of x is a power of two */
#define POWER_OF_TWO(x) ((x) && !((x) & ((x) - 1)))
+/* Macro to check if the value is in range */
+#define IN_RANGE(x, min, max) ((x) >= (min) && (x) < (max))
+
/*
* macros for integer division with various rounding variants
* default integer division rounds down.