1/*--------------------------------------------------------------------*/
2/*--- Basic Mach traps.                  mach_traps-amd64-darwin.S ---*/
3/*--------------------------------------------------------------------*/
4
5/*
6   This file is part of Valgrind, a dynamic binary instrumentation
7   framework.
8
9   Copyright (C) 2007-2017 Apple Inc.
10      Greg Parker  gparker@apple.com
11
12   This program is free software; you can redistribute it and/or
13   modify it under the terms of the GNU General Public License as
14   published by the Free Software Foundation; either version 2 of the
15   License, or (at your option) any later version.
16
17   This program is distributed in the hope that it will be useful, but
18   WITHOUT ANY WARRANTY; without even the implied warranty of
19   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20   General Public License for more details.
21
22   You should have received a copy of the GNU General Public License
23   along with this program; if not, write to the Free Software
24   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25   02111-1307, USA.
26
27   The GNU General Public License is contained in the file COPYING.
28*/
29
30#include "pub_core_basics_asm.h"
31
32#if defined(VGP_amd64_darwin)
33
34#include "vki/vki-scnums-darwin.h"
35
36	// mach_port_name_t task_self_trap(void)
37	.text
38	.align 4
39	.globl _task_self_trap
40_task_self_trap:
41	movq	$__NR_task_self_trap, %rax
42	movq	%rcx, %r10
43	syscall
44	ret
45
46// DDD: doesn't get used...
47//	// mach_port_name_t host_self_trap(void)
48//	.text
49//	.align 4
50//	.globl _host_self_trap
51//_host_self_trap:
52//	movq	$__NR_host_self_trap, %rax
53//	movq	%rcx, %r10
54//	syscall
55//	ret
56
57	// mach_port_name_t thread_self_trap(void)
58	.text
59	.align 4
60	.globl _thread_self_trap
61_thread_self_trap:
62	movq	$__NR_thread_self_trap, %rax
63	movq	%rcx, %r10
64	syscall
65	ret
66
67	// mach_msg_return_t mach_msg_trap(...)
68	.text
69	.align 4
70	.globl _mach_msg_trap
71_mach_msg_trap:
72	movq	$__NR_mach_msg_trap, %rax
73	movq	%rcx, %r10
74	syscall
75	ret
76
77	// mach_port_t mach_reply_port(...)
78	.text
79	.align 4
80	.globl _mach_reply_port
81_mach_reply_port:
82	movq	$__NR_mach_reply_port, %rax
83	movq	%rcx, %r10
84	syscall
85	ret
86
87	// boolean_t swtch_pri(int)
88	.text
89	.align 4
90	.globl _swtch_pri
91_swtch_pri:
92	movq	$__NR_swtch_pri, %rax
93	movq	%rcx, %r10
94	syscall
95	ret
96
97	// kern_return_t semaphore_wait(semaphore_t)
98	.text
99	.align 4
100	.globl _semaphore_wait
101_semaphore_wait:
102	movq	$__NR_semaphore_wait_trap, %rax
103	movq	%rcx, %r10
104	syscall
105	ret
106
107	// kern_return_t semaphore_signal(semaphore_t)
108	.text
109	.align 4
110	.globl _semaphore_signal
111_semaphore_signal:
112	movq	$__NR_semaphore_signal_trap, %rax
113	movq	%rcx, %r10
114	syscall
115	ret
116
117	// kern_return_t semaphore_signal_thread(semaphore_t, thread_t)
118	.text
119	.align 4
120	.globl _semaphore_signal_thread
121_semaphore_signal_thread:
122	movq	$__NR_semaphore_signal_thread_trap, %rax
123	movq	%rcx, %r10
124	syscall
125	ret
126
127	// kern_return_t semaphore_wait_signal(semaphore_t, semaphore_t)
128	.text
129	.align 4
130	.globl _semaphore_wait_signal
131_semaphore_wait_signal:
132	movq	$__NR_semaphore_wait_signal_trap, %rax
133	movq	%rcx, %r10
134	syscall
135	ret
136
137#endif // defined(VGP_amd64_darwin)
138
139/* Let the linker know we don't need an executable stack */
140MARK_STACK_NO_EXEC
141
142/*--------------------------------------------------------------------*/
143/*--- end                                                          ---*/
144/*--------------------------------------------------------------------*/
145