summaryrefslogtreecommitdiff
path: root/include/system.h
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-07-13 14:24:33 -0700
committerRandall Spangler <rspangler@chromium.org>2012-07-16 10:17:09 -0700
commit0e933d1ce987cb68e4c5682508aba47f925613ae (patch)
treeae26d125c16a10073a4936318ffb90a7ccb582bb /include/system.h
parent1dc7241e3a32635b3e3563fd5ddae482478dd92c (diff)
downloadchrome-ec-0e933d1ce987cb68e4c5682508aba47f925613ae.tar.gz
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 <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27417
Diffstat (limited to 'include/system.h')
-rw-r--r--include/system.h55
1 files changed, 35 insertions, 20 deletions
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