summaryrefslogtreecommitdiff
path: root/libcpu
diff options
context:
space:
mode:
authorjihongbin <[email protected]>2021-11-04 10:36:11 +0800
committerjihongbin <[email protected]>2021-11-04 10:36:11 +0800
commit7d07c61a47505a4380940d91adfb712bb703e6f2 (patch)
treec904287154e86b6736a4a0a5cdb2100022245c1d /libcpu
parent3f3418d173e5a5d3a5b9cea27da1987491bf9e6a (diff)
[fix][libcpu][riscv][t-head] fix rt_hw_interrupt_disable/rt_hw_interrupt_enable bug
使用不同的优化等级会出现不同的效果 当使用-O0 等级时,无法正确得到关闭中断之前的状态 Using different optimization levels will have different effects When the - o0 level is used, the state before the shutdown interrupt cannot be obtained correctly
Diffstat (limited to 'libcpu')
-rw-r--r--libcpu/risc-v/t-head/e9xx/context_gcc.S27
-rw-r--r--libcpu/risc-v/t-head/e9xx/cpuport.c28
2 files changed, 22 insertions, 33 deletions
diff --git a/libcpu/risc-v/t-head/e9xx/context_gcc.S b/libcpu/risc-v/t-head/e9xx/context_gcc.S
index b6adb65ff7..99c63c31de 100644
--- a/libcpu/risc-v/t-head/e9xx/context_gcc.S
+++ b/libcpu/risc-v/t-head/e9xx/context_gcc.S
@@ -45,12 +45,12 @@ rt_hw_context_switch_to:
/* save a0 to to_thread */
la t0, rt_interrupt_to_thread
STORE a0, (t0)
-
+
/* save 0 to from_thread */
la t0, rt_interrupt_from_thread
li t1, 0
STORE t1, (t0)
-
+
/* set rt_thread_switch_interrupt_flag=1 */
la t0, rt_thread_switch_interrupt_flag
li t1, 1
@@ -97,7 +97,7 @@ rt_hw_context_switch_interrupt:
beq t1, t2, .reswitch
/* set rt_thread_switch_interrupt_flag=1 */
STORE t2, (t0)
-
+
/* update from_thread */
la t0, rt_interrupt_from_thread
STORE a0, (t0)
@@ -137,7 +137,7 @@ PendSV_Handler:
la t0, rt_interrupt_from_thread
lw t1, (t0)
beqz t1, .switch_to_thead
-
+
/* restore from thread context t0,t1 */
lw t0, (-4)(sp)
lw t1, (-8)(sp)
@@ -328,6 +328,23 @@ PendSV_Handler:
.pendsv_exit:
mret
-
+/*
+ * rt_base_t rt_hw_interrupt_disable(void);
+ */
+ .globl rt_hw_interrupt_disable
+ .type rt_hw_interrupt_disable, %function
+rt_hw_interrupt_disable:
+ csrrci a0, mstatus, 8
+ ret
+
+
+/*
+ * void rt_hw_interrupt_enable(rt_base_t level);
+ */
+ .globl rt_hw_interrupt_enable
+ .type rt_hw_interrupt_enable, %function
+rt_hw_interrupt_enable:
+ csrw mstatus, a0
+ ret
diff --git a/libcpu/risc-v/t-head/e9xx/cpuport.c b/libcpu/risc-v/t-head/e9xx/cpuport.c
index e93dd67dc3..646220df56 100644
--- a/libcpu/risc-v/t-head/e9xx/cpuport.c
+++ b/libcpu/risc-v/t-head/e9xx/cpuport.c
@@ -134,34 +134,6 @@ rt_uint8_t *rt_hw_stack_init(void *tentry,
return stk;
}
-
-/**
- * This function will disable global interrupt
- *
- * @param none
- *
- * @return zero
- */
-
-rt_base_t rt_hw_interrupt_disable(void)
-{
- __asm volatile("csrrci a0, mstatus, 8");
- return;
-}
-
-/**
- * This function will ennable global interrupt
- *
- * @param level not used
- *
- * @return none
- */
-/* XXX:rename rt_hw_interrupt_restore? */
-void rt_hw_interrupt_enable(rt_base_t level)
-{
- __asm volatile("csrw mstatus, a0");
-}
-
/** shutdown CPU */
RT_WEAK void rt_hw_cpu_shutdown()
{