Changeset a35a3d8 in mainline for uspace/lib/c/arch
- Timestamp:
- 2018-03-12T17:13:46Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b127e4af
- Parents:
- f3d47c97
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-12 17:13:46)
- git-committer:
- GitHub <noreply@…> (2018-03-12 17:13:46)
- Location:
- uspace/lib/c/arch
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/arch/abs32le/src/fibril.c
rf3d47c97 ra35a3d8 30 30 */ 31 31 32 #include < fibril.h>32 #include <setjmp.h> 33 33 #include <stdbool.h> 34 34 35 int context_save(context_t *ctx)35 int __setjmp(context_t *ctx) 36 36 { 37 return 1;37 return 0; 38 38 } 39 39 40 void context_restore(context_t *ctx)40 void __longjmp(context_t *ctx, int val) 41 41 { 42 42 while (true); -
uspace/lib/c/arch/amd64/src/fibril.S
rf3d47c97 ra35a3d8 35 35 # 36 36 # Save CPU context to context_t variable 37 # pointed by the 1st argument. Returns 1 in EAX.37 # pointed by the 1st argument. Returns 0 in RAX. 38 38 # 39 FUNCTION_BEGIN( context_save)39 FUNCTION_BEGIN(__setjmp) 40 40 movq (%rsp), %rdx # the caller's return %eip 41 41 … … 54 54 movq %rax, CONTEXT_OFFSET_TLS(%rdi) 55 55 56 xorl %eax, %eax # context_save returns 1 57 incl %eax 56 xorq %rax, %rax # __setjmp returns 0 58 57 ret 59 FUNCTION_END( context_save)58 FUNCTION_END(__setjmp) 60 59 61 60 ## Restore current CPU context 62 61 # 63 62 # Restore CPU context from context_t variable 64 # pointed by the 1st argument. Returns 0 in EAX.63 # pointed by the 1st argument. Returns second argument in RAX. 65 64 # 66 FUNCTION_BEGIN( context_restore)65 FUNCTION_BEGIN(__longjmp) 67 66 movq CONTEXT_OFFSET_R15(%rdi), %r15 68 67 movq CONTEXT_OFFSET_R14(%rdi), %r14 … … 81 80 movq %rdi, %fs:0 82 81 83 xorl %eax, %eax # context_restore returns 082 movq %rsi, %rax # __longjmp returns second argument 84 83 ret 85 FUNCTION_END( context_restore)84 FUNCTION_END(__longjmp) 86 85 -
uspace/lib/c/arch/arm32/src/fibril.S
rf3d47c97 ra35a3d8 31 31 .text 32 32 33 FUNCTION_BEGIN( context_save)33 FUNCTION_BEGIN(__setjmp) 34 34 stmia r0!, {sp, lr} 35 35 stmia r0!, {r4-r11} 36 37 # return 138 mov r0, #139 mov pc, lr40 FUNCTION_END(context_save)41 42 FUNCTION_BEGIN(context_restore)43 ldmia r0!, {sp, lr}44 ldmia r0!, {r4-r11}45 36 46 37 # return 0 47 38 mov r0, #0 48 39 mov pc, lr 49 FUNCTION_END( context_restore)40 FUNCTION_END(__setjmp) 50 41 42 FUNCTION_BEGIN(__longjmp) 43 ldmia r0!, {sp, lr} 44 ldmia r0!, {r4-r11} 45 46 # return second argument 47 mov r0, r1 48 mov pc, lr 49 FUNCTION_END(__longjmp) 50 -
uspace/lib/c/arch/ia32/src/fibril.S
rf3d47c97 ra35a3d8 35 35 # 36 36 # Save CPU context to the context_t variable 37 # pointed by the 1st argument. Returns 1in EAX.37 # pointed by the 1st argument. Returns 0 in EAX. 38 38 # 39 FUNCTION_BEGIN( context_save)39 FUNCTION_BEGIN(__setjmp) 40 40 movl 0(%esp), %eax # the caller's return %eip 41 41 movl 4(%esp), %edx # address of the context variable to save context to … … 53 53 movl %eax, CONTEXT_OFFSET_TLS(%edx) # tls -> ctx->tls 54 54 55 xorl %eax, %eax # context_save returns 1 56 incl %eax 55 xorl %eax, %eax # __setjmp returns 0 57 56 ret 58 FUNCTION_END( context_save)57 FUNCTION_END(__setjmp) 59 58 60 59 ## Restore saved CPU context 61 60 # 62 61 # Restore CPU context from context_t variable 63 # pointed by the 1st argument. Returns 0in EAX.62 # pointed by the 1st argument. Returns second argument in EAX. 64 63 # 65 FUNCTION_BEGIN( context_restore)64 FUNCTION_BEGIN(__longjmp) 66 65 movl 4(%esp), %eax # address of the context variable to restore context from 66 movl 8(%esp), %ecx # return value 67 67 68 68 # restore registers from the context structure … … 80 80 movl %edx, %gs:0 81 81 82 xorl %eax, %eax # context_restore returns 082 movl %ecx, %eax 83 83 ret 84 FUNCTION_END( context_restore)84 FUNCTION_END(__longjmp) 85 85 -
uspace/lib/c/arch/ia64/include/libarch/fibril.h
rf3d47c97 ra35a3d8 43 43 44 44 /* 45 * context_save() and context_restore() are both leaf procedures.45 * __setjmp() and __longjmp() are both leaf procedures. 46 46 * No need to allocate scratch area. 47 47 */ -
uspace/lib/c/arch/ia64/src/fibril.S
rf3d47c97 ra35a3d8 32 32 .text 33 33 34 FUNCTION_BEGIN( context_save)34 FUNCTION_BEGIN(__setjmp) 35 35 alloc loc0 = ar.pfs, 1, 49, 0, 0 36 36 mov loc1 = ar.unat ;; … … 178 178 mov ar.unat = loc1 179 179 180 add r8 = r0, r0, 1 /* context_save returns 1*/180 mov r8 = 0 /* __setjmp returns 0 */ 181 181 br.ret.sptk.many b0 182 FUNCTION_END( context_save)183 184 FUNCTION_BEGIN( context_restore)185 alloc loc0 = ar.pfs, 1, 50, 0, 0 ;;182 FUNCTION_END(__setjmp) 183 184 FUNCTION_BEGIN(__longjmp) 185 alloc loc0 = ar.pfs, 2, 51, 0, 0 ;; 186 186 187 187 add loc9 = CONTEXT_OFFSET_AR_PFS, in0 … … 230 230 add loc47 = CONTEXT_OFFSET_F29, in0 231 231 add loc48 = CONTEXT_OFFSET_F30, in0 232 add loc49 = CONTEXT_OFFSET_F31, in0 ;; 232 add loc49 = CONTEXT_OFFSET_F31, in0 233 mov loc50 = in1 ;; 233 234 234 235 ld8 loc0 = [loc9] /* load ar.pfs */ … … 335 336 mov ar.unat = loc1 336 337 337 mov r8 = r0 /* context_restore returns 0*/338 mov r8 = loc50 /* __longjmp returns second argument */ 338 339 br.ret.sptk.many b0 339 FUNCTION_END( context_restore)340 FUNCTION_END(__longjmp) -
uspace/lib/c/arch/mips32/src/fibril.S
rf3d47c97 ra35a3d8 35 35 #include <libarch/fibril_context.h> 36 36 37 FUNCTION_BEGIN( context_save)37 FUNCTION_BEGIN(__setjmp) 38 38 sw $s0, CONTEXT_OFFSET_S0($a0) 39 39 sw $s1, CONTEXT_OFFSET_S1($a0) … … 87 87 sw $sp, CONTEXT_OFFSET_SP($a0) 88 88 89 # context_save returns 189 # __setjmp returns 0 90 90 j $ra 91 li $v0, 192 FUNCTION_END( context_save)91 li $v0, 0 92 FUNCTION_END(__setjmp) 93 93 94 FUNCTION_BEGIN( context_restore)94 FUNCTION_BEGIN(__longjmp) 95 95 lw $s0, CONTEXT_OFFSET_S0($a0) 96 96 lw $s1, CONTEXT_OFFSET_S1($a0) … … 147 147 move $t9, $ra 148 148 149 # context_restore returns 0149 # __longjmp returns second argument 150 150 j $ra 151 xor $v0, $v0152 FUNCTION_END( context_restore)151 move $v0, $a1 152 FUNCTION_END(__longjmp) -
uspace/lib/c/arch/ppc32/src/fibril.S
rf3d47c97 ra35a3d8 33 33 #include <libarch/fibril_context.h> 34 34 35 FUNCTION_BEGIN( context_save)35 FUNCTION_BEGIN(__setjmp) 36 36 stw sp, CONTEXT_OFFSET_SP(r3) 37 37 stw r2, CONTEXT_OFFSET_TLS(r3) … … 62 62 stw r4, CONTEXT_OFFSET_CR(r3) 63 63 64 # context_save returns 165 li r3, 164 # __setjmp returns 0 65 li r3, 0 66 66 blr 67 FUNCTION_END( context_save)67 FUNCTION_END(__setjmp) 68 68 69 FUNCTION_BEGIN( context_restore)69 FUNCTION_BEGIN(__longjmp) 70 70 lwz sp, CONTEXT_OFFSET_SP(r3) 71 71 lwz r2, CONTEXT_OFFSET_TLS(r3) … … 90 90 lwz r31, CONTEXT_OFFSET_R31(r3) 91 91 92 lwz r 4, CONTEXT_OFFSET_CR(r3)93 mtcr r 492 lwz r5, CONTEXT_OFFSET_CR(r3) 93 mtcr r5 94 94 95 lwz r 4, CONTEXT_OFFSET_PC(r3)96 mtlr r 495 lwz r5, CONTEXT_OFFSET_PC(r3) 96 mtlr r5 97 97 98 # context_restore returns 099 li r3, 098 # __longjmp returns second argument 99 mr r3, r4 100 100 blr 101 FUNCTION_END( context_restore)101 FUNCTION_END(__longjmp) -
uspace/lib/c/arch/riscv64/src/fibril.c
rf3d47c97 ra35a3d8 33 33 #include <stdbool.h> 34 34 35 int context_save(context_t *ctx)35 int __setjmp(context_t *ctx) 36 36 { 37 return 1;37 return 0; 38 38 } 39 39 40 void context_restore(context_t *ctx)40 void __longjmp(context_t *ctx, int ret) 41 41 { 42 42 while (true); -
uspace/lib/c/arch/sparc64/src/fibril.S
rf3d47c97 ra35a3d8 32 32 .text 33 33 34 FUNCTION_BEGIN( context_save)34 FUNCTION_BEGIN(__setjmp) 35 35 # 36 36 # We rely on the kernel to flush our active register windows to memory … … 57 57 stx %g7, [%o0 + CONTEXT_OFFSET_TP] 58 58 retl 59 mov 1, %o0 ! context_save_arch returns 160 FUNCTION_END( context_save)59 mov 0, %o0 ! __setjmp returns 0 60 FUNCTION_END(__setjmp) 61 61 62 FUNCTION_BEGIN( context_restore)62 FUNCTION_BEGIN(__longjmp) 63 63 # 64 64 # Flush all active windows. … … 89 89 ldx [%o0 + CONTEXT_OFFSET_TP], %g7 90 90 retl 91 xor %o0, %o0, %o0 ! context_restore_arch returns 092 FUNCTION_END( context_restore)91 mov %o1, %o0 ! __longjmp returns second argument 92 FUNCTION_END(__longjmp)
Note:
See TracChangeset
for help on using the changeset viewer.