]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/misc_protos.h
xnu-3789.51.2.tar.gz
[apple/xnu.git] / osfmk / kern / misc_protos.h
index 05b8acd9bb65fead6e77a4baede5c40e894d109d..355316d229244796e4a0c8721189548c4de405f3 100644 (file)
@@ -1,27 +1,39 @@
 /*
- * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2011 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
  */
+/*
+ * NOTICE: This file was modified by McAfee Research in 2004 to introduce
+ * support for mandatory and extensible security protections.  This notice
+ * is included in support of clause 2.2 (b) of the Apple Public License,
+ * Version 2.0.
+ */
 
 #ifndef        _MISC_PROTOS_H_
 #define        _MISC_PROTOS_H_
 #include <ipc/ipc_types.h>
 #include <kern/debug.h>
 
+#ifndef MIN
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#endif /* MIN */
+#ifndef MAX
+#define MAX(a,b) (((a)>(b))?(a):(b))
+#endif  /* MAX */
+
 /* Set a bit in a bit array */
 extern void setbit(
        int             which,
@@ -64,6 +83,18 @@ extern int copyin(
        char                *kernel_addr,
        vm_size_t           nbytes);
 
+/* Move an aligned 32 or 64-bit word from user space to kernel space
+ * using a single read instruction
+ *
+ * when reading a 32-bit word, the value is 0-extended into the kernel space
+ * 64-bit buffer passed as `kernel_addr`
+ * (think `*kernel_addr = *(uint32_t *)user_addr`)
+ */
+extern int copyin_word(
+       const user_addr_t   user_addr,
+       uint64_t            *kernel_addr,
+       vm_size_t           nbytes);
+
 /* Move a NUL-terminated string from a user space to kernel space */
 extern int copyinstr(
        const user_addr_t   user_addr,
@@ -79,7 +110,7 @@ extern int copyinmsg(
 
 /* Move arbitrarily-aligned data from a kernel space to user space */
 extern int copyout(
-       const char      *kernel_addr,
+       const void      *kernel_addr,
        user_addr_t     user_addr,
        vm_size_t       nbytes);
 
@@ -90,36 +121,66 @@ extern int copyoutmsg(
        mach_msg_size_t nbytes);
 
 /* Invalidate copy window(s) cache */
-extern void    inval_copy_windows(thread_t);
+extern void inval_copy_windows(thread_t);
+extern void copy_window_fault(thread_t, vm_map_t, int);
 
+extern int copyin_validate(const user_addr_t, uintptr_t, vm_size_t);
+extern int copyout_validate(uintptr_t, const user_addr_t, vm_size_t);
 
-extern int sscanf(const char *input, const char *fmt, ...);
+extern int sscanf(const char *input, const char *fmt, ...) __scanflike(2,3);
 
-extern integer_t sprintf(char *buf, const char *fmt, ...);
+/* sprintf() is being deprecated. Please use snprintf() instead. */ 
+extern integer_t sprintf(char *buf, const char *fmt, ...) __deprecated;
 
-extern void printf(const char *format, ...);
+extern int printf(const char *format, ...) __printflike(1,2);
+extern int vprintf(const char *format, va_list ap);
 
-extern void dbugprintf(const char *format, ...);
+#if KERNEL_PRIVATE
+int     _consume_printf_args(int, ...);
+#endif
 
-extern void kdb_printf(const char *format, ...);
+#if CONFIG_NO_PRINTF_STRINGS
+#if KERNEL_PRIVATE
+#define printf(x, ...)  _consume_printf_args( 0, ## __VA_ARGS__ )
+#else
+#define printf(x, ...)  do {} while (0)
+#endif
+#endif
+
+extern int kdb_printf(const char *format, ...) __printflike(1,2);
+
+extern int kdb_log(const char *format, ...) __printflike(1,2);
+
+extern int kdb_printf_unbuffered(const char *format, ...) __printflike(1,2);
 
 extern void printf_init(void);
 
+extern int snprintf(char *, size_t, const char *, ...) __printflike(3,4);
+
 extern void log(int level, char *fmt, ...);
 
 void 
 _doprnt(
-       register const char     *fmt,
+       const char      *fmt,
        va_list                 *argp,
        void                    (*putc)(char),
        int                     radix);
+
+void
+_doprnt_log(
+       const char      *fmt,
+       va_list                 *argp,
+       void                    (*putc)(char),
+       int                     radix);
+
 int
 __doprnt(
-       register const char     *fmt,
-       va_list                 *argp,
+       const char      *fmt,
+       va_list                 argp,
        void                    (*putc)(int, void *),
        void                    *arg,
-       int                     radix);
+       int                     radix,
+       int                     is_log);
 
 extern void safe_gets(
        char    *str,
@@ -129,10 +190,24 @@ extern void cnputcusr(char);
 
 extern void conslog_putc(char);
 
+extern void cons_putc_locked(char);
+
 extern void consdebug_putc(char);
 
+extern void consdebug_log(char);
+
+extern void consdebug_putc_unbuffered(char);
+
 extern void cnputc(char);
 
+extern void cnputc_unbuffered(char);
+
+extern void console_write(char *, int);
+
+extern void console_suspend(void);
+
+extern void console_resume(void);
+
 extern int cngetc(void);
 
 extern int cnmaygetc(void);
@@ -146,14 +221,25 @@ extern int _longjmp(
 
 extern void bootstrap_create(void);
 
+/* 
+ * Halt other cores before invoking debugger 
+ * Halting other cores as early as possible helps preserve
+ * the current system state for debugging
+ */
+extern void DebuggerHaltOtherCores(void);
+
+/* Resume other cores */
+extern void DebuggerResumeOtherCores(void);
+
 extern void Debugger(
                const char      * message);
 
-extern void delay(
-               int             n);
-
+extern void DebuggerWithContext(
+               unsigned int    reason,
+               void            *ctx,
+               const char      *message,
+               uint64_t        debugger_options_mask);
 
-extern void norma_bootstrap(void);
 
 #if    DIPC
 extern boolean_t       no_bootstrap_task(void);
@@ -165,4 +251,16 @@ extern kern_return_t       kernel_set_special_port(
                int             which,
                ipc_port_t      port);
 
+extern kern_return_t   kernel_get_special_port(
+               host_priv_t     host_priv,
+               int             which,
+               ipc_port_t      *portp);
+
+user_addr_t get_useraddr(void);
+
+/* symbol lookup */
+struct kmod_info_t;
+
+extern uint64_t early_random(void);
+
 #endif /* _MISC_PROTOS_H_ */