zephyr/arch/x86/core/intel64/fatal.c
Yong Cong Sin e54b27b967 arch: define struct arch_esf and deprecate z_arch_esf_t
Make `struct arch_esf` compulsory for all architectures by
declaring it in the `arch_interface.h` header.

After this commit, the named struct `z_arch_esf_t` is only used
internally to generate offsets, and is slated to be removed
from the `arch_interface.h` header in the future.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-04 14:02:51 -05:00

53 lines
1.1 KiB
C

/*
* Copyright (c) 2019 Intel Corporation
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <ksched.h>
#include <zephyr/kernel_structs.h>
#include <kernel_internal.h>
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
/* NMI handlers should override weak implementation
* return true if NMI is handled, false otherwise
*/
__weak bool z_x86_do_kernel_nmi(const struct arch_esf *esf)
{
ARG_UNUSED(esf);
return false;
}
void z_x86_exception(struct arch_esf *esf)
{
switch (esf->vector) {
case Z_X86_OOPS_VECTOR:
z_x86_do_kernel_oops(esf);
break;
case IV_PAGE_FAULT:
z_x86_page_fault_handler(esf);
break;
case IV_NON_MASKABLE_INTERRUPT:
if (!z_x86_do_kernel_nmi(esf)) {
z_x86_unhandled_cpu_exception(esf->vector, esf);
CODE_UNREACHABLE;
}
break;
default:
z_x86_unhandled_cpu_exception(esf->vector, esf);
CODE_UNREACHABLE;
}
}
#ifdef CONFIG_USERSPACE
void arch_syscall_oops(void *ssf_ptr)
{
struct x86_ssf *ssf = ssf_ptr;
LOG_ERR("Bad system call from RIP 0x%lx", ssf->rip);
z_x86_fatal_error(K_ERR_KERNEL_OOPS, NULL);
}
#endif /* CONFIG_USERSPACE */