]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kern/copyout_shim.h
xnu-4903.270.47.tar.gz
[apple/xnu.git] / osfmk / kern / copyout_shim.h
CommitLineData
5ba3f43e
A
1/*
2 * Copyright (c) 2017 Apple 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#ifndef __COPYOUT_SHIM_X86_64_H__
29#define __COPYOUT_SHIM_X86_64_H__
30#ifdef KERNEL_PRIVATE
31
32// Osfmk includes libsa/types.h which causes massive conflicts
33// with sys/types.h
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
39#else
40#error architecture not supported
41#endif
42
43#include <mach/mach_types.h>
44
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
48
0a7de745 49typedef void (*copyout_shim_fn_t)(const void *, user_addr_t, vm_size_t, unsigned co_src);
5ba3f43e
A
50
51#ifdef MACH_KERNEL_PRIVATE
52#if(DEVELOPMENT || DEBUG) && (COPYOUT_SHIM > 0)
53
54extern copyout_shim_fn_t copyout_shim_fn;
55extern unsigned co_src_flags;
56
57// void call_copyout_shim(const void *kernel_addr,user_addr_t user_addr,vm_size_t nbytes,int copy_type,int copyout_flavors);
58
0a7de745 59#define CALL_COPYOUT_SHIM_NRML(ka, ua, nb) \
5ba3f43e
A
60 if(copyout_shim_fn && (co_src_flags & CO_SRC_NORMAL)) {copyout_shim_fn(ka,ua,nb,CO_SRC_NORMAL); }
61
0a7de745 62#define CALL_COPYOUT_SHIM_MSG(ka, ua, nb) \
5ba3f43e 63 if(copyout_shim_fn && (co_src_flags & CO_SRC_MSG)){copyout_shim_fn(ka,ua,nb,CO_SRC_MSG); }
0a7de745
A
64
65#define CALL_COPYOUT_SHIM_PHYS(ka, ua, nb) \
5ba3f43e
A
66 if(copyout_shim_fn && (co_src_flags & CO_SRC_PHYS)){copyout_shim_fn(ka,ua,nb,CO_SRC_PHYS); }
67
68#else
0a7de745
A
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)
5ba3f43e
A
73#endif /* (DEVELOPMENT || DEBUG) && (COPYOUT_SHIM > 0) */
74#endif /* MACH_KERNEL_PRIVATE */
75
76
77kern_return_t
0a7de745 78register_copyout_shim(copyout_shim_fn_t copyout_shim_fn, unsigned co_src_flags);
5ba3f43e
A
79
80
81#define unregister_copyout_shim() register_copyout_shim(NULL,0)
82
83void *
84cos_kernel_unslide(const void *);
85
86void *
87cos_kernel_reslide(const void *);
88
89#endif /* KERNEL_PRIVATE */
90#endif /* __COPYOUT_SHIM_X86_64_H__ */