1
1
/*
2
2
* Copyright (c) 2006-2018, RT-Thread Development Team
3
+ * Copyright (c) 2021, Alibaba Group Holding Limited
3
4
*
4
5
* SPDX-License-Identifier: Apache-2.0
5
6
*
6
7
* Change Logs:
7
8
* Date Author Notes
8
9
* 2020/08/20 zx.chen The T-HEAD RISC-V CPU E906 porting implementation
10
+ * 2021/08/13 zx.chen update T-HEAD E9xx-series(E906/7/F/D/P) CPU porting code.
9
11
*/
10
12
11
13
#include "cpuport.h"
@@ -29,8 +31,6 @@ vPortYield:
29
31
30
32
ret
31
33
32
-
33
-
34
34
/*
35
35
* #ifdef RT_USING_SMP
36
36
* void rt_hw_context_switch_to(rt_ubase_t to, stuct rt_thread *to_thread);
@@ -56,12 +56,10 @@ rt_hw_context_switch_to:
56
56
li t1, 1
57
57
STORE t1, (t0)
58
58
59
- /* enable mexstatus SPUSHEN and SPSWAPEN */
60
- #if ((CONFIG_CPU_E906 ==1 ) || (CONFIG_CPU_E906F ==1 ) || (CONFIG_CPU_E906FD ==1 ))
61
- uint32_t mexstatus;
62
- mexstatus = __get_MEXSTATUS();
63
- mexstatus |= (0x2 << 16 );
64
- __set_MEXSTATUS(mexstatus);
59
+ /* enable mexstatus SPUSHEN */
60
+ #ifdef CONFIG_THEAD_EXT_SPUSHEN
61
+ li t0, 0x10000
62
+ csrs mexstatus, t0
65
63
#endif
66
64
67
65
csrw mscratch, sp
@@ -140,7 +138,7 @@ PendSV_Handler:
140
138
lw t1, (t0)
141
139
beqz t1, .switch_to_thead
142
140
143
- /* save from thread context */
141
+ /* restore from thread context t0,t1 */
144
142
lw t0, (-4 )(sp)
145
143
lw t1, (-8 )(sp)
146
144
@@ -191,10 +189,6 @@ PendSV_Handler:
191
189
csrr x1, mepc
192
190
STORE x1, 0 * REGBYTES(sp)
193
191
csrr x1, mstatus
194
- andi x1, x1, 8
195
- beqz x1, .save_mpie
196
- li x1, 0x80
197
- .save_mpie:
198
192
STORE x1, 2 * REGBYTES(sp)
199
193
/* x3 don't need save */
200
194
STORE x4, 4 * REGBYTES(sp)
@@ -256,11 +250,9 @@ PendSV_Handler:
256
250
csrw mepc, a1
257
251
LOAD x1, 1 * REGBYTES(sp)
258
252
259
- /* force to machin mode(MPP=11) */
260
- li a1, 0x1880
261
- csrs mstatus, a1
253
+ /* force to machine mode(MPP=11) */
262
254
LOAD a1, 2 * REGBYTES(sp)
263
- csrs mstatus, a1
255
+ csrw mstatus, a1
264
256
/* x3 don't need restore */
265
257
LOAD x4, 4 * REGBYTES(sp)
266
258
LOAD x5, 5 * REGBYTES(sp)
0 commit comments