xref: /xnu-12377.41.6/osfmk/mach/shared_memory_server.h (revision bbb1b6f9e71b8cdde6e5cd6f4841f207dee3d828)
1*bbb1b6f9SApple OSS Distributions /*
2*bbb1b6f9SApple OSS Distributions  * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
3*bbb1b6f9SApple OSS Distributions  *
4*bbb1b6f9SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*bbb1b6f9SApple OSS Distributions  *
6*bbb1b6f9SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*bbb1b6f9SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*bbb1b6f9SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*bbb1b6f9SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*bbb1b6f9SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*bbb1b6f9SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*bbb1b6f9SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*bbb1b6f9SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*bbb1b6f9SApple OSS Distributions  *
15*bbb1b6f9SApple OSS Distributions  * Please obtain a copy of the License at
16*bbb1b6f9SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*bbb1b6f9SApple OSS Distributions  *
18*bbb1b6f9SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*bbb1b6f9SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*bbb1b6f9SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*bbb1b6f9SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*bbb1b6f9SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*bbb1b6f9SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*bbb1b6f9SApple OSS Distributions  * limitations under the License.
25*bbb1b6f9SApple OSS Distributions  *
26*bbb1b6f9SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*bbb1b6f9SApple OSS Distributions  */
28*bbb1b6f9SApple OSS Distributions /*
29*bbb1b6f9SApple OSS Distributions  *
30*bbb1b6f9SApple OSS Distributions  *	File: mach/shared_memory_server.h
31*bbb1b6f9SApple OSS Distributions  *
32*bbb1b6f9SApple OSS Distributions  *      protos and struct definitions for shared library
33*bbb1b6f9SApple OSS Distributions  *	server and interface
34*bbb1b6f9SApple OSS Distributions  */
35*bbb1b6f9SApple OSS Distributions 
36*bbb1b6f9SApple OSS Distributions /*
37*bbb1b6f9SApple OSS Distributions  * XXX
38*bbb1b6f9SApple OSS Distributions  *
39*bbb1b6f9SApple OSS Distributions  * NOTE: this file is deprecated and will be removed in the near future.
40*bbb1b6f9SApple OSS Distributions  * Any project that includes this file should be changed to:
41*bbb1b6f9SApple OSS Distributions  * 1. use <mach/shared_region.h> instead of this file,
42*bbb1b6f9SApple OSS Distributions  * 2. handle the new shared regions, now available on more platforms
43*bbb1b6f9SApple OSS Distributions  */
44*bbb1b6f9SApple OSS Distributions 
45*bbb1b6f9SApple OSS Distributions #ifndef _MACH_SHARED_MEMORY_SERVER_H_
46*bbb1b6f9SApple OSS Distributions #define _MACH_SHARED_MEMORY_SERVER_H_
47*bbb1b6f9SApple OSS Distributions 
48*bbb1b6f9SApple OSS Distributions #warning "<mach/shared_memory_server.h> is deprecated.  Please use <mach/shared_region.h> instead."
49*bbb1b6f9SApple OSS Distributions 
50*bbb1b6f9SApple OSS Distributions #include <sys/cdefs.h>
51*bbb1b6f9SApple OSS Distributions #include <mach/vm_prot.h>
52*bbb1b6f9SApple OSS Distributions #include <mach/vm_types.h>
53*bbb1b6f9SApple OSS Distributions #include <mach/mach_types.h>
54*bbb1b6f9SApple OSS Distributions 
55*bbb1b6f9SApple OSS Distributions #define VM_PROT_COW  0x8  /* must not interfere with normal prot assignments */
56*bbb1b6f9SApple OSS Distributions #define VM_PROT_ZF  0x10  /* must not interfere with normal prot assignments */
57*bbb1b6f9SApple OSS Distributions 
58*bbb1b6f9SApple OSS Distributions #ifdef  __arm__
59*bbb1b6f9SApple OSS Distributions #define GLOBAL_SHARED_TEXT_SEGMENT      0x30000000U
60*bbb1b6f9SApple OSS Distributions #define GLOBAL_SHARED_DATA_SEGMENT      0x38000000U
61*bbb1b6f9SApple OSS Distributions #define GLOBAL_SHARED_SEGMENT_MASK      0xF8000000U
62*bbb1b6f9SApple OSS Distributions 
63*bbb1b6f9SApple OSS Distributions #define SHARED_TEXT_REGION_SIZE         0x08000000
64*bbb1b6f9SApple OSS Distributions #define SHARED_DATA_REGION_SIZE         0x08000000
65*bbb1b6f9SApple OSS Distributions #else
66*bbb1b6f9SApple OSS Distributions #define GLOBAL_SHARED_TEXT_SEGMENT      0x90000000U
67*bbb1b6f9SApple OSS Distributions #define GLOBAL_SHARED_DATA_SEGMENT      0xA0000000U
68*bbb1b6f9SApple OSS Distributions #define GLOBAL_SHARED_SEGMENT_MASK      0xF0000000U
69*bbb1b6f9SApple OSS Distributions 
70*bbb1b6f9SApple OSS Distributions #define SHARED_TEXT_REGION_SIZE         0x10000000
71*bbb1b6f9SApple OSS Distributions #define SHARED_DATA_REGION_SIZE         0x10000000
72*bbb1b6f9SApple OSS Distributions #endif
73*bbb1b6f9SApple OSS Distributions 
74*bbb1b6f9SApple OSS Distributions #if !defined(__LP64__)
75*bbb1b6f9SApple OSS Distributions 
76*bbb1b6f9SApple OSS Distributions #define SHARED_LIBRARY_SERVER_SUPPORTED
77*bbb1b6f9SApple OSS Distributions 
78*bbb1b6f9SApple OSS Distributions #define SHARED_ALTERNATE_LOAD_BASE      0x09000000
79*bbb1b6f9SApple OSS Distributions 
80*bbb1b6f9SApple OSS Distributions /*
81*bbb1b6f9SApple OSS Distributions  *  Note: the two masks below are useful because the assumption is
82*bbb1b6f9SApple OSS Distributions  *  made that these shared regions will always be mapped on natural boundaries
83*bbb1b6f9SApple OSS Distributions  *  i.e. if the size is 0x10000000 the object can be mapped at
84*bbb1b6f9SApple OSS Distributions  *  0x20000000, or 0x30000000, but not 0x1000000
85*bbb1b6f9SApple OSS Distributions  */
86*bbb1b6f9SApple OSS Distributions #ifdef  __arm__
87*bbb1b6f9SApple OSS Distributions #define SHARED_TEXT_REGION_MASK         0x07FFFFFF
88*bbb1b6f9SApple OSS Distributions #define SHARED_DATA_REGION_MASK         0x07FFFFFF
89*bbb1b6f9SApple OSS Distributions #else
90*bbb1b6f9SApple OSS Distributions #define SHARED_TEXT_REGION_MASK         0x0FFFFFFF
91*bbb1b6f9SApple OSS Distributions #define SHARED_DATA_REGION_MASK         0x0FFFFFFF
92*bbb1b6f9SApple OSS Distributions #endif
93*bbb1b6f9SApple OSS Distributions 
94*bbb1b6f9SApple OSS Distributions 
95*bbb1b6f9SApple OSS Distributions /* flags field aliases for copyin_shared_file and load_shared_file */
96*bbb1b6f9SApple OSS Distributions 
97*bbb1b6f9SApple OSS Distributions /* IN */
98*bbb1b6f9SApple OSS Distributions #define ALTERNATE_LOAD_SITE 0x1
99*bbb1b6f9SApple OSS Distributions #define NEW_LOCAL_SHARED_REGIONS 0x2
100*bbb1b6f9SApple OSS Distributions #define QUERY_IS_SYSTEM_REGION 0x4
101*bbb1b6f9SApple OSS Distributions 
102*bbb1b6f9SApple OSS Distributions /* OUT */
103*bbb1b6f9SApple OSS Distributions #define SF_PREV_LOADED    0x1
104*bbb1b6f9SApple OSS Distributions #define SYSTEM_REGION_BACKED 0x2
105*bbb1b6f9SApple OSS Distributions 
106*bbb1b6f9SApple OSS Distributions 
107*bbb1b6f9SApple OSS Distributions struct sf_mapping {
108*bbb1b6f9SApple OSS Distributions 	vm_offset_t     mapping_offset;
109*bbb1b6f9SApple OSS Distributions 	vm_size_t       size;
110*bbb1b6f9SApple OSS Distributions 	vm_offset_t     file_offset;
111*bbb1b6f9SApple OSS Distributions 	vm_prot_t       protection;  /* read/write/execute/COW/ZF */
112*bbb1b6f9SApple OSS Distributions 	vm_offset_t     cksum;
113*bbb1b6f9SApple OSS Distributions };
114*bbb1b6f9SApple OSS Distributions typedef struct sf_mapping sf_mapping_t;
115*bbb1b6f9SApple OSS Distributions 
116*bbb1b6f9SApple OSS Distributions #endif  /* !defined(__LP64__) */
117*bbb1b6f9SApple OSS Distributions 
118*bbb1b6f9SApple OSS Distributions /*
119*bbb1b6f9SApple OSS Distributions  * All shared_region_* declarations are a private interface
120*bbb1b6f9SApple OSS Distributions  * between dyld and the kernel.
121*bbb1b6f9SApple OSS Distributions  *
122*bbb1b6f9SApple OSS Distributions  */
123*bbb1b6f9SApple OSS Distributions struct shared_region_range_np {
124*bbb1b6f9SApple OSS Distributions 	mach_vm_address_t       srr_address;
125*bbb1b6f9SApple OSS Distributions 	mach_vm_size_t          srr_size;
126*bbb1b6f9SApple OSS Distributions };
127*bbb1b6f9SApple OSS Distributions 
128*bbb1b6f9SApple OSS Distributions #ifndef KERNEL
129*bbb1b6f9SApple OSS Distributions 
130*bbb1b6f9SApple OSS Distributions __BEGIN_DECLS
131*bbb1b6f9SApple OSS Distributions int     shared_region_map_file_np(int fd,
132*bbb1b6f9SApple OSS Distributions     uint32_t mappingCount,
133*bbb1b6f9SApple OSS Distributions     const struct shared_file_mapping_np *mappings,
134*bbb1b6f9SApple OSS Distributions     int64_t *slide_p);
135*bbb1b6f9SApple OSS Distributions int     shared_region_make_private_np(uint32_t rangeCount,
136*bbb1b6f9SApple OSS Distributions     const struct shared_region_range_np *ranges);
137*bbb1b6f9SApple OSS Distributions __END_DECLS
138*bbb1b6f9SApple OSS Distributions 
139*bbb1b6f9SApple OSS Distributions #endif /* !KERNEL */
140*bbb1b6f9SApple OSS Distributions 
141*bbb1b6f9SApple OSS Distributions #endif /* _MACH_SHARED_MEMORY_SERVER_H_ */
142