/* ** RTLinux Thread setup and context switching ** ** 15 March 2002 : ** Initial Version by Paul Coene & Vincent Nollet ** ** Copyright IMEC VZW ** ** This code is released under the provisions of GPL V2 and ** the RTLinux Open Patent License. This release is does ** not qualify as an Open RTLinux release under terms of the ** Open RTLinux Patent License. Both the terms of the GPL V2 ** and of the Open RTLinux Patent License will be strictly ** enforced. ** */ #include .text /* ** void __rtl_init_state(task, function, data, rt_startup) ** r0 r1 r2 r3 */ ENTRY(__rtl_init_state) mov ip,sp stmdb sp!,{fp,ip,lr,pc} sub fp,ip,#4 mov ip, r0 ldr r0, [r0] str r3, [r0, #-4] str r0, [r0, #-8] add r0, r0, #-8 stmdb r0!, {r2-r10} /* ** Fix the new stack so, at the next 'schedule' call, ** we can jump to rt_startup, with function and data ** as parameters ** r0 <= function ** r1 <= data */ stmdb r0!, {r1, r2} /* save the cpsr on the new stack */ mrs r1, cpsr stmdb r0!,{r1} /* Last but not least, store the position of the stack (r0) in task->stack */ mov r1, ip str r0, [r1] ldmdb fp, {fp, sp, pc} /* ** void rtl_switch_to(RTL_THREAD_STRUCT**,RTL_THREAD_STRUCT*) ** current task new task ** r0 r1 */ ENTRY(rtl_switch_to) stmdb sp!, {r0 - r10, fp, lr} mrs ip, cpsr str ip, [sp, #-4]! ldr r2, [r0] str sp, [r2] ldr sp, [r1] str r1, [r0] @ set current task to new task ldr ip, [sp], #4 msr cpsr, ip ldmia sp!, {r0 - r10, fp, pc}^