From bce8bb6e6ce5045ea611dae96857cf93d596a86c Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Fri, 11 Nov 2016 13:57:55 -0800 Subject: google/chromeec: Add elog events for recovery mode switches BUG=chrome-os-partner:59352 BRANCH=None TEST=Verified eventlog on reef 0 | 2016-11-12 19:49:25 | Log area cleared | 4088 1 | 2016-11-12 19:49:25 | Kernel Event | Clean Shutdown 2 | 2016-11-12 19:49:25 | ACPI Enter | S5 3 | 2016-11-12 19:49:39 | System boot | 365 4 | 2016-11-12 19:49:39 | EC Event | Power Button 5 | 2016-11-12 19:49:45 | Chrome OS Recovery Mode | Recovery Button Pressed 6 | 2016-11-12 19:49:45 | Chrome OS Developer Mode 7 | 2016-11-12 19:49:45 | EC Event | Keyboard Recovery 8 | 2016-11-12 19:49:45 | Memory Cache Update | Recovery | Success 9 | 2016-11-12 19:50:46 | System boot | 366 10 | 2016-11-12 19:50:46 | EC Event | Power Button 11 | 2016-11-12 19:50:52 | Chrome OS Recovery Mode | Recovery Button Pressed 12 | 2016-11-12 19:50:52 | Chrome OS Developer Mode 13 | 2016-11-12 19:50:52 | EC Event | Keyboard Recovery Forced Hardware Reinit 14 | 2016-11-12 19:50:52 | Memory Cache Update | Recovery | Success 15 | 2016-11-12 19:51:24 | Power Button 16 | 2016-11-12 19:51:24 | ACPI Enter | S5 17 | 2016-11-12 19:51:27 | System boot | 367 18 | 2016-11-12 19:51:27 | EC Event | Power Button 19 | 2016-11-12 19:51:32 | Wake Source | Power Button | 0 20 | 2016-11-12 19:51:32 | ACPI Wake | S5 21 | 2016-11-12 19:51:32 | Chrome OS Developer Mode 22 | 2016-11-12 19:51:32 | Memory Cache Update | Normal | Success Change-Id: I45dda210cf9d4e5a75404792fcee15b2010787a7 Signed-off-by: Furquan Shaikh Reviewed-on: https://review.coreboot.org/17394 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/ec/google/chromeec/ec.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/ec') diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index c8b6e7e10a..1308c3d13b 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -15,9 +15,13 @@ #include #include +#include #include #include +#include +#include #include +#include #include #include #include @@ -29,6 +33,41 @@ #include "ec.h" #include "ec_commands.h" +void log_recovery_mode_switch(void) +{ + uint32_t *events; + + if (cbmem_find(CBMEM_ID_EC_HOSTEVENT)) + return; + + events = cbmem_add(CBMEM_ID_EC_HOSTEVENT, sizeof(*events)); + if (!events) + return; + + *events = google_chromeec_get_events_b(); +} + +static void google_chromeec_elog_add_recovery_event(void *unused) +{ + uint32_t *events = cbmem_find(CBMEM_ID_EC_HOSTEVENT); + uint8_t event_byte = EC_EVENT_KEYBOARD_RECOVERY; + + if (!events) + return; + + if (!(*events & EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY))) + return; + + if (*events & + EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT)) + event_byte = EC_EVENT_KEYBOARD_RECOVERY_HWREINIT; + + elog_add_event_byte(ELOG_TYPE_EC_EVENT, event_byte); +} + +BOOT_STATE_INIT_ENTRY(BS_WRITE_TABLES, BS_ON_ENTRY, + google_chromeec_elog_add_recovery_event, NULL); + uint8_t google_chromeec_calc_checksum(const uint8_t *data, int size) { int csum; -- cgit v1.2.3