diff options
author | Patryk Duda <pdk@semihalf.com> | 2020-08-28 13:44:59 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-09-09 06:11:24 +0000 |
commit | 2187da39745e802fa89539ed28a9cf3fa9661876 (patch) | |
tree | 681322be139b896fdbd2d87af032421bcfe5d277 /include/panic.h | |
parent | e09ef0fdb5445b8994298cdee4c991b2dd0bbbac (diff) | |
download | chrome-ec-2187da39745e802fa89539ed28a9cf3fa9661876.tar.gz |
Introduce functions that provide safe pointer to panic data
panic_get_data() function should always return pointer to panic_data
structure that can be safely interpreted. When structure layout
left by previous EC is different than ours then panic_get_data()
should return NULL. Difference in layout can occur when we are jumping
from old RO, this happens in eve.
Introduce two new functions:
get_panic_data_start() - It can be used to obtain beginning of panic
data, eg. when copying raw data or when determining where jump data is.
get_panic_data_write() - It can be used to obtain pointer to panic_data
structure that can be safely written. This function moves jump data and
jump tags if necessary.
Signed-off-by: Patryk Duda <pdk@semihalf.com>
Change-Id: If5f73c86e2176a0169b0be4b890e399c2c259740
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2379845
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'include/panic.h')
-rw-r--r-- | include/panic.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/include/panic.h b/include/panic.h index 6daa4c408f..b6e1c0d8cd 100644 --- a/include/panic.h +++ b/include/panic.h @@ -198,14 +198,36 @@ void panic_get_reason(uint32_t *reason, uint32_t *info, uint8_t *exception); void ignore_bus_fault(int ignored); /** - * Return a pointer to the saved data from a previous panic. + * Return a pointer to the saved data from a previous panic that can be + * safely interpreted * - * @param pointer to the panic data, or NULL if none available (for example, + * @param pointer to the valid panic data, or NULL if none available (for example, * the last reboot was not caused by a panic). */ struct panic_data *panic_get_data(void); /** + * Return a pointer to the beginning of panic data. This function can be + * used to obtain pointer which can be used to calculate place of other + * structures (eg. jump_data). This function should not be used to get access + * to panic_data structure as it might not be valid + * + * @param pointer to the beginning of panic_data, or NULL if there is no + * panic_data + */ +uintptr_t get_panic_data_start(void); + +/* + * Return a pointer to panic_data structure that can be safely written. + * Please note that this function can move jump data and jump tags. + * It can also delete panic data from previous boot, so this function + * should be used when we are sure that we don't need it. + * + * @param pointer to panic_data structure that can be safely written + */ +struct panic_data *get_panic_data_write(void); + +/** * Chip-specific implementation for backing up panic data to persistent * storage. This function is used to ensure that the panic data can survive loss * of VCC power rail. |