mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-08-12 03:15:26 +00:00
The IRQ handler has had a major changes to manage syscall, reschedule and interrupt from user thread and stack guard. Add userspace support: - Use a global variable to know if the current execution is user or machine. The location of this variable is read only for all user thread and read/write for kernel thread. - Memory shared is supported. - Use dynamic allocation to optimize PMP slot usage. If the area size is a power of 2, only one PMP slot is used, else 2 are used. Add stack guard support: - Use MPRV bit to force PMP rules to machine mode execution. - IRQ stack have a locked stack guard to avoid re-write PMP configuration registers for each interruption and then win some cycle. - The IRQ stack is used as "temporary" stack at the beginning of IRQ handler to save current ESF. That avoid to trigger write fault on thread stack during store ESF which that call IRQ handler to infinity. - A stack guard is also setup for privileged stack of a user thread. Thread: - A PMP setup is specific to each thread. PMP setup are saved in each thread structure to improve reschedule performance. Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com> Reviewed-by: Nicolas Royer <nroyer@baylibre.com>
59 lines
1.2 KiB
C
59 lines
1.2 KiB
C
/*
|
|
* Copyright (c) 2016 Jean-Paul Etienne <fractalclone@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @file
|
|
* @brief Private kernel definitions
|
|
*
|
|
* This file contains private kernel function/macro definitions and various
|
|
* other definitions for the RISCV processor architecture.
|
|
*/
|
|
|
|
#ifndef ZEPHYR_ARCH_RISCV_INCLUDE_KERNEL_ARCH_FUNC_H_
|
|
#define ZEPHYR_ARCH_RISCV_INCLUDE_KERNEL_ARCH_FUNC_H_
|
|
|
|
#include <kernel_arch_data.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifndef _ASMLANGUAGE
|
|
static ALWAYS_INLINE void arch_kernel_init(void)
|
|
{
|
|
}
|
|
|
|
static ALWAYS_INLINE void
|
|
arch_thread_return_value_set(struct k_thread *thread, unsigned int value)
|
|
{
|
|
thread->arch.swap_return_value = value;
|
|
}
|
|
|
|
FUNC_NORETURN void z_riscv_fatal_error(unsigned int reason,
|
|
const z_arch_esf_t *esf);
|
|
|
|
static inline bool arch_is_in_isr(void)
|
|
{
|
|
return _kernel.cpus[0].nested != 0U;
|
|
}
|
|
|
|
extern FUNC_NORETURN void z_riscv_userspace_enter(k_thread_entry_t user_entry,
|
|
void *p1, void *p2, void *p3,
|
|
uint32_t stack_end,
|
|
uint32_t stack_start);
|
|
|
|
#ifdef CONFIG_IRQ_OFFLOAD
|
|
int z_irq_do_offload(void);
|
|
#endif
|
|
|
|
#endif /* _ASMLANGUAGE */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* ZEPHYR_ARCH_RISCV_INCLUDE_KERNEL_ARCH_FUNC_H_ */
|