summaryrefslogtreecommitdiff
path: root/include/system_safe_mode.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/system_safe_mode.h')
-rw-r--r--include/system_safe_mode.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/include/system_safe_mode.h b/include/system_safe_mode.h
new file mode 100644
index 0000000000..b7b31d9707
--- /dev/null
+++ b/include/system_safe_mode.h
@@ -0,0 +1,68 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __CROS_EC_SYSTEM_SAFE_MODE_H
+#define __CROS_EC_SYSTEM_SAFE_MODE_H
+
+#include "stdbool.h"
+
+/**
+ * Checks if running in system safe mode
+ *
+ * @return True if system is running in system safe mode
+ */
+bool system_is_in_safe_mode(void);
+
+/**
+ * Checks if command is allowed in system safe mode
+ *
+ * @return True if command is allowed in system safe mode
+ */
+bool command_is_allowed_in_safe_mode(int command);
+
+/**
+ * Checks if a task is critical for system safe mode
+ *
+ * @return True if task is safe mode critical
+ */
+bool is_task_safe_mode_critical(task_id_t task_id);
+
+/**
+ * Disables tasks that are not critical for safe mode
+ *
+ * @return EC_SUCCESS or EC_xxx on error
+ */
+int disable_non_safe_mode_critical_tasks(void);
+
+/**
+ * Start system safe mode.
+ *
+ * System safe mode can only be started after a panic in RW image.
+ * It will only run briefly so the AP can capture EC state.
+ *
+ * @return EC_SUCCESS or EC_xxx on error
+ */
+int start_system_safe_mode(void);
+
+/**
+ * Schedules safe mode timeout.
+ *
+ * @return EC_SUCCESS or EC_xxx on error
+ */
+int schedule_system_safe_mode_timeout(void);
+
+/**
+ * This handler is called when safe mode times out.
+ */
+void handle_system_safe_mode_timeout(void);
+
+#ifdef TEST_BUILD
+/**
+ * Directly set safe mode flag. Only used in tests.
+ */
+void set_system_safe_mode(bool mode);
+#endif
+
+#endif /* __CROS_EC_SYSTEM_SAFE_MODE_H */