arch: added support for the riscv32 architecture
RISC-V is an open-source instruction set architecture.
Added support for the 32bit version of RISC-V to Zephyr.
1) exceptions/interrupts/faults are handled at the architecture
level via the __irq_wrapper handler. Context saving/restoring
of registers can be handled at both architecture and SOC levels.
If SOC-specific registers need to be saved, SOC level needs to
provide __soc_save_context and __soc_restore_context functions
that shall be accounted by the architecture level, when
corresponding config variable RISCV_SOC_CONTEXT_SAVE is set.
2) As RISC-V architecture does not provide a clear ISA specification
about interrupt handling, each RISC-V SOC handles it in its own
way. Hence, at the architecture level, the __irq_wrapper handler
expects the following functions to be provided by the SOC level:
__soc_is_irq: to check if the exception is the result of an
interrupt or not.
__soc_handle_irq: handle pending IRQ at SOC level (ex: clear
pending IRQ in SOC-specific IRQ register)
3) Thread/task scheduling, as well as IRQ offloading are handled via
the RISC-V system call ("ecall"), which is also handled via the
__irq_wrapper handler. The _Swap asm function just calls "ecall"
to generate an exception.
4) As there is no conventional way of handling CPU power save in
RISC-V, the default nano_cpu_idle and nano_cpu_atomic_idle
functions just unlock interrupts and return to the caller, without
issuing any CPU power saving instruction. Nonetheless, to allow
SOC-level to implement proper CPU power save, nano_cpu_idle and
nano_cpu_atomic_idle functions are defined as __weak
at the architecture level.
Change-Id: I980a161d0009f3f404ad22b226a6229fbb492389
Signed-off-by: Jean-Paul Etienne <fractalclone@gmail.com>
2017-01-11 07:24:30 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Jean-Paul Etienne <fractalclone@gmail.com>
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
arch: added support for the riscv32 architecture
RISC-V is an open-source instruction set architecture.
Added support for the 32bit version of RISC-V to Zephyr.
1) exceptions/interrupts/faults are handled at the architecture
level via the __irq_wrapper handler. Context saving/restoring
of registers can be handled at both architecture and SOC levels.
If SOC-specific registers need to be saved, SOC level needs to
provide __soc_save_context and __soc_restore_context functions
that shall be accounted by the architecture level, when
corresponding config variable RISCV_SOC_CONTEXT_SAVE is set.
2) As RISC-V architecture does not provide a clear ISA specification
about interrupt handling, each RISC-V SOC handles it in its own
way. Hence, at the architecture level, the __irq_wrapper handler
expects the following functions to be provided by the SOC level:
__soc_is_irq: to check if the exception is the result of an
interrupt or not.
__soc_handle_irq: handle pending IRQ at SOC level (ex: clear
pending IRQ in SOC-specific IRQ register)
3) Thread/task scheduling, as well as IRQ offloading are handled via
the RISC-V system call ("ecall"), which is also handled via the
__irq_wrapper handler. The _Swap asm function just calls "ecall"
to generate an exception.
4) As there is no conventional way of handling CPU power save in
RISC-V, the default nano_cpu_idle and nano_cpu_atomic_idle
functions just unlock interrupts and return to the caller, without
issuing any CPU power saving instruction. Nonetheless, to allow
SOC-level to implement proper CPU power save, nano_cpu_idle and
nano_cpu_atomic_idle functions are defined as __weak
at the architecture level.
Change-Id: I980a161d0009f3f404ad22b226a6229fbb492389
Signed-off-by: Jean-Paul Etienne <fractalclone@gmail.com>
2017-01-11 07:24:30 +08:00
|
|
|
*/
|
|
|
|
|
2019-07-18 01:17:05 +08:00
|
|
|
#ifndef ZEPHYR_ARCH_RISCV_INCLUDE_OFFSETS_SHORT_ARCH_H_
|
|
|
|
#define ZEPHYR_ARCH_RISCV_INCLUDE_OFFSETS_SHORT_ARCH_H_
|
arch: added support for the riscv32 architecture
RISC-V is an open-source instruction set architecture.
Added support for the 32bit version of RISC-V to Zephyr.
1) exceptions/interrupts/faults are handled at the architecture
level via the __irq_wrapper handler. Context saving/restoring
of registers can be handled at both architecture and SOC levels.
If SOC-specific registers need to be saved, SOC level needs to
provide __soc_save_context and __soc_restore_context functions
that shall be accounted by the architecture level, when
corresponding config variable RISCV_SOC_CONTEXT_SAVE is set.
2) As RISC-V architecture does not provide a clear ISA specification
about interrupt handling, each RISC-V SOC handles it in its own
way. Hence, at the architecture level, the __irq_wrapper handler
expects the following functions to be provided by the SOC level:
__soc_is_irq: to check if the exception is the result of an
interrupt or not.
__soc_handle_irq: handle pending IRQ at SOC level (ex: clear
pending IRQ in SOC-specific IRQ register)
3) Thread/task scheduling, as well as IRQ offloading are handled via
the RISC-V system call ("ecall"), which is also handled via the
__irq_wrapper handler. The _Swap asm function just calls "ecall"
to generate an exception.
4) As there is no conventional way of handling CPU power save in
RISC-V, the default nano_cpu_idle and nano_cpu_atomic_idle
functions just unlock interrupts and return to the caller, without
issuing any CPU power saving instruction. Nonetheless, to allow
SOC-level to implement proper CPU power save, nano_cpu_idle and
nano_cpu_atomic_idle functions are defined as __weak
at the architecture level.
Change-Id: I980a161d0009f3f404ad22b226a6229fbb492389
Signed-off-by: Jean-Paul Etienne <fractalclone@gmail.com>
2017-01-11 07:24:30 +08:00
|
|
|
|
|
|
|
#include <offsets.h>
|
|
|
|
|
|
|
|
/* kernel */
|
|
|
|
|
|
|
|
/* nothing for now */
|
|
|
|
|
|
|
|
/* end - kernel */
|
|
|
|
|
|
|
|
/* threads */
|
|
|
|
|
|
|
|
#define _thread_offset_to_sp \
|
|
|
|
(___thread_t_callee_saved_OFFSET + ___callee_saved_t_sp_OFFSET)
|
|
|
|
|
|
|
|
#define _thread_offset_to_s0 \
|
|
|
|
(___thread_t_callee_saved_OFFSET + ___callee_saved_t_s0_OFFSET)
|
|
|
|
|
|
|
|
#define _thread_offset_to_s1 \
|
|
|
|
(___thread_t_callee_saved_OFFSET + ___callee_saved_t_s1_OFFSET)
|
|
|
|
|
|
|
|
#define _thread_offset_to_s2 \
|
|
|
|
(___thread_t_callee_saved_OFFSET + ___callee_saved_t_s2_OFFSET)
|
|
|
|
|
|
|
|
#define _thread_offset_to_s3 \
|
|
|
|
(___thread_t_callee_saved_OFFSET + ___callee_saved_t_s3_OFFSET)
|
|
|
|
|
|
|
|
#define _thread_offset_to_s4 \
|
|
|
|
(___thread_t_callee_saved_OFFSET + ___callee_saved_t_s4_OFFSET)
|
|
|
|
|
|
|
|
#define _thread_offset_to_s5 \
|
|
|
|
(___thread_t_callee_saved_OFFSET + ___callee_saved_t_s5_OFFSET)
|
|
|
|
|
|
|
|
#define _thread_offset_to_s6 \
|
|
|
|
(___thread_t_callee_saved_OFFSET + ___callee_saved_t_s6_OFFSET)
|
|
|
|
|
|
|
|
#define _thread_offset_to_s7 \
|
|
|
|
(___thread_t_callee_saved_OFFSET + ___callee_saved_t_s7_OFFSET)
|
|
|
|
|
|
|
|
#define _thread_offset_to_s8 \
|
|
|
|
(___thread_t_callee_saved_OFFSET + ___callee_saved_t_s8_OFFSET)
|
|
|
|
|
|
|
|
#define _thread_offset_to_s9 \
|
|
|
|
(___thread_t_callee_saved_OFFSET + ___callee_saved_t_s9_OFFSET)
|
|
|
|
|
|
|
|
#define _thread_offset_to_s10 \
|
|
|
|
(___thread_t_callee_saved_OFFSET + ___callee_saved_t_s10_OFFSET)
|
|
|
|
|
|
|
|
#define _thread_offset_to_s11 \
|
|
|
|
(___thread_t_callee_saved_OFFSET + ___callee_saved_t_s11_OFFSET)
|
|
|
|
|
|
|
|
#define _thread_offset_to_swap_return_value \
|
|
|
|
(___thread_t_arch_OFFSET + ___thread_arch_t_swap_return_value_OFFSET)
|
|
|
|
|
|
|
|
/* end - threads */
|
|
|
|
|
2019-07-18 01:17:05 +08:00
|
|
|
#endif /* ZEPHYR_ARCH_RISCV_INCLUDE_OFFSETS_SHORT_ARCH_H_ */
|