]> git.saurik.com Git - apple/xnu.git/blob - libsyscall/custom/custom.s
xnu-2422.115.4.tar.gz
[apple/xnu.git] / libsyscall / custom / custom.s
1 /*
2 * Copyright (c) 1999-2011 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 #elif defined(__x86_64__)
85
86 .globl _i386_get_ldt
87 ALIGN
88 _i386_get_ldt:
89 movl $6,%eax
90 MACHDEP_SYSCALL_TRAP
91 jnb 2f
92 movq %rax, %rdi
93 jmp _cerror
94 2: ret
95
96
97 .globl _i386_set_ldt
98 ALIGN
99 _i386_set_ldt:
100 movl $5,%eax
101 MACHDEP_SYSCALL_TRAP
102 jnb 2f
103 movq %rax, %rdi
104 jmp _cerror
105 2: ret
106
107 #endif