]> git.saurik.com Git - apple/xnu.git/blame - libsyscall/custom/custom.s
xnu-3789.70.16.tar.gz
[apple/xnu.git] / libsyscall / custom / custom.s
CommitLineData
2d21ac55 1/*
39037602 2 * Copyright (c) 1999-2015 Apple Inc. All rights reserved.
2d21ac55
A
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
6d2010ae 33#if defined(__i386__)
2d21ac55 34
39236c6e
A
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
40LABEL(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
2d21ac55 49
39236c6e
A
50LABEL(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
2d21ac55
A
58 ret
59
6d2010ae 60LABEL(__sysenter_trap)
2d21ac55
A
61 popl %edx
62 movl %esp, %ecx
63 sysenter
64
39236c6e
A
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
722: ret
2d21ac55 73
2d21ac55 74
39236c6e
A
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
822: ret
2d21ac55 83
39037602
A
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
39236c6e 94#elif defined(__x86_64__)
2d21ac55
A
95
96 .globl _i386_get_ldt
97 ALIGN
98_i386_get_ldt:
99 movl $6,%eax
100 MACHDEP_SYSCALL_TRAP
39236c6e
A
101 jnb 2f
102 movq %rax, %rdi
103 jmp _cerror
2d21ac55
A
1042: ret
105
106
107 .globl _i386_set_ldt
108 ALIGN
109_i386_set_ldt:
110 movl $5,%eax
111 MACHDEP_SYSCALL_TRAP
39236c6e
A
112 jnb 2f
113 movq %rax, %rdi
114 jmp _cerror
2d21ac55
A
1152: ret
116
39037602
A
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#else
126#error unknown architecture
2d21ac55 127#endif
39037602
A
128
129.subsections_via_symbols