and r2, r2, #3 // Extract cpu number
orr r1, r1, r2 //
mcr p15, 0, r1, c13, c0, 3 // Write TPIDRURO
- ldr r1, [r0, TH_CTH_DATA]
+ mov r1, #0
mcr p15, 0, r1, c13, c0, 2 // Write TPIDRURW
mov r7, #0 // Clear frame pointer
ldr r3, [r0, TH_KSTACKPTR] // Get kernel stack top
bx lr // Return
/*
- * void Call_continuation( void (*continuation)(void),
- * void *param,
- * wait_result_t wresult,
- * vm_offset_t stack_ptr)
+ * typedef void (*thread_continue_t)(void *param, wait_result_t)
+ *
+ * void Call_continuation( thread_continue_t continuation,
+ * void *param,
+ * wait_result_t wresult,
+ * bool enable interrupts)
*/
.text
.align 5
mrc p15, 0, r9, c13, c0, 4 // Read TPIDRPRW
ldr sp, [r9, TH_KSTACKPTR] // Set stack pointer
mov r7, #0 // Clear frame pointer
- mov r6,r0 // Load continuation
- mov r0,r1 // Set first parameter
- mov r1,r2 // Set wait result arg
- blx r6 // Branch to continuation
+
+ mov r4,r0 // Load continuation
+ mov r5,r1 // continuation parameter
+ mov r6,r2 // Set wait result arg
+
+ teq r3, #0
+ beq 1f
+ mov r0, #1
+ bl _ml_set_interrupts_enabled
+1:
+
+ mov r0,r5 // Set first parameter
+ mov r1,r6 // Set wait result arg
+ blx r4 // Branch to continuation
+
mrc p15, 0, r0, c13, c0, 4 // Read TPIDRPRW
LOAD_ADDR_PC(thread_terminate)
b . // Not reach
bne switch_threads // No need to save GPR/NEON state if we are
#if __ARM_VFP__
mov r1, r2 // r2 will be clobbered by the save, so preserve it
- add r3, r0, ACT_KVFP // Get the kernel VFP save area for the old thread...
+ ldr r3, [r0, TH_KSTACKPTR] // Get old kernel stack top
+ add r3, r3, SS_KVFP // Get the kernel VFP save area for the old thread...
save_vfp_registers // ...and save our VFP state to it
mov r2, r1 // Restore r2 (the new thread pointer)
#endif /* __ARM_VFP__ */
add r3, r3, SS_R4
stmia r3!, {r4-r14} // Save general registers to pcb
switch_threads:
+ ldr r3, [r2, ACT_CPUDATAP]
+ str r2, [r3, CPU_ACTIVE_THREAD]
ldr r3, [r2, TH_KSTACKPTR] // get kernel stack top
mcr p15, 0, r2, c13, c0, 4 // Write TPIDRPRW
ldr r6, [r2, TH_CTH_SELF]
and r5, r5, #3 // Extract cpu number
orr r6, r6, r5
mcr p15, 0, r6, c13, c0, 3 // Write TPIDRURO
- ldr r6, [r2, TH_CTH_DATA]
+ mov r6, #0
mcr p15, 0, r6, c13, c0, 2 // Write TPIDRURW
load_reg:
add r3, r3, SS_R4
ldmia r3!, {r4-r14} // Restore new thread status
#if __ARM_VFP__
- add r3, r2, ACT_KVFP // Get the kernel VFP save area for the new thread...
+ ldr r3, [r2, TH_KSTACKPTR] // get kernel stack top
+ add r3, r3, SS_KVFP // Get the kernel VFP save area for the new thread...
load_vfp_registers // ...and load the saved state
#endif /* __ARM_VFP__ */
bx lr // Return
LEXT(Shutdown_context)
mrc p15, 0, r9, c13, c0, 4 // Read TPIDRPRW
#if __ARM_VFP__
- add r3, r9, ACT_KVFP // Get the kernel VFP save area for the current thread...
+ ldr r3, [r9, TH_KSTACKPTR] // get kernel stack top
+ add r3, r3, SS_KVFP // Get the kernel VFP save area for the current thread...
save_vfp_registers // ...and save our VFP state to it
#endif
ldr r3, [r9, TH_KSTACKPTR] // Get kernel stack top
mrc p15, 0, r9, c13, c0, 4 // Read TPIDRPRW
#if __ARM_VFP__
- add r3, r9, ACT_KVFP // Get the kernel VFP save area for the current thread...
+ ldr r3, [r9, TH_KSTACKPTR] // get kernel stack top
+ add r3, r3, SS_KVFP // Get the kernel VFP save area for the current thread...
save_vfp_registers // ...and save our VFP state to it
#endif
ldr r3, [r9, TH_KSTACKPTR] // Get kernel stack top
add r3, r3, SS_R4
ldmia r3!, {r4-r14} // Restore new thread status
#if __ARM_VFP__
- add r3, r9, ACT_KVFP // Get the kernel VFP save area for the current thread...
+ ldr r3, [r9, TH_KSTACKPTR] // get kernel stack top
+ add r3, r3, SS_KVFP // Get the kernel VFP save area for the current thread...
load_vfp_registers // ...and load the saved state
#endif
bx lr // Return