From 0e933d1ce987cb68e4c5682508aba47f925613ae Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Fri, 13 Jul 2012 14:24:33 -0700 Subject: Refactor reset reasons Reasons are really bitflags, not a single reason. This will make it easier to implement flash protection on LM4, where hibernate is a subset of power-on reasons. Also added some additional flags we pass in a hibernate register so... 1) We don't recognize spurious RTC wake reasons 2) Hard reset via system_reset(1) is detected as a hard reset, not a RTC wake BUG=chrome-os-partner:11368 TEST=manual 1. Keyboard reset = power-on reset-pin 2. Pull battery = power-on 3. reboot = soft 4. reboot hard = power-on rtc-alarm 5. hibernate 10 then push power button = power-on wake-pin 6. reboot 3 sec later = soft 7. hibernate 1 = power-on rtc-alarm Change-Id: Icbbdbcf6dfd13c8a6a4f80a23f64cebebbfba26e Signed-off-by: Randall Spangler Reviewed-on: https://gerrit.chromium.org/gerrit/27417 --- include/system.h | 55 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 20 deletions(-) (limited to 'include/system.h') diff --git a/include/system.h b/include/system.h index 25d8232f1f..ba046cc1b6 100644 --- a/include/system.h +++ b/include/system.h @@ -11,19 +11,18 @@ #include "common.h" /* Reset causes */ -enum system_reset_cause_t { - SYSTEM_RESET_UNKNOWN = 0, /* Unknown reset cause */ - SYSTEM_RESET_OTHER, /* System reset cause is known, but not one - * of the causes listed below */ - SYSTEM_RESET_BROWNOUT, /* Brownout */ - SYSTEM_RESET_POWER_ON, /* Power-on reset */ - SYSTEM_RESET_RESET_PIN, /* Reset pin asserted */ - SYSTEM_RESET_SOFT, /* Soft reset trigger by core */ - SYSTEM_RESET_WATCHDOG, /* Watchdog timer reset */ - SYSTEM_RESET_RTC_ALARM, /* RTC alarm wake */ - SYSTEM_RESET_WAKE_PIN, /* Wake pin triggered wake */ - SYSTEM_RESET_LOW_BATTERY, /* Low battery triggered wake */ -}; +#define RESET_FLAG_OTHER (1 << 0) /* Other known reason */ +#define RESET_FLAG_RESET_PIN (1 << 1) /* Reset pin asserted */ +#define RESET_FLAG_BROWNOUT (1 << 2) /* Brownout */ +#define RESET_FLAG_POWER_ON (1 << 3) /* Power-on reset */ +#define RESET_FLAG_WATCHDOG (1 << 4) /* Watchdog timer reset */ +#define RESET_FLAG_SOFT (1 << 5) /* Soft reset trigger by core */ +#define RESET_FLAG_HIBERNATE (1 << 6) /* Wake from hibernate */ +#define RESET_FLAG_RTC_ALARM (1 << 7) /* RTC alarm wake */ +#define RESET_FLAG_WAKE_PIN (1 << 8) /* Wake pin triggered wake */ +#define RESET_FLAG_LOW_BATTERY (1 << 9) /* Low battery triggered wake */ +#define RESET_FLAG_SYSJUMP (1 << 10) /* Jumped directly to this image */ +#define RESET_FLAG_HARD (1 << 11) /* Hard reset from software */ /* System images */ enum system_image_copy_t { @@ -41,15 +40,31 @@ int system_pre_init(void); * system_pre_init(). */ int system_common_pre_init(void); -/* Returns the cause of the last reset, or SYSTEM_RESET_UNKNOWN if - * the cause is not known. */ -enum system_reset_cause_t system_get_reset_cause(void); +/** + * Get the reset flags. + * + * @return Reset flags (RESET_FLAG_*), or 0 if the cause is unknown. + */ +uint32_t system_get_reset_flags(void); -/* Record the cause of the last reset. */ -void system_set_reset_cause(enum system_reset_cause_t cause); +/** + * Set reset flags. + * + * @param flags Flags to set in reset flags + */ +void system_set_reset_flags(uint32_t flags); -/* Return a text description of the last reset cause. */ -const char *system_get_reset_cause_string(void); +/** + * Clear reset flags. + * + * @param flags Flags to clear in reset flags + */ +void system_clear_reset_flags(uint32_t flags); + +/** + * Print a description of the reset flags to the console. + */ +void system_print_reset_flags(void); /* Return non-zero if the system is locked down for normal consumer use. * Potentially-dangerous developer and/or factory commands must be disabled -- cgit v1.2.1