diff options
author | Rob Barnes <robbarnes@google.com> | 2022-11-15 01:46:49 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-12-06 07:11:49 +0000 |
commit | e6c5dc42187847f5b728d865d9c750555b9b33b8 (patch) | |
tree | 0eae5b11bf0f674635ce21d15b8bbfde1536cdbb /include/system_safe_mode.h | |
parent | 4df4ed38aff2fcfc5b469d168ac87c1ebedeec56 (diff) | |
download | chrome-ec-e6c5dc42187847f5b728d865d9c750555b9b33b8.tar.gz |
system: Implement system safe mode
Basic implementation of system safe mode recovery.
System safe mode is a recovery mode that may be started after
a fault/panic. It allows the AP to collect info about the fault
and system state before the system resets
This CL includes support for Zephyr EC and legacy CrOS EC
BUG=b:249128225
BRANCH=None
TEST=./twister -s
external/platform/ec/zephyr/test/rw_safe_mode/rw_safe_mode.default
Manually tested on skyrim
Change-Id: I15139bb082011485b54e4ca7813839940bf5401a
Signed-off-by: Rob Barnes <robbarnes@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4029604
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'include/system_safe_mode.h')
-rw-r--r-- | include/system_safe_mode.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/include/system_safe_mode.h b/include/system_safe_mode.h new file mode 100644 index 0000000000..a8bf23d5b0 --- /dev/null +++ b/include/system_safe_mode.h @@ -0,0 +1,66 @@ +/* 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 + +/** + * 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 current task critical for system safe mode + * + * @return True if current task is safe mode critical + */ +bool current_task_is_safe_mode_critical(void); + +/** + * 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 */ |