diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-10-04 10:24:13 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-10-07 23:26:46 +0000 |
commit | 3a48b16f1c75debdcac39ab481c5e9e07ce46cfd (patch) | |
tree | 48dc60c5b6911fbfb7c971223431b0792429a275 /core/host | |
parent | 4f6d8ca42115d3c39cbc6a476414df0be629f51e (diff) | |
download | chrome-ec-3a48b16f1c75debdcac39ab481c5e9e07ce46cfd.tar.gz |
core/host: Add implementation for host panic
panic_set_reason() and panic_get_reason() are called from
system_common_pre_init() if CONFIG_SOFTWARE_PANIC is enabled. A followup
commit removes CONFIG_SOFTWARE_PANIC since all boards enable it, so we
need stub implementations for the host in order to successfully compile.
LOW_COVERAGE_REASON=legacy code
BRANCH=none
BUG=none
TEST=make buildall
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I33322b593f707f3c8937f4a7cd2189841b197aa1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3935024
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'core/host')
-rw-r--r-- | core/host/panic.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/core/host/panic.c b/core/host/panic.c index ed1994f82e..e354757d75 100644 --- a/core/host/panic.c +++ b/core/host/panic.c @@ -3,9 +3,14 @@ * found in the LICENSE file. */ +#include <assert.h> #include <stdio.h> #include <stdlib.h> +#include <stdint.h> +#include <string.h> +#include "config.h" +#include "panic.h" #include "stack_trace.h" void panic_assert_fail(const char *msg, const char *func, const char *fname, @@ -20,3 +25,34 @@ void panic_assert_fail(const char *msg, const char *func, const char *fname, exit(1); } + +void panic_set_reason(uint32_t reason, uint32_t info, uint8_t exception) +{ + struct panic_data *const pdata = panic_get_data(); + + assert(pdata); + memset(pdata, 0, CONFIG_PANIC_DATA_SIZE); + pdata->magic = PANIC_DATA_MAGIC; + pdata->struct_size = CONFIG_PANIC_DATA_SIZE; + pdata->struct_version = 2; + pdata->arch = PANIC_ARCH_X86; + + pdata->x86.vector = reason; + pdata->x86.error_code = info; + pdata->x86.eflags = exception; +} + +void panic_get_reason(uint32_t *reason, uint32_t *info, uint8_t *exception) +{ + struct panic_data *const pdata = panic_get_data(); + + assert(pdata); + assert(pdata->struct_version == 2); + + if (reason) + *reason = pdata->x86.vector; + if (info) + *info = pdata->x86.error_code; + if (exception) + *exception = pdata->x86.eflags; +} |