]>
Commit | Line | Data |
---|---|---|
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 |