2015-04-11 01:44:37 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-19 02:01:01 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-11 01:44:37 +02:00
|
|
|
*/
|
|
|
|
|
2015-12-04 16:09:39 +01:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Fatal fault handling
|
|
|
|
*
|
2015-10-20 18:42:33 +02:00
|
|
|
* This module implements the routines necessary for handling fatal faults on
|
|
|
|
* ARCv2 CPUs.
|
2015-07-01 23:22:39 +02:00
|
|
|
*/
|
2015-04-11 01:44:37 +02:00
|
|
|
|
2019-10-24 17:08:21 +02:00
|
|
|
#include <kernel.h>
|
2016-11-08 16:36:50 +01:00
|
|
|
#include <offsets_short.h>
|
2015-05-28 19:56:47 +02:00
|
|
|
#include <arch/cpu.h>
|
2019-08-07 09:06:23 +02:00
|
|
|
#include <logging/log.h>
|
2020-05-13 22:30:01 +02:00
|
|
|
#include <kernel_arch_data.h>
|
|
|
|
#include <arch/arc/v2/exc.h>
|
|
|
|
|
2019-08-07 09:06:23 +02:00
|
|
|
LOG_MODULE_DECLARE(os);
|
2015-04-11 01:44:37 +02:00
|
|
|
|
2020-05-13 22:30:01 +02:00
|
|
|
#ifdef CONFIG_ARC_EXCEPTION_DEBUG
|
|
|
|
static void dump_arc_esf(const z_arch_esf_t *esf)
|
|
|
|
{
|
|
|
|
LOG_ERR(" r0: 0x%08x r1: 0x%08x r2: 0x%08x r3: 0x%08x",
|
|
|
|
esf->r0, esf->r1, esf->r2, esf->r3);
|
|
|
|
LOG_ERR(" r4: 0x%08x r5: 0x%08x r6: 0x%08x r7: 0x%08x",
|
|
|
|
esf->r4, esf->r5, esf->r6, esf->r7);
|
|
|
|
LOG_ERR(" r8: 0x%08x r9: 0x%08x r10: 0x%08x r11: 0x%08x",
|
|
|
|
esf->r8, esf->r9, esf->r10, esf->r11);
|
|
|
|
LOG_ERR("r12: 0x%08x r13: 0x%08x pc: 0x%08x",
|
|
|
|
esf->r12, esf->r13, esf->pc);
|
|
|
|
LOG_ERR(" blink: 0x%08x status32: 0x%08x", esf->blink, esf->status32);
|
|
|
|
LOG_ERR("lp_end: 0x%08x lp_start: 0x%08x lp_count: 0x%08x",
|
|
|
|
esf->lp_end, esf->lp_start, esf->lp_count);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-07-17 00:21:19 +02:00
|
|
|
void z_arc_fatal_error(unsigned int reason, const z_arch_esf_t *esf)
|
2015-04-11 01:44:37 +02:00
|
|
|
{
|
2020-05-13 22:30:01 +02:00
|
|
|
#ifdef CONFIG_ARC_EXCEPTION_DEBUG
|
|
|
|
if (esf != NULL) {
|
|
|
|
dump_arc_esf(esf);
|
2018-04-12 07:13:08 +02:00
|
|
|
}
|
2020-05-13 22:30:01 +02:00
|
|
|
#endif /* CONFIG_ARC_EXCEPTION_DEBUG */
|
2015-04-11 01:44:37 +02:00
|
|
|
|
2019-07-11 23:18:28 +02:00
|
|
|
z_fatal_error(reason, esf);
|
2015-04-11 01:44:37 +02:00
|
|
|
}
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 10:13:09 +01:00
|
|
|
|
2019-11-07 21:43:29 +01:00
|
|
|
FUNC_NORETURN void arch_syscall_oops(void *ssf_ptr)
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 10:13:09 +01:00
|
|
|
{
|
2020-05-13 22:30:01 +02:00
|
|
|
/* TODO: convert ssf_ptr contents into an esf, they are not the same */
|
|
|
|
ARG_UNUSED(ssf_ptr);
|
|
|
|
|
|
|
|
z_arc_fatal_error(K_ERR_KERNEL_OOPS, NULL);
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 10:13:09 +01:00
|
|
|
CODE_UNREACHABLE;
|
|
|
|
}
|
2019-10-16 13:44:16 +02:00
|
|
|
|
2019-11-07 21:43:29 +01:00
|
|
|
FUNC_NORETURN void arch_system_halt(unsigned int reason)
|
2019-10-16 13:44:16 +02:00
|
|
|
{
|
|
|
|
ARG_UNUSED(reason);
|
|
|
|
|
|
|
|
__asm__("brk");
|
|
|
|
|
|
|
|
CODE_UNREACHABLE;
|
|
|
|
}
|