]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
cb323159 | 2 | * Copyright (c) 2000-2018 Apple Inc. All rights reserved. |
1c79356b | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
0a7de745 | 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. | |
0a7de745 | 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. | |
0a7de745 | 17 | * |
2d21ac55 A |
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. | |
0a7de745 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * @OSF_COPYRIGHT@ | |
0a7de745 | 30 | * |
1c79356b | 31 | */ |
0a7de745 | 32 | #ifndef _MACH_VM_TYPES_H_ |
91447636 | 33 | #define _MACH_VM_TYPES_H_ |
9bccf70c | 34 | |
0b4e3aa0 | 35 | #include <mach/port.h> |
1c79356b A |
36 | #include <mach/machine/vm_types.h> |
37 | ||
91447636 A |
38 | #include <stdint.h> |
39 | ||
0a7de745 A |
40 | typedef vm_offset_t pointer_t; |
41 | typedef vm_offset_t vm_address_t; | |
1c79356b | 42 | |
55e303ae A |
43 | /* |
44 | * We use addr64_t for 64-bit addresses that are used on both | |
45 | * 32 and 64-bit machines. On PPC, they are passed and returned as | |
46 | * two adjacent 32-bit GPRs. We use addr64_t in places where | |
47 | * common code must be useable both on 32 and 64-bit machines. | |
48 | */ | |
0a7de745 | 49 | typedef uint64_t addr64_t; /* Basic effective address */ |
55e303ae A |
50 | |
51 | /* | |
52 | * We use reg64_t for addresses that are 32 bits on a 32-bit | |
53 | * machine, and 64 bits on a 64-bit machine, but are always | |
54 | * passed and returned in a single GPR on PPC. This type | |
55 | * cannot be used in generic 32-bit c, since on a 64-bit | |
56 | * machine the upper half of the register will be ignored | |
57 | * by the c compiler in 32-bit mode. In c, we can only use the | |
58 | * type in prototypes of functions that are written in and called | |
59 | * from assembly language. This type is basically a comment. | |
60 | */ | |
0a7de745 | 61 | typedef uint32_t reg64_t; |
55e303ae A |
62 | |
63 | /* | |
64 | * To minimize the use of 64-bit fields, we keep some physical | |
0a7de745 | 65 | * addresses (that are page aligned) as 32-bit page numbers. |
55e303ae A |
66 | * This limits the physical address space to 16TB of RAM. |
67 | */ | |
0a7de745 | 68 | typedef uint32_t ppnum_t; /* Physical page number */ |
e5568f75 | 69 | #define PPNUM_MAX UINT32_MAX |
55e303ae | 70 | |
1c79356b | 71 | |
0a7de745 | 72 | #ifdef KERNEL_PRIVATE |
0b4e3aa0 | 73 | |
91447636 A |
74 | #include <sys/cdefs.h> |
75 | ||
0a7de745 | 76 | #ifndef MACH_KERNEL_PRIVATE |
1c79356b A |
77 | /* |
78 | * Use specifically typed null structures for these in | |
79 | * other parts of the kernel to enable compiler warnings | |
80 | * about type mismatches, etc... Otherwise, these would | |
81 | * be void*. | |
82 | */ | |
91447636 A |
83 | __BEGIN_DECLS |
84 | ||
0a7de745 A |
85 | struct pmap; |
86 | struct _vm_map; | |
87 | struct vm_object; | |
9bccf70c | 88 | |
91447636 A |
89 | __END_DECLS |
90 | ||
0a7de745 | 91 | #endif /* MACH_KERNEL_PRIVATE */ |
9bccf70c | 92 | |
0a7de745 | 93 | typedef struct pmap *pmap_t; |
f427ee49 | 94 | typedef struct _vm_map *vm_map_t, *vm_map_read_t, *vm_map_inspect_t; |
0a7de745 A |
95 | typedef struct vm_object *vm_object_t; |
96 | typedef struct vm_object_fault_info *vm_object_fault_info_t; | |
91447636 | 97 | |
cb323159 A |
98 | #define PMAP_NULL ((pmap_t) NULL) |
99 | #define VM_OBJECT_NULL ((vm_object_t) NULL) | |
9bccf70c A |
100 | |
101 | #else /* KERNEL_PRIVATE */ | |
102 | ||
f427ee49 | 103 | typedef mach_port_t vm_map_t, vm_map_read_t, vm_map_inspect_t; |
9bccf70c A |
104 | |
105 | #endif /* KERNEL_PRIVATE */ | |
106 | ||
cb323159 A |
107 | #ifdef KERNEL |
108 | #define VM_MAP_NULL ((vm_map_t) NULL) | |
f427ee49 A |
109 | #define VM_MAP_INSPECT_NULL ((vm_map_inspect_t) NULL) |
110 | #define VM_MAP_READ_NULL ((vm_map_read_t) NULL) | |
cb323159 | 111 | #else |
0a7de745 | 112 | #define VM_MAP_NULL ((vm_map_t) 0) |
f427ee49 A |
113 | #define VM_MAP_INSPECT_NULL ((vm_map_inspect_t) 0) |
114 | #define VM_MAP_READ_NULL ((vm_map_read_t) 0) | |
cb323159 | 115 | #endif |
9bccf70c | 116 | |
91447636 A |
117 | /* |
118 | * Evolving definitions, likely to change. | |
119 | */ | |
9bccf70c | 120 | |
0a7de745 A |
121 | typedef uint64_t vm_object_offset_t; |
122 | typedef uint64_t vm_object_size_t; | |
9bccf70c | 123 | |
3e170ce0 A |
124 | |
125 | #ifdef XNU_KERNEL_PRIVATE | |
126 | ||
5ba3f43e | 127 | #define VM_TAG_ACTIVE_UPDATE 1 |
3e170ce0 | 128 | |
5ba3f43e | 129 | typedef uint16_t vm_tag_t; |
3e170ce0 | 130 | |
0a7de745 A |
131 | #define VM_TAG_NAME_LEN_MAX 0x7F |
132 | #define VM_TAG_NAME_LEN_SHIFT 0 | |
133 | #define VM_TAG_BT 0x0080 | |
134 | #define VM_TAG_UNLOAD 0x0100 | |
135 | #define VM_TAG_KMOD 0x0200 | |
5ba3f43e A |
136 | |
137 | #if DEBUG || DEVELOPMENT | |
f427ee49 A |
138 | #if __LP64__ |
139 | #define VM_MAX_TAG_ZONES 84 | |
140 | #else | |
141 | #define VM_MAX_TAG_ZONES 31 | |
142 | #endif | |
5ba3f43e | 143 | #else |
0a7de745 | 144 | #define VM_MAX_TAG_ZONES 0 |
5ba3f43e A |
145 | #endif |
146 | ||
147 | #if VM_MAX_TAG_ZONES | |
148 | // must be multiple of 64 | |
0a7de745 | 149 | #define VM_MAX_TAG_VALUE 1536 |
5ba3f43e | 150 | #else |
0a7de745 | 151 | #define VM_MAX_TAG_VALUE 256 |
5ba3f43e A |
152 | #endif |
153 | ||
154 | ||
0a7de745 | 155 | #define ARRAY_COUNT(a) (sizeof((a)) / sizeof((a)[0])) |
5ba3f43e | 156 | |
0a7de745 A |
157 | struct vm_allocation_total { |
158 | vm_tag_t tag; | |
159 | uint64_t total; | |
5ba3f43e A |
160 | }; |
161 | ||
0a7de745 | 162 | struct vm_allocation_zone_total { |
c3c9b80d A |
163 | vm_size_t vazt_total; |
164 | vm_size_t vazt_peak; | |
5ba3f43e A |
165 | }; |
166 | typedef struct vm_allocation_zone_total vm_allocation_zone_total_t; | |
167 | ||
0a7de745 A |
168 | struct vm_allocation_site { |
169 | uint64_t total; | |
5ba3f43e | 170 | #if DEBUG || DEVELOPMENT |
0a7de745 | 171 | uint64_t peak; |
5ba3f43e | 172 | #endif /* DEBUG || DEVELOPMENT */ |
0a7de745 A |
173 | uint64_t mapped; |
174 | int16_t refcount; | |
175 | vm_tag_t tag; | |
176 | uint16_t flags; | |
177 | uint16_t subtotalscount; | |
178 | struct vm_allocation_total subtotals[0]; | |
cb323159 | 179 | /* char name[0]; -- this is placed after subtotals, see KA_NAME() */ |
3e170ce0 A |
180 | }; |
181 | typedef struct vm_allocation_site vm_allocation_site_t; | |
182 | ||
0a7de745 | 183 | #define VM_ALLOC_SITE_STATIC(iflags, itag) \ |
5ba3f43e A |
184 | static vm_allocation_site_t site __attribute__((section("__DATA, __data"))) \ |
185 | = { .refcount = 2, .tag = (itag), .flags = (iflags) }; | |
186 | ||
f427ee49 | 187 | extern int vmrtf_extract(uint64_t, boolean_t, unsigned long, void *, unsigned long *); |
d9a64523 A |
188 | extern unsigned int vmrtfaultinfo_bufsz(void); |
189 | ||
3e170ce0 A |
190 | #endif /* XNU_KERNEL_PRIVATE */ |
191 | ||
9bccf70c A |
192 | #ifdef KERNEL_PRIVATE |
193 | ||
0a7de745 | 194 | #ifndef MACH_KERNEL_PRIVATE |
91447636 A |
195 | |
196 | __BEGIN_DECLS | |
197 | ||
0a7de745 A |
198 | struct upl; |
199 | struct vm_map_copy; | |
200 | struct vm_named_entry; | |
91447636 A |
201 | |
202 | __END_DECLS | |
203 | ||
0a7de745 | 204 | #endif /* MACH_KERNEL_PRIVATE */ |
1c79356b | 205 | |
0a7de745 A |
206 | typedef struct upl *upl_t; |
207 | typedef struct vm_map_copy *vm_map_copy_t; | |
208 | typedef struct vm_named_entry *vm_named_entry_t; | |
0b4e3aa0 | 209 | |
cb323159 | 210 | #define VM_MAP_COPY_NULL ((vm_map_copy_t) NULL) |
0b4e3aa0 | 211 | |
0a7de745 | 212 | #else /* KERNEL_PRIVATE */ |
0b4e3aa0 | 213 | |
0a7de745 A |
214 | typedef mach_port_t upl_t; |
215 | typedef mach_port_t vm_named_entry_t; | |
0b4e3aa0 | 216 | |
0a7de745 | 217 | #endif /* KERNEL_PRIVATE */ |
1c79356b | 218 | |
cb323159 A |
219 | #ifdef KERNEL |
220 | #define UPL_NULL ((upl_t) NULL) | |
221 | #define VM_NAMED_ENTRY_NULL ((vm_named_entry_t) NULL) | |
222 | #else | |
0a7de745 A |
223 | #define UPL_NULL ((upl_t) 0) |
224 | #define VM_NAMED_ENTRY_NULL ((vm_named_entry_t) 0) | |
cb323159 A |
225 | #endif |
226 | ||
d9a64523 A |
227 | #ifdef PRIVATE |
228 | typedef struct { | |
229 | uint64_t rtfabstime; // mach_continuous_time at start of fault | |
230 | uint64_t rtfduration; // fault service duration | |
231 | uint64_t rtfaddr; // fault address | |
232 | uint64_t rtfpc; // userspace program counter of thread incurring the fault | |
233 | uint64_t rtftid; // thread ID | |
234 | uint64_t rtfupid; // process identifier | |
235 | uint64_t rtftype; // fault type | |
236 | } vm_rtfault_record_t; | |
237 | #endif | |
0a7de745 | 238 | #endif /* _MACH_VM_TYPES_H_ */ |