2 * Copyright (c) 2017 Apple 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@
28 #ifndef __COPYOUT_SHIM_X86_64_H__
29 #define __COPYOUT_SHIM_X86_64_H__
32 // Osfmk includes libsa/types.h which causes massive conflicts
34 #if defined (__i386__) || defined(__x86_64__)
35 #include "i386/types.h"
36 #elif defined (__arm__) || defined (__arm64__)
37 //XXX when ready to turn on for arm: #include "arm/types.h"
38 #error ARM/ARM64 not supported
40 #error architecture not supported
43 #include <mach/mach_types.h>
45 #define CO_SRC_NORMAL 1 //copyout() called
46 #define CO_SRC_MSG (1<<1) //copyoutmsg() called
47 #define CO_SRC_PHYS (1<<2) //copyio(COPYOUTPHYS,...) called
49 typedef void (*copyout_shim_fn_t
)(const void *, user_addr_t
, vm_size_t
, unsigned co_src
);
51 #ifdef MACH_KERNEL_PRIVATE
52 #if(DEVELOPMENT || DEBUG) && (COPYOUT_SHIM > 0)
54 extern copyout_shim_fn_t copyout_shim_fn
;
55 extern unsigned co_src_flags
;
57 // void call_copyout_shim(const void *kernel_addr,user_addr_t user_addr,vm_size_t nbytes,int copy_type,int copyout_flavors);
59 #define CALL_COPYOUT_SHIM_NRML(ka, ua, nb) \
60 if(copyout_shim_fn && (co_src_flags & CO_SRC_NORMAL)) {copyout_shim_fn(ka,ua,nb,CO_SRC_NORMAL); }
62 #define CALL_COPYOUT_SHIM_MSG(ka, ua, nb) \
63 if(copyout_shim_fn && (co_src_flags & CO_SRC_MSG)){copyout_shim_fn(ka,ua,nb,CO_SRC_MSG); }
65 #define CALL_COPYOUT_SHIM_PHYS(ka, ua, nb) \
66 if(copyout_shim_fn && (co_src_flags & CO_SRC_PHYS)){copyout_shim_fn(ka,ua,nb,CO_SRC_PHYS); }
69 //Make these calls disappear if we're RELEASE or if COPYOUT_SHIM didn't get built
70 #define CALL_COPYOUT_SHIM_NRML(ka, ua, nb)
71 #define CALL_COPYOUT_SHIM_MSG(ka, ua, nb)
72 #define CALL_COPYOUT_SHIM_PHYS(ka, ua, nb)
73 #endif /* (DEVELOPMENT || DEBUG) && (COPYOUT_SHIM > 0) */
74 #endif /* MACH_KERNEL_PRIVATE */
78 register_copyout_shim(copyout_shim_fn_t copyout_shim_fn
, unsigned co_src_flags
);
81 #define unregister_copyout_shim() register_copyout_shim(NULL,0)
84 cos_kernel_unslide(const void *);
87 cos_kernel_reslide(const void *);
89 #endif /* KERNEL_PRIVATE */
90 #endif /* __COPYOUT_SHIM_X86_64_H__ */