]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. |
1c79356b | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 A |
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. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * @OSF_COPYRIGHT@ | |
30 | */ | |
2d21ac55 A |
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 | */ | |
1c79356b A |
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> | |
91447636 | 48 | #include <kern/debug.h> |
1c79356b | 49 | |
2d21ac55 A |
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 | ||
1c79356b A |
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 | ||
1c79356b | 80 | /* Move arbitrarily-aligned data from a user space to kernel space */ |
91447636 A |
81 | extern int copyin( |
82 | const user_addr_t user_addr, | |
83 | char *kernel_addr, | |
84 | vm_size_t nbytes); | |
1c79356b A |
85 | |
86 | /* Move a NUL-terminated string from a user space to kernel space */ | |
91447636 A |
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); | |
1c79356b A |
92 | |
93 | /* Move arbitrarily-aligned data from a user space to kernel space */ | |
91447636 A |
94 | extern int copyinmsg( |
95 | const user_addr_t user_addr, | |
96 | char *kernel_addr, | |
97 | mach_msg_size_t nbytes); | |
1c79356b A |
98 | |
99 | /* Move arbitrarily-aligned data from a kernel space to user space */ | |
91447636 | 100 | extern int copyout( |
2d21ac55 | 101 | const void *kernel_addr, |
91447636 A |
102 | user_addr_t user_addr, |
103 | vm_size_t nbytes); | |
1c79356b A |
104 | |
105 | /* Move arbitrarily-aligned data from a kernel space to user space */ | |
91447636 A |
106 | extern int copyoutmsg( |
107 | const char *kernel_addr, | |
108 | user_addr_t user_addr, | |
1c79356b A |
109 | mach_msg_size_t nbytes); |
110 | ||
0c530ab8 | 111 | /* Invalidate copy window(s) cache */ |
2d21ac55 | 112 | extern void inval_copy_windows(thread_t); |
0c530ab8 | 113 | |
2d21ac55 | 114 | extern int sscanf(const char *input, const char *fmt, ...) __scanflike(2,3); |
0c530ab8 | 115 | |
2d21ac55 A |
116 | /* sprintf() is being deprecated. Please use snprintf() instead. */ |
117 | extern integer_t sprintf(char *buf, const char *fmt, ...) __deprecated; | |
1c79356b | 118 | |
2d21ac55 | 119 | extern int printf(const char *format, ...) __printflike(1,2); |
1c79356b | 120 | |
2d21ac55 | 121 | extern void dbugprintf(const char *format, ...) __printflike(1,2); |
1c79356b | 122 | |
2d21ac55 | 123 | extern int kdb_printf(const char *format, ...) __printflike(1,2); |
9bccf70c | 124 | |
c910b4d9 A |
125 | extern int kdb_log(const char *format, ...) __printflike(1,2); |
126 | ||
1c79356b A |
127 | extern void printf_init(void); |
128 | ||
593a1d5f A |
129 | extern int snprintf(char *, size_t, const char *, ...) __printflike(3,4); |
130 | ||
1c79356b A |
131 | extern void log(int level, char *fmt, ...); |
132 | ||
133 | void | |
134 | _doprnt( | |
135 | register const char *fmt, | |
136 | va_list *argp, | |
137 | void (*putc)(char), | |
138 | int radix); | |
9bccf70c A |
139 | int |
140 | __doprnt( | |
141 | register const char *fmt, | |
142 | va_list *argp, | |
143 | void (*putc)(int, void *), | |
144 | void *arg, | |
145 | int radix); | |
1c79356b A |
146 | |
147 | extern void safe_gets( | |
148 | char *str, | |
149 | int maxlen); | |
150 | ||
151 | extern void cnputcusr(char); | |
152 | ||
9bccf70c A |
153 | extern void conslog_putc(char); |
154 | ||
155 | extern void consdebug_putc(char); | |
156 | ||
c910b4d9 A |
157 | extern void consdebug_log(char); |
158 | ||
1c79356b A |
159 | extern void cnputc(char); |
160 | ||
161 | extern int cngetc(void); | |
162 | ||
163 | extern int cnmaygetc(void); | |
164 | ||
165 | extern int _setjmp( | |
166 | jmp_buf_t *jmp_buf); | |
167 | ||
168 | extern int _longjmp( | |
169 | jmp_buf_t *jmp_buf, | |
170 | int value); | |
171 | ||
172 | extern void bootstrap_create(void); | |
173 | ||
1c79356b A |
174 | extern void Debugger( |
175 | const char * message); | |
176 | ||
177 | extern void delay( | |
178 | int n); | |
179 | ||
1c79356b A |
180 | |
181 | extern void norma_bootstrap(void); | |
182 | ||
183 | #if DIPC | |
184 | extern boolean_t no_bootstrap_task(void); | |
185 | extern ipc_port_t get_root_master_device_port(void); | |
186 | #endif /* DIPC */ | |
187 | ||
55e303ae A |
188 | extern kern_return_t kernel_set_special_port( |
189 | host_priv_t host_priv, | |
190 | int which, | |
191 | ipc_port_t port); | |
192 | ||
2d21ac55 A |
193 | user_addr_t get_useraddr(void); |
194 | ||
195 | /* symbol lookup */ | |
196 | struct kmod_info_t; | |
197 | ||
198 | extern int syms_formataddr( | |
199 | vm_offset_t addr, | |
200 | char *out, | |
201 | vm_offset_t outsize); | |
202 | ||
203 | extern const char *syms_nameforaddr( | |
204 | vm_offset_t addr, | |
205 | vm_offset_t *ofs, | |
206 | kmod_info_t **kmod); | |
207 | ||
1c79356b | 208 | #endif /* _MISC_PROTOS_H_ */ |