]> git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/misc_protos.h
xnu-3248.40.184.tar.gz
[apple/xnu.git] / osfmk / kern / misc_protos.h
1 /*
2 * Copyright (c) 2000-2011 Apple Computer, 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 /*
29 * @OSF_COPYRIGHT@
30 */
31 /*
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,
35 * Version 2.0.
36 */
37
38 #ifndef _MISC_PROTOS_H_
39 #define _MISC_PROTOS_H_
40
41 #include <stdarg.h>
42 #include <string.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>
49
50 #ifndef MIN
51 #define MIN(a,b) (((a)<(b))?(a):(b))
52 #endif /* MIN */
53 #ifndef MAX
54 #define MAX(a,b) (((a)>(b))?(a):(b))
55 #endif /* MAX */
56
57 /* Set a bit in a bit array */
58 extern void setbit(
59 int which,
60 int *bitmap);
61
62 /* Clear a bit in a bit array */
63 extern void clrbit(
64 int which,
65 int *bitmap);
66
67 /* Find the first set bit in a bit array */
68 extern int ffsbit(
69 int *bitmap);
70 extern int ffs(
71 unsigned int mask);
72
73 /*
74 * Test if indicated bit is set in bit string.
75 */
76 extern int testbit(
77 int which,
78 int *bitmap);
79
80 /* Move arbitrarily-aligned data from a user space to kernel space */
81 extern int copyin(
82 const user_addr_t user_addr,
83 char *kernel_addr,
84 vm_size_t nbytes);
85
86 /* Move a NUL-terminated string from a user space to kernel space */
87 extern int copyinstr(
88 const user_addr_t user_addr,
89 char *kernel_addr,
90 vm_size_t max,
91 vm_size_t *actual);
92
93 /* Move arbitrarily-aligned data from a user space to kernel space */
94 extern int copyinmsg(
95 const user_addr_t user_addr,
96 char *kernel_addr,
97 mach_msg_size_t nbytes);
98
99 /* Move arbitrarily-aligned data from a kernel space to user space */
100 extern int copyout(
101 const void *kernel_addr,
102 user_addr_t user_addr,
103 vm_size_t nbytes);
104
105 /* Move arbitrarily-aligned data from a kernel space to user space */
106 extern int copyoutmsg(
107 const char *kernel_addr,
108 user_addr_t user_addr,
109 mach_msg_size_t nbytes);
110
111 /* Invalidate copy window(s) cache */
112 extern void inval_copy_windows(thread_t);
113 extern void copy_window_fault(thread_t, vm_map_t, int);
114
115 extern int copyin_validate(const user_addr_t, uintptr_t, vm_size_t);
116 extern int copyout_validate(uintptr_t, const user_addr_t, vm_size_t);
117
118 extern int sscanf(const char *input, const char *fmt, ...) __scanflike(2,3);
119
120 /* sprintf() is being deprecated. Please use snprintf() instead. */
121 extern integer_t sprintf(char *buf, const char *fmt, ...) __deprecated;
122
123 extern int printf(const char *format, ...) __printflike(1,2);
124
125 #if KERNEL_PRIVATE
126 int _consume_printf_args(int, ...);
127 #endif
128
129 #if CONFIG_NO_PRINTF_STRINGS
130 #if KERNEL_PRIVATE
131 #define printf(x, ...) _consume_printf_args( 0, ## __VA_ARGS__ )
132 #else
133 #define printf(x, ...) do {} while (0)
134 #endif
135 #endif
136
137 extern int kdb_printf(const char *format, ...) __printflike(1,2);
138
139 extern int kdb_log(const char *format, ...) __printflike(1,2);
140
141 extern int kdb_printf_unbuffered(const char *format, ...) __printflike(1,2);
142
143 extern void printf_init(void);
144
145 extern int snprintf(char *, size_t, const char *, ...) __printflike(3,4);
146
147 extern void log(int level, char *fmt, ...);
148
149 void
150 _doprnt(
151 register const char *fmt,
152 va_list *argp,
153 void (*putc)(char),
154 int radix);
155
156 void
157 _doprnt_log(
158 register const char *fmt,
159 va_list *argp,
160 void (*putc)(char),
161 int radix);
162
163 int
164 __doprnt(
165 register const char *fmt,
166 va_list argp,
167 void (*putc)(int, void *),
168 void *arg,
169 int radix,
170 int is_log);
171
172 extern void safe_gets(
173 char *str,
174 int maxlen);
175
176 extern void cnputcusr(char);
177
178 extern void conslog_putc(char);
179
180 extern void cons_putc_locked(char);
181
182 extern void consdebug_putc(char);
183
184 extern void consdebug_log(char);
185
186 extern void consdebug_putc_unbuffered(char);
187
188 extern void cnputc(char);
189
190 extern void cnputc_unbuffered(char);
191
192 extern int cngetc(void);
193
194 extern int cnmaygetc(void);
195
196 extern int _setjmp(
197 jmp_buf_t *jmp_buf);
198
199 extern int _longjmp(
200 jmp_buf_t *jmp_buf,
201 int value);
202
203 extern void bootstrap_create(void);
204
205 extern void Debugger(
206 const char * message);
207
208 extern void DebuggerWithContext(
209 unsigned int reason,
210 void *ctx,
211 const char *message);
212
213 extern void delay(
214 int n);
215
216
217
218 #if DIPC
219 extern boolean_t no_bootstrap_task(void);
220 extern ipc_port_t get_root_master_device_port(void);
221 #endif /* DIPC */
222
223 extern kern_return_t kernel_set_special_port(
224 host_priv_t host_priv,
225 int which,
226 ipc_port_t port);
227
228 user_addr_t get_useraddr(void);
229
230 /* symbol lookup */
231 struct kmod_info_t;
232
233 extern uint64_t early_random(void);
234
235 #endif /* _MISC_PROTOS_H_ */