2015-04-11 07:44:37 +08:00
|
|
|
/* cpu.h - automatically selects the correct arch.h file to include */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1997-2014 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
2015-05-29 01:56:47 +08:00
|
|
|
#ifndef __ARCHCPU_H__
|
|
|
|
#define __ARCHCPU_H__
|
2015-04-11 07:44:37 +08:00
|
|
|
|
2015-10-09 18:20:52 +08:00
|
|
|
#if defined(CONFIG_X86)
|
2015-05-29 01:56:47 +08:00
|
|
|
#include <arch/x86/arch.h>
|
2015-06-06 10:27:08 +08:00
|
|
|
#elif defined(CONFIG_ARM)
|
2015-05-29 01:56:47 +08:00
|
|
|
#include <arch/arm/arch.h>
|
2015-06-06 10:27:49 +08:00
|
|
|
#elif defined(CONFIG_ARC)
|
2015-05-29 01:56:47 +08:00
|
|
|
#include <arch/arc/arch.h>
|
2016-04-22 05:47:09 +08:00
|
|
|
#elif defined(CONFIG_NIOS2)
|
|
|
|
#include <arch/nios2/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
|
|
|
#elif defined(CONFIG_RISCV32)
|
|
|
|
#include <arch/riscv32/arch.h>
|
2017-01-21 03:52:29 +08:00
|
|
|
#elif defined(CONFIG_XTENSA)
|
|
|
|
#include <arch/xtensa/arch.h>
|
2017-10-03 22:31:55 +08:00
|
|
|
#elif defined(CONFIG_ARCH_POSIX)
|
|
|
|
#include <arch/posix/arch.h>
|
2015-04-11 07:44:37 +08:00
|
|
|
#else
|
2015-06-06 10:33:49 +08:00
|
|
|
#error "Unknown Architecture"
|
2015-04-11 07:44:37 +08:00
|
|
|
#endif
|
|
|
|
|
2015-05-29 01:56:47 +08:00
|
|
|
#endif /* __ARCHCPU_H__ */
|