Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 794f7a5

Browse files
committedMay 22, 2024·
fixup: thread self
1 parent 5a819be commit 794f7a5

File tree

5 files changed

+14
-21
lines changed

5 files changed

+14
-21
lines changed
 

Diff for: ‎components/lwp/arch/risc-v/rv64/lwp_gcc.S

+4-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ arch_start_umode:
3535
// load kstack for user process
3636
csrw sscratch, a3
3737
li t0, SSTATUS_SPP | SSTATUS_SIE // set as user mode, close interrupt
38-
csrc sstatus, t0
38+
csrc sstatus, t0
3939
li t0, SSTATUS_SPIE // enable interrupt when return to user mode
4040
csrs sstatus, t0
4141

@@ -112,7 +112,7 @@ arch_signal_quit:
112112
mv sp, a0
113113

114114
/* restore user sp before enter trap */
115-
addi a0, sp, CTX_REG_NR * REGBYTES
115+
addi a0, sp, CTX_REG_NR * REGBYTES
116116
csrw sscratch, a0
117117

118118

@@ -234,8 +234,7 @@ __restore_sp_from_sscratch: // from kernel
234234
j __move_stack_context
235235

236236
__restore_sp_from_tcb: // from user
237-
la a0, rt_current_thread
238-
LOAD a0, 0(a0)
237+
jal rt_thread_self
239238
jal get_thread_kernel_stack_top
240239
mv t0, a0
241240

@@ -272,7 +271,7 @@ copy_context_loop:
272271
call syscall_handler
273272
j arch_syscall_exit
274273
START_POINT_END(syscall_entry)
275-
274+
276275
.global arch_syscall_exit
277276
arch_syscall_exit:
278277
CLOSE_INTERRUPT

Diff for: ‎libcpu/arm/cortex-m33/context_gcc.S

+1-2
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ contex_ns_load:
196196

197197
#if defined (RT_USING_MEM_PROTECTION)
198198
PUSH {r0-r3, r12, lr}
199-
LDR r1, =rt_current_thread
200-
LDR r0, [r1]
199+
BL rt_thread_self
201200
BL rt_hw_mpu_table_switch
202201
POP {r0-r3, r12, lr}
203202
#endif

Diff for: ‎libcpu/arm/cortex-m7/context_gcc.S

+1-2
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ switch_to_thread:
156156

157157
#if defined (RT_USING_MEM_PROTECTION)
158158
PUSH {r0-r3, r12, lr}
159-
LDR r1, =rt_current_thread
160-
LDR r0, [r1]
159+
BL rt_thread_self
161160
BL rt_hw_mpu_table_switch
162161
POP {r0-r3, r12, lr}
163162
#endif

Diff for: ‎libcpu/risc-v/t-head/c906/context_gcc.S

+4-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
rt_hw_context_switch_to:
1818
LOAD sp, (a0)
1919

20-
la s0, rt_current_thread
21-
LOAD s1, (s0)
20+
jal rt_thread_self
21+
mv s1, a0
2222

2323
#ifdef RT_USING_SMART
24-
mv a0, s1
2524
jal lwp_aspace_switch
2625
#endif
2726

@@ -50,11 +49,10 @@ rt_hw_context_switch:
5049
//restore to thread context
5150
LOAD sp, (a1)
5251

53-
la s0, rt_current_thread
54-
LOAD s1, (s0)
52+
jal rt_thread_self
53+
mv s1, a0
5554

5655
#ifdef RT_USING_SMART
57-
mv a0, s1
5856
jal lwp_aspace_switch
5957
#endif
6058

Diff for: ‎libcpu/risc-v/virt64/context_gcc.S

+4-6
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,10 @@
7575
rt_hw_context_switch_to:
7676
LOAD sp, (a0)
7777

78-
la s0, rt_current_thread
79-
LOAD s1, (s0)
78+
jal rt_thread_self
79+
mv s1, a0
8080

8181
#ifdef RT_USING_SMART
82-
mv a0, s1
8382
jal lwp_aspace_switch
8483
#endif
8584

@@ -103,11 +102,10 @@ rt_hw_context_switch:
103102
LOAD sp, (a1)
104103

105104
// restore Address Space
106-
la s0, rt_current_thread
107-
LOAD s1, (s0)
105+
jal rt_thread_self
106+
mv s1, a0
108107

109108
#ifdef RT_USING_SMART
110-
mv a0, s1
111109
jal lwp_aspace_switch
112110
#endif
113111

0 commit comments

Comments
 (0)
Please sign in to comment.