[rtems commit] riscv: Implement ISR set/get level
Sebastian Huber
sebh at rtems.org
Fri Jun 29 09:56:26 UTC 2018
Module: rtems
Branch: master
Commit: 7c3b0df10752cc4bdd1175f5b16fd0978763ff46
Changeset: http://git.rtems.org/rtems/commit/?id=7c3b0df10752cc4bdd1175f5b16fd0978763ff46
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Jun 22 13:30:49 2018 +0200
riscv: Implement ISR set/get level
Fix prototypes.
Update #3433.
---
cpukit/score/cpu/riscv/cpu.c | 12 +++++-------
cpukit/score/cpu/riscv/include/rtems/score/cpu.h | 15 +++++++++++++--
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/cpukit/score/cpu/riscv/cpu.c b/cpukit/score/cpu/riscv/cpu.c
index fbdb4c5..7c14a8b 100644
--- a/cpukit/score/cpu/riscv/cpu.c
+++ b/cpukit/score/cpu/riscv/cpu.c
@@ -59,15 +59,13 @@ void _CPU_Initialize(void)
/* Do nothing */
}
-void _CPU_ISR_Set_level(unsigned long level)
+uint32_t _CPU_ISR_Get_level( void )
{
- /* Do nothing */
-}
+ if ( _CPU_ISR_Is_enabled( read_csr( mstatus ) ) ) {
+ return 0;
+ }
-unsigned long _CPU_ISR_Get_level( void )
-{
- /* Do nothing */
- return 0;
+ return 1;
}
void _CPU_ISR_install_raw_handler(
diff --git a/cpukit/score/cpu/riscv/include/rtems/score/cpu.h b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
index 1e72dd3..d70db39 100644
--- a/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
@@ -187,9 +187,20 @@ RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( unsigned long level )
return ( level & MSTATUS_MIE ) != 0;
}
-void _CPU_ISR_Set_level( unsigned long level );
+RTEMS_INLINE_ROUTINE void _CPU_ISR_Set_level( uint32_t level )
+{
+ if ( ( level & CPU_MODES_INTERRUPT_MASK) == 0 ) {
+ __asm__ volatile (
+ "csrrs zero, mstatus, " RTEMS_XSTRING( MSTATUS_MIE )
+ );
+ } else {
+ __asm__ volatile (
+ "csrrc zero, mstatus, " RTEMS_XSTRING( MSTATUS_MIE )
+ );
+ }
+}
-unsigned long _CPU_ISR_Get_level( void );
+uint32_t _CPU_ISR_Get_level( void );
/* end of ISR handler macros */
More information about the vc
mailing list