]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/misc_protos.h
2 * Copyright (c) 2000-2011 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
32 * NOTICE: This file was modified by McAfee Research in 2004 to introduce
33 * support for mandatory and extensible security protections. This notice
34 * is included in support of clause 2.2 (b) of the Apple Public License,
38 #ifndef _MISC_PROTOS_H_
39 #define _MISC_PROTOS_H_
43 #include <machine/setjmp.h>
44 #include <mach/boolean.h>
45 #include <mach/message.h>
46 #include <mach/machine/vm_types.h>
47 #include <ipc/ipc_types.h>
48 #include <kern/debug.h>
51 #define MIN(a,b) (((a)<(b))?(a):(b))
54 #define MAX(a,b) (((a)>(b))?(a):(b))
57 /* Set a bit in a bit array */
62 /* Clear a bit in a bit array */
67 /* Find the first set bit in a bit array */
74 * Test if indicated bit is set in bit string.
80 /* Move arbitrarily-aligned data from a user space to kernel space */
82 const user_addr_t user_addr
,
86 /* Move an aligned 32 or 64-bit word from user space to kernel space
87 * using a single read instruction
89 * when reading a 32-bit word, the value is 0-extended into the kernel space
90 * 64-bit buffer passed as `kernel_addr`
91 * (think `*kernel_addr = *(uint32_t *)user_addr`)
93 extern int copyin_word(
94 const user_addr_t user_addr
,
95 uint64_t *kernel_addr
,
98 /* Move a NUL-terminated string from a user space to kernel space */
100 const user_addr_t user_addr
,
105 /* Move arbitrarily-aligned data from a user space to kernel space */
106 extern int copyinmsg(
107 const user_addr_t user_addr
,
109 mach_msg_size_t nbytes
);
111 /* Move arbitrarily-aligned data from a kernel space to user space */
113 const void *kernel_addr
,
114 user_addr_t user_addr
,
117 /* Move arbitrarily-aligned data from a kernel space to user space */
118 extern int copyoutmsg(
119 const char *kernel_addr
,
120 user_addr_t user_addr
,
121 mach_msg_size_t nbytes
);
123 /* Invalidate copy window(s) cache */
124 extern void inval_copy_windows(thread_t
);
125 extern void copy_window_fault(thread_t
, vm_map_t
, int);
127 extern int copyin_validate(const user_addr_t
, uintptr_t, vm_size_t
);
128 extern int copyout_validate(uintptr_t, const user_addr_t
, vm_size_t
);
130 extern int sscanf(const char *input
, const char *fmt
, ...) __scanflike(2,3);
132 /* sprintf() is being deprecated. Please use snprintf() instead. */
133 extern integer_t
sprintf(char *buf
, const char *fmt
, ...) __deprecated
;
135 extern int printf(const char *format
, ...) __printflike(1,2);
136 extern int vprintf(const char *format
, va_list ap
);
139 int _consume_printf_args(int, ...);
142 #if CONFIG_NO_PRINTF_STRINGS
144 #define printf(x, ...) _consume_printf_args( 0, ## __VA_ARGS__ )
146 #define printf(x, ...) do {} while (0)
150 extern int kdb_printf(const char *format
, ...) __printflike(1,2);
152 extern int kdb_log(const char *format
, ...) __printflike(1,2);
154 extern int kdb_printf_unbuffered(const char *format
, ...) __printflike(1,2);
156 extern void printf_init(void);
158 extern int snprintf(char *, size_t, const char *, ...) __printflike(3,4);
160 extern void log(int level
, char *fmt
, ...);
180 void (*putc
)(int, void *),
185 extern void safe_gets(
189 extern void cnputcusr(char);
191 extern void conslog_putc(char);
193 extern void cons_putc_locked(char);
195 extern void consdebug_putc(char);
197 extern void consdebug_log(char);
199 extern void consdebug_putc_unbuffered(char);
201 extern void cnputc(char);
203 extern void cnputc_unbuffered(char);
205 extern void console_write(char *, int);
207 extern void console_suspend(void);
209 extern void console_resume(void);
211 extern int cngetc(void);
213 extern int cnmaygetc(void);
222 extern void bootstrap_create(void);
225 * Halt other cores before invoking debugger
226 * Halting other cores as early as possible helps preserve
227 * the current system state for debugging
229 extern void DebuggerHaltOtherCores(void);
231 /* Resume other cores */
232 extern void DebuggerResumeOtherCores(void);
234 extern void Debugger(
235 const char * message
);
237 extern void DebuggerWithContext(
241 uint64_t debugger_options_mask
);
245 extern boolean_t
no_bootstrap_task(void);
246 extern ipc_port_t
get_root_master_device_port(void);
249 extern kern_return_t
kernel_set_special_port(
250 host_priv_t host_priv
,
254 extern kern_return_t
kernel_get_special_port(
255 host_priv_t host_priv
,
259 user_addr_t
get_useraddr(void);
264 extern uint64_t early_random(void);
266 #endif /* _MISC_PROTOS_H_ */