Skip to content

Commit

Permalink
core: riscv: Let platform choose native and foreign interrupts
Browse files Browse the repository at this point in the history
Platform may want to choose different types of native and foreign
interrupts. This commit adds two definitions for the platforms:
1. PLAT_THREAD_EXCP_FOREIGN_INTR: to define platform specific foreign
   interrupts
2. PLAT_THREAD_EXCP_NATIVE_INTR: to define platform specific native
   interrupts.

For RISC-V virt machine, we define external interrupts as foreign
interrupts, and mtimer/software interrupts as native interrupts. For
RISC-V spike platform, the definitions are same as virt machine.

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com>
  • Loading branch information
gagachang committed Aug 20, 2024
1 parent ef55bf0 commit 655469d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
28 changes: 13 additions & 15 deletions core/arch/riscv/include/kernel/thread_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@

#ifndef __ASSEMBLER__
#include <compiler.h>
#include <riscv.h>
#include <types_ext.h>
#endif

#include <platform_config.h>
#include <riscv.h>

/*
* Each RISC-V platform must define their own values.
* See core/arch/riscv/plat-virt/platform_config.h for example.
*/
#define THREAD_EXCP_FOREIGN_INTR PLAT_THREAD_EXCP_FOREIGN_INTR
#define THREAD_EXCP_NATIVE_INTR PLAT_THREAD_EXCP_NATIVE_INTR

#define THREAD_EXCP_ALL (THREAD_EXCP_FOREIGN_INTR |\
THREAD_EXCP_NATIVE_INTR)

#ifndef __ASSEMBLER__

#define THREAD_CORE_LOCAL_ALIGNED __aligned(16)
Expand Down Expand Up @@ -154,20 +166,6 @@ struct thread_ctx_regs {

struct user_mode_ctx;

/*
* These flags should vary according to the privilege mode selected
* to run OP-TEE core on (M/HS/S). For now default to S-Mode.
*/

#define CSR_XIE_SIE BIT64(IRQ_XSOFT)
#define CSR_XIE_TIE BIT64(IRQ_XTIMER)
#define CSR_XIE_EIE BIT64(IRQ_XEXT)

#define THREAD_EXCP_FOREIGN_INTR CSR_XIE_EIE
#define THREAD_EXCP_NATIVE_INTR (CSR_XIE_SIE | CSR_XIE_TIE)
#define THREAD_EXCP_ALL (THREAD_EXCP_FOREIGN_INTR |\
THREAD_EXCP_NATIVE_INTR)

#ifdef CFG_WITH_VFP
uint32_t thread_kernel_enable_vfp(void);
void thread_kernel_disable_vfp(uint32_t state);
Expand Down
4 changes: 4 additions & 0 deletions core/arch/riscv/plat-spike/platform_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define PLATFORM_CONFIG_H

#include <mm/generic_ram_layout.h>
#include <riscv.h>

#ifndef HTIF_BASE
#define HTIF_BASE 0x40008000
Expand All @@ -19,4 +20,7 @@
#define CLINT_BASE 0x02000000
#endif

#define PLAT_THREAD_EXCP_FOREIGN_INTR (CSR_XIE_EIE)
#define PLAT_THREAD_EXCP_NATIVE_INTR (CSR_XIE_SIE | CSR_XIE_TIE)

#endif
4 changes: 4 additions & 0 deletions core/arch/riscv/plat-virt/platform_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define PLATFORM_CONFIG_H

#include <mm/generic_ram_layout.h>
#include <riscv.h>

/* The stack pointer is always kept 16-byte aligned */
#define STACK_ALIGNMENT 16
Expand Down Expand Up @@ -92,4 +93,7 @@
#define RISCV_MTIME_RATE 1000000
#endif

#define PLAT_THREAD_EXCP_FOREIGN_INTR (CSR_XIE_EIE)
#define PLAT_THREAD_EXCP_NATIVE_INTR (CSR_XIE_SIE | CSR_XIE_TIE)

#endif /*PLATFORM_CONFIG_H*/

0 comments on commit 655469d

Please sign in to comment.