this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix libsyscall assembly extensions and update `defs` symlinks

+2126 -8
src/duct/include/commpage.h

This is a binary file and will not be displayed.

+1 -1
src/kernel/emulation/linux/signal/exc.defs
··· 1 - ../../../../../platform-include/mach/exc.defs 1 + ../../../../../Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/exc.defs
+1 -1
src/kernel/emulation/linux/signal/mach_exc.defs
··· 1 - ../../../../../platform-include/mach/mach_exc.defs 1 + ../../../../../Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/mach_exc.defs
+18
src/kernel/libsyscall/bsdsyscalls/___coalition_ledger.S
··· 1 + #define __SYSCALL_32BIT_ARG_BYTES 16 2 + #include "SYS.h" 3 + 4 + #ifndef SYS_coalition_ledger 5 + #error "SYS_coalition_ledger not defined. The header files libsyscall is building against do not match syscalls.master." 6 + #endif 7 + 8 + #if defined(__arm64__) 9 + MI_ENTRY_POINT(___coalition_ledger) 10 + SYSCALL_NONAME(coalition_ledger, 4, cerror_nocancel) 11 + ret 12 + #else 13 + #if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__arm__) || defined(__arm64__) 14 + __SYSCALL2(___coalition_ledger, coalition_ledger, 4, cerror_nocancel) 15 + #endif 16 + 17 + #endif 18 +
+1 -1
src/kernel/libsyscall/bsdsyscalls/___fork.S
··· 54 54 movl $ SYS_fork,%eax; // code for fork -> eax 55 55 #ifdef DARLING 56 56 call __darling_bsd_syscall 57 - cmpq $0, %eax 57 + cmpl $0, %eax 58 58 jnb L1 59 59 #else 60 60 UNIX_SYSCALL_TRAP // do the system call
+1 -1
src/kernel/libsyscall/bsdsyscalls/___fork.s
··· 54 54 movl $ SYS_fork,%eax; // code for fork -> eax 55 55 #ifdef DARLING 56 56 call __darling_bsd_syscall 57 - cmpq $0, %eax 57 + cmpl $0, %eax 58 58 jnb L1 59 59 #else 60 60 UNIX_SYSCALL_TRAP // do the system call
+18
src/kernel/libsyscall/bsdsyscalls/___log_data.S
··· 1 + #define __SYSCALL_32BIT_ARG_BYTES 16 2 + #include "SYS.h" 3 + 4 + #ifndef SYS_log_data 5 + #error "SYS_log_data not defined. The header files libsyscall is building against do not match syscalls.master." 6 + #endif 7 + 8 + #if defined(__arm64__) 9 + MI_ENTRY_POINT(___log_data) 10 + SYSCALL_NONAME(log_data, 4, cerror_nocancel) 11 + ret 12 + #else 13 + #if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__arm__) || defined(__arm64__) 14 + __SYSCALL2(___log_data, log_data, 4, cerror_nocancel) 15 + #endif 16 + 17 + #endif 18 +
+18
src/kernel/libsyscall/bsdsyscalls/___memorystatus_available_memory.S
··· 1 + #define __SYSCALL_32BIT_ARG_BYTES 0 2 + #include "SYS.h" 3 + 4 + #ifndef SYS_memorystatus_available_memory 5 + #error "SYS_memorystatus_available_memory not defined. The header files libsyscall is building against do not match syscalls.master." 6 + #endif 7 + 8 + #if defined(__arm64__) 9 + MI_ENTRY_POINT(___memorystatus_available_memory) 10 + SYSCALL_NONAME(memorystatus_available_memory, 0, cerror_nocancel) 11 + ret 12 + #else 13 + #if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__arm__) || defined(__arm64__) 14 + __SYSCALL2(___memorystatus_available_memory, memorystatus_available_memory, 0, cerror_nocancel) 15 + #endif 16 + 17 + #endif 18 +
+1 -1
src/kernel/libsyscall/bsdsyscalls/___vfork.S
··· 68 68 #ifdef DARLING 69 69 movl $ SYS_vfork, %eax 70 70 call __darling_bsd_syscall 71 - cmpq $0, %eax 71 + cmpl $0, %eax 72 72 jnb L1 73 73 #else 74 74 movl $(SYS_vfork), %eax // code for vfork -> eax
+1 -1
src/kernel/libsyscall/bsdsyscalls/___vfork.s
··· 68 68 #ifdef DARLING 69 69 movl $ SYS_vfork, %eax 70 70 call __darling_bsd_syscall 71 - cmpq $0, %eax 71 + cmpl $0, %eax 72 72 jnb L1 73 73 #else 74 74 movl $(SYS_vfork), %eax // code for vfork -> eax
+19
src/kernel/libsyscall/bsdsyscalls/_fsgetpath_ext.S
··· 1 + #define __SYSCALL_32BIT_ARG_BYTES 24 2 + #include "SYS.h" 3 + 4 + #ifndef SYS_fsgetpath_ext 5 + #error "SYS_fsgetpath_ext not defined. The header files libsyscall is building against do not match syscalls.master." 6 + #endif 7 + 8 + #if defined(__arm64__) 9 + MI_ENTRY_POINT(_fsgetpath_ext) 10 + ZERO_EXTEND(1) 11 + SYSCALL_NONAME(fsgetpath_ext, 5, cerror_nocancel) 12 + ret 13 + #else 14 + #if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__arm__) || defined(__arm64__) 15 + __SYSCALL2(_fsgetpath_ext, fsgetpath_ext, 5, cerror_nocancel) 16 + #endif 17 + 18 + #endif 19 +
+177
src/kernel/libsyscall/custom/__fork.S
··· 1 + /* 2 + * Copyright (c) 1999-2010 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. 29 + * 30 + * File: libc/ppc/sys/fork.s 31 + * 32 + * HISTORY 33 + * 18-Nov-92 Ben Fathi (benf@next.com) 34 + * Created from M88K sources 35 + * 36 + * 11-Jan-92 Peter King (king@next.com) 37 + * Created from M68K sources 38 + */ 39 + 40 + /* 41 + * All of the asm stubs in this file have been adjusted so the pre/post 42 + * fork handlers and dyld fixup are done in C inside Libc. As such, Libc 43 + * expects the __fork asm to fix up the return code to be -1, 0 or pid 44 + * and errno if needed. 45 + */ 46 + 47 + #include "SYS.h" 48 + 49 + #if defined(__i386__) 50 + 51 + LEAF(___fork, 0) 52 + subl $28, %esp // Align the stack, with 16 bytes of extra padding that we'll need 53 + 54 + movl $ SYS_fork,%eax; // code for fork -> eax 55 + #ifdef DARLING 56 + call __darling_bsd_syscall 57 + cmpl $0, %eax 58 + jnb L1 59 + #else 60 + UNIX_SYSCALL_TRAP // do the system call 61 + jnc L1 // jump if CF==0 62 + #endif 63 + 64 + CALL_EXTERN(tramp_cerror) 65 + movl $-1,%eax 66 + addl $28, %esp // restore the stack 67 + ret 68 + 69 + L1: 70 + orl %edx,%edx // CF=OF=0, ZF set if zero result 71 + jz L2 // parent, since r1 == 0 in parent, 1 in child 72 + 73 + //child here... 74 + xorl %eax,%eax // zero eax 75 + REG_TO_EXTERN(%eax, __current_pid); 76 + L2: 77 + addl $28, %esp // restore the stack 78 + // parent ends up here skipping child portion 79 + ret 80 + 81 + #elif defined(__x86_64__) 82 + 83 + LEAF(___fork, 0) 84 + subq $24, %rsp // Align the stack, plus room for local storage 85 + 86 + #ifdef DARLING 87 + movl $ SYS_fork, %eax 88 + call __darling_bsd_syscall 89 + cmpq $0, %rax 90 + jnb L1 91 + #else 92 + movl $ SYSCALL_CONSTRUCT_UNIX(SYS_fork),%eax; // code for fork -> rax 93 + UNIX_SYSCALL_TRAP // do the system call 94 + jnc L1 // jump if CF==0 95 + #endif 96 + 97 + movq %rax, %rdi 98 + CALL_EXTERN(_cerror) 99 + movq $-1, %rax 100 + addq $24, %rsp // restore the stack 101 + ret 102 + 103 + L1: 104 + #ifdef DARLING 105 + testl %eax, %eax 106 + jnz L2 107 + #else 108 + orl %edx,%edx // CF=OF=0, ZF set if zero result 109 + jz L2 // parent, since r1 == 0 in parent, 1 in child 110 + #endif 111 + 112 + //child here... 113 + xorq %rax, %rax 114 + PICIFY(__current_pid) 115 + movl %eax,(%r11) 116 + L2: 117 + // parent ends up here skipping child portion 118 + addq $24, %rsp // restore the stack 119 + ret 120 + 121 + #elif defined(__arm__) 122 + 123 + MI_ENTRY_POINT(___fork) 124 + stmfd sp!, {r4, r7, lr} 125 + add r7, sp, #4 126 + 127 + mov r1, #1 // prime results 128 + mov r12, #SYS_fork 129 + swi #SWI_SYSCALL // make the syscall 130 + bcs Lbotch // error? 131 + 132 + cmp r1, #0 // parent (r1=0) or child(r1=1) 133 + beq Lparent 134 + 135 + //child here... 136 + MI_GET_ADDRESS(r3, __current_pid) 137 + mov r0, #0 138 + str r0, [r3] // clear cached pid in child 139 + ldmfd sp!, {r4, r7, pc} 140 + 141 + Lbotch: 142 + MI_CALL_EXTERNAL(_cerror) // jump here on error 143 + mov r0,#-1 // set the error 144 + // fall thru 145 + Lparent: 146 + ldmfd sp!, {r4, r7, pc} // pop and return 147 + 148 + #elif defined(__arm64__) 149 + 150 + #include <mach/arm64/asm.h> 151 + 152 + MI_ENTRY_POINT(___fork) 153 + ARM64_STACK_PROLOG 154 + PUSH_FRAME 155 + // ARM moves a 1 in to r1 here, but I can't see why. 156 + mov x16, #SYS_fork // Syscall code 157 + svc #SWI_SYSCALL // Trap to kernel 158 + b.cs Lbotch // Carry bit indicates failure 159 + cbz x1, Lparent // x1 == 0 indicates that we are the parent 160 + 161 + // Child 162 + MI_GET_ADDRESS(x9, __current_pid) // Get address of cached "current pid" 163 + mov w0, #0 164 + str w0, [x9] // Clear cached current pid 165 + POP_FRAME // And done 166 + ARM64_STACK_EPILOG 167 + 168 + Lbotch: 169 + MI_CALL_EXTERNAL(_cerror) // Handle error 170 + mov w0, #-1 // Return value is -1 171 + Lparent: 172 + POP_FRAME // Return 173 + ARM64_STACK_EPILOG 174 + 175 + #else 176 + #error Unsupported architecture 177 + #endif
+1 -1
src/kernel/libsyscall/custom/__fork.s
··· 54 54 movl $ SYS_fork,%eax; // code for fork -> eax 55 55 #ifdef DARLING 56 56 call __darling_bsd_syscall 57 - cmpq $0, %eax 57 + cmpl $0, %eax 58 58 jnb L1 59 59 #else 60 60 UNIX_SYSCALL_TRAP // do the system call
+173
src/kernel/libsyscall/custom/__getpid.S
··· 1 + /* 2 + * Copyright (c) 1999-2007 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + 29 + #include "SYS.h" 30 + 31 + #if defined(__i386__) 32 + 33 + .data 34 + .private_extern __current_pid 35 + L__current_pid_addr: 36 + __current_pid: 37 + .long 0 38 + 39 + #if defined(__DYNAMIC__) 40 + #define GET_CURRENT_PID \ 41 + call 0f ; \ 42 + 0: ; \ 43 + popl %ecx ; \ 44 + leal L__current_pid_addr-0b(%ecx), %ecx 45 + 46 + #define __current_pid (%ecx) 47 + 48 + #else 49 + #define GET_CURRENT_PID 50 + #endif 51 + 52 + /* 53 + * If __current_pid is > 0, return it, else make syscall. 54 + * If __current_pid is 0, cache result of syscall. 55 + */ 56 + TEXT 57 + LEAF(___getpid, 0) 58 + GET_CURRENT_PID 59 + movl __current_pid, %eax 60 + testl %eax, %eax 61 + jle 1f 62 + ret 63 + 1: 64 + UNIX_SYSCALL_NONAME(getpid, 0, cerror_nocancel) 65 + movl %eax, %edx 66 + xorl %eax, %eax 67 + GET_CURRENT_PID 68 + lock 69 + cmpxchgl %edx, __current_pid 70 + movl %edx, %eax 71 + ret 72 + 73 + #elif defined(__x86_64__) 74 + 75 + .data 76 + .private_extern __current_pid 77 + __current_pid: 78 + .long 0 79 + 80 + /* 81 + * If __current_pid is > 0, return it, else make syscall. 82 + * If __current_pid is 0, cache result of syscall. 83 + */ 84 + TEXT 85 + LEAF(___getpid, 0) 86 + movl __current_pid(%rip), %eax 87 + testl %eax, %eax 88 + jle 1f 89 + ret 90 + 1: 91 + UNIX_SYSCALL_NONAME(getpid, 0, cerror_nocancel) 92 + movl %eax, %edx 93 + xorl %eax, %eax 94 + leaq __current_pid(%rip), %rcx 95 + lock 96 + cmpxchgl %edx, (%rcx) 97 + movl %edx, %eax 98 + ret 99 + 100 + #elif defined(__arm__) 101 + 102 + #include <arm/arch.h> 103 + 104 + .data 105 + .globl __current_pid 106 + .align 2 107 + __current_pid: 108 + /* Cached pid. Possible values: 109 + * 0: no value cached 110 + * > 0: cached PID of current process 111 + * < 0: negative number of vforks in progress 112 + * INT_MIN: for pre-ARMv6, "looking" value (0x80000000) 113 + */ 114 + .long 0 115 + 116 + MI_ENTRY_POINT(___getpid) 117 + ldr r3, L__current_pid 118 + L1: add r3, pc, r3 // r3 = &__current_pid 119 + ldr r0, [r3] // get the cached pid 120 + cmp r0, #0 121 + bxgt lr // if positive, return it 122 + 123 + SYSCALL_NONAME(getpid, 0, cerror_nocancel) 124 + 125 + #ifdef _ARM_ARCH_6 126 + ldrex r2, [r3] // see if we can cache it 127 + cmp r2, #0 // we can't if there are any... 128 + bxlt lr // ...vforks in progress 129 + strex r2, r0, [r3] // ignore conflicts 130 + #else 131 + mov r1, #0x80000000 // load "looking" value 132 + swp r2, r1, [r3] // look at the value, lock others out 133 + cmp r2, r1 // anyone else trying to look? 134 + bxeq lr // yes, so return immediately/ 135 + cmp r2, #0 // see if we can cache it 136 + streq r0, [r3] // if zero, we can 137 + strne r2, [r3] // otherwise restore previous value 138 + #endif 139 + 140 + bx lr 141 + 142 + L__current_pid: 143 + .long __current_pid - (L1+8) 144 + 145 + #elif defined(__arm64__) 146 + .data 147 + .globl __current_pid 148 + .align 2 149 + __current_pid: 150 + /* cached pid. possible values: 151 + * 0: no value cached 152 + * > 0: cached pid of current process 153 + * < 0: negative number of vforks in progress 154 + * int_min: for pre-armv6, "looking" value (0x80000000) 155 + */ 156 + .long 0 157 + 158 + MI_ENTRY_POINT(___getpid) 159 + MI_GET_ADDRESS(x9, __current_pid) // Get address of cached value 160 + ldr w0, [x9] // Load it 161 + cmp w0, #0 // See if there's a cached value 162 + b.le L_notcached // If not, make syscall 163 + ret // Else, we're done 164 + L_notcached: 165 + SYSCALL_NONAME(getpid, 0, cerror_nocancel) 166 + ldxr w10, [x9] // Exclusive load 167 + cbnz w10, L_done // Unless unset, don't even try 168 + stxr wzr, w0, [x9] // Try to store, but don't care if we fail (someone will win, or not) 169 + L_done: 170 + ret // Done 171 + #else 172 + #error Unsupported architecture 173 + #endif
+120
src/kernel/libsyscall/custom/__gettimeofday.S
··· 1 + /* 2 + * Copyright (c) 1999-2016 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + 29 + #include "SYS.h" 30 + 31 + /* 32 + * A third argument, of type uint64_t*, was added to the gettimeofday syscall 33 + * for use cases that also want to know the mach_absolute_time that matches the 34 + * time value returned. 35 + * 36 + * __gettimeofday takes the traditional two arguments. It will zero out the 37 + * third argument argument before entering the kernel, behaving like the old 38 + * call. 39 + * 40 + * __gettimeofday_with_mach will pass it through and supporting kernels will 41 + * copy-out the mach_absolute_time. Old kernels will leave the pointed to 42 + * value alone. 43 + */ 44 + 45 + .private_extern ___gettimeofday_with_mach 46 + 47 + #if defined(__i386__) 48 + 49 + LABEL(___gettimeofday) 50 + pushl $0 51 + pushl 12(%esp) 52 + pushl 12(%esp) 53 + calll ___gettimeofday_with_mach 54 + addl $12, %esp 55 + ret 56 + 57 + LABEL(___gettimeofday_with_mach) 58 + UNIX_SYSCALL_INT_NONAME(gettimeofday,0) 59 + /* 60 + * <rdar://problem/26410029> 61 + * If eax is 0, we're on a new kernel and timeval was written by the kernel. 62 + * Otherwise, eax:edx contains the timeval and we marshal into timeval. 63 + */ 64 + cmp $0, %eax 65 + je 2f 66 + mov 4(%esp),%ecx 67 + mov %eax,(%ecx) 68 + mov %edx,4(%ecx) 69 + xor %eax,%eax 70 + 2: 71 + ret 72 + 73 + #elif defined(__x86_64__) 74 + 75 + __SYSCALL(___gettimeofday_with_mach, gettimeofday, 3) 76 + 77 + LABEL(___gettimeofday) 78 + movq $0x0, %rdx // zero out third argument 79 + 80 + UNIX_SYSCALL_NONAME(gettimeofday,0,cerror_nocancel) 81 + /* 82 + * <rdar://problem/26410029> 83 + * If rax is 0, we're on a new kernel and timeval was written by the kernel. 84 + * Otherwise, rax:rdx contains the timeval and we marshal into timeval. 85 + */ 86 + cmp $0, %rax 87 + je 2f 88 + movq %rax, (%rdi) 89 + movl %edx, 8(%rdi) 90 + xorl %eax, %eax 91 + 2: 92 + ret 93 + 94 + #elif defined(__arm__) 95 + 96 + __SYSCALL2(___gettimeofday_with_mach, gettimeofday, 3, cerror_nocancel) 97 + 98 + .text 99 + .align 2 100 + .globl ___gettimeofday 101 + ___gettimeofday: 102 + mov r2, #0x0 103 + SYSCALL_NONAME(gettimeofday, 3, cerror_nocancel) 104 + bx lr 105 + 106 + #elif defined(__arm64__) 107 + 108 + __SYSCALL2(___gettimeofday_with_mach, gettimeofday, 3, cerror_nocancel) 109 + 110 + .text 111 + .align 2 112 + .globl ___gettimeofday 113 + ___gettimeofday: 114 + movz x2, #0x0 115 + SYSCALL_NONAME(gettimeofday, 3, cerror_nocancel) 116 + ret 117 + 118 + #else 119 + #error Unsupported architecture 120 + #endif
+49
src/kernel/libsyscall/custom/__kdebug_trace_string.S
··· 1 + /* 2 + * Copyright (c) 1999-2007 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + 29 + #include "SYS.h" 30 + 31 + #if defined(__x86_64__) 32 + 33 + __SYSCALL(___kdebug_trace_string, kdebug_trace_string, 3) 34 + 35 + #elif defined(__i386__) 36 + 37 + __SYSCALL_INT(___kdebug_trace_string, kdebug_trace_string, 3) 38 + 39 + #elif defined(__arm__) 40 + 41 + __SYSCALL(___kdebug_trace_string, kdebug_trace_string, 4) 42 + 43 + #elif defined(__arm64__) 44 + 45 + __SYSCALL(___kdebug_trace_string, kdebug_trace_string, 3) 46 + 47 + #else 48 + #error Unsupported architecture 49 + #endif
+49
src/kernel/libsyscall/custom/__lseek.S
··· 1 + /* 2 + * Copyright (c) 1999-2007 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + 29 + #include "SYS.h" 30 + 31 + #if defined(__x86_64__) 32 + 33 + __SYSCALL(___lseek, lseek, 3) 34 + 35 + #elif defined(__i386__) 36 + 37 + __SYSCALL_INT(___lseek, lseek, 3) 38 + 39 + #elif defined(__arm__) 40 + 41 + __SYSCALL(___lseek, lseek, 4) 42 + 43 + #elif defined(__arm64__) 44 + 45 + __SYSCALL(___lseek, lseek, 3) 46 + 47 + #else 48 + #error Unsupported architecture 49 + #endif
+70
src/kernel/libsyscall/custom/__pipe.S
··· 1 + /* 2 + * Copyright (c) 1999-2007 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. */ 29 + 30 + #include "SYS.h" 31 + 32 + #if defined(__i386__) 33 + 34 + PSEUDO_INT(___pipe, pipe, 0) 35 + movl 4(%esp),%ecx 36 + movl %eax,(%ecx) 37 + movl %edx,4(%ecx) 38 + xorl %eax,%eax 39 + ret 40 + 41 + #elif defined(__x86_64__) 42 + 43 + PSEUDO(___pipe, pipe, 0, cerror_nocancel) 44 + movl %eax, (%rdi) 45 + movl %edx, 4(%rdi) 46 + xorl %eax, %eax 47 + ret 48 + 49 + #elif defined(__arm__) 50 + 51 + MI_ENTRY_POINT(___pipe) 52 + mov r3,r0 // save fildes across syscall 53 + SYSCALL_NONAME(pipe, 0, cerror_nocancel) 54 + str r0, [r3, #0] 55 + str r1, [r3, #4] 56 + mov r0,#0 57 + bx lr 58 + 59 + #elif defined(__arm64__) 60 + 61 + MI_ENTRY_POINT(___pipe) 62 + mov x9, x0 // Stash FD array 63 + SYSCALL_NONAME(pipe, 0, cerror_nocancel) 64 + stp w0, w1, [x9] // Save results 65 + mov x0, #0 // Success 66 + ret // Done 67 + 68 + #else 69 + #error Unsupported architecture 70 + #endif
+74
src/kernel/libsyscall/custom/__ptrace.S
··· 1 + /* 2 + * Copyright (c) 1999-2007 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. */ 29 + 30 + #include "SYS.h" 31 + 32 + #if defined(__i386__) 33 + 34 + .globl _errno 35 + 36 + LEAF(___ptrace, 0) 37 + xorl %eax,%eax 38 + REG_TO_EXTERN(%eax,_errno) 39 + UNIX_SYSCALL_NONAME(ptrace, 4, cerror) 40 + ret 41 + 42 + #elif defined(__x86_64__) 43 + 44 + .globl _errno 45 + 46 + LEAF(___ptrace, 0) 47 + xorq %rax,%rax 48 + PICIFY(_errno) 49 + movl %eax,(%r11) 50 + UNIX_SYSCALL_NONAME(ptrace, 4, cerror) 51 + ret 52 + 53 + #elif defined(__arm__) 54 + 55 + MI_ENTRY_POINT(___ptrace) 56 + MI_GET_ADDRESS(ip,_errno) 57 + str r8, [sp, #-4]! 58 + mov r8, #0 59 + str r8, [ip] 60 + ldr r8, [sp], #4 61 + SYSCALL_NONAME(ptrace, 4, cerror) 62 + bx lr 63 + 64 + #elif defined(__arm64__) 65 + 66 + MI_ENTRY_POINT(___ptrace) 67 + MI_GET_ADDRESS(x9,_errno) 68 + str wzr, [x9] 69 + SYSCALL_NONAME(ptrace, 4, cerror) 70 + ret 71 + 72 + #else 73 + #error Unsupported architecture 74 + #endif
+49
src/kernel/libsyscall/custom/__sigaltstack.S
··· 1 + /* 2 + * Copyright (c) 1999-2007 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + 29 + #include "SYS.h" 30 + 31 + #if defined(__x86_64__) 32 + 33 + __SYSCALL(___sigaltstack, sigaltstack, 3) 34 + 35 + #elif defined(__i386__) 36 + 37 + __SYSCALL_INT(___sigaltstack, sigaltstack, 3) 38 + 39 + #elif defined(__arm__) 40 + 41 + __SYSCALL(___sigaltstack, sigaltstack, 3) 42 + 43 + #elif defined(__arm64__) 44 + 45 + __SYSCALL(___sigaltstack, sigaltstack, 3) 46 + 47 + #else 48 + #error Unsupported architecture 49 + #endif
+49
src/kernel/libsyscall/custom/__sigreturn.S
··· 1 + /* 2 + * Copyright (c) 1999-2007 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + 29 + #include "SYS.h" 30 + 31 + #if defined(__x86_64__) 32 + 33 + __SYSCALL(___sigreturn, sigreturn, 3) 34 + 35 + #elif defined(__i386__) 36 + 37 + __SYSCALL_INT(___sigreturn, sigreturn, 3) 38 + 39 + #elif defined(__arm__) 40 + 41 + __SYSCALL(___sigreturn, sigreturn, 3) 42 + 43 + #elif defined(__arm64__) 44 + 45 + __SYSCALL(___sigreturn, sigreturn, 3) 46 + 47 + #else 48 + #error Unsupported architecture 49 + #endif
+73
src/kernel/libsyscall/custom/__syscall.S
··· 1 + /* 2 + * Copyright (c) 1999-2007 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. */ 29 + 30 + #include "SYS.h" 31 + 32 + #if defined(__i386__) 33 + 34 + LEAF(___syscall, 0) 35 + popl %ecx // ret addr 36 + popl %eax // syscall number 37 + pushl %ecx 38 + UNIX_SYSCALL_TRAP 39 + movl (%esp),%edx // add one element to stack so 40 + pushl %ecx // caller "pop" will work 41 + jnb 2f 42 + BRANCH_EXTERN(tramp_cerror) 43 + 2: 44 + END(___syscall) 45 + 46 + #elif defined(__x86_64__) 47 + 48 + // For x86-64, the kernel slides the argument list for us. 49 + // The number of arguments here is variable, but our macros ignore 50 + // that value anyway. 51 + __SYSCALL(___syscall, syscall, 0); 52 + 53 + #elif defined(__arm__) 54 + 55 + __SYSCALL(___syscall, syscall, 7) 56 + 57 + #elif defined(__arm64__) 58 + 59 + /* 60 + * Ignore nominal number of arguments: just pop from stack and let the kernel 61 + * interpret. 62 + */ 63 + #include <mach/arm64/asm.h> 64 + MI_ENTRY_POINT(___syscall) 65 + ldp x1, x2, [sp] 66 + ldp x3, x4, [sp, #16] 67 + ldp x5, x6, [sp, #32] 68 + ldr x7, [sp, #48] 69 + DO_SYSCALL(SYS_syscall, cerror) 70 + ret 71 + #else 72 + #error Unsupported architecture 73 + #endif
+47
src/kernel/libsyscall/custom/__thread_selfid.S
··· 1 + /* 2 + * Copyright (c) 1999-2007 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + 29 + #include "SYS.h" 30 + 31 + #if defined(__x86_64__) 32 + 33 + __SYSCALL(___thread_selfid, thread_selfid, 0) 34 + 35 + #elif defined(__i386__) 36 + 37 + __SYSCALL_INT(___thread_selfid, thread_selfid, 0) 38 + 39 + #elif defined(__arm__) 40 + 41 + __SYSCALL(___thread_selfid, thread_selfid, 0) 42 + 43 + #elif defined(__arm64__) 44 + 45 + __SYSCALL(___thread_selfid, thread_selfid, 0) 46 + 47 + #endif
+47
src/kernel/libsyscall/custom/__thread_selfusage.S
··· 1 + /* 2 + * Copyright (c) 2014 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + 29 + #include "SYS.h" 30 + 31 + #if defined(__x86_64__) 32 + 33 + __SYSCALL(___thread_selfusage, thread_selfusage, 0) 34 + 35 + #elif defined(__i386__) 36 + 37 + __SYSCALL_INT(___thread_selfusage, thread_selfusage, 0) 38 + 39 + #elif defined(__arm__) 40 + 41 + __SYSCALL(___thread_selfusage, thread_selfusage, 0) 42 + 43 + #elif defined(__arm64__) 44 + 45 + __SYSCALL(___thread_selfusage, thread_selfusage, 0) 46 + 47 + #endif
+248
src/kernel/libsyscall/custom/__vfork.S
··· 1 + /* 2 + * Copyright (c) 1999-2007 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + /* Copyright (c) 1998 Apple Computer, Inc. All rights reserved. 29 + * 30 + * File: libc/ppc/sys/vfork.s 31 + * 32 + * HISTORY 33 + * 23-Jun-1998 Umesh Vaishampayan (umeshv@apple.com) 34 + * Created from fork.s 35 + * 36 + */ 37 + 38 + #include "SYS.h" 39 + 40 + #if defined(__i386__) 41 + 42 + #if defined(__DYNAMIC__) 43 + #define GET_CURRENT_PID PICIFY(__current_pid) 44 + 45 + NON_LAZY_STUB(__current_pid) 46 + #define __current_pid (%edx) 47 + #else 48 + #define GET_CURRENT_PID 49 + #endif 50 + 51 + /* 52 + * If __current_pid >= 0, we want to put a -1 in there 53 + * otherwise we just decrement it 54 + */ 55 + 56 + LEAF(___vfork, 0) 57 + GET_CURRENT_PID 58 + movl __current_pid, %eax 59 + 0: 60 + xorl %ecx, %ecx 61 + testl %eax, %eax 62 + cmovs %eax, %ecx 63 + decl %ecx 64 + lock 65 + cmpxchgl %ecx, __current_pid 66 + jne 0b 67 + popl %ecx 68 + #ifdef DARLING 69 + movl $ SYS_vfork, %eax 70 + call __darling_bsd_syscall 71 + cmpl $0, %eax 72 + jnb L1 73 + #else 74 + movl $(SYS_vfork), %eax // code for vfork -> eax 75 + UNIX_SYSCALL_TRAP // do the system call 76 + jnb L1 // jump if CF==0 77 + #endif 78 + GET_CURRENT_PID 79 + lock 80 + incl __current_pid 81 + pushl %ecx 82 + BRANCH_EXTERN(tramp_cerror) 83 + 84 + L1: 85 + testl %edx, %edx // CF=OF=0, ZF set if zero result 86 + jz L2 // parent, since r1 == 0 in parent, 1 in child 87 + xorl %eax, %eax // zero eax 88 + jmp *%ecx 89 + 90 + L2: 91 + GET_CURRENT_PID 92 + lock 93 + incl __current_pid 94 + jmp *%ecx 95 + 96 + #elif defined(__x86_64__) 97 + 98 + /* 99 + * If __current_pid >= 0, we want to put a -1 in there 100 + * otherwise we just decrement it 101 + */ 102 + 103 + LEAF(___vfork, 0) 104 + movq __current_pid@GOTPCREL(%rip), %rax 105 + movl (%rax), %eax 106 + 0: 107 + xorl %ecx, %ecx 108 + testl %eax, %eax 109 + cmovs %eax, %ecx 110 + subl $1, %ecx 111 + movq __current_pid@GOTPCREL(%rip), %rdx 112 + lock 113 + cmpxchgl %ecx, (%rdx) 114 + jne 0b 115 + #ifdef DARLING 116 + movl $ SYS_vfork, %eax 117 + call __darling_bsd_syscall 118 + cmpq $0, %rax 119 + jnb L1 120 + #else 121 + popq %rdi // return address in %rdi 122 + movq $ SYSCALL_CONSTRUCT_UNIX(SYS_vfork), %rax // code for vfork -> rax 123 + UNIX_SYSCALL_TRAP // do the system call 124 + jnb L1 // jump if CF==0 125 + pushq %rdi // put return address back on stack for cerror 126 + #endif 127 + movq __current_pid@GOTPCREL(%rip), %rcx 128 + lock 129 + addl $1, (%rcx) 130 + movq %rax, %rdi 131 + BRANCH_EXTERN(_cerror) 132 + 133 + L1: 134 + testl %edx, %edx // CF=OF=0, ZF set if zero result 135 + jz L2 // parent, since r1 == 0 in parent, 1 in child 136 + xorq %rax, %rax // zero rax 137 + jmp *%rdi 138 + 139 + L2: 140 + movq __current_pid@GOTPCREL(%rip), %rdx 141 + lock 142 + addl $1, (%rdx) 143 + jmp *%rdi 144 + 145 + #elif defined(__arm__) 146 + 147 + #include <arm/arch.h> 148 + 149 + .globl cerror 150 + MI_ENTRY_POINT(___vfork) 151 + 152 + MI_GET_ADDRESS(r3, __current_pid) // get address of __current_pid 153 + #ifdef _ARM_ARCH_6 154 + L0: 155 + ldrex r1, [r3] 156 + subs r1, r1, #1 // if __current_pid <= 0, decrement it 157 + movpl r1, #-1 // otherwise put -1 in there 158 + strex r2, r1, [r3] 159 + cmp r2, #0 160 + bne L0 161 + #else 162 + mov r2, #0x80000000 // load "looking" value 163 + L0: 164 + swp r1, r2, [r3] // look at the value, lock others out 165 + cmp r1, r2 // anyone else trying to look? 166 + beq L0 // yes, so wait our turn 167 + subs r1, r1, #1 // if __current_pid <= 0, decrement it 168 + movpl r1, #-1 // otherwise put -1 in there 169 + str r1, [r3] 170 + #endif 171 + 172 + mov r1, #1 // prime results 173 + mov r12, #SYS_vfork 174 + swi #SWI_SYSCALL // make the syscall 175 + bcs Lbotch // error? 176 + cmp r1, #0 // parent (r1=0) or child(r1=1) 177 + beq Lparent 178 + 179 + //child here... 180 + mov r0, #0 181 + bx lr // return 182 + 183 + Lbotch: 184 + MI_CALL_EXTERNAL(_cerror) // jump here on error 185 + mov r0,#-1 // set the error 186 + // reload values clobbered by cerror (so we can treat them as live in Lparent) 187 + MI_GET_ADDRESS(r3, __current_pid) // get address of __current_pid 188 + #ifndef _ARM_ARCH_6 189 + mov r2, #0x80000000 // load "looking" value 190 + #endif 191 + // fall thru 192 + 193 + Lparent: 194 + #ifdef _ARM_ARCH_6 195 + ldrex r1, [r3] 196 + add r1, r1, #1 // we're back, decrement vfork count 197 + strex r2, r1, [r3] 198 + cmp r2, #0 199 + bne Lparent 200 + #else 201 + swp r1, r2, [r3] // look at the value, lock others out 202 + cmp r1, r2 // anyone else trying to look? 203 + beq Lparent // yes, so wait our turn 204 + add r1, r1, #1 // we're back, decrement vfork count 205 + str r1, [r3] 206 + #endif 207 + 208 + bx lr // return 209 + 210 + #elif defined(__arm64__) 211 + 212 + MI_ENTRY_POINT(___vfork) 213 + 214 + MI_GET_ADDRESS(x9, __current_pid) 215 + Ltry_set_vfork: 216 + ldxr w10, [x9] // Get old current pid value (exclusive) 217 + mov w11, #-1 // Will be -1 if current value is positive 218 + subs w10, w10, #1 // Subtract one 219 + csel w12, w11, w10, pl // If >= 0, set to -1, else set to (current - 1) 220 + stxr w13, w12, [x9] // Attempt exclusive store to current pid 221 + cbnz w13, Ltry_set_vfork // If store failed, retry 222 + 223 + // ARM sets r1 to 1 here. I don't see why. 224 + mov w16, #SYS_vfork // Set syscall code 225 + svc #SWI_SYSCALL 226 + b.cs Lbotch 227 + cbz w1, Lparent 228 + 229 + // Child 230 + mov w0, #0 231 + ret 232 + 233 + // Error case 234 + Lbotch: 235 + bl _cerror // Update errno 236 + mov w0, #-1 // Set return value 237 + MI_GET_ADDRESS(x9, __current_pid) // Reload current pid address 238 + // Fall through 239 + Lparent: 240 + ldxr w10, [x9] // Exclusive load current pid value 241 + add w10, w10, #1 // Increment (i.e. decrement vfork count) 242 + stxr w11, w10, [x9] // Attempt exclusive store of updated vfork count 243 + cbnz w11, Lparent // If exclusive store failed, retry 244 + ret // Done, return 245 + 246 + #else 247 + #error Unsupported architecture 248 + #endif
+1 -1
src/kernel/libsyscall/custom/__vfork.s
··· 68 68 #ifdef DARLING 69 69 movl $ SYS_vfork, %eax 70 70 call __darling_bsd_syscall 71 - cmpq $0, %eax 71 + cmpl $0, %eax 72 72 jnb L1 73 73 #else 74 74 movl $(SYS_vfork), %eax // code for vfork -> eax
+149
src/kernel/libsyscall/custom/custom.S
··· 1 + /* 2 + * Copyright (c) 1999-2015 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. 29 + */ 30 + 31 + #include "SYS.h" 32 + 33 + #if defined(__i386__) 34 + 35 + /* 36 + * i386 needs custom assembly to transform the return from syscalls 37 + * into a proper stack for a function call out to cerror{,_nocancel}. 38 + */ 39 + 40 + LABEL(tramp_cerror) 41 + mov %esp, %edx 42 + andl $0xfffffff0, %esp 43 + subl $16, %esp 44 + movl %edx, 4(%esp) 45 + movl %eax, (%esp) 46 + CALL_EXTERN(_cerror) 47 + movl 4(%esp), %esp 48 + ret 49 + 50 + LABEL(tramp_cerror_nocancel) 51 + mov %esp, %edx 52 + andl $0xfffffff0, %esp 53 + subl $16, %esp 54 + movl %edx, 4(%esp) 55 + movl %eax, (%esp) 56 + CALL_EXTERN(_cerror_nocancel) 57 + movl 4(%esp), %esp 58 + ret 59 + 60 + LABEL(__sysenter_trap) 61 + popl %edx 62 + movl %esp, %ecx 63 + sysenter 64 + 65 + .globl _i386_get_ldt 66 + ALIGN 67 + _i386_get_ldt: 68 + movl $6,%eax 69 + MACHDEP_SYSCALL_TRAP 70 + jnb 2f 71 + jmp tramp_cerror 72 + 2: ret 73 + 74 + 75 + .globl _i386_set_ldt 76 + ALIGN 77 + _i386_set_ldt: 78 + movl $5,%eax 79 + MACHDEP_SYSCALL_TRAP 80 + jnb 2f 81 + jmp tramp_cerror 82 + 2: ret 83 + 84 + ALIGN 85 + .globl __thread_set_tsd_base 86 + __thread_set_tsd_base: 87 + pushl 4(%esp) 88 + pushl $0 89 + movl $3,%eax 90 + MACHDEP_SYSCALL_TRAP 91 + addl $8,%esp 92 + ret 93 + 94 + #elif defined(__x86_64__) 95 + 96 + .globl _i386_get_ldt 97 + ALIGN 98 + _i386_get_ldt: 99 + movl $SYSCALL_CONSTRUCT_MDEP(6), %eax 100 + MACHDEP_SYSCALL_TRAP 101 + jnb 2f 102 + movq %rax, %rdi 103 + jmp _cerror 104 + 2: ret 105 + 106 + 107 + .globl _i386_set_ldt 108 + ALIGN 109 + _i386_set_ldt: 110 + movl $SYSCALL_CONSTRUCT_MDEP(5), %eax 111 + MACHDEP_SYSCALL_TRAP 112 + jnb 2f 113 + movq %rax, %rdi 114 + jmp _cerror 115 + 2: ret 116 + 117 + ALIGN 118 + .globl __thread_set_tsd_base 119 + __thread_set_tsd_base: 120 + movl $0, %esi // 0 as the second argument 121 + movl $ SYSCALL_CONSTRUCT_MDEP(3), %eax // Machine-dependent syscall number 3 122 + MACHDEP_SYSCALL_TRAP 123 + ret 124 + 125 + #elif defined(__arm__) 126 + 127 + .align 2 128 + .globl __thread_set_tsd_base 129 + __thread_set_tsd_base: 130 + mov r3, #2 131 + mov r12, #0x80000000 132 + swi #SWI_SYSCALL 133 + bx lr 134 + 135 + #elif defined(__arm64__) 136 + 137 + .align 2 138 + .globl __thread_set_tsd_base 139 + __thread_set_tsd_base: 140 + mov x3, #2 141 + mov x16, #0x80000000 142 + svc #SWI_SYSCALL 143 + ret 144 + 145 + #else 146 + #error unknown architecture 147 + #endif 148 + 149 + .subsections_via_symbols
+278
src/kernel/libsyscall/wrappers/mach_absolute_time.S
··· 1 + /* 2 + * Copyright (c) 2003-2007 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + 29 + #include <sys/appleapiopts.h> 30 + #include <machine/cpu_capabilities.h> 31 + 32 + #if defined(__i386__) 33 + 34 + /* return mach_absolute_time in %edx:%eax 35 + * 36 + * The algorithm we use is: 37 + * 38 + * ns = ((((rdtsc - rnt_tsc_base)<<rnt_shift)*rnt_tsc_scale) / 2**32) + rnt_ns_base; 39 + * 40 + * rnt_shift, a constant computed during initialization, is the smallest value for which: 41 + * 42 + * (tscFreq << rnt_shift) > SLOW_TSC_THRESHOLD 43 + * 44 + * Where SLOW_TSC_THRESHOLD is about 10e9. Since most processor's tscFreq is greater 45 + * than 1GHz, rnt_shift is usually 0. rnt_tsc_scale is also a 32-bit constant: 46 + * 47 + * rnt_tsc_scale = (10e9 * 2**32) / (tscFreq << rnt_shift); 48 + */ 49 + 50 + .globl _mach_absolute_time 51 + _mach_absolute_time: 52 + pushl %ebp 53 + movl %esp,%ebp 54 + pushl %esi 55 + pushl %ebx 56 + 57 + 0: 58 + movl _COMM_PAGE_NT_GENERATION,%esi /* get generation (0 if being changed) */ 59 + testl %esi,%esi /* if being updated, loop until stable */ 60 + jz 0b 61 + 62 + lfence 63 + rdtsc /* get TSC in %edx:%eax */ 64 + lfence 65 + 66 + subl _COMM_PAGE_NT_TSC_BASE,%eax 67 + sbbl _COMM_PAGE_NT_TSC_BASE+4,%edx 68 + 69 + /* 70 + * Prior to supporting "slow" processors, xnu always set _NT_SHIFT to 32. 71 + * Now it defaults to 0, unless the processor is slow. The shifts 72 + * below implicitly mask the count down to 5 bits, handling either default. 73 + */ 74 + movl _COMM_PAGE_NT_SHIFT,%ecx 75 + shldl %cl,%eax,%edx /* shift %edx left, filling in from %eax */ 76 + shll %cl,%eax /* finish shifting %edx:%eax left by _COMM_PAGE_NT_SHIFT bits */ 77 + 78 + movl _COMM_PAGE_NT_SCALE,%ecx 79 + 80 + movl %edx,%ebx 81 + mull %ecx 82 + movl %ebx,%eax 83 + movl %edx,%ebx 84 + mull %ecx 85 + addl %ebx,%eax 86 + adcl $0,%edx 87 + 88 + addl _COMM_PAGE_NT_NS_BASE,%eax 89 + adcl _COMM_PAGE_NT_NS_BASE+4,%edx 90 + 91 + cmpl _COMM_PAGE_NT_GENERATION,%esi /* have the parameters changed? */ 92 + jne 0b /* yes, loop until stable */ 93 + 94 + popl %ebx 95 + popl %esi 96 + popl %ebp 97 + ret 98 + 99 + #elif defined(__x86_64__) 100 + 101 + /* 102 + * 64-bit version _mach_absolute_time. We return the 64-bit nanotime in %rax. 103 + * 104 + * The algorithm we use is: 105 + * 106 + * ns = ((((rdtsc - rnt_tsc_base)<<rnt_shift)*rnt_tsc_scale) / 2**32) + rnt_ns_base; 107 + * 108 + * rnt_shift, a constant computed during initialization, is the smallest value for which: 109 + * 110 + * tscFreq << rnt_shift) > SLOW_TSC_THRESHOLD 111 + * 112 + * Where SLOW_TSC_THRESHOLD is about 10e9. Since most processor's tscFreqs are greater 113 + * than 1GHz, rnt_shift is usually 0. rnt_tsc_scale is also a 32-bit constant: 114 + * 115 + * rnt_tsc_scale = (10e9 * 2**32) / (tscFreq << rnt_shift); 116 + * 117 + */ 118 + .globl _mach_absolute_time 119 + _mach_absolute_time: 120 + pushq %rbp // set up a frame for backtraces 121 + movq %rsp,%rbp 122 + movq $(_COMM_PAGE_TIME_DATA_START),%rsi 123 + 1: 124 + movl _NT_GENERATION(%rsi),%r8d // get generation 125 + testl %r8d,%r8d // if 0, data is being changed... 126 + jz 1b // ...so loop until stable 127 + lfence 128 + rdtsc // edx:eax := tsc 129 + lfence 130 + shlq $32,%rdx // rax := ((edx << 32) | eax), ie 64-bit tsc 131 + orq %rdx,%rax 132 + 133 + /* 134 + * Prior to supporting "slow" processors, xnu always set _NT_SHIFT to 32. 135 + * Now it defaults to 0, unless the processor is slow. In order to maintain 136 + * compatibility with both old and new versions of xnu, we mask the shift 137 + * down to 0x1F, which maps the old default (32) into the new default (0). 138 + */ 139 + movl _NT_SHIFT(%rsi),%ecx 140 + andl $0x1F,%ecx // *** remove this line once 10.9 is GM *** 141 + subq _NT_TSC_BASE(%rsi), %rax // rax := (tsc - base_tsc) 142 + shlq %cl,%rax // rax := (tsc - base_tsc) << NT_SHIFT 143 + movl _NT_SCALE(%rsi),%ecx 144 + mulq %rcx // rdx:rax := ((tsc - base_tsc)<<shift) * scale 145 + shrdq $32,%rdx,%rax // divide by 2**32 146 + addq _NT_NS_BASE(%rsi),%rax // (((tsc - base_tsc) * scale) >> 32) + ns_base 147 + 148 + cmpl _NT_GENERATION(%rsi),%r8d // did the data change during computation? 149 + jne 1b 150 + popq %rbp 151 + ret 152 + 153 + #elif defined(__arm__) 154 + 155 + #include <mach/arm/syscall_sw.h> 156 + 157 + /* 158 + * If userspace access to the timebase is supported (indicated through the commpage), 159 + * directly reads the timebase and uses it and the current timebase offset (also in 160 + * the commpage, and updated whenever the system wakes from sleep) to construct the 161 + * current time value; otherwise, traps to the kernel to handle this. 162 + * 163 + * If we do this in user mode, there are two cases where we may need to redrive the 164 + * read. We do 3 reads (high-low-high) to the timebase, because we only have a 165 + * 32-bit interface to it (despite the use of mrrc). If the high bits change, we 166 + * need to reread the register (as our returned value could otherwise be off by 167 + * 2^32 mach absolute time units). 168 + * 169 + * We do two reads of the offset, before and after the register reads. If the offset 170 + * changes, we have gone to sleep in the midst of doing a read. This case should be 171 + * exceedingly rare, but could result in a terribly inaccurate result, so we need 172 + * to get a fresh timebase value. 173 + */ 174 + .text 175 + .align 2 176 + .globl _mach_absolute_time 177 + _mach_absolute_time: 178 + movw ip, #((_COMM_PAGE_TIMEBASE_OFFSET) & 0x0000FFFF) 179 + movt ip, #(((_COMM_PAGE_TIMEBASE_OFFSET) >> 16) & 0x0000FFFF) 180 + ldrb r0, [ip, #((_COMM_PAGE_USER_TIMEBASE) - (_COMM_PAGE_TIMEBASE_OFFSET))] 181 + cmp r0, #USER_TIMEBASE_NONE // Are userspace reads supported? 182 + beq _mach_absolute_time_kernel // If not, go to the kernel 183 + isb // Prevent speculation on CNTPCT across calls 184 + // (see ARMV7C.b section B8.1.2, ARMv8 section D6.1.2) 185 + push {r4, r5, r7, lr} // Push a frame 186 + add r7, sp, #8 187 + L_mach_absolute_time_user: 188 + ldr r4, [ip] // Load offset low bits 189 + ldr r5, [ip, #4] // Load offset high bits 190 + mrrc p15, 0, r3, r1, c14 // Read timebase high to r1 191 + mrrc p15, 0, r0, r3, c14 // Read timebase low to r0 192 + mrrc p15, 0, r3, r2, c14 // Read timebase high to r2 193 + cmp r1, r2 // Did the high bits change? 194 + bne L_mach_absolute_time_user // Loop if timebase high changed 195 + ldr r2, [ip] // Load offset low bits 196 + ldr r3, [ip, #4] // Load offset high bits 197 + eor r4, r2 // Compare our offset values... 198 + eor r5, r3 199 + orrs r5, r4 200 + bne L_mach_absolute_time_user // If they changed, try again 201 + adds r0, r0, r2 // Construct mach_absolute_time 202 + adcs r1, r1, r3 203 + pop {r4, r5, r7, pc} // Pop the frame 204 + 205 + .text 206 + .align 2 207 + .globl _mach_absolute_time_kernel 208 + _mach_absolute_time_kernel: 209 + mov r12, #-3 // Load the magic MAT number 210 + swi #SWI_SYSCALL 211 + bx lr 212 + 213 + .text 214 + .align 2 215 + .globl _mach_continuous_time_kernel 216 + _mach_continuous_time_kernel: 217 + mov r12, #-4 // Load the magic MCT number 218 + swi #SWI_SYSCALL 219 + bx lr 220 + 221 + #elif defined(__arm64__) 222 + 223 + #include <mach/arm/syscall_sw.h> 224 + 225 + /* 226 + * If userspace access to the timebase is supported (indicated through the commpage), 227 + * directly reads the timebase and uses it and the current timebase offset (also in 228 + * the commpage, and updated whenever the system wakes from sleep) to construct the 229 + * current time value; otherwise, traps to the kernel to handle this. 230 + * 231 + * If we do this in user mode, we do two reads of the offset, before and after we 232 + * read the register. If the offset changes, we have gone to sleep in the midst of 233 + * doing a read. This case should be exceedingly rare, but could result in a terribly 234 + * inaccurate result, so we need to get a fresh timebase value. 235 + */ 236 + .text 237 + .align 2 238 + .globl _mach_absolute_time 239 + _mach_absolute_time: 240 + movk x3, #(((_COMM_PAGE_TIMEBASE_OFFSET) >> 48) & 0x000000000000FFFF), lsl #48 241 + movk x3, #(((_COMM_PAGE_TIMEBASE_OFFSET) >> 32) & 0x000000000000FFFF), lsl #32 242 + movk x3, #(((_COMM_PAGE_TIMEBASE_OFFSET) >> 16) & 0x000000000000FFFF), lsl #16 243 + movk x3, #((_COMM_PAGE_TIMEBASE_OFFSET) & 0x000000000000FFFF) 244 + ldrb w2, [x3, #((_COMM_PAGE_USER_TIMEBASE) - (_COMM_PAGE_TIMEBASE_OFFSET))] 245 + cmp x2, #USER_TIMEBASE_NONE // Are userspace reads supported? 246 + b.eq _mach_absolute_time_kernel // If not, go to the kernel 247 + isb // Prevent speculation on CNTPCT across calls 248 + // (see ARMV7C.b section B8.1.2, ARMv8 section D6.1.2) 249 + L_mach_absolute_time_user: 250 + ldr x1, [x3] // Load the offset 251 + mrs x0, CNTPCT_EL0 // Read the timebase 252 + ldr x2, [x3] // Load the offset 253 + cmp x1, x2 // Compare our offset values... 254 + b.ne L_mach_absolute_time_user // If they changed, try again 255 + add x0, x0, x1 // Construct mach_absolute_time 256 + ret 257 + 258 + 259 + 260 + .text 261 + .align 2 262 + .globl _mach_absolute_time_kernel 263 + _mach_absolute_time_kernel: 264 + mov w16, #-3 // Load the magic MAT number 265 + svc #SWI_SYSCALL 266 + ret 267 + 268 + .text 269 + .align 2 270 + .globl _mach_continuous_time_kernel 271 + _mach_continuous_time_kernel: 272 + mov w16, #-4 // Load the magic MCT number 273 + svc #SWI_SYSCALL 274 + ret 275 + 276 + #else 277 + #error Unsupported architecture 278 + #endif
+100
src/kernel/libsyscall/wrappers/mach_approximate_time.S
··· 1 + /* 2 + * Copyright (c) 2003-2007 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + 29 + #include <sys/appleapiopts.h> 30 + #include <machine/cpu_capabilities.h> 31 + 32 + #if defined(__arm__) 33 + 34 + .text 35 + .align 2 36 + .globl _mach_approximate_time 37 + _mach_approximate_time: 38 + 39 + movw r0, #((_COMM_PAGE_APPROX_TIME_SUPPORTED>>0)&0x0FFFF) 40 + movt r0, #((_COMM_PAGE_APPROX_TIME_SUPPORTED>>16)&0x0FFFF) 41 + ldrb r0, [r0] // load COMM_PAGE_APPROX_TIME_SUPPORTED 42 + cmp r0, #1 // check if approx time is supported 43 + 44 + bne _mach_absolute_time // if not supported, fall through to 45 + // absolute_time 46 + 47 + movw r2, #((_COMM_PAGE_APPROX_TIME>>0)&0x0FFFF) 48 + movt r2, #((_COMM_PAGE_APPROX_TIME>>16)&0x0FFFF) 49 + 50 + // at this point, r2->COMM_PAGE_APPROX_TIME, which is a 64-bit value. 51 + // Since this is a 32-bit architecture, and the commpage is readonly, 52 + // there is no "guaranteed" atomic way to read all 64-bits with 53 + // hardware protection. Even the ldrd instruction is not guaranteed to 54 + // complete atomically. The solution is to use a 32-bit high/low/high 55 + // read with a consistency check on the high bits. To further 56 + // complicate things, reading the same location in memory back to back 57 + // could trigger a predictive read, which would defeat the purpose of 58 + // doing the consistency check so we insert a data memory barrier to 59 + // prevent this. 60 + _consistency_check: 61 + ldr r1, [r2,#4] // load high 62 + ldr r0, [r2] // load low 63 + dsb // avoid predictive reads that could 64 + // be invalid if interrupted 65 + ldr r3, [r2,#4] // load high again 66 + cmp r1, r3 // check that high1 == high2 67 + bne _consistency_check // try again if not 68 + bx lr 69 + 70 + #elif defined(__i386__) 71 + 72 + .text 73 + .align 4, 0x90 74 + .globl _mach_approximate_time 75 + _mach_approximate_time: 76 + pushl %ebp // push a frame 77 + movl %esp, %ebp 78 + cmpb $0, _COMM_PAGE_APPROX_TIME_SUPPORTED // check commpage 79 + // "is supported" flag. 80 + je _approx_time_not_supported // if zero, fall through to 81 + // absolute_time 82 + // note the comment above for 32-bit ARM applies equally to 32-bit i386. 83 + .align 4, 0x90 84 + _approx_time_consistency_check: 85 + movl _COMM_PAGE_APPROX_TIME+4, %edx // load high 86 + movl _COMM_PAGE_APPROX_TIME, %eax // load low 87 + lfence // avoid predictive reads that 88 + // could be invalid if 89 + // interrupted 90 + cmpl _COMM_PAGE_APPROX_TIME+4, %edx // load high and check if equal 91 + // to the first read 92 + jne _approx_time_consistency_check // if not, try again. 93 + popl %ebp 94 + ret 95 + 96 + _approx_time_not_supported: 97 + popl %ebp 98 + jmp _mach_absolute_time 99 + 100 + #endif
+43
src/kernel/libsyscall/wrappers/skywalk/cpu_copy_in_cksum.S
··· 1 + /* 2 + * Copyright (c) 2017 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + 29 + /* 30 + * extern int cpu_copy_in_cksum(const void *src, void *dst, uint32_t len, 31 + * uint32_t initial_sum); 32 + * 33 + * input : 34 + * src : source starting address 35 + * dst : destination starting address 36 + * len : byte stream length 37 + * initial_sum : 32bit sum 38 + * 39 + * output : 40 + * the source byte stream is copied into the destination buffer 41 + * the function returns the final 16bit checksum 42 + */ 43 +
+44
src/kernel/libsyscall/wrappers/skywalk/cpu_in_cksum.S
··· 1 + /* 2 + * Copyright (c) 2017 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. The rights granted to you under the License 10 + * may not be used to create, or enable the creation or redistribution of, 11 + * unlawful or unlicensed copies of an Apple operating system, or to 12 + * circumvent, violate, or enable the circumvention or violation of, any 13 + * terms of an Apple operating system software license agreement. 14 + * 15 + * Please obtain a copy of the License at 16 + * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 + * 18 + * The Original Code and all software distributed under the License are 19 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 + * Please see the License for the specific language governing rights and 24 + * limitations under the License. 25 + * 26 + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 + */ 28 + 29 + /* 30 + * extern uint32_t os_cpu_in_cksum(const void *data, uint32_t len, 31 + * uint32_t initial_sum); 32 + * 33 + * input : 34 + * data : starting address 35 + * len : byte stream length 36 + * initial_sum : 32-bit sum 37 + * 38 + * output : 39 + * This function returns the partial 16-bit checksum accumulated in 40 + * a 32-bit variable (withouth 1's complement); caller is responsible 41 + * for folding the 32-bit sum into 16-bit and performinng the 1's 42 + * complement if applicable 43 + */ 44 +
+206
src/kernel/libsyscall/wrappers/varargs_wrappers.S
··· 1 + /* 2 + * Copyright (c) 2011-2013 Apple Inc. All rights reserved. 3 + * 4 + * @APPLE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. Please obtain a copy of the License at 10 + * http://www.opensource.apple.com/apsl/ and read it before using this 11 + * file. 12 + * 13 + * The Original Code and all software distributed under the License are 14 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 + * Please see the License for the specific language governing rights and 19 + * limitations under the License. 20 + * 21 + * @APPLE_LICENSE_HEADER_END@ 22 + */ 23 + 24 + #ifdef __arm64__ 25 + 26 + #include "../custom/SYS.h" 27 + #include <mach/arm64/asm.h> 28 + 29 + /* 30 + * Stubs are to handle the ARM64 ABI for variadic functions' 31 + * not matching the ABI used by the system call handler. 32 + */ 33 + 34 + /* 35 + * sem_t* sem_open(const char *name, int oflag, ...); 36 + * sem_t* __sem_open(const char *name, int oflag, int mode, int value); 37 + */ 38 + MI_ENTRY_POINT(_sem_open) 39 + ARM64_STACK_PROLOG 40 + PUSH_FRAME 41 + #if __LP64__ 42 + ldp x2, x3, [fp, #16] 43 + #else 44 + ldp w2, w3, [fp, #16] 45 + #endif 46 + MI_CALL_EXTERNAL(___sem_open) 47 + #if !__LP64__ 48 + /* xnu returns a 64-bit '-1' on failure, but pointers must have the high 49 + * 32-bits set to zero. The following instruction is equivalent to 50 + * masking off the top 32-bits. 51 + */ 52 + mov w0, w0 53 + #endif 54 + POP_FRAME 55 + ARM64_STACK_EPILOG 56 + 57 + /* 58 + * int open(const char *name, int oflag, ...); 59 + * int __open(const char *name, int oflag, int mode, int value); 60 + */ 61 + MI_ENTRY_POINT(_open) 62 + ARM64_STACK_PROLOG 63 + PUSH_FRAME 64 + #if __LP64__ 65 + ldr x2, [fp, #16] 66 + #else 67 + ldr w2, [fp, #16] 68 + #endif 69 + MI_CALL_EXTERNAL(___open) 70 + POP_FRAME 71 + ARM64_STACK_EPILOG 72 + 73 + /* 74 + * int open_nocancel(const char *name, int oflag, ...); 75 + * int __open_nocancel(const char *name, int oflag, int mode); 76 + */ 77 + MI_ENTRY_POINT(_open$NOCANCEL) 78 + ARM64_STACK_PROLOG 79 + PUSH_FRAME 80 + #if __LP64__ 81 + ldr x2, [fp, #16] 82 + #else 83 + ldr w2, [fp, #16] 84 + #endif 85 + MI_CALL_EXTERNAL(___open_nocancel) 86 + POP_FRAME 87 + ARM64_STACK_EPILOG 88 + 89 + /* 90 + * int openat(int fd,const char *name, int oflag, ...); 91 + * int __openat(int fd, const char *name, int oflag, int mode, int value); 92 + */ 93 + MI_ENTRY_POINT(_openat) 94 + ARM64_STACK_PROLOG 95 + PUSH_FRAME 96 + #if __LP64__ 97 + ldr x3, [fp, #16] 98 + #else 99 + ldr w3, [fp, #16] 100 + #endif 101 + MI_CALL_EXTERNAL(___openat) 102 + POP_FRAME 103 + ARM64_STACK_EPILOG 104 + 105 + /* 106 + * int openat_nocancel(int fd, const char *name, int oflag, ...); 107 + * int __openat_nocancel(int fd, const char *name, int oflag, int mode); 108 + */ 109 + MI_ENTRY_POINT(_openat$NOCANCEL) 110 + ARM64_STACK_PROLOG 111 + PUSH_FRAME 112 + #if __LP64__ 113 + ldr x3, [fp, #16] 114 + #else 115 + ldr w3, [fp, #16] 116 + #endif 117 + MI_CALL_EXTERNAL(___openat_nocancel) 118 + POP_FRAME 119 + ARM64_STACK_EPILOG 120 + 121 + /* 122 + * int shm_open(const char *, int, ...); 123 + * int __shm_open(const char*, int oflag, int mode); 124 + */ 125 + MI_ENTRY_POINT(_shm_open) 126 + ARM64_STACK_PROLOG 127 + PUSH_FRAME 128 + #if __LP64__ 129 + ldr x2, [fp, #16] 130 + #else 131 + ldr w2, [fp, #16] 132 + #endif 133 + MI_CALL_EXTERNAL(___shm_open) 134 + POP_FRAME 135 + ARM64_STACK_EPILOG 136 + 137 + /* 138 + * int msgsys(int, ...); 139 + * int __msgsys(int which, int a2, int a3, int a4, int a5); 140 + */ 141 + MI_ENTRY_POINT(_msgsys) 142 + ARM64_STACK_PROLOG 143 + PUSH_FRAME 144 + #if __LP64__ 145 + ldp x1, x2, [fp, #16] 146 + ldp x3, x4, [fp, #32] 147 + #else 148 + ldp w1, w2, [fp, #16] 149 + ldp w3, w4, [fp, #24] 150 + #endif 151 + MI_CALL_EXTERNAL(___msgsys) 152 + POP_FRAME 153 + 154 + /* 155 + * int semsys(int, ...); 156 + * int __semsys(int which, int a2, int a3, int a4, int a5); 157 + */ 158 + MI_ENTRY_POINT(_semsys) 159 + ARM64_STACK_PROLOG 160 + PUSH_FRAME 161 + #if __LP64__ 162 + ldp x1, x2, [fp, #16] 163 + ldp x3, x4, [fp, #32] 164 + #else 165 + ldp w1, w2, [fp, #16] 166 + ldp w3, w4, [fp, #24] 167 + #endif 168 + MI_CALL_EXTERNAL(___semsys) 169 + POP_FRAME 170 + ARM64_STACK_EPILOG 171 + 172 + /* 173 + * int semctl(int, int, int, ...); 174 + * int __semctl(int semid, int semnum, int cmd, semun_t arg); 175 + */ 176 + MI_ENTRY_POINT(_semctl) 177 + ARM64_STACK_PROLOG 178 + PUSH_FRAME 179 + #if __LP64__ 180 + ldr x3, [fp, #16] 181 + #else 182 + ldr w3, [fp, #16] 183 + #endif 184 + MI_CALL_EXTERNAL(___semctl) 185 + POP_FRAME 186 + ARM64_STACK_EPILOG 187 + 188 + /* 189 + * int shmsys(int, ...); 190 + * int __shmsys(int which, int a2, int a3, int a4); 191 + */ 192 + MI_ENTRY_POINT(_shmsys) 193 + ARM64_STACK_PROLOG 194 + PUSH_FRAME 195 + #if __LP64__ 196 + ldp x1, x2, [fp, #16] 197 + ldr x3, [fp, #32] 198 + #else 199 + ldp w1, w2, [fp, #16] 200 + ldr w3, [fp, #24] 201 + #endif 202 + MI_CALL_EXTERNAL(___shmsys) 203 + POP_FRAME 204 + ARM64_STACK_EPILOG 205 + 206 + #endif /* defined(__arm64__) */