Christian Thalinger
Edwin Steiner
- $Id: asmpart.S 4921 2006-05-15 14:24:36Z twisti $
+ $Id: asmpart.S 4922 2006-05-15 14:39:05Z twisti $
*/
.globl asm_replacement_out
.globl asm_replacement_in
- .globl asm_perform_threadswitch
- .globl asm_initialize_thread_stack
- .globl asm_switchstackandcall
.globl asm_criticalsections
.globl asm_getclassvalues_atomic
.end asm_replacement_in
-/******************* function asm_initialize_thread_stack **********************
-* *
-* initialized a thread stack *
-* *
-*******************************************************************************/
-
- .ent asm_initialize_thread_stack
-
-asm_initialize_thread_stack:
- lda a1,-128(a1)
- stq zero, 0(a1)
- stq zero, 8(a1)
- stq zero, 16(a1)
- stq zero, 24(a1)
- stq zero, 32(a1)
- stq zero, 40(a1)
- stq zero, 48(a1)
- stt fzero, 56(a1)
- stt fzero, 64(a1)
- stt fzero, 72(a1)
- stt fzero, 80(a1)
- stt fzero, 88(a1)
- stt fzero, 96(a1)
- stt fzero, 104(a1)
- stt fzero, 112(a1)
- stq a0, 120(a1)
- mov a1, v0
- jmp zero,(ra)
-
- .end asm_initialize_thread_stack
-
-
-/******************* function asm_perform_threadswitch *************************
-* *
-* void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
-* *
-* performs a threadswitch *
-* *
-*******************************************************************************/
-
- .ent asm_perform_threadswitch
-
-asm_perform_threadswitch:
- subq sp,128,sp
- stq s0, 0(sp)
- stq s1, 8(sp)
- stq s2, 16(sp)
- stq s3, 24(sp)
- stq s4, 32(sp)
- stq s5, 40(sp)
- stq s6, 48(sp)
- stt fs0, 56(sp)
- stt fs1, 64(sp)
- stt fs2, 72(sp)
- stt fs3, 80(sp)
- stt fs4, 88(sp)
- stt fs5, 96(sp)
- stt fs6, 104(sp)
- stt fs7, 112(sp)
- stq ra, 120(sp)
- stq sp, 0(a0)
- stq sp, 0(a2)
- ldq sp, 0(a1)
- ldq s0, 0(sp)
- ldq s1, 8(sp)
- ldq s2, 16(sp)
- ldq s3, 24(sp)
- ldq s4, 32(sp)
- ldq s5, 40(sp)
- ldq s6, 48(sp)
- ldt fs0, 56(sp)
- ldt fs1, 64(sp)
- ldt fs2, 72(sp)
- ldt fs3, 80(sp)
- ldt fs4, 88(sp)
- ldt fs5, 96(sp)
- ldt fs6, 104(sp)
- ldt fs7, 112(sp)
- ldq ra, 120(sp)
- mov ra, pv
- addq sp, 128, sp
- jmp zero,(ra)
-
- .end asm_perform_threadswitch
-
-
-/********************* function asm_switchstackandcall *************************
-* *
-* void *asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
-* void *p); *
-* *
-* Switches to a new stack, calls a function and switches back. *
-* a0 new stack pointer *
-* a1 function pointer *
-* a2 pointer to variable where stack top should be stored *
-* a3 pointer to user data, is passed to the function *
-* *
-*******************************************************************************/
-
-
- .ent asm_switchstackandcall
-
-asm_switchstackandcall:
- lda a0,-2*8(a0) /* allocate new stack */
- stq ra,0(a0) /* save return address on new stack */
- stq sp,1*8(a0) /* save old stack pointer on new stack */
- stq sp,0(a2) /* save old stack pointer to variable */
- mov a0,sp /* switch to new stack */
-
- mov a1,pv /* load function pointer */
- mov a3,a0 /* pass pointer */
- jmp ra,(pv) /* and call function */
-
- ldq ra,0(sp) /* load return address */
- ldq sp,1*8(sp) /* switch to old stack */
-
- jmp zero,(ra) /* return */
-
- .end asm_switchstackandcall
-
.ent asm_getclassvalues_atomic
Changes: Joseph Wenninger
Edwin Steiner
- $Id: asmpart.S 4921 2006-05-15 14:24:36Z twisti $
+ $Id: asmpart.S 4922 2006-05-15 14:39:05Z twisti $
*/
.globl asm_builtin_d2i
.globl asm_builtin_d2l
- .globl asm_perform_threadswitch
- .globl asm_initialize_thread_stack
- .globl asm_switchstackandcall
.globl asm_criticalsections
.globl asm_getclassvalues_atomic
ret
-/******************* function asm_initialize_thread_stack **********************
-* *
-* initialized a thread stack *
-* (to)->restorePoint = asm_initialize_thread_stack((u1*)(func), (to)->stackEnd)*
-* *
-*******************************************************************************/
-
-asm_initialize_thread_stack:
- mov 8(%esp),%eax /* (to)->stackEnd */
- sub $36,%eax /* 4 bytes * 8 regs + 4 bytes func */
-
- xor %edx,%edx
- mov %edx,0(%eax)
- mov %edx,4(%eax)
- mov %edx,8(%eax)
- mov %edx,12(%eax)
- mov %edx,16(%eax)
- mov %edx,20(%eax)
- mov %edx,24(%eax)
- mov %edx,28(%eax)
-
- mov 4(%esp),%edx /* save (u1*) (func) */
- mov %edx,32(%eax)
-
- ret /* return restorepoint in %eax */
-
-
-/******************* function asm_perform_threadswitch *************************
-* *
-* void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
-* *
-* performs a threadswitch *
-* *
-*******************************************************************************/
-
-asm_perform_threadswitch:
- sub $36,%esp
-
- mov %eax,0(%esp)
- mov %ecx,4(%esp)
- mov %edx,8(%esp)
- mov %ebx,12(%esp)
- mov %esp,16(%esp)
- mov %ebp,20(%esp)
- mov %esi,24(%esp)
- mov %edi,28(%esp)
-
- mov 36(%esp),%eax /* save current return address */
- mov %eax,32(%esp)
-
- mov 40(%esp),%eax /* first argument **from */
- mov %esp,0(%eax)
-
- mov 48(%esp),%eax /* third argument **stackTop */
- mov %esp,0(%eax)
-
- mov 44(%esp),%eax /* second argument **to */
- mov 0(%eax),%esp /* load new stack pointer */
-
- mov 0(%esp),%eax
- mov 4(%esp),%ecx
- mov 8(%esp),%edx
- mov 12(%esp),%ebx
- /* skip stack pointer */
- mov 20(%esp),%ebp
- mov 24(%esp),%esi
- mov 28(%esp),%edi
-
- add $32,%esp /* leave return address on stack */
- ret
-
-
-/********************* function asm_switchstackandcall *************************
-* *
-* int asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
-* void *p); *
-* *
-* Switches to a new stack, calls a function and switches back. *
-* a0 new stack pointer *
-* a1 function pointer *
-* a2 pointer to variable where stack top should be stored *
-* a3 pointer to user data, is passed to the function *
-* *
-*******************************************************************************/
-
-asm_switchstackandcall:
- mov 4(%esp),%edx /* first argument *stack */
- sub $8,%edx /* allocate new stack */
-
- mov (%esp),%eax /* save return address on new stack */
- mov %eax,(%edx)
-
- mov %esp,4(%edx) /* save old stack pointer on new stack */
-
- mov 12(%esp),%eax /* third argument **stacktopsave */
- mov %esp,(%eax) /* save old stack pointer to variable */
-
- mov 8(%esp),%eax /* load function pointer */
- mov 16(%esp),%ecx /* fourth argument *p */
-
- mov %edx,%esp /* switch to new stack */
-
- sub $4,%esp
- mov %ecx,0(%esp) /* pass pointer */
- call *%eax /* and call function */
- add $4,%esp
-
- mov (%esp),%edx /* load return address */
- mov 4(%esp),%esp /* switch to old stack */
- mov %edx,(%esp)
- ret
-
-
asm_getclassvalues_atomic:
_crit_restart2:
mov 4(%esp),%ecx /* super */
Changes: Christian Thalinger
Edwin Steiner
- $Id: asmpart.S 4921 2006-05-15 14:24:36Z twisti $
+ $Id: asmpart.S 4922 2006-05-15 14:39:05Z twisti $
*/
.globl asm_replacement_out
.globl asm_replacement_in
- .globl asm_perform_threadswitch
- .globl asm_initialize_thread_stack
- .globl asm_switchstackandcall
.globl asm_getclassvalues_atomic
.globl asm_criticalsections
.end asm_replacement_in
-/******************* function asm_initialize_thread_stack **********************
-* *
-* u1* asm_initialize_thread_stack (void *func, u1 *stack); *
-* *
-* initialize a thread stack *
-* *
-*******************************************************************************/
-
- .ent asm_initialize_thread_stack
-
-asm_initialize_thread_stack:
- aaddiu a1,a1,-14*8 /* allocate save area */
- sd zero, 0*8(a1) /* s0 initalize thread area */
- sd zero, 1*8(a1) /* s1 */
- sd zero, 2*8(a1) /* s2 */
- sd zero, 3*8(a1) /* s3 */
- sd zero, 4*8(a1) /* s4 */
- sd zero, 5*8(a1) /* s5 */
- sd zero, 6*8(a1) /* s6 */
- sd zero, 7*8(a1) /* s7 */
- sd zero, 8*8(a1) /* s8 */
- sd zero, 9*8(a1) /* fs0 */
- sd zero,10*8(a1) /* fs1 */
- sd zero,11*8(a1) /* fs2 */
- sd zero,12*8(a1) /* fs3 */
- sd a0, 13*8(a1)
- move v0,a1
- j ra /* return */
-
- .end asm_initialize_thread_stack
-
-
-/******************* function asm_perform_threadswitch *************************
-* *
-* void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
-* *
-* performs a threadswitch *
-* *
-*******************************************************************************/
-
- .ent asm_perform_threadswitch
-
-asm_perform_threadswitch:
- aaddiu sp,sp,-14*8 /* allocate new stack */
- sd s0, 0*8(sp) /* save saved registers of old thread */
- sd s1, 1*8(sp)
- sd s2, 2*8(sp)
- sd s3, 3*8(sp)
- sd s4, 4*8(sp)
- sd s5, 5*8(sp)
- sd s6, 6*8(sp)
- sd s7, 7*8(sp)
- sd s8, 8*8(sp)
- sdc1 fs0, 9*8(sp)
- sdc1 fs1,10*8(sp)
- sdc1 fs2,11*8(sp)
- sdc1 fs3,12*8(sp)
- sd ra, 13*8(sp)
- ast sp,0(a0) /* save old stack pointer */
- ast sp,0(a2) /* stackTop = old stack pointer */
- ald sp,0(a1) /* load new stack pointer */
- ld s0, 0*8(sp) /* load saved registers of new thread */
- ld s1, 1*8(sp)
- ld s2, 2*8(sp)
- ld s3, 3*8(sp)
- ld s4, 4*8(sp)
- ld s5, 5*8(sp)
- ld s6, 6*8(sp)
- ld s7, 7*8(sp)
- ld s8, 8*8(sp)
- ldc1 fs0, 9*8(sp)
- ldc1 fs1,10*8(sp)
- ldc1 fs2,11*8(sp)
- ldc1 fs3,12*8(sp)
- ld ra, 13*8(sp)
- aaddiu sp,sp,14*8 /* deallocate new stack */
- move itmp3, ra
- j ra /* return */
-
- .end asm_perform_threadswitch
-
-
-/********************* function asm_switchstackandcall *************************
-* *
-* void asm_switchstackandcall (void *stack, void *func, void **stacktopsave); *
-* *
-* Switches to a new stack, calls a function and switches back. *
-* a0 new stack pointer *
-* a1 function pointer *
-* a2 pointer to variable where stack top should be stored *
-* *
-*******************************************************************************/
-
- .ent asm_switchstackandcall
-
-asm_switchstackandcall:
- aaddiu a0,a0,-16 /* allocate new stack */
- sd ra,0(a0) /* save return address on new stack */
- sd sp,8(a0) /* save old stack pointer on new stack */
- sd sp,0(a2) /* save old stack pointer to variable */
- move sp,a0 /* switch to new stack */
-
- move itmp3,a1
- move a0,a3
- jalr itmp3 /* and call function */
-
- ld ra,0(sp) /* load return address */
- ld sp,8(sp) /* switch to old stack */
-
- j ra /* return */
-
- .end asm_switchstackandcall
-
.ent asm_getclassvalues_atomic
Changes: Edwin Steiner
- $Id: asmpart.S 4921 2006-05-15 14:24:36Z twisti $
+ $Id: asmpart.S 4922 2006-05-15 14:39:05Z twisti $
*/
.globl asm_builtin_d2i
.globl asm_builtin_d2l
- .globl asm_perform_threadswitch
- .globl asm_initialize_thread_stack
- .globl asm_switchstackandcall
.globl asm_criticalsections
.globl asm_getclassvalues_atomic
/* jump to new code */
ret
+
/* asm_builtin_x2x *************************************************************
* *
* Wrapper functions for float to int corner cases *
ret
-/******************* function asm_initialize_thread_stack **********************
-* *
-* initialized a thread stack *
-* (to)->restorePoint = asm_initialize_thread_stack((u1*)(func), (to)->stackEnd)*
-* *
-*******************************************************************************/
-
-asm_initialize_thread_stack:
- sub $(7*8),%rsi
-
- xor %r10,%r10
- mov %r10,0*8(%rsi)
- mov %r10,1*8(%rsi)
- mov %r10,2*8(%rsi)
- mov %r10,3*8(%rsi)
- mov %r10,4*8(%rsi)
- mov %r10,5*8(%rsi)
-
- mov %rdi,6*8(%rsi) /* save (u1*) (func) */
- mov %rsi,%rax /* return restorepoint in %rax */
- ret
-
-
-/******************* function asm_perform_threadswitch *************************
-* *
-* void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
-* *
-* performs a threadswitch *
-* *
-*******************************************************************************/
-
-asm_perform_threadswitch:
- sub $(7*8),%rsp /* allocate stack frame */
-
- mov %rbx,0*8(%rsp)
- mov %rbp,1*8(%rsp)
- mov %r12,2*8(%rsp)
- mov %r13,3*8(%rsp)
- mov %r14,4*8(%rsp)
- mov %r15,5*8(%rsp)
-
- mov 7*8(%rsp),%rax /* save current return address */
- mov %rax,6*8(%rsp)
-
- mov %rsp,(%rdi) /* first argument **from */
- mov %rsp,(%rdx) /* third argument **stackTop */
-
- mov (%rsi),%rsp /* load new stack pointer */
-
- mov 0*8(%rsp),%rbx
- mov 1*8(%rsp),%rbp
- mov 2*8(%rsp),%r12
- mov 3*8(%rsp),%r13
- mov 4*8(%rsp),%r14
- mov 5*8(%rsp),%r15
-
- mov 6*8(%rsp),%rax /* restore return address */
- add $(7*8),%rsp /* free stack frame */
- mov %rax,(%rsp)
- ret
-
-
-/********************* function asm_switchstackandcall *************************
-* *
-* int asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
-* void *p); *
-* *
-* Switches to a new stack, calls a function and switches back. *
-* a0 (%rdi) new stack pointer *
-* a1 (%rsi) function pointer *
-* a2 (%rdx) pointer to variable where stack top should be stored *
-* a3 (%rcx) pointer to user data, is passed to the function *
-* *
-*******************************************************************************/
-
-asm_switchstackandcall:
- sub $(1*8),%rsp /* keep stack 16-byte aligned */
- sub $16,%rdi /* allocate new stack */
-
- mov 8(%rsp),%rax /* save return address on new stack */
- mov %rax,(%rdi)
- mov %rsp,8(%rdi) /* save old stack pointer on new stack*/
- mov %rsp,(%rdx) /* save old stack pointer to variable */
-
- mov %rdi,%rsp /* switch to new stack */
-
- mov %rcx,%rdi /* pass pointer */
- call *%rsi /* and call function */
-
- mov (%rsp),%r10 /* load return address */
- mov 8(%rsp),%rsp /* switch to old stack */
- add $(1*8),%rsp /* free stack space */
- mov %r10,(%rsp) /* write return adress */
- ret
-
-
asm_getclassvalues_atomic:
_crit_restart:
_crit_begin: