summaryrefslogtreecommitdiff
path: root/include/system_safe_mode.h
blob: b7b31d97079201148c4b09179c72dec5926377e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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 */