2016-11-08 16:36:50 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014-2016 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-19 02:01:01 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-11-08 16:36:50 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Private kernel definitions
|
|
|
|
*
|
|
|
|
* This file contains private kernel structures definitions and various
|
|
|
|
* other definitions for the ARCv2 processor architecture.
|
|
|
|
*
|
|
|
|
* This file is also included by assembly language files which must #define
|
|
|
|
* _ASMLANGUAGE before including this header file. Note that kernel
|
|
|
|
* assembly source files obtains structure offset values via "absolute
|
|
|
|
* symbols" in the offsets.o module.
|
|
|
|
*/
|
|
|
|
|
2018-09-14 19:43:44 +02:00
|
|
|
#ifndef ZEPHYR_ARCH_ARC_INCLUDE_KERNEL_ARCH_FUNC_H_
|
|
|
|
#define ZEPHYR_ARCH_ARC_INCLUDE_KERNEL_ARCH_FUNC_H_
|
2016-11-08 16:36:50 +01:00
|
|
|
|
|
|
|
#if !defined(_ASMLANGUAGE)
|
|
|
|
|
2019-10-24 17:08:21 +02:00
|
|
|
#include <kernel_arch_data.h>
|
|
|
|
|
2016-11-08 16:36:50 +01:00
|
|
|
#include <v2/irq.h>
|
|
|
|
|
2019-08-12 19:52:11 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-11-07 21:43:29 +01:00
|
|
|
static ALWAYS_INLINE void arch_kernel_init(void)
|
2016-11-08 16:36:50 +01:00
|
|
|
{
|
2019-03-14 16:20:46 +01:00
|
|
|
z_irq_setup();
|
2016-11-08 16:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-04-19 19:16:15 +02:00
|
|
|
* @brief Indicates the interrupt number of the highest priority
|
2016-11-08 16:36:50 +01:00
|
|
|
* active interrupt
|
|
|
|
*
|
|
|
|
* @return IRQ number
|
|
|
|
*/
|
2019-03-14 16:20:46 +01:00
|
|
|
static ALWAYS_INLINE int Z_INTERRUPT_CAUSE(void)
|
2016-11-08 16:36:50 +01:00
|
|
|
{
|
2020-05-27 18:26:57 +02:00
|
|
|
uint32_t irq_num = z_arc_v2_aux_reg_read(_ARC_V2_ICAUSE);
|
2016-11-08 16:36:50 +01:00
|
|
|
|
|
|
|
return irq_num;
|
|
|
|
}
|
|
|
|
|
2019-11-07 21:43:29 +01:00
|
|
|
static inline bool arch_is_in_isr(void)
|
2019-10-03 23:32:22 +02:00
|
|
|
{
|
|
|
|
return z_arc_v2_irq_unit_is_in_isr();
|
|
|
|
}
|
2016-11-08 16:36:50 +01:00
|
|
|
|
2019-03-14 16:20:46 +01:00
|
|
|
extern void z_thread_entry_wrapper(void);
|
|
|
|
extern void z_user_thread_entry_wrapper(void);
|
2016-11-08 16:36:50 +01:00
|
|
|
|
2019-03-14 16:20:46 +01:00
|
|
|
extern void z_arc_userspace_enter(k_thread_entry_t user_entry, void *p1,
|
2020-05-27 18:26:57 +02:00
|
|
|
void *p2, void *p3, uint32_t stack, uint32_t size,
|
2020-03-02 06:45:34 +01:00
|
|
|
struct k_thread *thread);
|
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-07-17 00:21:19 +02:00
|
|
|
extern void z_arc_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
|
2019-07-25 06:13:13 +02:00
|
|
|
|
2019-11-07 21:43:29 +01:00
|
|
|
extern void arch_sched_ipi(void);
|
2019-07-25 06:13:13 +02:00
|
|
|
|
2020-07-03 10:01:44 +02:00
|
|
|
extern void z_arc_switch(void *switch_to, void **switched_from);
|
|
|
|
|
|
|
|
static inline void arch_switch(void *switch_to, void **switched_from)
|
|
|
|
{
|
|
|
|
z_arc_switch(switch_to, switched_from);
|
|
|
|
}
|
|
|
|
|
2022-05-12 17:21:07 +02:00
|
|
|
#if !defined(CONFIG_MULTITHREADING)
|
|
|
|
extern FUNC_NORETURN void z_arc_switch_to_main_no_multithreading(
|
|
|
|
k_thread_entry_t main_func, void *p1, void *p2, void *p3);
|
|
|
|
|
|
|
|
#define ARCH_SWITCH_TO_MAIN_NO_MULTITHREADING \
|
|
|
|
z_arc_switch_to_main_no_multithreading
|
|
|
|
|
|
|
|
#endif /* !CONFIG_MULTITHREADING */
|
|
|
|
|
|
|
|
|
2016-11-08 16:36:50 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-08-12 19:52:11 +02:00
|
|
|
#endif /* _ASMLANGUAGE */
|
|
|
|
|
2018-09-14 19:43:44 +02:00
|
|
|
#endif /* ZEPHYR_ARCH_ARC_INCLUDE_KERNEL_ARCH_FUNC_H_ */
|