Changeset 3fcea34 in mainline for uspace/lib/c/arch
- Timestamp:
- 2024-09-20T12:16:28Z (13 months ago)
- Branches:
- master
- Children:
- d3109ff
- Parents:
- 2cf8f994
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2024-09-20 11:42:13)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2024-09-20 12:16:28)
- Location:
- uspace/lib/c/arch
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/arch/abs32le/include/libarch/thread.h
r2cf8f994 r3fcea34 36 36 #define _LIBC_abs32le_THREAD_H_ 37 37 38 #include <align.h> 39 40 static inline uintptr_t arch_thread_prepare(void *stack, size_t stack_size, 41 void (*main)(void *), void *arg) 42 { 43 uintptr_t *sp = (uintptr_t *) ALIGN_DOWN((uintptr_t) stack + stack_size, 16); 44 45 sp[-1] = (uintptr_t) arg; 46 sp[-2] = (uintptr_t) main; 47 48 return (uintptr_t) sp; 49 } 50 38 51 #endif 39 52 -
uspace/lib/c/arch/abs32le/src/thread_entry.c
r2cf8f994 r3fcea34 30 30 */ 31 31 32 #include <stdbool.h> 32 33 #include <stddef.h> 33 34 #include "../../../generic/private/thread.h" … … 35 36 void __thread_entry(void) 36 37 { 37 __thread_main(NULL); 38 while (true) 39 ; 38 40 } 39 41 -
uspace/lib/c/arch/amd64/include/libarch/thread.h
r2cf8f994 r3fcea34 36 36 #define _LIBC_amd64_THREAD_H_ 37 37 38 #include <align.h> 39 #include <stddef.h> 40 #include <stdint.h> 41 42 static inline uintptr_t arch_thread_prepare(void *stack, size_t stack_size, 43 void (*main)(void *), void *arg) 44 { 45 uintptr_t *sp = (uintptr_t *) ALIGN_DOWN((uintptr_t) stack + stack_size, 16); 46 47 *--sp = (uintptr_t) arg; 48 *--sp = (uintptr_t) main; 49 50 return (uintptr_t) sp; 51 } 52 38 53 #endif 39 54 -
uspace/lib/c/arch/amd64/src/thread_entry.S
r2cf8f994 r3fcea34 35 35 # 36 36 SYMBOL_BEGIN(__thread_entry) 37 # Pop libc thread entry function and argument 38 popq %rax 39 popq %rdi 40 37 41 # 38 42 # Create the first stack frame. … … 42 46 movq %rsp, %rbp 43 47 44 # 45 # RAX contains address of uarg 46 # 47 movq %rax, %rdi 48 call FUNCTION_REF(__thread_main) 48 call *%rax 49 49 SYMBOL_END(__thread_entry) -
uspace/lib/c/arch/arm32/include/libarch/thread.h
r2cf8f994 r3fcea34 37 37 #define _LIBC_arm32_THREAD_H_ 38 38 39 #include <align.h> 40 41 static inline uintptr_t arch_thread_prepare(void *stack, size_t stack_size, 42 void (*main)(void *), void *arg) 43 { 44 uintptr_t *sp = (uintptr_t *) ALIGN_DOWN((uintptr_t) stack + stack_size, 16); 45 46 *--sp = (uintptr_t) main; 47 *--sp = (uintptr_t) arg; 48 49 return (uintptr_t) sp; 50 } 51 39 52 #endif 40 53 -
uspace/lib/c/arch/arm32/src/thread_entry.S
r2cf8f994 r3fcea34 35 35 # 36 36 SYMBOL(__thread_entry) 37 # Pop libc entry function and its argument. 38 pop { r0, r4 } 39 37 40 # 38 41 # Create the first stack frame. … … 43 46 sub fp, ip, #4 44 47 45 b __thread_main48 bx r4 -
uspace/lib/c/arch/arm64/include/libarch/thread.h
r2cf8f994 r3fcea34 36 36 #define _LIBC_arm64_THREAD_H_ 37 37 38 #include <align.h> 39 40 static inline uintptr_t arch_thread_prepare(void *stack, size_t stack_size, 41 void (*main)(void *), void *arg) 42 { 43 uintptr_t *sp = (uintptr_t *) ALIGN_DOWN((uintptr_t) stack + stack_size, 16); 44 45 *--sp = (uintptr_t) arg; 46 *--sp = (uintptr_t) main; 47 48 return (uintptr_t) sp; 49 } 50 38 51 #endif 39 52 -
uspace/lib/c/arch/arm64/src/thread_entry.S
r2cf8f994 r3fcea34 35 35 # 36 36 SYMBOL(__thread_entry) 37 # 37 # Load entry function and argument from stack. 38 ldp x1, x0, [sp], #16 39 38 40 # Create the first stack frame. 39 #40 41 mov x29, #0 41 42 stp x29, x30, [sp, #-16]! 42 43 mov x29, sp 43 44 44 b __thread_main45 br x1 -
uspace/lib/c/arch/ia32/include/libarch/thread.h
r2cf8f994 r3fcea34 36 36 #define _LIBC_ia32_THREAD_H_ 37 37 38 #include <align.h> 39 #include <stddef.h> 40 #include <stdint.h> 41 42 static inline uintptr_t arch_thread_prepare(void *stack, size_t stack_size, 43 void (*main)(void *), void *arg) 44 { 45 uintptr_t *sp = (uintptr_t *) ALIGN_DOWN((uintptr_t) stack + stack_size, 16); 46 47 *--sp = (uintptr_t) arg; 48 *--sp = (uintptr_t) main; 49 50 return (uintptr_t) sp; 51 } 52 38 53 #endif 39 54 -
uspace/lib/c/arch/ia32/src/syscall.S
r2cf8f994 r3fcea34 77 77 pushl %ebp 78 78 mov %esp, %ebp 79 lea ra, %edi80 79 movl 20(%esp), %edx # First argument. 81 80 movl 24(%esp), %ecx # Second argument. … … 83 82 movl 32(%esp), %esi # Fourth argument. 84 83 movl 44(%esp), %eax # Syscall number. 85 sysenter 86 ra: 84 call 1f 87 85 movw %cs, %cx 88 86 addw $8, %cx … … 95 93 popl %ebx 96 94 ret 95 96 /* Trampoline for entering kernel */ 97 1: 98 pop %edi 99 sysenter 97 100 FUNCTION_END(__syscall_fast) -
uspace/lib/c/arch/ia32/src/thread_entry.S
r2cf8f994 r3fcea34 41 41 # Do not set %gs, it contains descriptor that can see TLS 42 42 43 # Pop libc thread main function. 44 popl %eax 45 # Pop argument. 46 popl %ebx 47 43 48 # 44 49 # Create the first stack frame. … … 48 53 mov %esp, %ebp 49 54 50 # 51 # EAX contains address of uarg. 52 # 53 pushl %eax 54 call __thread_main 55 pushl %ebx 56 call *%eax 55 57 56 58 # -
uspace/lib/c/arch/ia64/include/libarch/thread.h
r2cf8f994 r3fcea34 36 36 #define _LIBC_ia64_THREAD_H_ 37 37 38 #include <align.h> 39 40 static inline uintptr_t arch_thread_prepare(void *stack, size_t stack_size, 41 void (*main)(void *), void *arg) 42 { 43 uintptr_t *sp = (uintptr_t *) (ALIGN_DOWN((uintptr_t) stack + stack_size / 2, 16)); 44 45 /* Store data under stack pointer */ 46 sp[-1] = (uintptr_t) arg; 47 sp[-2] = (uintptr_t) main; 48 49 return (uintptr_t) sp; 50 } 51 38 52 #endif 39 53 -
uspace/lib/c/arch/ia64/src/thread_entry.S
r2cf8f994 r3fcea34 37 37 alloc loc0 = ar.pfs, 0, 1, 1, 0 38 38 39 #ifndef CONFIG_RTLD 40 # XXX This does not work in a shared library 41 movl gp = __gp 42 #endif 39 add r8 = -8, sp ;; 40 # Entry function argument 41 ld8 out0 = [r8], -8 ;; 43 42 44 # 45 # r8 contains address of uarg structure. 46 # 43 # Entry function descriptor 44 ld8 r8 = [r8] ;; 45 # Entry function address 46 ld8 r9 = [r8], 8 ;; 47 # Entry function global pointer 48 ld8 gp = [r8] ;; 47 49 48 mov out0 = r8;;49 # XXX br.call.sptk.many b0 = FUNCTION_REF(__thread_main) 50 br.call.sptk.many b0 = __thread_main50 mov b1 = r9 ;; 51 52 br.call.sptk.many b0 = b1 ;; 51 53 52 54 # -
uspace/lib/c/arch/mips32/include/libarch/thread.h
r2cf8f994 r3fcea34 37 37 #define _LIBC_mips32_THREAD_H_ 38 38 39 #include <align.h> 40 41 static inline uintptr_t arch_thread_prepare(void *stack, size_t stack_size, 42 void (*main)(void *), void *arg) 43 { 44 uintptr_t *sp = (uintptr_t *) ALIGN_DOWN((uintptr_t) stack + stack_size, 16); 45 46 sp[-1] = (uintptr_t) arg; 47 sp[-2] = (uintptr_t) main; 48 49 return (uintptr_t) sp; 50 } 51 39 52 #endif 40 53 -
uspace/lib/c/arch/mips32/src/thread_entry.S
r2cf8f994 r3fcea34 40 40 # 41 41 SYMBOL(__thread_entry) 42 .ent __thread_entry 43 .frame $sp, ABI_STACK_FRAME, $ra 44 .cpload $t9 42 # All registers should be zero, including $fp and $ra. 43 # Instead of setting up a stack frame here, we leave it for __thread_main. 45 44 46 # 47 # v0 contains address of uarg.48 # 49 add $a0, $v0, 045 # Function argument. 46 lw $a0, -4($sp) 47 # Function pointer. 48 lw $t0, -8($sp) 50 49 51 # Allocate the stack frame. 52 addiu $sp, -ABI_STACK_FRAME 53 54 # Allow PIC code 55 .cprestore 16 56 57 jal __thread_main 50 j $t0 58 51 nop 59 60 #61 # Not reached.62 #63 addiu $sp, ABI_STACK_FRAME64 .end __thread_entry -
uspace/lib/c/arch/ppc32/include/libarch/thread.h
r2cf8f994 r3fcea34 36 36 #define _LIBC_ppc32_THREAD_H_ 37 37 38 #include <align.h> 39 40 static inline uintptr_t arch_thread_prepare(void *stack, size_t stack_size, 41 void (*main)(void *), void *arg) 42 { 43 uintptr_t *sp = (uintptr_t *) ALIGN_DOWN((uintptr_t) stack + stack_size - sizeof(void *), 16); 44 45 sp[0] = 0; 46 sp[-1] = (uintptr_t) arg; 47 sp[-2] = (uintptr_t) main; 48 49 return (uintptr_t) sp; 50 } 51 38 52 #endif 39 53 -
uspace/lib/c/arch/ppc32/src/thread_entry.S
r2cf8f994 r3fcea34 35 35 # 36 36 SYMBOL(__thread_entry) 37 # 38 # Create the first stack frame. 39 # 40 li %r4, 0 41 stw %r4, 0(%r1) 42 stwu %r1, -16(%r1) 37 # Load function and argument. 38 lwz %r3, -4(%r1) 39 lwz %r4, -8(%r1) 43 40 44 b __thread_main 41 # Clear LR 42 li %r0, 0 43 mtlr %r0 45 44 45 mtctr %r4 46 bctr -
uspace/lib/c/arch/riscv64/include/libarch/thread.h
r2cf8f994 r3fcea34 36 36 #define _LIBC_riscv64_THREAD_H_ 37 37 38 #include <align.h> 39 40 static inline uintptr_t arch_thread_prepare(void *stack, size_t stack_size, 41 void (*main)(void *), void *arg) 42 { 43 uintptr_t *sp = (uintptr_t *) ALIGN_DOWN((uintptr_t) stack + stack_size, 16); 44 45 sp[-1] = (uintptr_t) arg; 46 sp[-2] = (uintptr_t) main; 47 48 return (uintptr_t) sp; 49 } 50 38 51 #endif 39 52 -
uspace/lib/c/arch/riscv64/src/thread_entry.c
r2cf8f994 r3fcea34 35 35 void __thread_entry(void) 36 36 { 37 __thread_main((void *) 0); 37 // TODO 38 while (true) 39 ; 38 40 } 39 41 -
uspace/lib/c/arch/sparc64/include/libarch/thread.h
r2cf8f994 r3fcea34 35 35 #define _LIBC_sparc64_THREAD_H_ 36 36 37 #include <assert.h> 38 #include <align.h> 39 #include <libarch/stack.h> 40 41 static inline uintptr_t arch_thread_prepare(void *stack, size_t stack_size, 42 void (*main)(void *), void *arg) 43 { 44 /* We must leave space above the stack pointer for initial register spill area. */ 45 uintptr_t *sp = (uintptr_t *) ALIGN_DOWN((uintptr_t) stack + stack_size - STACK_WINDOW_SAVE_AREA_SIZE - STACK_ARG_SAVE_AREA_SIZE, 16); 46 47 sp[-1] = (uintptr_t) arg; 48 sp[-2] = (uintptr_t) main; 49 50 return ((uintptr_t) sp) - STACK_BIAS; 51 } 52 37 53 #endif 38 54 -
uspace/lib/c/arch/sparc64/src/thread_entry.S
r2cf8f994 r3fcea34 35 35 # 36 36 SYMBOL(__thread_entry) 37 add %sp, 0x7ff, %g1 38 37 39 # 38 40 # Create the first stack frame. … … 43 45 44 46 # 45 # Propagate the input arguments to the new window.47 # Load libc entry point address and argument from stack 46 48 # 49 ldn [%g1 - 8], %o0 50 ldn [%g1 - 16], %g1 47 51 48 call __thread_main ! %o0 contains address of uarg 49 mov %i0, %o0 52 jmpl %g1, %r0 53 # Wipe link register 54 xor %o7, %o7, %o7 50 55 51 56 ! not reached
Note:
See TracChangeset
for help on using the changeset viewer.