aarch64: error: Handle software-generated fatal exceptions

Introduce a new SVC call ID to trigger software-generated CPU
exceptions.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
This commit is contained in:
Carlo Caione 2020-11-06 18:55:16 +01:00 committed by Ioannis Glaropoulos
commit 47ebde30b9
5 changed files with 66 additions and 1 deletions

View file

@ -28,6 +28,7 @@
#include <arch/arm/aarch64/macro.inc>
#include <arch/arm/aarch64/sys_io.h>
#include <arch/arm/aarch64/timer.h>
#include <arch/arm/aarch64/error.h>
#include <arch/common/addr_types.h>
#include <arch/common/sys_bitops.h>
#include <arch/common/ffs.h>

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) 2020 Carlo Caione <ccaione@baylibre.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief ARM AArch64 public error handling
*
* ARM AArch64-specific kernel error handling interface. Included by arch.h.
*/
#ifndef ZEPHYR_INCLUDE_ARCH_ARM_AARCH64_ERROR_H_
#define ZEPHYR_INCLUDE_ARCH_ARM_AARCH64_ERROR_H_
#include <arch/arm/aarch64/syscall.h>
#include <arch/arm/aarch64/exc.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#define ARCH_EXCEPT(reason_p) \
do { \
register uint64_t x8 __asm__("x8") = reason_p; \
\
__asm__ volatile("svc %[id]\n" \
: \
: [id] "i" (_SVC_CALL_RUNTIME_EXCEPT), \
"r" (x8) \
: "memory"); \
} while (false)
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_ARCH_ARM_AARCH64_ERROR_H_ */

View file

@ -18,5 +18,6 @@
#define _SVC_CALL_CONTEXT_SWITCH 0
#define _SVC_CALL_IRQ_OFFLOAD 1
#define _SVC_CALL_RUNTIME_EXCEPT 2
#endif /* ZEPHYR_INCLUDE_ARCH_ARM_AARCH64_SYSCALL_H_ */