2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
28 * All Rights Reserved.
30 * Permission to use, copy, modify and ditribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
53 #include <mach/error.h>
54 #include <mach/vm_param.h>
55 #include <mach/boolean.h>
56 #include <kern/misc_protos.h>
57 #include <kern/syscall_emulation.h>
58 #include <kern/task.h>
59 #include <kern/kalloc.h>
60 #include <vm/vm_kern.h>
61 #include <machine/thread.h> /* for syscall_emulation_sync */
69 * This code knows that kalloc() allocates memory most efficiently
70 * in sizes that are powers of 2, and asks for those sizes.
74 * Go from number of entries to size of struct eml_dispatch and back.
76 #define base_size (sizeof(struct eml_dispatch) - sizeof(eml_routine_t))
77 #define count_to_size(count) \
78 (base_size + sizeof(vm_offset_t) * (count))
80 #define size_to_count(size) \
81 ( ((size) - base_size) / sizeof(vm_offset_t) )
85 task_set_emulation_vector_internal(
88 emulation_vector_t emulation_vector
,
89 mach_msg_type_number_t emulation_vector_count
);
92 * eml_init: initialize user space emulation code
100 * eml_task_reference() [Exported]
102 * Bumps the reference count on the common emulation
111 register eml_dispatch_t eml
;
113 if (parent
== TASK_NULL
)
114 eml
= EML_DISPATCH_NULL
;
116 eml
= parent
->eml_dispatch
;
118 if (eml
!= EML_DISPATCH_NULL
) {
119 mutex_lock(&eml
->lock
);
121 mutex_unlock(&eml
->lock
);
123 task
->eml_dispatch
= eml
;
128 * eml_task_deallocate() [Exported]
130 * Cleans up after the emulation code when a process exits.
137 register eml_dispatch_t eml
;
139 eml
= task
->eml_dispatch
;
140 if (eml
!= EML_DISPATCH_NULL
) {
143 mutex_lock(&eml
->lock
);
144 count
= --eml
->ref_count
;
145 mutex_unlock(&eml
->lock
);
148 kfree((vm_offset_t
)eml
, count_to_size(eml
->disp_count
));
150 task
->eml_dispatch
= EML_DISPATCH_NULL
;
155 * task_set_emulation_vector: [Server Entry]
156 * set a list of emulated system calls for this task.
159 task_set_emulation_vector_internal(
162 emulation_vector_t emulation_vector
,
163 mach_msg_type_number_t emulation_vector_count
)
165 return KERN_NOT_SUPPORTED
;
169 * task_set_emulation_vector: [Server Entry]
171 * Set the list of emulated system calls for this task.
172 * The list is out-of-line.
175 task_set_emulation_vector(
178 emulation_vector_t emulation_vector
,
179 mach_msg_type_number_t emulation_vector_count
)
181 return KERN_NOT_SUPPORTED
;
185 * task_get_emulation_vector: [Server Entry]
187 * Get the list of emulated system calls for this task.
188 * List is returned out-of-line.
191 task_get_emulation_vector(
193 int *vector_start
, /* out */
194 emulation_vector_t
*emulation_vector
, /* out */
195 mach_msg_type_number_t
*emulation_vector_count
) /* out */
197 return KERN_NOT_SUPPORTED
;
201 * task_set_emulation: [Server Entry]
202 * set up for user space emulation of syscalls within this task.
207 vm_offset_t routine_entry_pt
,
210 return KERN_NOT_SUPPORTED
;