this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Import of several XNU headers, Mach kernel basic VM implementation

+4760 -25
+9
libmac/kernel-mach/host.cpp
··· 1 + 2 + #include "host.h" 3 + #include <unistd.h> 4 + 5 + kern_return_t host_page_size(void* host, size_t* size) 6 + { 7 + *size = getpagesize(); 8 + return KERN_SUCCESS; 9 + }
+16
libmac/kernel-mach/host.h
··· 1 + #ifndef MACH_HOST_H 2 + #define MACH_HOST_H 3 + #include <mach/kern_return.h> 4 + #include <mach/i386/vm_types.h> 5 + 6 + extern "C" 7 + { 8 + 9 + typedef long host_t; 10 + typedef long host_priv_t; 11 + 12 + kern_return_t host_page_size(host_t host, vm_size_t* size); 13 + 14 + } 15 + 16 + #endif
+8
libmac/kernel-mach/mach-stub.h
··· 1 + #ifndef MACH_STUB_H 2 + #define MACH_STUB_H 3 + #include <cstdio> 4 + 5 + #define MACH_STUB() { fprintf(stderr, "MACH_STUB(): %s\n", __PRETTY_FUNCTION__); return KERN_FAILURE; } 6 + #define CHECK_TASK_SELF(task) { if (task->pid != getpid()) MACH_STUB(); } 7 + 8 + #endif
+7
libmac/kernel-mach/task.cpp
··· 1 + #include "task.h" 2 + #include <sys/types.h> 3 + #include <unistd.h> 4 + 5 + 6 + static darwin_task_t mach_task_self_static = { ::getpid() }; 7 + darwin_task_t* mach_task_self_ = &mach_task_self_static;
+16
libmac/kernel-mach/task.h
··· 1 + #ifndef MACH_TASK_H 2 + #define MACH_TASK_H 3 + #include <sys/types.h> 4 + 5 + struct darwin_task_t 6 + { 7 + pid_t pid; 8 + }; 9 + 10 + extern "C" 11 + { 12 + extern darwin_task_t* mach_task_self_; 13 + inline darwin_task_t* mach_task_self() { return mach_task_self_; } 14 + } 15 + 16 + #endif
+216
libmac/kernel-mach/vm.cpp
··· 1 + 2 + #include "vm.h" 3 + #include "task.h" 4 + #include "mach-stub.h" 5 + #include <sys/types.h> 6 + #include <sys/stat.h> 7 + #include <fcntl.h> 8 + #include <sys/mman.h> 9 + #include <unistd.h> 10 + #include <errno.h> 11 + #include <cstring> 12 + 13 + static bool memory_readable(const void* ptr, size_t bytes) 14 + { 15 + int fd = ::open("/dev/null", O_WRONLY); 16 + if (fd == -1) 17 + return false; 18 + 19 + int r = ::write(fd, ptr, bytes); 20 + ::close(fd); 21 + 22 + if (r != bytes) 23 + { 24 + if (errno == EFAULT) 25 + return false; 26 + } 27 + return true; 28 + } 29 + 30 + static bool memory_writable(void* ptr, size_t bytes) 31 + { 32 + int fd = ::open("/dev/zero", O_RDONLY); 33 + if (fd == -1) 34 + return false; 35 + 36 + int r = ::read(fd, ptr, bytes); 37 + ::close(fd); 38 + 39 + if (r != bytes) 40 + { 41 + if (errno == EFAULT) 42 + return false; 43 + } 44 + return true; 45 + } 46 + 47 + kern_return_t vm_msync(vm_task_t target_task, void* addr, vm_size_t size, vm_sync_t in_flags) 48 + { 49 + CHECK_TASK_SELF(target_task); 50 + 51 + int flags = 0; 52 + if (in_flags & VM_SYNC_SYNCHRONOUS) 53 + flags |= MS_SYNC; 54 + if (in_flags & VM_SYNC_ASYNCHRONOUS) 55 + flags |= MS_ASYNC; 56 + if (in_flags & VM_SYNC_INVALIDATE) 57 + flags |= MS_INVALIDATE; 58 + 59 + if (::msync(addr, size, flags) == -1) 60 + return KERN_INVALID_ADDRESS; 61 + else 62 + return KERN_SUCCESS; 63 + } 64 + 65 + kern_return_t vm_allocate(vm_task_t target_task, void** addr, vm_size_t size, boolean_t anywhere) 66 + { 67 + CHECK_TASK_SELF(target_task); 68 + 69 + int flags = MAP_ANONYMOUS|MAP_PRIVATE; 70 + 71 + if (!anywhere) 72 + flags |= MAP_FIXED; 73 + 74 + // Give the memory all permissions, as per vm_allocate definition 75 + *addr = ::mmap(*addr, size, PROT_EXEC|PROT_READ|PROT_WRITE, flags, 0, 0); 76 + 77 + if (!*addr) 78 + { 79 + if (errno == EINVAL) 80 + return KERN_INVALID_ADDRESS; 81 + else 82 + return KERN_NO_SPACE; // No other return values are permitted 83 + } 84 + else 85 + return KERN_SUCCESS; 86 + } 87 + 88 + kern_return_t vm_deallocate(vm_task_t target_task, void* addr, vm_size_t size) 89 + { 90 + CHECK_TASK_SELF(target_task); 91 + 92 + if (::munmap(addr, size) == -1) 93 + return KERN_INVALID_ADDRESS; 94 + else 95 + return KERN_SUCCESS; 96 + } 97 + 98 + kern_return_t vm_copy(vm_task_t target_task, const void* source_address, vm_size_t count, void* dest_address) 99 + { 100 + CHECK_TASK_SELF(target_task); 101 + 102 + if (!memory_readable(source_address, count)) 103 + return KERN_INVALID_ADDRESS; 104 + if (!memory_writable(dest_address, count)) 105 + return KERN_INVALID_ADDRESS; 106 + 107 + ::memcpy(dest_address, source_address, count); 108 + return KERN_SUCCESS; 109 + } 110 + 111 + kern_return_t vm_write(vm_task_t target_task, void* address, const void* data, vm_size_t data_count) 112 + { 113 + CHECK_TASK_SELF(target_task); 114 + 115 + if (!memory_writable(address, data_count)) 116 + return KERN_INVALID_ADDRESS; 117 + if (!memory_readable(data, data_count)) 118 + return KERN_INVALID_ADDRESS; 119 + 120 + ::memcpy(address, data, data_count); 121 + return KERN_SUCCESS; 122 + } 123 + 124 + kern_return_t vm_behavior_set (vm_task_t target_task, void* address, vm_size_t size, vm_behavior_t behavior) 125 + { 126 + CHECK_TASK_SELF(target_task); 127 + MACH_STUB(); 128 + } 129 + 130 + kern_return_t vm_inherit (vm_task_t target_task, void* address, vm_size_t size, vm_inherit_t new_inheritance) 131 + { 132 + CHECK_TASK_SELF(target_task); 133 + MACH_STUB(); 134 + } 135 + 136 + kern_return_t vm_machine_attribute(vm_task_t target_task, void* address, vm_size_t size, vm_machine_attribute_t attribute, vm_machine_attribute_val_t value) 137 + { 138 + CHECK_TASK_SELF(target_task); 139 + MACH_STUB(); 140 + } 141 + 142 + kern_return_t vm_map(vm_task_t target_task, void* address, vm_size_t size, void* mask, boolean_t anywhere, memory_object_t memory_object, vm_offset_t offset, 143 + boolean_t copy, vm_prot_t cur_protection, vm_prot_t max_protection, vm_inherit_t inheritance) 144 + { 145 + CHECK_TASK_SELF(target_task); 146 + MACH_STUB(); 147 + } 148 + 149 + kern_return_t vm_protect(vm_task_t target_task, void* address, vm_size_t size, boolean_t set_maximum, vm_prot_t new_protection) 150 + { 151 + CHECK_TASK_SELF(target_task); 152 + 153 + // FIXME: Here we ignore set_maximum, not sure what to do with that 154 + int flags = 0; 155 + 156 + if (new_protection & VM_PROT_READ) 157 + flags |= PROT_READ; 158 + if (new_protection & VM_PROT_WRITE) 159 + flags |= PROT_WRITE; 160 + if (new_protection & VM_PROT_EXECUTE) 161 + flags |= PROT_EXEC; 162 + 163 + if (::mprotect(address, size, flags) == -1) 164 + { 165 + if (errno == EACCES) 166 + return KERN_PROTECTION_FAILURE; 167 + else if (errno == EINVAL || errno == ENOMEM) 168 + return KERN_INVALID_ADDRESS; 169 + else 170 + return KERN_FAILURE; 171 + } 172 + else 173 + return KERN_SUCCESS; 174 + } 175 + 176 + kern_return_t vm_read(vm_task_t target_task, const void* address, vm_size_t size, void** data_out, natural_t* data_count) 177 + { 178 + CHECK_TASK_SELF(target_task); 179 + 180 + if (!memory_readable(address, size)) 181 + return KERN_INVALID_ADDRESS; 182 + 183 + kern_return_t ret = vm_allocate(mach_task_self_, data_out, size, true); 184 + if (ret != KERN_SUCCESS) 185 + return ret; 186 + 187 + ::memcpy(*data_out, address, size); 188 + *data_count = size; // Is this correct? 189 + 190 + return KERN_SUCCESS; 191 + } 192 + 193 + kern_return_t vm_read_overwrite (vm_task_t target_task, void* address, vm_size_t size, void* data_in, natural_t* data_count) 194 + { 195 + CHECK_TASK_SELF(target_task); 196 + MACH_STUB(); 197 + } 198 + 199 + kern_return_t vm_region(vm_task_t target_task, void* address, vm_size_t size, vm_region_flavor_t flavor, vm_region_info_t info, mach_msg_type_number_t info_count, memory_object_name_t object_name) 200 + { 201 + CHECK_TASK_SELF(target_task); 202 + MACH_STUB(); 203 + } 204 + 205 + kern_return_t vm_remap(vm_task_t target_task, void* target_address, vm_size_t size, void* mask, boolean_t anywhere, mach_port_t source_task, void* source_address, boolean_t copy, 206 + vm_prot_t cur_protection, vm_prot_t max_protection, vm_inherit_t inheritance) 207 + { 208 + CHECK_TASK_SELF(target_task); 209 + MACH_STUB(); 210 + } 211 + 212 + kern_return_t vm_wire(host_priv_t host, vm_task_t target_task, void* address, vm_size_t size, vm_prot_t wired_access) 213 + { 214 + CHECK_TASK_SELF(target_task); 215 + MACH_STUB(); 216 + }
+48
libmac/kernel-mach/vm.h
··· 1 + #ifndef MACH_VM_H 2 + #define MACH_VM_H 3 + #include "task.h" 4 + #include "host.h" 5 + #include <mach/kern_return.h> 6 + #include <mach/vm_attributes.h> 7 + #include <mach/vm_sync.h> 8 + #include <mach/vm_behavior.h> 9 + #include <mach/vm_prot.h> 10 + #include <mach/vm_inherit.h> 11 + #include <mach/vm_region.h> 12 + #include <mach/vm_types.h> 13 + #include <mach/memory_object_types.h> 14 + 15 + extern "C" 16 + { 17 + 18 + typedef darwin_task_t* vm_task_t; 19 + 20 + kern_return_t vm_msync(vm_task_t target_task, void* addr, vm_size_t size, vm_sync_t in_flags); 21 + kern_return_t vm_allocate(vm_task_t target_task, void** addr, vm_size_t size, boolean_t anywhere); 22 + kern_return_t vm_deallocate(vm_task_t target_task, void* addr, vm_size_t size); 23 + kern_return_t vm_copy(vm_task_t target_task, const void* source_address, vm_size_t count, void* dest_address); 24 + kern_return_t vm_write(vm_task_t target_task, void* address, const void* data, vm_size_t data_count); 25 + kern_return_t vm_behavior_set (vm_task_t target_task, void* address, vm_size_t size, vm_behavior_t behavior); 26 + kern_return_t vm_inherit (vm_task_t target_task, void* address, vm_size_t size, vm_inherit_t new_inheritance); 27 + kern_return_t vm_machine_attribute(vm_task_t target_task, void* address, vm_size_t size, vm_machine_attribute_t attribute, vm_machine_attribute_val_t value); 28 + 29 + kern_return_t vm_map(vm_task_t target_task, void* address, vm_size_t size, void* mask, boolean_t anywhere, memory_object_t memory_object, vm_offset_t offset, 30 + boolean_t copy, vm_prot_t cur_protection, vm_prot_t max_protection, vm_inherit_t inheritance); 31 + 32 + kern_return_t vm_protect(vm_task_t target_task, void* address, vm_size_t size, boolean_t set_maximum, vm_prot_t new_protection); 33 + 34 + kern_return_t vm_read(vm_task_t target_task, const void* address, vm_size_t size, void** data_out, natural_t* data_count); 35 + 36 + kern_return_t vm_read_overwrite (vm_task_t target_task, void* address, vm_size_t size, void* data_in, natural_t* data_count); 37 + 38 + kern_return_t vm_region(vm_task_t target_task, void* address, vm_size_t size, vm_region_flavor_t flavor, vm_region_info_t info, mach_msg_type_number_t info_count, memory_object_name_t object_name); 39 + 40 + kern_return_t vm_remap(vm_task_t target_task, void* target_address, vm_size_t size, void* mask, boolean_t anywhere, mach_port_t source_task, void* source_address, boolean_t copy, 41 + vm_prot_t cur_protection, vm_prot_t max_protection, vm_inherit_t inheritance); 42 + 43 + kern_return_t vm_wire(host_priv_t host, vm_task_t target_task, void* address, vm_size_t size, vm_prot_t wired_access); 44 + 45 + 46 + } // extern "C" 47 + 48 + #endif
+7 -25
libmac/mac.c
··· 300 300 return 0; 301 301 } 302 302 303 - void* mach_task_self_; 303 + struct task_t 304 + { 305 + pid_t pid; 306 + }; 307 + 308 + static task_t mach_task_self_static = { getpid(); }; 309 + task_t* mach_task_self_ = &mach_task_self_static; 304 310 305 311 // From /usr/include/mach/host_info.h 306 312 struct __darwin_host_basic_info { ··· 364 370 //abort(); 365 371 return NULL; 366 372 } 367 - 368 373 int mach_port_deallocate() { 369 374 // TODO(hamaji): leak 370 375 //abort(); 371 - return 0; 372 - } 373 - 374 - /* FIXME implement vm_function corectly. 375 - * OznOg Obviosly, all this remain completelly wrong because completely void. 376 - * This functions allow programs to start correctly and usually to run (almost) 377 - * correctly, but the memory managment remains wrong. I do not really have good ideas 378 - * to handle all this without reimplementing the whole memory managment now. Feel free 379 - * to give me some good ideas. 380 - * I do not think implementing vm_allocate vm_deallocate and vm_msync is a priority 381 - * but I guess some programs really need them to work correctly. 382 - */ 383 - int vm_msync(int target_task, void** addr, size_t size, int flags) { 384 - return 0; 385 - } 386 - 387 - int vm_allocate(int target_task, void** addr, size_t size, int flags) { 388 - *addr = calloc(size, 1); 389 - return 0; 390 - } 391 - 392 - int vm_deallocate() { 393 - // TODO(hamaji): munmap, maybe 394 376 return 0; 395 377 } 396 378
+125
libmac/xnu/bsd/i386/_types.h
··· 1 + /* 2 + * Copyright (c) 2000-2003 Apple Computer, 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 _BSD_I386__TYPES_H_ 29 + #define _BSD_I386__TYPES_H_ 30 + 31 + /* 32 + * This header file contains integer types. It's intended to also contain 33 + * flotaing point and other arithmetic types, as needed, later. 34 + */ 35 + 36 + /* Some of these are provided by standard Linux headers */ 37 + 38 + #ifdef __GNUC__ 39 + typedef __signed char __int8_t; 40 + #else 41 + typedef char __int8_t; 42 + #endif 43 + typedef unsigned char __uint8_t; 44 + typedef short __int16_t; 45 + typedef unsigned short __uint16_t; 46 + typedef int __int32_t; 47 + typedef unsigned int __uint32_t; 48 + /* 49 + typedef long long __int64_t; 50 + typedef unsigned long long __uint64_t; 51 + */ 52 + typedef long __darwin_intptr_t; 53 + typedef unsigned int __darwin_natural_t; 54 + 55 + /* 56 + * The rune type below is declared to be an ``int'' instead of the more natural 57 + * ``unsigned long'' or ``long''. Two things are happening here. It is not 58 + * unsigned so that EOF (-1) can be naturally assigned to it and used. Also, 59 + * it looks like 10646 will be a 31 bit standard. This means that if your 60 + * ints cannot hold 32 bits, you will be in trouble. The reason an int was 61 + * chosen over a long is that the is*() and to*() routines take ints (says 62 + * ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it 63 + * here, you lose a bit of ANSI conformance, but your programs will still 64 + * work. 65 + * 66 + * NOTE: rune_t is not covered by ANSI nor other standards, and should not 67 + * be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and 68 + * rune_t must be the same type. Also wint_t must be no narrower than 69 + * wchar_t, and should also be able to hold all members of the largest 70 + * character set plus one extra value (WEOF). wint_t must be at least 16 bits. 71 + */ 72 + 73 + typedef int __darwin_ct_rune_t; /* ct_rune_t */ 74 + 75 + /* 76 + * mbstate_t is an opaque object to keep conversion state, during multibyte 77 + * stream conversions. The content must not be referenced by user programs. 78 + */ 79 + 80 + typedef union { 81 + char __mbstate8[128]; 82 + long long _mbstateL; /* for alignment */ 83 + } __darwin_mbstate_t; 84 + 85 + 86 + /*typedef __mbstate_t __darwin_mbstate_t;*/ 87 + 88 + #if defined(__GNUC__) && defined(__PTRDIFF_TYPE__) 89 + typedef __PTRDIFF_TYPE__ __darwin_ptrdiff_t; /* ptr1 - ptr2 */ 90 + #else 91 + typedef int __darwin_ptrdiff_t; /* ptr1 - ptr2 */ 92 + #endif /* __GNUC__ */ 93 + 94 + #if defined(__GNUC__) && defined(__SIZE_TYPE__) 95 + typedef __SIZE_TYPE__ __darwin_size_t; /* sizeof() */ 96 + #else 97 + typedef unsigned long __darwin_size_t; /* sizeof() */ 98 + #endif 99 + 100 + #if (__GNUC__ > 2) 101 + typedef __builtin_va_list __darwin_va_list; /* va_list */ 102 + #else 103 + typedef void * __darwin_va_list; /* va_list */ 104 + #endif 105 + 106 + #if defined(__GNUC__) && defined(__WCHAR_TYPE__) 107 + typedef __WCHAR_TYPE__ __darwin_wchar_t; /* wchar_t */ 108 + #else 109 + typedef __darwin_ct_rune_t __darwin_wchar_t; /* wchar_t */ 110 + #endif 111 + 112 + typedef __darwin_wchar_t __darwin_rune_t; /* rune_t */ 113 + 114 + #if defined(__GNUC__) && defined(__WINT_TYPE__) 115 + typedef __WINT_TYPE__ __darwin_wint_t; /* wint_t */ 116 + #else 117 + typedef __darwin_ct_rune_t __darwin_wint_t; /* wint_t */ 118 + #endif 119 + 120 + typedef unsigned long __darwin_clock_t; /* clock() */ 121 + typedef __uint32_t __darwin_socklen_t; /* socklen_t (duh) */ 122 + typedef long __darwin_ssize_t; /* byte count or error */ 123 + typedef long __darwin_time_t; /* time() */ 124 + 125 + #endif /* _BSD_I386__TYPES_H_ */
+62
libmac/xnu/bsd/sys/appleapiopts.h
··· 1 + /* 2 + * Copyright (c) 2002 Apple Computer, 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 + 29 + #ifndef __SYS_APPLEAPIOPTS_H__ 30 + #define __SYS_APPLEAPIOPTS_H__ 31 + 32 + 33 + #ifndef __APPLE_API_STANDARD 34 + #define __APPLE_API_STANDARD 35 + #endif /* __APPLE_API_STANDARD */ 36 + 37 + #ifndef __APPLE_API_STABLE 38 + #define __APPLE_API_STABLE 39 + #endif /* __APPLE_API_STABLE */ 40 + 41 + #ifndef __APPLE_API_STRICT_CONFORMANCE 42 + 43 + #ifndef __APPLE_API_EVOLVING 44 + #define __APPLE_API_EVOLVING 45 + #endif /* __APPLE_API_EVOLVING */ 46 + 47 + #ifndef __APPLE_API_UNSTABLE 48 + #define __APPLE_API_UNSTABLE 49 + #endif /* __APPLE_API_UNSTABLE */ 50 + 51 + #ifndef __APPLE_API_PRIVATE 52 + #define __APPLE_API_PRIVATE 53 + #endif /* __APPLE_API_PRIVATE */ 54 + 55 + #ifndef __APPLE_API_OBSOLETE 56 + #define __APPLE_API_OBSOLETE 57 + #endif /* __APPLE_API_OBSOLETE */ 58 + 59 + #endif /* __APPLE_API_STRICT_CONFORMANCE */ 60 + 61 + #endif /* __SYS_APPLEAPIOPTS_H__ */ 62 +
+88
libmac/xnu/mach/boolean.h
··· 1 + /* 2 + * Copyright (c) 2000 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * Mach Operating System 33 + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University 34 + * All Rights Reserved. 35 + * 36 + * Permission to use, copy, modify and distribute this software and its 37 + * documentation is hereby granted, provided that both the copyright 38 + * notice and this permission notice appear in all copies of the 39 + * software, derivative works or modified versions, and any portions 40 + * thereof, and that both notices appear in supporting documentation. 41 + * 42 + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 + * 46 + * Carnegie Mellon requests users of this software to return to 47 + * 48 + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 + * School of Computer Science 50 + * Carnegie Mellon University 51 + * Pittsburgh PA 15213-3890 52 + * 53 + * any improvements or extensions that they make and grant Carnegie Mellon 54 + * the rights to redistribute these changes. 55 + */ 56 + /* 57 + */ 58 + /* 59 + * File: mach/boolean.h 60 + * 61 + * Boolean data type. 62 + * 63 + */ 64 + 65 + #ifndef _MACH_BOOLEAN_H_ 66 + #define _MACH_BOOLEAN_H_ 67 + 68 + /* 69 + * Pick up "boolean_t" type definition 70 + */ 71 + 72 + #ifndef ASSEMBLER 73 + #include <mach/machine/boolean.h> 74 + #endif /* ASSEMBLER */ 75 + 76 + /* 77 + * Define TRUE and FALSE if not defined. 78 + */ 79 + 80 + #ifndef TRUE 81 + #define TRUE 1 82 + #endif /* TRUE */ 83 + 84 + #ifndef FALSE 85 + #define FALSE 0 86 + #endif /* FALSE */ 87 + 88 + #endif /* _MACH_BOOLEAN_H_ */
+74
libmac/xnu/mach/i386/boolean.h
··· 1 + /* 2 + * Copyright (c) 2000-2006 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * Mach Operating System 33 + * Copyright (c) 1991,1990,1989 Carnegie Mellon University 34 + * All Rights Reserved. 35 + * 36 + * Permission to use, copy, modify and distribute this software and its 37 + * documentation is hereby granted, provided that both the copyright 38 + * notice and this permission notice appear in all copies of the 39 + * software, derivative works or modified versions, and any portions 40 + * thereof, and that both notices appear in supporting documentation. 41 + * 42 + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 + * 46 + * Carnegie Mellon requests users of this software to return to 47 + * 48 + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 + * School of Computer Science 50 + * Carnegie Mellon University 51 + * Pittsburgh PA 15213-3890 52 + * 53 + * any improvements or extensions that they make and grant Carnegie Mellon 54 + * the rights to redistribute these changes. 55 + */ 56 + /* 57 + */ 58 + 59 + /* 60 + * File: boolean.h 61 + * 62 + * Boolean type, for I386. 63 + */ 64 + 65 + #ifndef _MACH_I386_BOOLEAN_H_ 66 + #define _MACH_I386_BOOLEAN_H_ 67 + 68 + #if defined(__x86_64__) && !defined(KERNEL) 69 + typedef unsigned int boolean_t; 70 + #else 71 + typedef int boolean_t; 72 + #endif 73 + 74 + #endif /* _MACH_I386_BOOLEAN_H_ */
+74
libmac/xnu/mach/i386/kern_return.h
··· 1 + /* 2 + * Copyright (c) 2000 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * Mach Operating System 33 + * Copyright (c) 1991,1990,1989 Carnegie Mellon University 34 + * All Rights Reserved. 35 + * 36 + * Permission to use, copy, modify and distribute this software and its 37 + * documentation is hereby granted, provided that both the copyright 38 + * notice and this permission notice appear in all copies of the 39 + * software, derivative works or modified versions, and any portions 40 + * thereof, and that both notices appear in supporting documentation. 41 + * 42 + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 + * 46 + * Carnegie Mellon requests users of this software to return to 47 + * 48 + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 + * School of Computer Science 50 + * Carnegie Mellon University 51 + * Pittsburgh PA 15213-3890 52 + * 53 + * any improvements or extensions that they make and grant Carnegie Mellon 54 + * the rights to redistribute these changes. 55 + */ 56 + /* 57 + */ 58 + 59 + /* 60 + * File: kern_return.h 61 + * Author: Avadis Tevanian, Jr., Michael Wayne Young 62 + * Date: 1985 63 + * 64 + * Machine-dependent kernel return definitions. 65 + */ 66 + 67 + #ifndef _MACH_I386_KERN_RETURN_H_ 68 + #define _MACH_I386_KERN_RETURN_H_ 69 + 70 + #ifndef ASSEMBLER 71 + typedef int kern_return_t; 72 + #endif /* ASSEMBLER */ 73 + 74 + #endif /* _MACH_I386_KERN_RETURN_H_ */
+298
libmac/xnu/mach/i386/vm_param.h
··· 1 + /* 2 + * Copyright (c) 2000-2006 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * Mach Operating System 33 + * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University 34 + * All Rights Reserved. 35 + * 36 + * Permission to use, copy, modify and distribute this software and its 37 + * documentation is hereby granted, provided that both the copyright 38 + * notice and this permission notice appear in all copies of the 39 + * software, derivative works or modified versions, and any portions 40 + * thereof, and that both notices appear in supporting documentation. 41 + * 42 + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 + * 46 + * Carnegie Mellon requests users of this software to return to 47 + * 48 + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 + * School of Computer Science 50 + * Carnegie Mellon University 51 + * Pittsburgh PA 15213-3890 52 + * 53 + * any improvements or extensions that they make and grant Carnegie Mellon 54 + * the rights to redistribute these changes. 55 + */ 56 + 57 + /* 58 + * Copyright (c) 1994 The University of Utah and 59 + * the Computer Systems Laboratory at the University of Utah (CSL). 60 + * All rights reserved. 61 + * 62 + * Permission to use, copy, modify and distribute this software is hereby 63 + * granted provided that (1) source code retains these copyright, permission, 64 + * and disclaimer notices, and (2) redistributions including binaries 65 + * reproduce the notices in supporting documentation, and (3) all advertising 66 + * materials mentioning features or use of this software display the following 67 + * acknowledgement: ``This product includes software developed by the 68 + * Computer Systems Laboratory at the University of Utah.'' 69 + * 70 + * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS 71 + * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF 72 + * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 73 + * 74 + * CSL requests users of this software to return to csl-dist@cs.utah.edu any 75 + * improvements that they make and grant CSL redistribution rights. 76 + * 77 + */ 78 + 79 + /* 80 + * File: vm_param.h 81 + * Author: Avadis Tevanian, Jr. 82 + * Date: 1985 83 + * 84 + * I386 machine dependent virtual memory parameters. 85 + * Most of the declarations are preceeded by I386_ (or i386_) 86 + * which is OK because only I386 specific code will be using 87 + * them. 88 + */ 89 + 90 + #ifndef _MACH_I386_VM_PARAM_H_ 91 + #define _MACH_I386_VM_PARAM_H_ 92 + 93 + #define BYTE_SIZE 8 /* byte size in bits */ 94 + 95 + #define I386_PGBYTES 4096 /* bytes per 80386 page */ 96 + #define I386_PGSHIFT 12 /* bitshift for pages */ 97 + 98 + #define PAGE_SIZE I386_PGBYTES 99 + #define PAGE_SHIFT I386_PGSHIFT 100 + #define PAGE_MASK (PAGE_SIZE - 1) 101 + 102 + #define I386_LPGBYTES 2*1024*1024 /* bytes per large page */ 103 + #define I386_LPGSHIFT 21 /* bitshift for large pages */ 104 + #define I386_LPGMASK (I386_LPGBYTES-1) 105 + 106 + /* 107 + * Convert bytes to pages and convert pages to bytes. 108 + * No rounding is used. 109 + */ 110 + 111 + #define i386_btop(x) ((ppnum_t)((x) >> I386_PGSHIFT)) 112 + #define machine_btop(x) i386_btop(x) 113 + #define i386_ptob(x) (((pmap_paddr_t)(x)) << I386_PGSHIFT) 114 + #define machine_ptob(x) i386_ptob(x) 115 + 116 + /* 117 + * Round off or truncate to the nearest page. These will work 118 + * for either addresses or counts. (i.e. 1 byte rounds to 1 page 119 + * bytes. 120 + */ 121 + 122 + #define i386_round_page(x) ((((pmap_paddr_t)(x)) + I386_PGBYTES - 1) & \ 123 + ~(I386_PGBYTES-1)) 124 + #define i386_trunc_page(x) (((pmap_paddr_t)(x)) & ~(I386_PGBYTES-1)) 125 + 126 + 127 + 128 + #define VM_MIN_ADDRESS64 ((user_addr_t) 0x0000000000000000ULL) 129 + /* 130 + * default top of user stack... it grows down from here 131 + */ 132 + #define VM_USRSTACK64 ((user_addr_t) 0x00007FFF5FC00000ULL) 133 + #define VM_DYLD64 ((user_addr_t) 0x00007FFF5FC00000ULL) 134 + #define VM_LIB64_SHR_DATA ((user_addr_t) 0x00007FFF60000000ULL) 135 + #define VM_LIB64_SHR_TEXT ((user_addr_t) 0x00007FFF80000000ULL) 136 + /* 137 + * the end of the usable user address space , for now about 47 bits. 138 + * the 64 bit commpage is past the end of this 139 + */ 140 + #define VM_MAX_PAGE_ADDRESS ((user_addr_t) 0x00007FFFFFE00000ULL) 141 + /* 142 + * canonical end of user address space for limits checking 143 + */ 144 + #define VM_MAX_USER_PAGE_ADDRESS ((user_addr_t)0x00007FFFFFFFF000ULL) 145 + 146 + 147 + /* system-wide values */ 148 + #define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) 0) 149 + #define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) VM_MAX_PAGE_ADDRESS) 150 + 151 + /* process-relative values (all 32-bit legacy only for now) */ 152 + #define VM_MIN_ADDRESS ((vm_offset_t) 0) 153 + #define VM_USRSTACK32 ((vm_offset_t) 0xC0000000) /* ASLR slides stack down by up to 1 MB */ 154 + #define VM_MAX_ADDRESS ((vm_offset_t) 0xFFE00000) 155 + 156 + 157 + #ifdef KERNEL_PRIVATE 158 + 159 + /* Kernel-wide values */ 160 + 161 + #define KB (1024ULL) 162 + #define MB (1024*KB) 163 + #define GB (1024*MB) 164 + 165 + /* 166 + * Maximum physical memory supported. 167 + */ 168 + #define K32_MAXMEM (32*GB) 169 + #define K64_MAXMEM (96*GB) 170 + #if defined(__i386__) 171 + #define KERNEL_MAXMEM K32_MAXMEM 172 + #else 173 + #define KERNEL_MAXMEM K64_MAXMEM 174 + #endif 175 + 176 + /* 177 + * XXX 178 + * The kernel max VM address is limited to 0xFF3FFFFF for now because 179 + * some data structures are explicitly allocated at 0xFF400000 without 180 + * VM's knowledge (see osfmk/i386/locore.s for the allocation of PTmap and co.). 181 + * We can't let VM allocate memory from there. 182 + */ 183 + 184 + #if defined(__i386__) 185 + 186 + #define KERNEL_IMAGE_TO_PHYS(x) (x) 187 + #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0x00001000U) 188 + #define VM_MIN_KERNEL_AND_KEXT_ADDRESS VM_MIN_KERNEL_ADDRESS 189 + #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0xFE7FFFFFU) 190 + 191 + #elif defined(__x86_64__) 192 + 193 + #define KERNEL_IMAGE_TO_PHYS(x) (x) 194 + #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0xFFFFFF8000000000UL) 195 + #define VM_MIN_KERNEL_PAGE ((ppnum_t)0) 196 + #define VM_MIN_KERNEL_AND_KEXT_ADDRESS (VM_MIN_KERNEL_ADDRESS - 0x80000000ULL) 197 + #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0xFFFFFFFFFFFFEFFFUL) 198 + #define VM_MAX_KERNEL_ADDRESS_EFI32 ((vm_offset_t) 0xFFFFFF80FFFFEFFFUL) 199 + #define KEXT_ALLOC_MAX_OFFSET (2 * 1024 * 1024 * 1024UL) 200 + #define KEXT_ALLOC_BASE(x) ((x) - KEXT_ALLOC_MAX_OFFSET) 201 + #define KEXT_ALLOC_SIZE(x) (KEXT_ALLOC_MAX_OFFSET - (x)) 202 + 203 + #define VM_KERNEL_IS_KEXT(_o) \ 204 + (((vm_offset_t)(_o) >= VM_MIN_KERNEL_AND_KEXT_ADDRESS) && \ 205 + ((vm_offset_t)(_o) < VM_MIN_KERNEL_ADDRESS)) 206 + 207 + #else 208 + #error unsupported architecture 209 + #endif 210 + 211 + #define KERNEL_STACK_SIZE (I386_PGBYTES*4) 212 + 213 + #define VM_MAP_MIN_ADDRESS MACH_VM_MIN_ADDRESS 214 + #define VM_MAP_MAX_ADDRESS MACH_VM_MAX_ADDRESS 215 + 216 + /* FIXME - always leave like this? */ 217 + #define INTSTACK_SIZE (I386_PGBYTES*4) 218 + 219 + #ifdef MACH_KERNEL_PRIVATE 220 + 221 + /* For implementing legacy 32-bit interfaces */ 222 + #define VM32_SUPPORT 1 223 + #define VM32_MIN_ADDRESS ((vm32_offset_t) 0) 224 + #define VM32_MAX_ADDRESS ((vm32_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF)) 225 + 226 + /* 227 + * kalloc() parameters: 228 + * 229 + * Historically kalloc's underlying zones were power-of-2 sizes, with a 230 + * KALLOC_MINSIZE of 16 bytes. The allocator ensured that 231 + * (sizeof == alignof) >= 16 for all kalloc allocations. 232 + * 233 + * Today kalloc may use zones with intermediate sizes, constrained by 234 + * KALLOC_MINSIZE and a minimum alignment, expressed by KALLOC_LOG2_MINALIGN. 235 + * 236 + * The common alignment for LP64 is for longs and pointers i.e. 8 bytes. 237 + */ 238 + 239 + #if defined(__i386__) 240 + 241 + #define KALLOC_MINSIZE 16 /* minimum allocation size */ 242 + #define KALLOC_LOG2_MINALIGN 4 /* log2 minimum alignment */ 243 + 244 + #define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0x00000000) 245 + 246 + #define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x00000000U) 247 + #define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x1FFFFFFFU) 248 + 249 + #define NCOPY_WINDOWS 4 250 + 251 + #elif defined(__x86_64__) 252 + 253 + #define KALLOC_MINSIZE 16 /* minimum allocation size */ 254 + #define KALLOC_LOG2_MINALIGN 4 /* log2 minimum alignment */ 255 + 256 + #define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0x00000000) 257 + 258 + #define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0xFFFFFF8000000000UL) 259 + #define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0xFFFFFF801FFFFFFFUL) 260 + 261 + #define NCOPY_WINDOWS 0 262 + 263 + 264 + #else 265 + #error unsupported architecture 266 + #endif 267 + 268 + /* 269 + * Conversion between 80386 pages and VM pages 270 + */ 271 + 272 + #define trunc_i386_to_vm(p) (atop(trunc_page(i386_ptob(p)))) 273 + #define round_i386_to_vm(p) (atop(round_page(i386_ptob(p)))) 274 + #define vm_to_i386(p) (i386_btop(ptoa(p))) 275 + 276 + 277 + #define PMAP_SET_CACHE_ATTR(mem, object, cache_attr, batch_pmap_op) \ 278 + MACRO_BEGIN \ 279 + pmap_set_cache_attributes((mem)->phys_page, (cache_attr)); \ 280 + (object)->set_cache_attr = TRUE; \ 281 + (void) batch_pmap_op; \ 282 + MACRO_END 283 + 284 + #define PMAP_BATCH_SET_CACHE_ATTR(object, user_page_list, cache_attr, num_pages, batch_pmap_op)\ 285 + MACRO_BEGIN \ 286 + (void) user_page_list; \ 287 + (void) num_pages; \ 288 + (void) batch_pmap_op; \ 289 + MACRO_END 290 + 291 + #define IS_USERADDR64_CANONICAL(addr) \ 292 + ((addr) < (VM_MAX_USER_PAGE_ADDRESS + PAGE_SIZE)) 293 + 294 + #endif /* MACH_KERNEL_PRIVATE */ 295 + 296 + #endif /* KERNEL_PRIVATE */ 297 + 298 + #endif /* _MACH_I386_VM_PARAM_H_ */
+157
libmac/xnu/mach/i386/vm_types.h
··· 1 + /* 2 + * Copyright (c) 2000-2006 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * Mach Operating System 33 + * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University 34 + * All Rights Reserved. 35 + * 36 + * Permission to use, copy, modify and distribute this software and its 37 + * documentation is hereby granted, provided that both the copyright 38 + * notice and this permission notice appear in all copies of the 39 + * software, derivative works or modified versions, and any portions 40 + * thereof, and that both notices appear in supporting documentation. 41 + * 42 + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 + * 46 + * Carnegie Mellon requests users of this software to return to 47 + * 48 + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 + * School of Computer Science 50 + * Carnegie Mellon University 51 + * Pittsburgh PA 15213-3890 52 + * 53 + * any improvements or extensions that they make and grant Carnegie Mellon 54 + * the rights to redistribute these changes. 55 + */ 56 + /* 57 + */ 58 + 59 + /* 60 + * File: vm_types.h 61 + * Author: Avadis Tevanian, Jr. 62 + * Date: 1985 63 + * 64 + * Header file for VM data types. I386 version. 65 + */ 66 + 67 + #ifndef _MACH_I386_VM_TYPES_H_ 68 + #define _MACH_I386_VM_TYPES_H_ 69 + 70 + #ifndef ASSEMBLER 71 + 72 + #include <i386/_types.h> 73 + #include <mach/i386/vm_param.h> 74 + #include <stdint.h> 75 + 76 + /* 77 + * natural_t and integer_t are Mach's legacy types for machine- 78 + * independent integer types (unsigned, and signed, respectively). 79 + * Their original purpose was to define other types in a machine/ 80 + * compiler independent way. 81 + * 82 + * They also had an implicit "same size as pointer" characteristic 83 + * to them (i.e. Mach's traditional types are very ILP32 or ILP64 84 + * centric). We support x86 ABIs that do not follow either of 85 + * these models (specifically LP64). Therefore, we had to make a 86 + * choice between making these types scale with pointers or stay 87 + * tied to integers. Because their use is predominantly tied to 88 + * to the size of an integer, we are keeping that association and 89 + * breaking free from pointer size guarantees. 90 + * 91 + * New use of these types is discouraged. 92 + */ 93 + typedef __darwin_natural_t natural_t; 94 + typedef int integer_t; 95 + 96 + /* 97 + * A vm_offset_t is a type-neutral pointer, 98 + * e.g. an offset into a virtual memory space. 99 + */ 100 + #ifdef __LP64__ 101 + typedef uintptr_t vm_offset_t; 102 + #else /* __LP64__ */ 103 + typedef natural_t vm_offset_t; 104 + #endif /* __LP64__ */ 105 + 106 + /* 107 + * A vm_size_t is the proper type for e.g. 108 + * expressing the difference between two 109 + * vm_offset_t entities. 110 + */ 111 + #ifdef __LP64__ 112 + typedef uintptr_t vm_size_t; 113 + #else /* __LP64__ */ 114 + typedef natural_t vm_size_t; 115 + #endif /* __LP64__ */ 116 + 117 + /* 118 + * This new type is independent of a particular vm map's 119 + * implementation size - and represents appropriate types 120 + * for all possible maps. This is used for interfaces 121 + * where the size of the map is not known - or we don't 122 + * want to have to distinguish. 123 + */ 124 + typedef uint64_t mach_vm_address_t; 125 + typedef uint64_t mach_vm_offset_t; 126 + typedef uint64_t mach_vm_size_t; 127 + 128 + typedef uint64_t vm_map_offset_t; 129 + typedef uint64_t vm_map_address_t; 130 + typedef uint64_t vm_map_size_t; 131 + 132 + typedef mach_vm_address_t mach_port_context_t; 133 + 134 + #ifdef MACH_KERNEL_PRIVATE 135 + 136 + #if VM32_SUPPORT 137 + 138 + /* 139 + * These are types used internal to Mach to implement the 140 + * legacy 32-bit VM APIs published by the kernel. 141 + */ 142 + typedef uint32_t vm32_address_t; 143 + typedef uint32_t vm32_offset_t; 144 + typedef uint32_t vm32_size_t; 145 + 146 + #endif /* VM32_SUPPORT */ 147 + 148 + #endif /* MACH_KERNEL_PRIVATE */ 149 + 150 + #endif /* ASSEMBLER */ 151 + 152 + /* 153 + * If composing messages by hand (please do not) 154 + */ 155 + #define MACH_MSG_TYPE_INTEGER_T MACH_MSG_TYPE_INTEGER_32 156 + 157 + #endif /* _MACH_I386_VM_TYPES_H_ */
+322
libmac/xnu/mach/kern_return.h
··· 1 + /* 2 + * Copyright (c) 2000 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * Mach Operating System 33 + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University 34 + * All Rights Reserved. 35 + * 36 + * Permission to use, copy, modify and distribute this software and its 37 + * documentation is hereby granted, provided that both the copyright 38 + * notice and this permission notice appear in all copies of the 39 + * software, derivative works or modified versions, and any portions 40 + * thereof, and that both notices appear in supporting documentation. 41 + * 42 + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 + * 46 + * Carnegie Mellon requests users of this software to return to 47 + * 48 + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 + * School of Computer Science 50 + * Carnegie Mellon University 51 + * Pittsburgh PA 15213-3890 52 + * 53 + * any improvements or extensions that they make and grant Carnegie Mellon 54 + * the rights to redistribute these changes. 55 + */ 56 + /* 57 + */ 58 + /* 59 + * File: h/kern_return.h 60 + * Author: Avadis Tevanian, Jr. 61 + * Date: 1985 62 + * 63 + * Kernel return codes. 64 + * 65 + */ 66 + 67 + #ifndef _MACH_KERN_RETURN_H_ 68 + #define _MACH_KERN_RETURN_H_ 69 + 70 + #include <mach/machine/kern_return.h> 71 + 72 + #define KERN_SUCCESS 0 73 + 74 + #define KERN_INVALID_ADDRESS 1 75 + /* Specified address is not currently valid. 76 + */ 77 + 78 + #define KERN_PROTECTION_FAILURE 2 79 + /* Specified memory is valid, but does not permit the 80 + * required forms of access. 81 + */ 82 + 83 + #define KERN_NO_SPACE 3 84 + /* The address range specified is already in use, or 85 + * no address range of the size specified could be 86 + * found. 87 + */ 88 + 89 + #define KERN_INVALID_ARGUMENT 4 90 + /* The function requested was not applicable to this 91 + * type of argument, or an argument is invalid 92 + */ 93 + 94 + #define KERN_FAILURE 5 95 + /* The function could not be performed. A catch-all. 96 + */ 97 + 98 + #define KERN_RESOURCE_SHORTAGE 6 99 + /* A system resource could not be allocated to fulfill 100 + * this request. This failure may not be permanent. 101 + */ 102 + 103 + #define KERN_NOT_RECEIVER 7 104 + /* The task in question does not hold receive rights 105 + * for the port argument. 106 + */ 107 + 108 + #define KERN_NO_ACCESS 8 109 + /* Bogus access restriction. 110 + */ 111 + 112 + #define KERN_MEMORY_FAILURE 9 113 + /* During a page fault, the target address refers to a 114 + * memory object that has been destroyed. This 115 + * failure is permanent. 116 + */ 117 + 118 + #define KERN_MEMORY_ERROR 10 119 + /* During a page fault, the memory object indicated 120 + * that the data could not be returned. This failure 121 + * may be temporary; future attempts to access this 122 + * same data may succeed, as defined by the memory 123 + * object. 124 + */ 125 + 126 + #define KERN_ALREADY_IN_SET 11 127 + /* The receive right is already a member of the portset. 128 + */ 129 + 130 + #define KERN_NOT_IN_SET 12 131 + /* The receive right is not a member of a port set. 132 + */ 133 + 134 + #define KERN_NAME_EXISTS 13 135 + /* The name already denotes a right in the task. 136 + */ 137 + 138 + #define KERN_ABORTED 14 139 + /* The operation was aborted. Ipc code will 140 + * catch this and reflect it as a message error. 141 + */ 142 + 143 + #define KERN_INVALID_NAME 15 144 + /* The name doesn't denote a right in the task. 145 + */ 146 + 147 + #define KERN_INVALID_TASK 16 148 + /* Target task isn't an active task. 149 + */ 150 + 151 + #define KERN_INVALID_RIGHT 17 152 + /* The name denotes a right, but not an appropriate right. 153 + */ 154 + 155 + #define KERN_INVALID_VALUE 18 156 + /* A blatant range error. 157 + */ 158 + 159 + #define KERN_UREFS_OVERFLOW 19 160 + /* Operation would overflow limit on user-references. 161 + */ 162 + 163 + #define KERN_INVALID_CAPABILITY 20 164 + /* The supplied (port) capability is improper. 165 + */ 166 + 167 + #define KERN_RIGHT_EXISTS 21 168 + /* The task already has send or receive rights 169 + * for the port under another name. 170 + */ 171 + 172 + #define KERN_INVALID_HOST 22 173 + /* Target host isn't actually a host. 174 + */ 175 + 176 + #define KERN_MEMORY_PRESENT 23 177 + /* An attempt was made to supply "precious" data 178 + * for memory that is already present in a 179 + * memory object. 180 + */ 181 + 182 + #define KERN_MEMORY_DATA_MOVED 24 183 + /* A page was requested of a memory manager via 184 + * memory_object_data_request for an object using 185 + * a MEMORY_OBJECT_COPY_CALL strategy, with the 186 + * VM_PROT_WANTS_COPY flag being used to specify 187 + * that the page desired is for a copy of the 188 + * object, and the memory manager has detected 189 + * the page was pushed into a copy of the object 190 + * while the kernel was walking the shadow chain 191 + * from the copy to the object. This error code 192 + * is delivered via memory_object_data_error 193 + * and is handled by the kernel (it forces the 194 + * kernel to restart the fault). It will not be 195 + * seen by users. 196 + */ 197 + 198 + #define KERN_MEMORY_RESTART_COPY 25 199 + /* A strategic copy was attempted of an object 200 + * upon which a quicker copy is now possible. 201 + * The caller should retry the copy using 202 + * vm_object_copy_quickly. This error code 203 + * is seen only by the kernel. 204 + */ 205 + 206 + #define KERN_INVALID_PROCESSOR_SET 26 207 + /* An argument applied to assert processor set privilege 208 + * was not a processor set control port. 209 + */ 210 + 211 + #define KERN_POLICY_LIMIT 27 212 + /* The specified scheduling attributes exceed the thread's 213 + * limits. 214 + */ 215 + 216 + #define KERN_INVALID_POLICY 28 217 + /* The specified scheduling policy is not currently 218 + * enabled for the processor set. 219 + */ 220 + 221 + #define KERN_INVALID_OBJECT 29 222 + /* The external memory manager failed to initialize the 223 + * memory object. 224 + */ 225 + 226 + #define KERN_ALREADY_WAITING 30 227 + /* A thread is attempting to wait for an event for which 228 + * there is already a waiting thread. 229 + */ 230 + 231 + #define KERN_DEFAULT_SET 31 232 + /* An attempt was made to destroy the default processor 233 + * set. 234 + */ 235 + 236 + #define KERN_EXCEPTION_PROTECTED 32 237 + /* An attempt was made to fetch an exception port that is 238 + * protected, or to abort a thread while processing a 239 + * protected exception. 240 + */ 241 + 242 + #define KERN_INVALID_LEDGER 33 243 + /* A ledger was required but not supplied. 244 + */ 245 + 246 + #define KERN_INVALID_MEMORY_CONTROL 34 247 + /* The port was not a memory cache control port. 248 + */ 249 + 250 + #define KERN_INVALID_SECURITY 35 251 + /* An argument supplied to assert security privilege 252 + * was not a host security port. 253 + */ 254 + 255 + #define KERN_NOT_DEPRESSED 36 256 + /* thread_depress_abort was called on a thread which 257 + * was not currently depressed. 258 + */ 259 + 260 + #define KERN_TERMINATED 37 261 + /* Object has been terminated and is no longer available 262 + */ 263 + 264 + #define KERN_LOCK_SET_DESTROYED 38 265 + /* Lock set has been destroyed and is no longer available. 266 + */ 267 + 268 + #define KERN_LOCK_UNSTABLE 39 269 + /* The thread holding the lock terminated before releasing 270 + * the lock 271 + */ 272 + 273 + #define KERN_LOCK_OWNED 40 274 + /* The lock is already owned by another thread 275 + */ 276 + 277 + #define KERN_LOCK_OWNED_SELF 41 278 + /* The lock is already owned by the calling thread 279 + */ 280 + 281 + #define KERN_SEMAPHORE_DESTROYED 42 282 + /* Semaphore has been destroyed and is no longer available. 283 + */ 284 + 285 + #define KERN_RPC_SERVER_TERMINATED 43 286 + /* Return from RPC indicating the target server was 287 + * terminated before it successfully replied 288 + */ 289 + 290 + #define KERN_RPC_TERMINATE_ORPHAN 44 291 + /* Terminate an orphaned activation. 292 + */ 293 + 294 + #define KERN_RPC_CONTINUE_ORPHAN 45 295 + /* Allow an orphaned activation to continue executing. 296 + */ 297 + 298 + #define KERN_NOT_SUPPORTED 46 299 + /* Empty thread activation (No thread linked to it) 300 + */ 301 + 302 + #define KERN_NODE_DOWN 47 303 + /* Remote node down or inaccessible. 304 + */ 305 + 306 + #define KERN_NOT_WAITING 48 307 + /* A signalled thread was not actually waiting. */ 308 + 309 + #define KERN_OPERATION_TIMED_OUT 49 310 + /* Some thread-oriented operation (semaphore_wait) timed out 311 + */ 312 + 313 + #define KERN_CODESIGN_ERROR 50 314 + /* During a page fault, indicates that the page was rejected 315 + * as a result of a signature check. 316 + */ 317 + 318 + #define KERN_RETURN_MAX 0x100 319 + /* Maximum return value allowable 320 + */ 321 + 322 + #endif /* _MACH_KERN_RETURN_H_ */
+38
libmac/xnu/mach/machine/boolean.h
··· 1 + /* 2 + * Copyright (c) 2000-2007 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 + 29 + #ifndef _MACH_MACHINE_BOOLEAN_H_ 30 + #define _MACH_MACHINE_BOOLEAN_H_ 31 + 32 + #if defined (__i386__) || defined(__x86_64__) 33 + #include "mach/i386/boolean.h" 34 + #else 35 + #error architecture not supported 36 + #endif 37 + 38 + #endif /* _MACH_MACHINE_BOOLEAN_H_ */
+38
libmac/xnu/mach/machine/kern_return.h
··· 1 + /* 2 + * Copyright (c) 2000-2007 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 + 29 + #ifndef _MACH_MACHINE_KERN_RETURN_H_ 30 + #define _MACH_MACHINE_KERN_RETURN_H_ 31 + 32 + #if defined (__i386__) || defined(__x86_64__) 33 + #include "mach/i386/kern_return.h" 34 + #else 35 + #error architecture not supported 36 + #endif 37 + 38 + #endif /* _MACH_MACHINE_KERN_RETURN_H_ */
+38
libmac/xnu/mach/machine/vm_param.h
··· 1 + /* 2 + * Copyright (c) 2000-2007 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 + 29 + #ifndef _MACH_MACHINE_VM_PARAM_H_ 30 + #define _MACH_MACHINE_VM_PARAM_H_ 31 + 32 + #if defined (__i386__) || defined(__x86_64__) 33 + #include "mach/i386/vm_param.h" 34 + #else 35 + #error architecture not supported 36 + #endif 37 + 38 + #endif /* _MACH_MACHINE_VM_PARAM_H_ */
+38
libmac/xnu/mach/machine/vm_types.h
··· 1 + /* 2 + * Copyright (c) 2000-2007 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 + 29 + #ifndef _MACH_MACHINE_VM_TYPES_H_ 30 + #define _MACH_MACHINE_VM_TYPES_H_ 31 + 32 + #if defined (__i386__) || defined(__x86_64__) 33 + #include "mach/i386/vm_types.h" 34 + #else 35 + #error architecture not supported 36 + #endif 37 + 38 + #endif /* _MACH_MACHINE_VM_TYPES_H_ */
+228
libmac/xnu/mach/memory_object.h
··· 1 + /* 2 + * Copyright (c) 2000-2005 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * Mach Operating System 33 + * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University 34 + * All Rights Reserved. 35 + * 36 + * Permission to use, copy, modify and distribute this software and its 37 + * documentation is hereby granted, provided that both the copyright 38 + * notice and this permission notice appear in all copies of the 39 + * software, derivative works or modified versions, and any portions 40 + * thereof, and that both notices appear in supporting documentation. 41 + * 42 + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 + * 46 + * Carnegie Mellon requests users of this software to return to 47 + * 48 + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 + * School of Computer Science 50 + * Carnegie Mellon University 51 + * Pittsburgh PA 15213-3890 52 + * 53 + * any improvements or extensions that they make and grant Carnegie Mellon 54 + * the rights to redistribute these changes. 55 + */ 56 + /* 57 + */ 58 + /* 59 + * File: memory_object.h 60 + * Author: Michael Wayne Young 61 + * 62 + * External memory management interface definition. 63 + */ 64 + 65 + #ifndef _MACH_MEMORY_OBJECT_H_ 66 + #define _MACH_MEMORY_OBJECT_H_ 67 + 68 + /* 69 + * User-visible types used in the external memory 70 + * management interface: 71 + */ 72 + 73 + #include <mach/port.h> 74 + #include <mach/message.h> 75 + #include <mach/machine/vm_types.h> 76 + 77 + typedef mach_port_t memory_object_t; 78 + /* A memory object ... */ 79 + /* Used by the kernel to retrieve */ 80 + /* or store data */ 81 + 82 + typedef mach_port_t memory_object_control_t; 83 + /* Provided to a memory manager; ... */ 84 + /* used to control a memory object */ 85 + 86 + typedef mach_port_t memory_object_name_t; 87 + /* Used to describe the memory ... */ 88 + /* object in vm_regions() calls */ 89 + 90 + typedef mach_port_t memory_object_rep_t; 91 + /* Per-client handle for mem object */ 92 + /* Used by user programs to specify */ 93 + /* the object to map */ 94 + 95 + typedef int memory_object_copy_strategy_t; 96 + /* How memory manager handles copy: */ 97 + #define MEMORY_OBJECT_COPY_NONE 0 98 + /* ... No special support */ 99 + #define MEMORY_OBJECT_COPY_CALL 1 100 + /* ... Make call on memory manager */ 101 + #define MEMORY_OBJECT_COPY_DELAY 2 102 + /* ... Memory manager doesn't 103 + * change data externally. 104 + */ 105 + #define MEMORY_OBJECT_COPY_TEMPORARY 3 106 + /* ... Memory manager doesn't 107 + * change data externally, and 108 + * doesn't need to see changes. 109 + */ 110 + #define MEMORY_OBJECT_COPY_SYMMETRIC 4 111 + /* ... Memory manager doesn't 112 + * change data externally, 113 + * doesn't need to see changes, 114 + * and object will not be 115 + * multiply mapped. 116 + * 117 + * XXX 118 + * Not yet safe for non-kernel use. 119 + */ 120 + 121 + #define MEMORY_OBJECT_COPY_INVALID 5 122 + /* ... An invalid copy strategy, 123 + * for external objects which 124 + * have not been initialized. 125 + * Allows copy_strategy to be 126 + * examined without also 127 + * examining pager_ready and 128 + * internal. 129 + */ 130 + 131 + typedef int memory_object_return_t; 132 + /* Which pages to return to manager 133 + this time (lock_request) */ 134 + #define MEMORY_OBJECT_RETURN_NONE 0 135 + /* ... don't return any. */ 136 + #define MEMORY_OBJECT_RETURN_DIRTY 1 137 + /* ... only dirty pages. */ 138 + #define MEMORY_OBJECT_RETURN_ALL 2 139 + /* ... dirty and precious pages. */ 140 + #define MEMORY_OBJECT_RETURN_ANYTHING 3 141 + /* ... any resident page. */ 142 + 143 + #define MEMORY_OBJECT_NULL MACH_PORT_NULL 144 + 145 + 146 + /* 147 + * Types for the memory object flavor interfaces 148 + */ 149 + 150 + #define MEMORY_OBJECT_INFO_MAX (1024) 151 + typedef int *memory_object_info_t; 152 + typedef int memory_object_flavor_t; 153 + typedef int memory_object_info_data_t[MEMORY_OBJECT_INFO_MAX]; 154 + 155 + 156 + #define OLD_MEMORY_OBJECT_BEHAVIOR_INFO 10 157 + #define MEMORY_OBJECT_PERFORMANCE_INFO 11 158 + #define OLD_MEMORY_OBJECT_ATTRIBUTE_INFO 12 159 + #define MEMORY_OBJECT_ATTRIBUTE_INFO 14 160 + #define MEMORY_OBJECT_BEHAVIOR_INFO 15 161 + 162 + 163 + struct old_memory_object_behave_info { 164 + memory_object_copy_strategy_t copy_strategy; 165 + boolean_t temporary; 166 + boolean_t invalidate; 167 + }; 168 + 169 + struct memory_object_perf_info { 170 + memory_object_cluster_size_t cluster_size; 171 + boolean_t may_cache; 172 + }; 173 + 174 + struct old_memory_object_attr_info { /* old attr list */ 175 + boolean_t object_ready; 176 + boolean_t may_cache; 177 + memory_object_copy_strategy_t copy_strategy; 178 + }; 179 + 180 + struct memory_object_attr_info { 181 + memory_object_copy_strategy_t copy_strategy; 182 + memory_object_cluster_size_t cluster_size; 183 + boolean_t may_cache_object; 184 + boolean_t temporary; 185 + }; 186 + 187 + struct memory_object_behave_info { 188 + memory_object_copy_strategy_t copy_strategy; 189 + boolean_t temporary; 190 + boolean_t invalidate; 191 + boolean_t silent_overwrite; 192 + boolean_t advisory_pageout; 193 + }; 194 + 195 + typedef struct old_memory_object_behave_info *old_memory_object_behave_info_t; 196 + typedef struct old_memory_object_behave_info old_memory_object_behave_info_data_t; 197 + 198 + typedef struct memory_object_behave_info *memory_object_behave_info_t; 199 + typedef struct memory_object_behave_info memory_object_behave_info_data_t; 200 + 201 + typedef struct memory_object_perf_info *memory_object_perf_info_t; 202 + typedef struct memory_object_perf_info memory_object_perf_info_data_t; 203 + 204 + typedef struct old_memory_object_attr_info *old_memory_object_attr_info_t; 205 + typedef struct old_memory_object_attr_info old_memory_object_attr_info_data_t; 206 + 207 + typedef struct memory_object_attr_info *memory_object_attr_info_t; 208 + typedef struct memory_object_attr_info memory_object_attr_info_data_t; 209 + 210 + #define OLD_MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \ 211 + (sizeof(old_memory_object_behave_info_data_t)/sizeof(int))) 212 + #define MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \ 213 + (sizeof(memory_object_behave_info_data_t)/sizeof(int))) 214 + #define MEMORY_OBJECT_PERF_INFO_COUNT ((mach_msg_type_number_t) \ 215 + (sizeof(memory_object_perf_info_data_t)/sizeof(int))) 216 + #define OLD_MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \ 217 + (sizeof(old_memory_object_attr_info_data_t)/sizeof(int))) 218 + #define MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \ 219 + (sizeof(memory_object_attr_info_data_t)/sizeof(int))) 220 + 221 + #define invalid_memory_object_flavor(f) \ 222 + (f != MEMORY_OBJECT_ATTRIBUTE_INFO && \ 223 + f != MEMORY_OBJECT_PERFORMANCE_INFO && \ 224 + f != OLD_MEMORY_OBJECT_BEHAVIOR_INFO && \ 225 + f != MEMORY_OBJECT_BEHAVIOR_INFO && \ 226 + f != OLD_MEMORY_OBJECT_ATTRIBUTE_INFO) 227 + 228 + #endif /* _MACH_MEMORY_OBJECT_H_ */
+707
libmac/xnu/mach/memory_object_types.h
··· 1 + /* 2 + * Copyright (c) 2000-2006 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * Mach Operating System 33 + * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University 34 + * All Rights Reserved. 35 + * 36 + * Permission to use, copy, modify and distribute this software and its 37 + * documentation is hereby granted, provided that both the copyright 38 + * notice and this permission notice appear in all copies of the 39 + * software, derivative works or modified versions, and any portions 40 + * thereof, and that both notices appear in supporting documentation. 41 + * 42 + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 + * 46 + * Carnegie Mellon requests users of this software to return to 47 + * 48 + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 + * School of Computer Science 50 + * Carnegie Mellon University 51 + * Pittsburgh PA 15213-3890 52 + * 53 + * any improvements or extensions that they make and grant Carnegie Mellon 54 + * the rights to redistribute these changes. 55 + */ 56 + /* 57 + */ 58 + /* 59 + * File: memory_object.h 60 + * Author: Michael Wayne Young 61 + * 62 + * External memory management interface definition. 63 + */ 64 + 65 + #ifndef _MACH_MEMORY_OBJECT_TYPES_H_ 66 + #define _MACH_MEMORY_OBJECT_TYPES_H_ 67 + 68 + /* 69 + * User-visible types used in the external memory 70 + * management interface: 71 + */ 72 + 73 + #include <mach/port.h> 74 + #include <mach/message.h> 75 + #include <mach/vm_prot.h> 76 + #include <mach/vm_sync.h> 77 + #include <mach/vm_types.h> 78 + #include <mach/machine/vm_types.h> 79 + 80 + #include <sys/cdefs.h> 81 + 82 + #define VM_64_BIT_DATA_OBJECTS 83 + 84 + typedef unsigned long long memory_object_offset_t; 85 + typedef unsigned long long memory_object_size_t; 86 + typedef natural_t memory_object_cluster_size_t; 87 + typedef natural_t * memory_object_fault_info_t; 88 + 89 + typedef unsigned long long vm_object_id_t; 90 + 91 + 92 + /* 93 + * Temporary until real EMMI version gets re-implemented 94 + */ 95 + 96 + #ifdef KERNEL_PRIVATE 97 + 98 + struct memory_object_pager_ops; /* forward declaration */ 99 + 100 + typedef struct memory_object { 101 + unsigned int _pad1; /* struct ipc_object_header */ 102 + #ifdef __LP64__ 103 + unsigned int _pad2; /* pad to natural boundary */ 104 + #endif 105 + const struct memory_object_pager_ops *mo_pager_ops; 106 + } *memory_object_t; 107 + 108 + typedef struct memory_object_control { 109 + unsigned int moc_ikot; /* struct ipc_object_header */ 110 + #ifdef __LP64__ 111 + unsigned int _pad; /* pad to natural boundary */ 112 + #endif 113 + struct vm_object *moc_object; 114 + } *memory_object_control_t; 115 + 116 + typedef const struct memory_object_pager_ops { 117 + void (*memory_object_reference)( 118 + memory_object_t mem_obj); 119 + void (*memory_object_deallocate)( 120 + memory_object_t mem_obj); 121 + kern_return_t (*memory_object_init)( 122 + memory_object_t mem_obj, 123 + memory_object_control_t mem_control, 124 + memory_object_cluster_size_t size); 125 + kern_return_t (*memory_object_terminate)( 126 + memory_object_t mem_obj); 127 + kern_return_t (*memory_object_data_request)( 128 + memory_object_t mem_obj, 129 + memory_object_offset_t offset, 130 + memory_object_cluster_size_t length, 131 + vm_prot_t desired_access, 132 + memory_object_fault_info_t fault_info); 133 + kern_return_t (*memory_object_data_return)( 134 + memory_object_t mem_obj, 135 + memory_object_offset_t offset, 136 + memory_object_cluster_size_t size, 137 + memory_object_offset_t *resid_offset, 138 + int *io_error, 139 + boolean_t dirty, 140 + boolean_t kernel_copy, 141 + int upl_flags); 142 + kern_return_t (*memory_object_data_initialize)( 143 + memory_object_t mem_obj, 144 + memory_object_offset_t offset, 145 + memory_object_cluster_size_t size); 146 + kern_return_t (*memory_object_data_unlock)( 147 + memory_object_t mem_obj, 148 + memory_object_offset_t offset, 149 + memory_object_size_t size, 150 + vm_prot_t desired_access); 151 + kern_return_t (*memory_object_synchronize)( 152 + memory_object_t mem_obj, 153 + memory_object_offset_t offset, 154 + memory_object_size_t size, 155 + vm_sync_t sync_flags); 156 + kern_return_t (*memory_object_map)( 157 + memory_object_t mem_obj, 158 + vm_prot_t prot); 159 + kern_return_t (*memory_object_last_unmap)( 160 + memory_object_t mem_obj); 161 + kern_return_t (*memory_object_data_reclaim)( 162 + memory_object_t mem_obj, 163 + boolean_t reclaim_backing_store); 164 + const char *memory_object_pager_name; 165 + } * memory_object_pager_ops_t; 166 + 167 + #else /* KERNEL_PRIVATE */ 168 + 169 + typedef mach_port_t memory_object_t; 170 + typedef mach_port_t memory_object_control_t; 171 + 172 + #endif /* KERNEL_PRIVATE */ 173 + 174 + typedef memory_object_t *memory_object_array_t; 175 + /* A memory object ... */ 176 + /* Used by the kernel to retrieve */ 177 + /* or store data */ 178 + 179 + typedef mach_port_t memory_object_name_t; 180 + /* Used to describe the memory ... */ 181 + /* object in vm_regions() calls */ 182 + 183 + typedef mach_port_t memory_object_default_t; 184 + /* Registered with the host ... */ 185 + /* for creating new internal objects */ 186 + 187 + #define MEMORY_OBJECT_NULL ((memory_object_t) 0) 188 + #define MEMORY_OBJECT_CONTROL_NULL ((memory_object_control_t) 0) 189 + #define MEMORY_OBJECT_NAME_NULL ((memory_object_name_t) 0) 190 + #define MEMORY_OBJECT_DEFAULT_NULL ((memory_object_default_t) 0) 191 + 192 + 193 + typedef int memory_object_copy_strategy_t; 194 + /* How memory manager handles copy: */ 195 + #define MEMORY_OBJECT_COPY_NONE 0 196 + /* ... No special support */ 197 + #define MEMORY_OBJECT_COPY_CALL 1 198 + /* ... Make call on memory manager */ 199 + #define MEMORY_OBJECT_COPY_DELAY 2 200 + /* ... Memory manager doesn't 201 + * change data externally. 202 + */ 203 + #define MEMORY_OBJECT_COPY_TEMPORARY 3 204 + /* ... Memory manager doesn't 205 + * change data externally, and 206 + * doesn't need to see changes. 207 + */ 208 + #define MEMORY_OBJECT_COPY_SYMMETRIC 4 209 + /* ... Memory manager doesn't 210 + * change data externally, 211 + * doesn't need to see changes, 212 + * and object will not be 213 + * multiply mapped. 214 + * 215 + * XXX 216 + * Not yet safe for non-kernel use. 217 + */ 218 + 219 + #define MEMORY_OBJECT_COPY_INVALID 5 220 + /* ... An invalid copy strategy, 221 + * for external objects which 222 + * have not been initialized. 223 + * Allows copy_strategy to be 224 + * examined without also 225 + * examining pager_ready and 226 + * internal. 227 + */ 228 + 229 + typedef int memory_object_return_t; 230 + /* Which pages to return to manager 231 + this time (lock_request) */ 232 + #define MEMORY_OBJECT_RETURN_NONE 0 233 + /* ... don't return any. */ 234 + #define MEMORY_OBJECT_RETURN_DIRTY 1 235 + /* ... only dirty pages. */ 236 + #define MEMORY_OBJECT_RETURN_ALL 2 237 + /* ... dirty and precious pages. */ 238 + #define MEMORY_OBJECT_RETURN_ANYTHING 3 239 + /* ... any resident page. */ 240 + 241 + /* 242 + * Data lock request flags 243 + */ 244 + 245 + #define MEMORY_OBJECT_DATA_FLUSH 0x1 246 + #define MEMORY_OBJECT_DATA_NO_CHANGE 0x2 247 + #define MEMORY_OBJECT_DATA_PURGE 0x4 248 + #define MEMORY_OBJECT_COPY_SYNC 0x8 249 + #define MEMORY_OBJECT_DATA_SYNC 0x10 250 + #define MEMORY_OBJECT_IO_SYNC 0x20 251 + #define MEMORY_OBJECT_DATA_FLUSH_ALL 0x40 252 + 253 + /* 254 + * Types for the memory object flavor interfaces 255 + */ 256 + 257 + #define MEMORY_OBJECT_INFO_MAX (1024) 258 + typedef int *memory_object_info_t; 259 + typedef int memory_object_flavor_t; 260 + typedef int memory_object_info_data_t[MEMORY_OBJECT_INFO_MAX]; 261 + 262 + 263 + #define MEMORY_OBJECT_PERFORMANCE_INFO 11 264 + #define MEMORY_OBJECT_ATTRIBUTE_INFO 14 265 + #define MEMORY_OBJECT_BEHAVIOR_INFO 15 266 + 267 + #ifdef PRIVATE 268 + 269 + #define OLD_MEMORY_OBJECT_BEHAVIOR_INFO 10 270 + #define OLD_MEMORY_OBJECT_ATTRIBUTE_INFO 12 271 + 272 + struct old_memory_object_behave_info { 273 + memory_object_copy_strategy_t copy_strategy; 274 + boolean_t temporary; 275 + boolean_t invalidate; 276 + }; 277 + 278 + struct old_memory_object_attr_info { /* old attr list */ 279 + boolean_t object_ready; 280 + boolean_t may_cache; 281 + memory_object_copy_strategy_t copy_strategy; 282 + }; 283 + 284 + typedef struct old_memory_object_behave_info *old_memory_object_behave_info_t; 285 + typedef struct old_memory_object_behave_info old_memory_object_behave_info_data_t; 286 + typedef struct old_memory_object_attr_info *old_memory_object_attr_info_t; 287 + typedef struct old_memory_object_attr_info old_memory_object_attr_info_data_t; 288 + 289 + #define OLD_MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \ 290 + (sizeof(old_memory_object_behave_info_data_t)/sizeof(int))) 291 + #define OLD_MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \ 292 + (sizeof(old_memory_object_attr_info_data_t)/sizeof(int))) 293 + 294 + #ifdef KERNEL 295 + 296 + __BEGIN_DECLS 297 + extern void memory_object_reference(memory_object_t object); 298 + extern void memory_object_deallocate(memory_object_t object); 299 + 300 + extern void memory_object_default_reference(memory_object_default_t); 301 + extern void memory_object_default_deallocate(memory_object_default_t); 302 + 303 + extern void memory_object_control_reference(memory_object_control_t control); 304 + extern void memory_object_control_deallocate(memory_object_control_t control); 305 + extern int memory_object_control_uiomove(memory_object_control_t, memory_object_offset_t, void *, int, int, int, int); 306 + __END_DECLS 307 + 308 + #endif /* KERNEL */ 309 + 310 + #endif /* PRIVATE */ 311 + 312 + struct memory_object_perf_info { 313 + memory_object_cluster_size_t cluster_size; 314 + boolean_t may_cache; 315 + }; 316 + 317 + struct memory_object_attr_info { 318 + memory_object_copy_strategy_t copy_strategy; 319 + memory_object_cluster_size_t cluster_size; 320 + boolean_t may_cache_object; 321 + boolean_t temporary; 322 + }; 323 + 324 + struct memory_object_behave_info { 325 + memory_object_copy_strategy_t copy_strategy; 326 + boolean_t temporary; 327 + boolean_t invalidate; 328 + boolean_t silent_overwrite; 329 + boolean_t advisory_pageout; 330 + }; 331 + 332 + 333 + typedef struct memory_object_behave_info *memory_object_behave_info_t; 334 + typedef struct memory_object_behave_info memory_object_behave_info_data_t; 335 + 336 + typedef struct memory_object_perf_info *memory_object_perf_info_t; 337 + typedef struct memory_object_perf_info memory_object_perf_info_data_t; 338 + 339 + typedef struct memory_object_attr_info *memory_object_attr_info_t; 340 + typedef struct memory_object_attr_info memory_object_attr_info_data_t; 341 + 342 + #define MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \ 343 + (sizeof(memory_object_behave_info_data_t)/sizeof(int))) 344 + #define MEMORY_OBJECT_PERF_INFO_COUNT ((mach_msg_type_number_t) \ 345 + (sizeof(memory_object_perf_info_data_t)/sizeof(int))) 346 + #define MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \ 347 + (sizeof(memory_object_attr_info_data_t)/sizeof(int))) 348 + 349 + #define invalid_memory_object_flavor(f) \ 350 + (f != MEMORY_OBJECT_ATTRIBUTE_INFO && \ 351 + f != MEMORY_OBJECT_PERFORMANCE_INFO && \ 352 + f != OLD_MEMORY_OBJECT_BEHAVIOR_INFO && \ 353 + f != MEMORY_OBJECT_BEHAVIOR_INFO && \ 354 + f != OLD_MEMORY_OBJECT_ATTRIBUTE_INFO) 355 + 356 + 357 + /* 358 + * Used to support options on memory_object_release_name call 359 + */ 360 + #define MEMORY_OBJECT_TERMINATE_IDLE 0x1 361 + #define MEMORY_OBJECT_RESPECT_CACHE 0x2 362 + #define MEMORY_OBJECT_RELEASE_NO_OP 0x4 363 + 364 + 365 + /* named entry processor mapping options */ 366 + /* enumerated */ 367 + #define MAP_MEM_NOOP 0 368 + #define MAP_MEM_COPYBACK 1 369 + #define MAP_MEM_IO 2 370 + #define MAP_MEM_WTHRU 3 371 + #define MAP_MEM_WCOMB 4 /* Write combining mode */ 372 + /* aka store gather */ 373 + #define MAP_MEM_INNERWBACK 5 374 + 375 + #define GET_MAP_MEM(flags) \ 376 + ((((unsigned int)(flags)) >> 24) & 0xFF) 377 + 378 + #define SET_MAP_MEM(caching, flags) \ 379 + ((flags) = ((((unsigned int)(caching)) << 24) \ 380 + & 0xFF000000) | ((flags) & 0xFFFFFF)); 381 + 382 + /* leave room for vm_prot bits */ 383 + #define MAP_MEM_ONLY 0x010000 /* change processor caching */ 384 + #define MAP_MEM_NAMED_CREATE 0x020000 /* create extant object */ 385 + #define MAP_MEM_PURGABLE 0x040000 /* create a purgable VM object */ 386 + #define MAP_MEM_NAMED_REUSE 0x080000 /* reuse provided entry if identical */ 387 + 388 + #ifdef KERNEL 389 + 390 + /* 391 + * Universal Page List data structures 392 + * 393 + * A UPL describes a bounded set of physical pages 394 + * associated with some range of an object or map 395 + * and a snapshot of the attributes associated with 396 + * each of those pages. 397 + */ 398 + #ifdef PRIVATE 399 + #define MAX_UPL_TRANSFER 256 400 + #define MAX_UPL_SIZE 8192 401 + 402 + struct upl_page_info { 403 + ppnum_t phys_addr; /* physical page index number */ 404 + unsigned int 405 + #ifdef XNU_KERNEL_PRIVATE 406 + pageout:1, /* page is to be removed on commit */ 407 + absent:1, /* No valid data in this page */ 408 + dirty:1, /* Page must be cleaned (O) */ 409 + precious:1, /* must be cleaned, we have only copy */ 410 + device:1, /* no page data, mapped dev memory */ 411 + speculative:1, /* page is valid, but not yet accessed */ 412 + cs_validated:1, /* CODE SIGNING: page was validated */ 413 + cs_tainted:1, /* CODE SIGNING: page is tainted */ 414 + needed:1, /* page should be left in cache on abort */ 415 + :0; /* force to long boundary */ 416 + #else 417 + opaque; /* use upl_page_xxx() accessor funcs */ 418 + #endif /* XNU_KERNEL_PRIVATE */ 419 + }; 420 + 421 + #else 422 + 423 + struct upl_page_info { 424 + unsigned int opaque[2]; /* use upl_page_xxx() accessor funcs */ 425 + }; 426 + 427 + #endif /* PRIVATE */ 428 + 429 + typedef struct upl_page_info upl_page_info_t; 430 + typedef upl_page_info_t *upl_page_info_array_t; 431 + typedef upl_page_info_array_t upl_page_list_ptr_t; 432 + 433 + typedef uint32_t upl_offset_t; /* page-aligned byte offset */ 434 + typedef uint32_t upl_size_t; /* page-aligned byte size */ 435 + 436 + /* upl invocation flags */ 437 + /* top nibble is used by super upl */ 438 + 439 + #define UPL_FLAGS_NONE 0x00000000 440 + #define UPL_COPYOUT_FROM 0x00000001 441 + #define UPL_PRECIOUS 0x00000002 442 + #define UPL_NO_SYNC 0x00000004 443 + #define UPL_CLEAN_IN_PLACE 0x00000008 444 + #define UPL_NOBLOCK 0x00000010 445 + #define UPL_RET_ONLY_DIRTY 0x00000020 446 + #define UPL_SET_INTERNAL 0x00000040 447 + #define UPL_QUERY_OBJECT_TYPE 0x00000080 448 + #define UPL_RET_ONLY_ABSENT 0x00000100 /* used only for COPY_FROM = FALSE */ 449 + #define UPL_FILE_IO 0x00000200 450 + #define UPL_SET_LITE 0x00000400 451 + #define UPL_SET_INTERRUPTIBLE 0x00000800 452 + #define UPL_SET_IO_WIRE 0x00001000 453 + #define UPL_FOR_PAGEOUT 0x00002000 454 + #define UPL_WILL_BE_DUMPED 0x00004000 455 + #define UPL_FORCE_DATA_SYNC 0x00008000 456 + /* continued after the ticket bits... */ 457 + 458 + #define UPL_PAGE_TICKET_MASK 0x000F0000 459 + #define UPL_PAGE_TICKET_SHIFT 16 460 + 461 + /* ... flags resume here */ 462 + #define UPL_BLOCK_ACCESS 0x00100000 463 + #define UPL_ENCRYPT 0x00200000 464 + #define UPL_NOZEROFILL 0x00400000 465 + #define UPL_WILL_MODIFY 0x00800000 /* caller will modify the pages */ 466 + 467 + #define UPL_NEED_32BIT_ADDR 0x01000000 468 + #define UPL_UBC_MSYNC 0x02000000 469 + #define UPL_UBC_PAGEOUT 0x04000000 470 + #define UPL_UBC_PAGEIN 0x08000000 471 + #define UPL_REQUEST_SET_DIRTY 0x10000000 472 + 473 + /* UPL flags known by this kernel */ 474 + #define UPL_VALID_FLAGS 0x1FFFFFFF 475 + 476 + 477 + /* upl abort error flags */ 478 + #define UPL_ABORT_RESTART 0x1 479 + #define UPL_ABORT_UNAVAILABLE 0x2 480 + #define UPL_ABORT_ERROR 0x4 481 + #define UPL_ABORT_FREE_ON_EMPTY 0x8 /* only implemented in wrappers */ 482 + #define UPL_ABORT_DUMP_PAGES 0x10 483 + #define UPL_ABORT_NOTIFY_EMPTY 0x20 484 + /* deprecated: #define UPL_ABORT_ALLOW_ACCESS 0x40 */ 485 + #define UPL_ABORT_REFERENCE 0x80 486 + 487 + /* upl pages check flags */ 488 + #define UPL_CHECK_DIRTY 0x1 489 + 490 + 491 + /* 492 + * upl pagein/pageout flags 493 + * 494 + * 495 + * when I/O is issued from this UPL it should be done synchronously 496 + */ 497 + #define UPL_IOSYNC 0x1 498 + 499 + /* 500 + * the passed in UPL should not have either a commit or abort 501 + * applied to it by the underlying layers... the site that 502 + * created the UPL is responsible for cleaning it up. 503 + */ 504 + #define UPL_NOCOMMIT 0x2 505 + 506 + /* 507 + * turn off any speculative read-ahead applied at the I/O layer 508 + */ 509 + #define UPL_NORDAHEAD 0x4 510 + 511 + /* 512 + * pageout request is targeting a real file 513 + * as opposed to a swap file. 514 + */ 515 + 516 + #define UPL_VNODE_PAGER 0x8 517 + /* 518 + * this pageout is being originated as part of an explicit 519 + * memory synchronization operation... no speculative clustering 520 + * should be applied, only the range specified should be pushed. 521 + */ 522 + #define UPL_MSYNC 0x10 523 + 524 + /* 525 + * 526 + */ 527 + #define UPL_PAGING_ENCRYPTED 0x20 528 + 529 + /* 530 + * this pageout is being originated as part of an explicit 531 + * memory synchronization operation that is checking for I/O 532 + * errors and taking it's own action... if an error occurs, 533 + * just abort the pages back into the cache unchanged 534 + */ 535 + #define UPL_KEEPCACHED 0x40 536 + 537 + /* 538 + * this pageout originated from within cluster_io to deal 539 + * with a dirty page that hasn't yet been seen by the FS 540 + * that backs it... tag it so that the FS can take the 541 + * appropriate action w/r to its locking model since the 542 + * pageout will reenter the FS for the same file currently 543 + * being handled in this context. 544 + */ 545 + #define UPL_NESTED_PAGEOUT 0x80 546 + 547 + /* 548 + * we've detected a sequential access pattern and 549 + * we are speculatively and aggressively pulling 550 + * pages in... do not count these as real PAGEINs 551 + * w/r to our hard throttle maintenance 552 + */ 553 + #define UPL_IOSTREAMING 0x100 554 + 555 + 556 + 557 + 558 + /* upl commit flags */ 559 + #define UPL_COMMIT_FREE_ON_EMPTY 0x1 /* only implemented in wrappers */ 560 + #define UPL_COMMIT_CLEAR_DIRTY 0x2 561 + #define UPL_COMMIT_SET_DIRTY 0x4 562 + #define UPL_COMMIT_INACTIVATE 0x8 563 + #define UPL_COMMIT_NOTIFY_EMPTY 0x10 564 + /* deprecated: #define UPL_COMMIT_ALLOW_ACCESS 0x20 */ 565 + #define UPL_COMMIT_CS_VALIDATED 0x40 566 + #define UPL_COMMIT_CLEAR_PRECIOUS 0x80 567 + #define UPL_COMMIT_SPECULATE 0x100 568 + #define UPL_COMMIT_FREE_ABSENT 0x200 569 + 570 + #define UPL_COMMIT_KERNEL_ONLY_FLAGS (UPL_COMMIT_CS_VALIDATED | UPL_COMMIT_FREE_ABSENT) 571 + 572 + /* flags for return of state from vm_map_get_upl, vm_upl address space */ 573 + /* based call */ 574 + #define UPL_DEV_MEMORY 0x1 575 + #define UPL_PHYS_CONTIG 0x2 576 + 577 + 578 + /* 579 + * Flags for the UPL page ops routine. This routine is not exported 580 + * out of the kernel at the moment and so the defs live here. 581 + */ 582 + #define UPL_POP_DIRTY 0x1 583 + #define UPL_POP_PAGEOUT 0x2 584 + #define UPL_POP_PRECIOUS 0x4 585 + #define UPL_POP_ABSENT 0x8 586 + #define UPL_POP_BUSY 0x10 587 + 588 + #define UPL_POP_PHYSICAL 0x10000000 589 + #define UPL_POP_DUMP 0x20000000 590 + #define UPL_POP_SET 0x40000000 591 + #define UPL_POP_CLR 0x80000000 592 + 593 + /* 594 + * Flags for the UPL range op routine. This routine is not exported 595 + * out of the kernel at the moemet and so the defs live here. 596 + */ 597 + /* 598 + * UPL_ROP_ABSENT: Returns the extent of the range presented which 599 + * is absent, starting with the start address presented 600 + */ 601 + #define UPL_ROP_ABSENT 0x01 602 + /* 603 + * UPL_ROP_PRESENT: Returns the extent of the range presented which 604 + * is present (i.e. resident), starting with the start address presented 605 + */ 606 + #define UPL_ROP_PRESENT 0x02 607 + /* 608 + * UPL_ROP_DUMP: Dump the pages which are found in the target object 609 + * for the target range. 610 + */ 611 + #define UPL_ROP_DUMP 0x04 612 + 613 + #ifdef PRIVATE 614 + 615 + /* access macros for upl_t */ 616 + 617 + #define UPL_DEVICE_PAGE(upl) \ 618 + (((upl)[0].phys_addr != 0) ? ((upl)[0].device) : FALSE) 619 + 620 + #define UPL_PAGE_PRESENT(upl, index) \ 621 + ((upl)[(index)].phys_addr != 0) 622 + 623 + #define UPL_PHYS_PAGE(upl, index) \ 624 + ((upl)[(index)].phys_addr) 625 + 626 + #define UPL_SPECULATIVE_PAGE(upl, index) \ 627 + (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].speculative) : FALSE) 628 + 629 + #define UPL_DIRTY_PAGE(upl, index) \ 630 + (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].dirty) : FALSE) 631 + 632 + #define UPL_PRECIOUS_PAGE(upl, index) \ 633 + (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].precious) : FALSE) 634 + 635 + #define UPL_VALID_PAGE(upl, index) \ 636 + (((upl)[(index)].phys_addr != 0) ? (!((upl)[(index)].absent)) : FALSE) 637 + 638 + #define UPL_PAGEOUT_PAGE(upl, index) \ 639 + (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].pageout) : FALSE) 640 + 641 + #define UPL_SET_PAGE_FREE_ON_COMMIT(upl, index) \ 642 + (((upl)[(index)].phys_addr != 0) ? \ 643 + ((upl)[(index)].pageout = TRUE) : FALSE) 644 + 645 + #define UPL_CLR_PAGE_FREE_ON_COMMIT(upl, index) \ 646 + (((upl)[(index)].phys_addr != 0) ? \ 647 + ((upl)[(index)].pageout = FALSE) : FALSE) 648 + 649 + /* modifier macros for upl_t */ 650 + 651 + #define UPL_SET_CS_VALIDATED(upl, index, value) \ 652 + ((upl)[(index)].cs_validated = ((value) ? TRUE : FALSE)) 653 + 654 + #define UPL_SET_CS_TAINTED(upl, index, value) \ 655 + ((upl)[(index)].cs_tainted = ((value) ? TRUE : FALSE)) 656 + 657 + /* The call prototyped below is used strictly by UPL_GET_INTERNAL_PAGE_LIST */ 658 + 659 + extern vm_size_t upl_offset_to_pagelist; 660 + extern vm_size_t upl_get_internal_pagelist_offset(void); 661 + extern void* upl_get_internal_vectorupl(upl_t); 662 + extern upl_page_info_t* upl_get_internal_vectorupl_pagelist(upl_t); 663 + 664 + /*Use this variant to get the UPL's page list iff:*/ 665 + /*- the upl being passed in is already part of a vector UPL*/ 666 + /*- the page list you want is that of this "sub-upl" and not that of the entire vector-upl*/ 667 + 668 + #define UPL_GET_INTERNAL_PAGE_LIST_SIMPLE(upl) \ 669 + ((upl_page_info_t *)((upl_offset_to_pagelist == 0) ? \ 670 + (uintptr_t)upl + (unsigned int)(upl_offset_to_pagelist = upl_get_internal_pagelist_offset()): \ 671 + (uintptr_t)upl + (unsigned int)upl_offset_to_pagelist)) 672 + 673 + /* UPL_GET_INTERNAL_PAGE_LIST is only valid on internal objects where the */ 674 + /* list request was made with the UPL_INTERNAL flag */ 675 + 676 + 677 + #define UPL_GET_INTERNAL_PAGE_LIST(upl) \ 678 + ((upl_get_internal_vectorupl(upl) != NULL ) ? (upl_get_internal_vectorupl_pagelist(upl)) : \ 679 + ((upl_page_info_t *)((upl_offset_to_pagelist == 0) ? \ 680 + (uintptr_t)upl + (unsigned int)(upl_offset_to_pagelist = upl_get_internal_pagelist_offset()): \ 681 + (uintptr_t)upl + (unsigned int)upl_offset_to_pagelist))) 682 + 683 + __BEGIN_DECLS 684 + 685 + extern ppnum_t upl_phys_page(upl_page_info_t *upl, int index); 686 + extern boolean_t upl_device_page(upl_page_info_t *upl); 687 + extern boolean_t upl_speculative_page(upl_page_info_t *upl, int index); 688 + extern void upl_clear_dirty(upl_t upl, boolean_t value); 689 + extern void upl_set_referenced(upl_t upl, boolean_t value); 690 + extern void upl_range_needed(upl_t upl, int index, int count); 691 + 692 + __END_DECLS 693 + 694 + #endif /* PRIVATE */ 695 + 696 + __BEGIN_DECLS 697 + 698 + extern boolean_t upl_page_present(upl_page_info_t *upl, int index); 699 + extern boolean_t upl_dirty_page(upl_page_info_t *upl, int index); 700 + extern boolean_t upl_valid_page(upl_page_info_t *upl, int index); 701 + extern void upl_deallocate(upl_t upl); 702 + 703 + __END_DECLS 704 + 705 + #endif /* KERNEL */ 706 + 707 + #endif /* _MACH_MEMORY_OBJECT_TYPES_H_ */
+812
libmac/xnu/mach/message.h
··· 1 + /* 2 + * Copyright (c) 2000-2005 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * Mach Operating System 33 + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University 34 + * All Rights Reserved. 35 + * 36 + * Permission to use, copy, modify and distribute this software and its 37 + * documentation is hereby granted, provided that both the copyright 38 + * notice and this permission notice appear in all copies of the 39 + * software, derivative works or modified versions, and any portions 40 + * thereof, and that both notices appear in supporting documentation. 41 + * 42 + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 + * 46 + * Carnegie Mellon requests users of this software to return to 47 + * 48 + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 + * School of Computer Science 50 + * Carnegie Mellon University 51 + * Pittsburgh PA 15213-3890 52 + * 53 + * any improvements or extensions that they make and grant Carnegie Mellon 54 + * the rights to redistribute these changes. 55 + */ 56 + /* 57 + * NOTICE: This file was modified by McAfee Research in 2004 to introduce 58 + * support for mandatory and extensible security protections. This notice 59 + * is included in support of clause 2.2 (b) of the Apple Public License, 60 + * Version 2.0. 61 + * Copyright (c) 2005 SPARTA, Inc. 62 + */ 63 + /* 64 + */ 65 + /* 66 + * File: mach/message.h 67 + * 68 + * Mach IPC message and primitive function definitions. 69 + */ 70 + 71 + #ifndef _MACH_MESSAGE_H_ 72 + #define _MACH_MESSAGE_H_ 73 + 74 + #include <stdint.h> 75 + #include <mach/port.h> 76 + #include <mach/boolean.h> 77 + #include <mach/kern_return.h> 78 + #include <mach/machine/vm_types.h> 79 + 80 + #include <sys/cdefs.h> 81 + #include <sys/appleapiopts.h> 82 + 83 + /* 84 + * The timeout mechanism uses mach_msg_timeout_t values, 85 + * passed by value. The timeout units are milliseconds. 86 + * It is controlled with the MACH_SEND_TIMEOUT 87 + * and MACH_RCV_TIMEOUT options. 88 + */ 89 + 90 + typedef natural_t mach_msg_timeout_t; 91 + 92 + /* 93 + * The value to be used when there is no timeout. 94 + * (No MACH_SEND_TIMEOUT/MACH_RCV_TIMEOUT option.) 95 + */ 96 + 97 + #define MACH_MSG_TIMEOUT_NONE ((mach_msg_timeout_t) 0) 98 + 99 + /* 100 + * The kernel uses MACH_MSGH_BITS_COMPLEX as a hint. If it isn't on, it 101 + * assumes the body of the message doesn't contain port rights or OOL 102 + * data. The field is set in received messages. A user task must 103 + * use caution in interpreting the body of a message if the bit isn't 104 + * on, because the mach_msg_type's in the body might "lie" about the 105 + * contents. If the bit isn't on, but the mach_msg_types 106 + * in the body specify rights or OOL data, the behavior is undefined. 107 + * (Ie, an error may or may not be produced.) 108 + * 109 + * The value of MACH_MSGH_BITS_REMOTE determines the interpretation 110 + * of the msgh_remote_port field. It is handled like a msgt_name. 111 + * 112 + * The value of MACH_MSGH_BITS_LOCAL determines the interpretation 113 + * of the msgh_local_port field. It is handled like a msgt_name. 114 + * 115 + * MACH_MSGH_BITS() combines two MACH_MSG_TYPE_* values, for the remote 116 + * and local fields, into a single value suitable for msgh_bits. 117 + * 118 + * MACH_MSGH_BITS_CIRCULAR should be zero; is is used internally. 119 + * 120 + * The unused bits should be zero and are reserved for the kernel 121 + * or for future interface expansion. 122 + */ 123 + 124 + #define MACH_MSGH_BITS_ZERO 0x00000000 125 + #define MACH_MSGH_BITS_REMOTE_MASK 0x000000ff 126 + #define MACH_MSGH_BITS_LOCAL_MASK 0x0000ff00 127 + #define MACH_MSGH_BITS_COMPLEX 0x80000000U 128 + #define MACH_MSGH_BITS_USER 0x8000ffffU 129 + 130 + #define MACH_MSGH_BITS_CIRCULAR 0x40000000 /* internal use only */ 131 + #define MACH_MSGH_BITS_USED 0xc000ffffU 132 + 133 + #define MACH_MSGH_BITS_PORTS_MASK \ 134 + (MACH_MSGH_BITS_REMOTE_MASK|MACH_MSGH_BITS_LOCAL_MASK) 135 + 136 + #define MACH_MSGH_BITS(remote, local) \ 137 + ((remote) | ((local) << 8)) 138 + #define MACH_MSGH_BITS_REMOTE(bits) \ 139 + ((bits) & MACH_MSGH_BITS_REMOTE_MASK) 140 + #define MACH_MSGH_BITS_LOCAL(bits) \ 141 + (((bits) & MACH_MSGH_BITS_LOCAL_MASK) >> 8) 142 + #define MACH_MSGH_BITS_PORTS(bits) \ 143 + ((bits) & MACH_MSGH_BITS_PORTS_MASK) 144 + #define MACH_MSGH_BITS_OTHER(bits) \ 145 + ((bits) &~ MACH_MSGH_BITS_PORTS_MASK) 146 + 147 + /* 148 + * Every message starts with a message header. 149 + * Following the message header, if the message is complex, are a count 150 + * of type descriptors and the type descriptors themselves 151 + * (mach_msg_descriptor_t). The size of the message must be specified in 152 + * bytes, and includes the message header, descriptor count, descriptors, 153 + * and inline data. 154 + * 155 + * The msgh_remote_port field specifies the destination of the message. 156 + * It must specify a valid send or send-once right for a port. 157 + * 158 + * The msgh_local_port field specifies a "reply port". Normally, 159 + * This field carries a send-once right that the receiver will use 160 + * to reply to the message. It may carry the values MACH_PORT_NULL, 161 + * MACH_PORT_DEAD, a send-once right, or a send right. 162 + * 163 + * The msgh_seqno field carries a sequence number associated with the 164 + * received-from port. A port's sequence number is incremented every 165 + * time a message is received from it. In sent messages, the field's 166 + * value is ignored. 167 + * 168 + * The msgh_id field is uninterpreted by the message primitives. 169 + * It normally carries information specifying the format 170 + * or meaning of the message. 171 + */ 172 + 173 + typedef unsigned int mach_msg_bits_t; 174 + typedef natural_t mach_msg_size_t; 175 + typedef integer_t mach_msg_id_t; 176 + 177 + 178 + #define MACH_MSG_SIZE_NULL (mach_msg_size_t *) 0 179 + 180 + typedef unsigned int mach_msg_type_name_t; 181 + 182 + #define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive rights */ 183 + #define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send rights */ 184 + #define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce rights */ 185 + #define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send rights */ 186 + #define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive rights */ 187 + #define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive rights */ 188 + #define MACH_MSG_TYPE_COPY_RECEIVE 22 /* Must hold receive rights */ 189 + 190 + typedef unsigned int mach_msg_copy_options_t; 191 + 192 + #define MACH_MSG_PHYSICAL_COPY 0 193 + #define MACH_MSG_VIRTUAL_COPY 1 194 + #define MACH_MSG_ALLOCATE 2 195 + #define MACH_MSG_OVERWRITE 3 196 + #ifdef MACH_KERNEL 197 + #define MACH_MSG_KALLOC_COPY_T 4 198 + #endif /* MACH_KERNEL */ 199 + 200 + /* 201 + * In a complex mach message, the mach_msg_header_t is followed by 202 + * a descriptor count, then an array of that number of descriptors 203 + * (mach_msg_*_descriptor_t). The type field of mach_msg_type_descriptor_t 204 + * (which any descriptor can be cast to) indicates the flavor of the 205 + * descriptor. 206 + * 207 + * Note that in LP64, the various types of descriptors are no longer all 208 + * the same size as mach_msg_descriptor_t, so the array cannot be indexed 209 + * as expected. 210 + */ 211 + 212 + typedef unsigned int mach_msg_descriptor_type_t; 213 + 214 + #define MACH_MSG_PORT_DESCRIPTOR 0 215 + #define MACH_MSG_OOL_DESCRIPTOR 1 216 + #define MACH_MSG_OOL_PORTS_DESCRIPTOR 2 217 + #define MACH_MSG_OOL_VOLATILE_DESCRIPTOR 3 218 + 219 + #pragma pack(4) 220 + 221 + typedef struct 222 + { 223 + natural_t pad1; 224 + mach_msg_size_t pad2; 225 + unsigned int pad3 : 24; 226 + mach_msg_descriptor_type_t type : 8; 227 + } mach_msg_type_descriptor_t; 228 + 229 + typedef struct 230 + { 231 + mach_port_t name; 232 + #if !(defined(KERNEL) && defined(__LP64__)) 233 + // Pad to 8 bytes everywhere except the K64 kernel where mach_port_t is 8 bytes 234 + mach_msg_size_t pad1; 235 + #endif 236 + unsigned int pad2 : 16; 237 + mach_msg_type_name_t disposition : 8; 238 + mach_msg_descriptor_type_t type : 8; 239 + #if defined(KERNEL) 240 + uint32_t pad_end; 241 + #endif 242 + } mach_msg_port_descriptor_t; 243 + 244 + typedef struct 245 + { 246 + uint32_t address; 247 + mach_msg_size_t size; 248 + boolean_t deallocate: 8; 249 + mach_msg_copy_options_t copy: 8; 250 + unsigned int pad1: 8; 251 + mach_msg_descriptor_type_t type: 8; 252 + } mach_msg_ool_descriptor32_t; 253 + 254 + typedef struct 255 + { 256 + uint64_t address; 257 + boolean_t deallocate: 8; 258 + mach_msg_copy_options_t copy: 8; 259 + unsigned int pad1: 8; 260 + mach_msg_descriptor_type_t type: 8; 261 + mach_msg_size_t size; 262 + } mach_msg_ool_descriptor64_t; 263 + 264 + typedef struct 265 + { 266 + void* address; 267 + #if !defined(__LP64__) 268 + mach_msg_size_t size; 269 + #endif 270 + boolean_t deallocate: 8; 271 + mach_msg_copy_options_t copy: 8; 272 + unsigned int pad1: 8; 273 + mach_msg_descriptor_type_t type: 8; 274 + #if defined(__LP64__) 275 + mach_msg_size_t size; 276 + #endif 277 + #if defined(KERNEL) && !defined(__LP64__) 278 + uint32_t pad_end; 279 + #endif 280 + } mach_msg_ool_descriptor_t; 281 + 282 + typedef struct 283 + { 284 + uint32_t address; 285 + mach_msg_size_t count; 286 + boolean_t deallocate: 8; 287 + mach_msg_copy_options_t copy: 8; 288 + mach_msg_type_name_t disposition : 8; 289 + mach_msg_descriptor_type_t type : 8; 290 + } mach_msg_ool_ports_descriptor32_t; 291 + 292 + typedef struct 293 + { 294 + uint64_t address; 295 + boolean_t deallocate: 8; 296 + mach_msg_copy_options_t copy: 8; 297 + mach_msg_type_name_t disposition : 8; 298 + mach_msg_descriptor_type_t type : 8; 299 + mach_msg_size_t count; 300 + } mach_msg_ool_ports_descriptor64_t; 301 + 302 + typedef struct 303 + { 304 + void* address; 305 + #if !defined(__LP64__) 306 + mach_msg_size_t count; 307 + #endif 308 + boolean_t deallocate: 8; 309 + mach_msg_copy_options_t copy: 8; 310 + mach_msg_type_name_t disposition : 8; 311 + mach_msg_descriptor_type_t type : 8; 312 + #if defined(__LP64__) 313 + mach_msg_size_t count; 314 + #endif 315 + #if defined(KERNEL) && !defined(__LP64__) 316 + uint32_t pad_end; 317 + #endif 318 + } mach_msg_ool_ports_descriptor_t; 319 + 320 + /* 321 + * LP64support - This union definition is not really 322 + * appropriate in LP64 mode because not all descriptors 323 + * are of the same size in that environment. 324 + */ 325 + #if defined(__LP64__) && defined(KERNEL) 326 + typedef union 327 + { 328 + mach_msg_port_descriptor_t port; 329 + mach_msg_ool_descriptor32_t out_of_line; 330 + mach_msg_ool_ports_descriptor32_t ool_ports; 331 + mach_msg_type_descriptor_t type; 332 + } mach_msg_descriptor_t; 333 + #else 334 + typedef union 335 + { 336 + mach_msg_port_descriptor_t port; 337 + mach_msg_ool_descriptor_t out_of_line; 338 + mach_msg_ool_ports_descriptor_t ool_ports; 339 + mach_msg_type_descriptor_t type; 340 + } mach_msg_descriptor_t; 341 + #endif 342 + 343 + typedef struct 344 + { 345 + mach_msg_size_t msgh_descriptor_count; 346 + } mach_msg_body_t; 347 + 348 + #define MACH_MSG_BODY_NULL (mach_msg_body_t *) 0 349 + #define MACH_MSG_DESCRIPTOR_NULL (mach_msg_descriptor_t *) 0 350 + 351 + typedef struct 352 + { 353 + mach_msg_bits_t msgh_bits; 354 + mach_msg_size_t msgh_size; 355 + mach_port_t msgh_remote_port; 356 + mach_port_t msgh_local_port; 357 + mach_msg_size_t msgh_reserved; 358 + mach_msg_id_t msgh_id; 359 + } mach_msg_header_t; 360 + 361 + #define MACH_MSG_NULL (mach_msg_header_t *) 0 362 + 363 + typedef struct 364 + { 365 + mach_msg_header_t header; 366 + mach_msg_body_t body; 367 + } mach_msg_base_t; 368 + 369 + typedef unsigned int mach_msg_trailer_type_t; 370 + 371 + #define MACH_MSG_TRAILER_FORMAT_0 0 372 + 373 + typedef unsigned int mach_msg_trailer_size_t; 374 + 375 + typedef struct 376 + { 377 + mach_msg_trailer_type_t msgh_trailer_type; 378 + mach_msg_trailer_size_t msgh_trailer_size; 379 + } mach_msg_trailer_t; 380 + 381 + typedef struct 382 + { 383 + mach_msg_trailer_type_t msgh_trailer_type; 384 + mach_msg_trailer_size_t msgh_trailer_size; 385 + mach_port_seqno_t msgh_seqno; 386 + } mach_msg_seqno_trailer_t; 387 + 388 + typedef struct 389 + { 390 + unsigned int val[2]; 391 + } security_token_t; 392 + 393 + typedef struct 394 + { 395 + mach_msg_trailer_type_t msgh_trailer_type; 396 + mach_msg_trailer_size_t msgh_trailer_size; 397 + mach_port_seqno_t msgh_seqno; 398 + security_token_t msgh_sender; 399 + } mach_msg_security_trailer_t; 400 + 401 + /* 402 + * The audit token is an opaque token which identifies 403 + * Mach tasks and senders of Mach messages as subjects 404 + * to the BSM audit system. Only the appropriate BSM 405 + * library routines should be used to interpret the 406 + * contents of the audit token as the representation 407 + * of the subject identity within the token may change 408 + * over time. 409 + */ 410 + typedef struct 411 + { 412 + unsigned int val[8]; 413 + } audit_token_t; 414 + 415 + typedef struct 416 + { 417 + mach_msg_trailer_type_t msgh_trailer_type; 418 + mach_msg_trailer_size_t msgh_trailer_size; 419 + mach_port_seqno_t msgh_seqno; 420 + security_token_t msgh_sender; 421 + audit_token_t msgh_audit; 422 + } mach_msg_audit_trailer_t; 423 + 424 + typedef struct 425 + { 426 + mach_msg_trailer_type_t msgh_trailer_type; 427 + mach_msg_trailer_size_t msgh_trailer_size; 428 + mach_port_seqno_t msgh_seqno; 429 + security_token_t msgh_sender; 430 + audit_token_t msgh_audit; 431 + mach_port_context_t msgh_context; 432 + } mach_msg_context_trailer_t; 433 + 434 + typedef struct 435 + { 436 + mach_port_name_t sender; 437 + } msg_labels_t; 438 + 439 + /* 440 + Trailer type to pass MAC policy label info as a mach message trailer. 441 + 442 + */ 443 + 444 + typedef struct 445 + { 446 + mach_msg_trailer_type_t msgh_trailer_type; 447 + mach_msg_trailer_size_t msgh_trailer_size; 448 + mach_port_seqno_t msgh_seqno; 449 + security_token_t msgh_sender; 450 + audit_token_t msgh_audit; 451 + mach_port_context_t msgh_context; 452 + int msgh_ad; 453 + msg_labels_t msgh_labels; 454 + } mach_msg_mac_trailer_t; 455 + 456 + #define MACH_MSG_TRAILER_MINIMUM_SIZE sizeof(mach_msg_trailer_t) 457 + 458 + /* 459 + * These values can change from release to release - but clearly 460 + * code cannot request additional trailer elements one was not 461 + * compiled to understand. Therefore, it is safe to use this 462 + * constant when the same module specified the receive options. 463 + * Otherwise, you run the risk that the options requested by 464 + * another module may exceed the local modules notion of 465 + * MAX_TRAILER_SIZE. 466 + */ 467 + typedef mach_msg_mac_trailer_t mach_msg_max_trailer_t; 468 + #define MAX_TRAILER_SIZE ((mach_msg_size_t)sizeof(mach_msg_max_trailer_t)) 469 + 470 + /* 471 + * Legacy requirements keep us from ever updating these defines (even 472 + * when the format_0 trailers gain new option data fields in the future). 473 + * Therefore, they shouldn't be used going forward. Instead, the sizes 474 + * should be compared against the specific element size requested using 475 + * REQUESTED_TRAILER_SIZE. 476 + */ 477 + typedef mach_msg_security_trailer_t mach_msg_format_0_trailer_t; 478 + 479 + /*typedef mach_msg_mac_trailer_t mach_msg_format_0_trailer_t; 480 + */ 481 + 482 + #define MACH_MSG_TRAILER_FORMAT_0_SIZE sizeof(mach_msg_format_0_trailer_t) 483 + 484 + #define KERNEL_SECURITY_TOKEN_VALUE { {0, 1} } 485 + extern security_token_t KERNEL_SECURITY_TOKEN; 486 + 487 + #define KERNEL_AUDIT_TOKEN_VALUE { {0, 0, 0, 0, 0, 0, 0, 0} } 488 + extern audit_token_t KERNEL_AUDIT_TOKEN; 489 + 490 + typedef integer_t mach_msg_options_t; 491 + 492 + typedef struct 493 + { 494 + mach_msg_header_t header; 495 + } mach_msg_empty_send_t; 496 + 497 + typedef struct 498 + { 499 + mach_msg_header_t header; 500 + mach_msg_trailer_t trailer; 501 + } mach_msg_empty_rcv_t; 502 + 503 + typedef union 504 + { 505 + mach_msg_empty_send_t send; 506 + mach_msg_empty_rcv_t rcv; 507 + } mach_msg_empty_t; 508 + 509 + #pragma pack() 510 + 511 + /* utility to round the message size - will become machine dependent */ 512 + #define round_msg(x) (((mach_msg_size_t)(x) + sizeof (natural_t) - 1) & \ 513 + ~(sizeof (natural_t) - 1)) 514 + 515 + /* 516 + * There is no fixed upper bound to the size of Mach messages. 517 + */ 518 + #define MACH_MSG_SIZE_MAX ((mach_msg_size_t) ~0) 519 + 520 + #if defined(__APPLE_API_PRIVATE) 521 + /* 522 + * But architectural limits of a given implementation, or 523 + * temporal conditions may cause unpredictable send failures 524 + * for messages larger than MACH_MSG_SIZE_RELIABLE. 525 + * 526 + * In either case, waiting for memory is [currently] outside 527 + * the scope of send timeout values provided to IPC. 528 + */ 529 + #define MACH_MSG_SIZE_RELIABLE ((mach_msg_size_t) 256 * 1024) 530 + #endif 531 + /* 532 + * Compatibility definitions, for code written 533 + * when there was a msgh_kind instead of msgh_seqno. 534 + */ 535 + #define MACH_MSGH_KIND_NORMAL 0x00000000 536 + #define MACH_MSGH_KIND_NOTIFICATION 0x00000001 537 + #define msgh_kind msgh_seqno 538 + #define mach_msg_kind_t mach_port_seqno_t 539 + 540 + typedef natural_t mach_msg_type_size_t; 541 + typedef natural_t mach_msg_type_number_t; 542 + 543 + /* 544 + * Values received/carried in messages. Tells the receiver what 545 + * sort of port right he now has. 546 + * 547 + * MACH_MSG_TYPE_PORT_NAME is used to transfer a port name 548 + * which should remain uninterpreted by the kernel. (Port rights 549 + * are not transferred, just the port name.) 550 + */ 551 + 552 + #define MACH_MSG_TYPE_PORT_NONE 0 553 + 554 + #define MACH_MSG_TYPE_PORT_NAME 15 555 + #define MACH_MSG_TYPE_PORT_RECEIVE MACH_MSG_TYPE_MOVE_RECEIVE 556 + #define MACH_MSG_TYPE_PORT_SEND MACH_MSG_TYPE_MOVE_SEND 557 + #define MACH_MSG_TYPE_PORT_SEND_ONCE MACH_MSG_TYPE_MOVE_SEND_ONCE 558 + 559 + #define MACH_MSG_TYPE_LAST 22 /* Last assigned */ 560 + 561 + /* 562 + * A dummy value. Mostly used to indicate that the actual value 563 + * will be filled in later, dynamically. 564 + */ 565 + 566 + #define MACH_MSG_TYPE_POLYMORPHIC ((mach_msg_type_name_t) -1) 567 + 568 + /* 569 + * Is a given item a port type? 570 + */ 571 + 572 + #define MACH_MSG_TYPE_PORT_ANY(x) \ 573 + (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \ 574 + ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE)) 575 + 576 + #define MACH_MSG_TYPE_PORT_ANY_SEND(x) \ 577 + (((x) >= MACH_MSG_TYPE_MOVE_SEND) && \ 578 + ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE)) 579 + 580 + #define MACH_MSG_TYPE_PORT_ANY_RIGHT(x) \ 581 + (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \ 582 + ((x) <= MACH_MSG_TYPE_MOVE_SEND_ONCE)) 583 + 584 + typedef integer_t mach_msg_option_t; 585 + 586 + #define MACH_MSG_OPTION_NONE 0x00000000 587 + 588 + #define MACH_SEND_MSG 0x00000001 589 + #define MACH_RCV_MSG 0x00000002 590 + #define MACH_RCV_LARGE 0x00000004 591 + 592 + #define MACH_SEND_TIMEOUT 0x00000010 593 + #define MACH_SEND_INTERRUPT 0x00000040 /* libmach implements */ 594 + #define MACH_SEND_NOTIFY 0x00000080 /* arm send-possible notify */ 595 + #define MACH_SEND_ALWAYS 0x00010000 /* internal use only */ 596 + #define MACH_SEND_TRAILER 0x00020000 597 + 598 + #define MACH_RCV_TIMEOUT 0x00000100 599 + #define MACH_RCV_NOTIFY 0x00000200 /* reserved - legacy */ 600 + #define MACH_RCV_INTERRUPT 0x00000400 /* libmach implements */ 601 + #define MACH_RCV_OVERWRITE 0x00001000 602 + 603 + /* 604 + * NOTE: a 0x00------ RCV mask implies to ask for 605 + * a MACH_MSG_TRAILER_FORMAT_0 with 0 Elements, 606 + * which is equivalent to a mach_msg_trailer_t. 607 + * 608 + * XXXMAC: unlike the rest of the MACH_RCV_* flags, MACH_RCV_TRAILER_LABELS 609 + * needs its own private bit since we only calculate its fields when absolutely 610 + * required. 611 + */ 612 + #define MACH_RCV_TRAILER_NULL 0 613 + #define MACH_RCV_TRAILER_SEQNO 1 614 + #define MACH_RCV_TRAILER_SENDER 2 615 + #define MACH_RCV_TRAILER_AUDIT 3 616 + #define MACH_RCV_TRAILER_CTX 4 617 + #define MACH_RCV_TRAILER_AV 7 618 + #define MACH_RCV_TRAILER_LABELS 8 619 + 620 + #define MACH_RCV_TRAILER_TYPE(x) (((x) & 0xf) << 28) 621 + #define MACH_RCV_TRAILER_ELEMENTS(x) (((x) & 0xf) << 24) 622 + #define MACH_RCV_TRAILER_MASK ((0xff << 24)) 623 + 624 + #define GET_RCV_ELEMENTS(y) (((y) >> 24) & 0xf) 625 + 626 + /* 627 + * XXXMAC: note that in the case of MACH_RCV_TRAILER_LABELS, 628 + * we just fall through to mach_msg_max_trailer_t. 629 + * This is correct behavior since mach_msg_max_trailer_t is defined as 630 + * mac_msg_mac_trailer_t which is used for the LABELS trailer. 631 + * It also makes things work properly if MACH_RCV_TRAILER_LABELS is ORed 632 + * with one of the other options. 633 + */ 634 + 635 + #define REQUESTED_TRAILER_SIZE_NATIVE(y) \ 636 + ((mach_msg_trailer_size_t) \ 637 + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ? \ 638 + sizeof(mach_msg_trailer_t) : \ 639 + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ? \ 640 + sizeof(mach_msg_seqno_trailer_t) : \ 641 + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ? \ 642 + sizeof(mach_msg_security_trailer_t) : \ 643 + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AUDIT) ? \ 644 + sizeof(mach_msg_audit_trailer_t) : \ 645 + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_CTX) ? \ 646 + sizeof(mach_msg_context_trailer_t) : \ 647 + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AV) ? \ 648 + sizeof(mach_msg_mac_trailer_t) : \ 649 + sizeof(mach_msg_max_trailer_t)))))))) 650 + 651 + 652 + #ifdef XNU_KERNEL_PRIVATE 653 + 654 + #define REQUESTED_TRAILER_SIZE(is64, y) REQUESTED_TRAILER_SIZE_NATIVE(y) 655 + 656 + #else /* XNU_KERNEL_PRIVATE */ 657 + #define REQUESTED_TRAILER_SIZE(y) REQUESTED_TRAILER_SIZE_NATIVE(y) 658 + #endif /* XNU_KERNEL_PRIVATE */ 659 + 660 + /* 661 + * Much code assumes that mach_msg_return_t == kern_return_t. 662 + * This definition is useful for descriptive purposes. 663 + * 664 + * See <mach/error.h> for the format of error codes. 665 + * IPC errors are system 4. Send errors are subsystem 0; 666 + * receive errors are subsystem 1. The code field is always non-zero. 667 + * The high bits of the code field communicate extra information 668 + * for some error codes. MACH_MSG_MASK masks off these special bits. 669 + */ 670 + 671 + typedef kern_return_t mach_msg_return_t; 672 + 673 + #define MACH_MSG_SUCCESS 0x00000000 674 + 675 + 676 + #define MACH_MSG_MASK 0x00003e00 677 + /* All special error code bits defined below. */ 678 + #define MACH_MSG_IPC_SPACE 0x00002000 679 + /* No room in IPC name space for another capability name. */ 680 + #define MACH_MSG_VM_SPACE 0x00001000 681 + /* No room in VM address space for out-of-line memory. */ 682 + #define MACH_MSG_IPC_KERNEL 0x00000800 683 + /* Kernel resource shortage handling an IPC capability. */ 684 + #define MACH_MSG_VM_KERNEL 0x00000400 685 + /* Kernel resource shortage handling out-of-line memory. */ 686 + 687 + #define MACH_SEND_IN_PROGRESS 0x10000001 688 + /* Thread is waiting to send. (Internal use only.) */ 689 + #define MACH_SEND_INVALID_DATA 0x10000002 690 + /* Bogus in-line data. */ 691 + #define MACH_SEND_INVALID_DEST 0x10000003 692 + /* Bogus destination port. */ 693 + #define MACH_SEND_TIMED_OUT 0x10000004 694 + /* Message not sent before timeout expired. */ 695 + #define MACH_SEND_INTERRUPTED 0x10000007 696 + /* Software interrupt. */ 697 + #define MACH_SEND_MSG_TOO_SMALL 0x10000008 698 + /* Data doesn't contain a complete message. */ 699 + #define MACH_SEND_INVALID_REPLY 0x10000009 700 + /* Bogus reply port. */ 701 + #define MACH_SEND_INVALID_RIGHT 0x1000000a 702 + /* Bogus port rights in the message body. */ 703 + #define MACH_SEND_INVALID_NOTIFY 0x1000000b 704 + /* Bogus notify port argument. */ 705 + #define MACH_SEND_INVALID_MEMORY 0x1000000c 706 + /* Invalid out-of-line memory pointer. */ 707 + #define MACH_SEND_NO_BUFFER 0x1000000d 708 + /* No message buffer is available. */ 709 + #define MACH_SEND_TOO_LARGE 0x1000000e 710 + /* Send is too large for port */ 711 + #define MACH_SEND_INVALID_TYPE 0x1000000f 712 + /* Invalid msg-type specification. */ 713 + #define MACH_SEND_INVALID_HEADER 0x10000010 714 + /* A field in the header had a bad value. */ 715 + #define MACH_SEND_INVALID_TRAILER 0x10000011 716 + /* The trailer to be sent does not match kernel format. */ 717 + #define MACH_SEND_INVALID_RT_OOL_SIZE 0x10000015 718 + /* compatibility: no longer a returned error */ 719 + 720 + #define MACH_RCV_IN_PROGRESS 0x10004001 721 + /* Thread is waiting for receive. (Internal use only.) */ 722 + #define MACH_RCV_INVALID_NAME 0x10004002 723 + /* Bogus name for receive port/port-set. */ 724 + #define MACH_RCV_TIMED_OUT 0x10004003 725 + /* Didn't get a message within the timeout value. */ 726 + #define MACH_RCV_TOO_LARGE 0x10004004 727 + /* Message buffer is not large enough for inline data. */ 728 + #define MACH_RCV_INTERRUPTED 0x10004005 729 + /* Software interrupt. */ 730 + #define MACH_RCV_PORT_CHANGED 0x10004006 731 + /* compatibility: no longer a returned error */ 732 + #define MACH_RCV_INVALID_NOTIFY 0x10004007 733 + /* Bogus notify port argument. */ 734 + #define MACH_RCV_INVALID_DATA 0x10004008 735 + /* Bogus message buffer for inline data. */ 736 + #define MACH_RCV_PORT_DIED 0x10004009 737 + /* Port/set was sent away/died during receive. */ 738 + #define MACH_RCV_IN_SET 0x1000400a 739 + /* compatibility: no longer a returned error */ 740 + #define MACH_RCV_HEADER_ERROR 0x1000400b 741 + /* Error receiving message header. See special bits. */ 742 + #define MACH_RCV_BODY_ERROR 0x1000400c 743 + /* Error receiving message body. See special bits. */ 744 + #define MACH_RCV_INVALID_TYPE 0x1000400d 745 + /* Invalid msg-type specification in scatter list. */ 746 + #define MACH_RCV_SCATTER_SMALL 0x1000400e 747 + /* Out-of-line overwrite region is not large enough */ 748 + #define MACH_RCV_INVALID_TRAILER 0x1000400f 749 + /* trailer type or number of trailer elements not supported */ 750 + #define MACH_RCV_IN_PROGRESS_TIMED 0x10004011 751 + /* Waiting for receive with timeout. (Internal use only.) */ 752 + 753 + 754 + __BEGIN_DECLS 755 + 756 + /* 757 + * Routine: mach_msg_overwrite 758 + * Purpose: 759 + * Send and/or receive a message. If the message operation 760 + * is interrupted, and the user did not request an indication 761 + * of that fact, then restart the appropriate parts of the 762 + * operation silently (trap version does not restart). 763 + * 764 + * Distinct send and receive buffers may be specified. If 765 + * no separate receive buffer is specified, the msg parameter 766 + * will be used for both send and receive operations. 767 + * 768 + * In addition to a distinct receive buffer, that buffer may 769 + * already contain scatter control information to direct the 770 + * receiving of the message. 771 + */ 772 + 773 + extern mach_msg_return_t mach_msg_overwrite( 774 + mach_msg_header_t *msg, 775 + mach_msg_option_t option, 776 + mach_msg_size_t send_size, 777 + mach_msg_size_t rcv_size, 778 + mach_port_name_t rcv_name, 779 + mach_msg_timeout_t timeout, 780 + mach_port_name_t notify, 781 + mach_msg_header_t *rcv_msg, 782 + mach_msg_size_t rcv_limit); 783 + 784 + #ifndef KERNEL 785 + 786 + /* 787 + * Routine: mach_msg 788 + * Purpose: 789 + * Send and/or receive a message. If the message operation 790 + * is interrupted, and the user did not request an indication 791 + * of that fact, then restart the appropriate parts of the 792 + * operation silently (trap version does not restart). 793 + */ 794 + extern mach_msg_return_t mach_msg( 795 + mach_msg_header_t *msg, 796 + mach_msg_option_t option, 797 + mach_msg_size_t send_size, 798 + mach_msg_size_t rcv_size, 799 + mach_port_name_t rcv_name, 800 + mach_msg_timeout_t timeout, 801 + mach_port_name_t notify); 802 + 803 + #elif defined(MACH_KERNEL_PRIVATE) 804 + 805 + extern mach_msg_return_t mach_msg_receive_results(void); 806 + 807 + #endif /* KERNEL */ 808 + 809 + __END_DECLS 810 + 811 + #endif /* _MACH_MESSAGE_H_ */ 812 +
+372
libmac/xnu/mach/port.h
··· 1 + /* 2 + * Copyright (c) 2000-2006 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * Mach Operating System 33 + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University 34 + * All Rights Reserved. 35 + * 36 + * Permission to use, copy, modify and distribute this software and its 37 + * documentation is hereby granted, provided that both the copyright 38 + * notice and this permission notice appear in all copies of the 39 + * software, derivative works or modified versions, and any portions 40 + * thereof, and that both notices appear in supporting documentation. 41 + * 42 + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 + * 46 + * Carnegie Mellon requests users of this software to return to 47 + * 48 + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 + * School of Computer Science 50 + * Carnegie Mellon University 51 + * Pittsburgh PA 15213-3890 52 + * 53 + * any improvements or extensions that they make and grant Carnegie Mellon 54 + * the rights to redistribute these changes. 55 + */ 56 + /* 57 + * NOTICE: This file was modified by McAfee Research in 2004 to introduce 58 + * support for mandatory and extensible security protections. This notice 59 + * is included in support of clause 2.2 (b) of the Apple Public License, 60 + * Version 2.0. 61 + */ 62 + /* 63 + */ 64 + /* 65 + * File: mach/port.h 66 + * 67 + * Definition of a Mach port 68 + * 69 + * Mach ports are the endpoints to Mach-implemented communications 70 + * channels (usually uni-directional message queues, but other types 71 + * also exist). 72 + * 73 + * Unique collections of these endpoints are maintained for each 74 + * Mach task. Each Mach port in the task's collection is given a 75 + * [task-local] name to identify it - and the the various "rights" 76 + * held by the task for that specific endpoint. 77 + * 78 + * This header defines the types used to identify these Mach ports 79 + * and the various rights associated with them. For more info see: 80 + * 81 + * <mach/mach_port.h> - manipulation of port rights in a given space 82 + * <mach/message.h> - message queue [and port right passing] mechanism 83 + * 84 + */ 85 + 86 + #ifndef _MACH_PORT_H_ 87 + #define _MACH_PORT_H_ 88 + 89 + #include <sys/cdefs.h> 90 + #include <stdint.h> 91 + #include <mach/boolean.h> 92 + #include <mach/machine/vm_types.h> 93 + 94 + /* 95 + * mach_port_name_t - the local identity for a Mach port 96 + * 97 + * The name is Mach port namespace specific. It is used to 98 + * identify the rights held for that port by the task whose 99 + * namespace is implied [or specifically provided]. 100 + * 101 + * Use of this type usually implies just a name - no rights. 102 + * See mach_port_t for a type that implies a "named right." 103 + * 104 + */ 105 + 106 + typedef natural_t mach_port_name_t; 107 + typedef mach_port_name_t *mach_port_name_array_t; 108 + 109 + #ifdef KERNEL 110 + 111 + /* 112 + * mach_port_t - a named port right 113 + * 114 + * In the kernel, "rights" are represented [named] by pointers to 115 + * the ipc port object in question. There is no port namespace for the 116 + * rights to be collected. 117 + * 118 + * Actually, there is namespace for the kernel task. But most kernel 119 + * code - including, but not limited to, Mach IPC code - lives in the 120 + * limbo between the current user-level task and the "next" task. Very 121 + * little of the kernel code runs in full kernel task context. So very 122 + * little of it gets to use the kernel task's port name space. 123 + * 124 + * Because of this implementation approach, all in-kernel rights for 125 + * a given port coalesce [have the same name/pointer]. The actual 126 + * references are counted in the port itself. It is up to the kernel 127 + * code in question to "just remember" how many [and what type of] 128 + * rights it holds and handle them appropriately. 129 + * 130 + */ 131 + 132 + #ifndef MACH_KERNEL_PRIVATE 133 + /* 134 + * For kernel code that resides outside of Mach proper, we opaque the 135 + * port structure definition. 136 + */ 137 + struct ipc_port ; 138 + 139 + #endif /* MACH_KERNEL_PRIVATE */ 140 + 141 + typedef struct ipc_port *ipc_port_t; 142 + 143 + #define IPC_PORT_NULL ((ipc_port_t) 0UL) 144 + #define IPC_PORT_DEAD ((ipc_port_t)~0UL) 145 + #define IPC_PORT_VALID(port) \ 146 + ((port) != IPC_PORT_NULL && (port) != IPC_PORT_DEAD) 147 + 148 + typedef ipc_port_t mach_port_t; 149 + 150 + /* 151 + * Since the 32-bit and 64-bit representations of ~0 are different, 152 + * explicitly handle MACH_PORT_DEAD 153 + */ 154 + 155 + #define CAST_MACH_PORT_TO_NAME(x) ((mach_port_name_t)(uintptr_t)(x)) 156 + #define CAST_MACH_NAME_TO_PORT(x) ((x) == MACH_PORT_DEAD ? (mach_port_t)IPC_PORT_DEAD : (mach_port_t)(uintptr_t)(x)) 157 + 158 + #else /* KERNEL */ 159 + 160 + /* 161 + * mach_port_t - a named port right 162 + * 163 + * In user-space, "rights" are represented by the name of the 164 + * right in the Mach port namespace. Even so, this type is 165 + * presented as a unique one to more clearly denote the presence 166 + * of a right coming along with the name. 167 + * 168 + * Often, various rights for a port held in a single name space 169 + * will coalesce and are, therefore, be identified by a single name 170 + * [this is the case for send and receive rights]. But not 171 + * always [send-once rights currently get a unique name for 172 + * each right]. 173 + * 174 + */ 175 + 176 + #ifndef _MACH_PORT_T 177 + #define _MACH_PORT_T 178 + typedef mach_port_name_t mach_port_t; 179 + #endif 180 + 181 + #endif /* KERNEL */ 182 + 183 + typedef mach_port_t *mach_port_array_t; 184 + 185 + /* 186 + * MACH_PORT_NULL is a legal value that can be carried in messages. 187 + * It indicates the absence of any port or port rights. (A port 188 + * argument keeps the message from being "simple", even if the 189 + * value is MACH_PORT_NULL.) The value MACH_PORT_DEAD is also a legal 190 + * value that can be carried in messages. It indicates 191 + * that a port right was present, but it died. 192 + */ 193 + 194 + #define MACH_PORT_NULL 0 /* intentional loose typing */ 195 + #define MACH_PORT_DEAD ((mach_port_name_t) ~0) 196 + #define MACH_PORT_VALID(name) \ 197 + (((name) != MACH_PORT_NULL) && \ 198 + ((name) != MACH_PORT_DEAD)) 199 + 200 + 201 + /* 202 + * For kernel-selected [assigned] port names, the name is 203 + * comprised of two parts: a generation number and an index. 204 + * This approach keeps the exact same name from being generated 205 + * and reused too quickly [to catch right/reference counting bugs]. 206 + * The dividing line between the constituent parts is exposed so 207 + * that efficient "mach_port_name_t to data structure pointer" 208 + * conversion implementation can be made. But it is possible 209 + * for user-level code to assign their own names to Mach ports. 210 + * These are not required to participate in this algorithm. So 211 + * care should be taken before "assuming" this model. 212 + * 213 + */ 214 + 215 + #ifndef NO_PORT_GEN 216 + 217 + #define MACH_PORT_INDEX(name) ((name) >> 8) 218 + #define MACH_PORT_GEN(name) (((name) & 0xff) << 24) 219 + #define MACH_PORT_MAKE(index, gen) \ 220 + (((index) << 8) | (gen) >> 24) 221 + 222 + #else /* NO_PORT_GEN */ 223 + 224 + #define MACH_PORT_INDEX(name) (name) 225 + #define MACH_PORT_GEN(name) (0) 226 + #define MACH_PORT_MAKE(index, gen) (index) 227 + 228 + #endif /* NO_PORT_GEN */ 229 + 230 + 231 + /* 232 + * These are the different rights a task may have for a port. 233 + * The MACH_PORT_RIGHT_* definitions are used as arguments 234 + * to mach_port_allocate, mach_port_get_refs, etc, to specify 235 + * a particular right to act upon. The mach_port_names and 236 + * mach_port_type calls return bitmasks using the MACH_PORT_TYPE_* 237 + * definitions. This is because a single name may denote 238 + * multiple rights. 239 + */ 240 + 241 + typedef natural_t mach_port_right_t; 242 + 243 + #define MACH_PORT_RIGHT_SEND ((mach_port_right_t) 0) 244 + #define MACH_PORT_RIGHT_RECEIVE ((mach_port_right_t) 1) 245 + #define MACH_PORT_RIGHT_SEND_ONCE ((mach_port_right_t) 2) 246 + #define MACH_PORT_RIGHT_PORT_SET ((mach_port_right_t) 3) 247 + #define MACH_PORT_RIGHT_DEAD_NAME ((mach_port_right_t) 4) 248 + #define MACH_PORT_RIGHT_LABELH ((mach_port_right_t) 5) 249 + #define MACH_PORT_RIGHT_NUMBER ((mach_port_right_t) 6) 250 + 251 + typedef natural_t mach_port_type_t; 252 + typedef mach_port_type_t *mach_port_type_array_t; 253 + 254 + #define MACH_PORT_TYPE(right) \ 255 + ((mach_port_type_t)(((mach_port_type_t) 1) \ 256 + << ((right) + ((mach_port_right_t) 16)))) 257 + #define MACH_PORT_TYPE_NONE ((mach_port_type_t) 0L) 258 + #define MACH_PORT_TYPE_SEND MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND) 259 + #define MACH_PORT_TYPE_RECEIVE MACH_PORT_TYPE(MACH_PORT_RIGHT_RECEIVE) 260 + #define MACH_PORT_TYPE_SEND_ONCE MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND_ONCE) 261 + #define MACH_PORT_TYPE_PORT_SET MACH_PORT_TYPE(MACH_PORT_RIGHT_PORT_SET) 262 + #define MACH_PORT_TYPE_DEAD_NAME MACH_PORT_TYPE(MACH_PORT_RIGHT_DEAD_NAME) 263 + #define MACH_PORT_TYPE_LABELH MACH_PORT_TYPE(MACH_PORT_RIGHT_LABELH) 264 + 265 + /* Convenient combinations. */ 266 + 267 + #define MACH_PORT_TYPE_SEND_RECEIVE \ 268 + (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_RECEIVE) 269 + #define MACH_PORT_TYPE_SEND_RIGHTS \ 270 + (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_SEND_ONCE) 271 + #define MACH_PORT_TYPE_PORT_RIGHTS \ 272 + (MACH_PORT_TYPE_SEND_RIGHTS|MACH_PORT_TYPE_RECEIVE) 273 + #define MACH_PORT_TYPE_PORT_OR_DEAD \ 274 + (MACH_PORT_TYPE_PORT_RIGHTS|MACH_PORT_TYPE_DEAD_NAME) 275 + #define MACH_PORT_TYPE_ALL_RIGHTS \ 276 + (MACH_PORT_TYPE_PORT_OR_DEAD|MACH_PORT_TYPE_PORT_SET) 277 + 278 + /* Dummy type bits that mach_port_type/mach_port_names can return. */ 279 + 280 + #define MACH_PORT_TYPE_DNREQUEST 0x80000000 281 + #define MACH_PORT_TYPE_SPREQUEST 0x40000000 282 + #define MACH_PORT_TYPE_SPREQUEST_DELAYED 0x20000000 283 + 284 + /* User-references for capabilities. */ 285 + 286 + typedef natural_t mach_port_urefs_t; 287 + typedef integer_t mach_port_delta_t; /* change in urefs */ 288 + 289 + /* Attributes of ports. (See mach_port_get_receive_status.) */ 290 + 291 + typedef natural_t mach_port_seqno_t; /* sequence number */ 292 + typedef natural_t mach_port_mscount_t; /* make-send count */ 293 + typedef natural_t mach_port_msgcount_t; /* number of msgs */ 294 + typedef natural_t mach_port_rights_t; /* number of rights */ 295 + 296 + /* 297 + * Are there outstanding send rights for a given port? 298 + */ 299 + #define MACH_PORT_SRIGHTS_NONE 0 /* no srights */ 300 + #define MACH_PORT_SRIGHTS_PRESENT 1 /* srights */ 301 + typedef unsigned int mach_port_srights_t; /* status of send rights */ 302 + 303 + typedef struct mach_port_status { 304 + mach_port_rights_t mps_pset; /* count of containing port sets */ 305 + mach_port_seqno_t mps_seqno; /* sequence number */ 306 + mach_port_mscount_t mps_mscount; /* make-send count */ 307 + mach_port_msgcount_t mps_qlimit; /* queue limit */ 308 + mach_port_msgcount_t mps_msgcount; /* number in the queue */ 309 + mach_port_rights_t mps_sorights; /* how many send-once rights */ 310 + boolean_t mps_srights; /* do send rights exist? */ 311 + boolean_t mps_pdrequest; /* port-deleted requested? */ 312 + boolean_t mps_nsrequest; /* no-senders requested? */ 313 + natural_t mps_flags; /* port flags */ 314 + } mach_port_status_t; 315 + 316 + /* System-wide values for setting queue limits on a port */ 317 + #define MACH_PORT_QLIMIT_ZERO ((mach_port_msgcount_t) 0) 318 + #define MACH_PORT_QLIMIT_BASIC ((mach_port_msgcount_t) 5) 319 + #define MACH_PORT_QLIMIT_SMALL ((mach_port_msgcount_t) 16) 320 + #define MACH_PORT_QLIMIT_LARGE ((mach_port_msgcount_t) 1024) 321 + #define MACH_PORT_QLIMIT_KERNEL ((mach_port_msgcount_t) 65536) 322 + #define MACH_PORT_QLIMIT_MIN MACH_PORT_QLIMIT_ZERO 323 + #define MACH_PORT_QLIMIT_DEFAULT MACH_PORT_QLIMIT_BASIC 324 + #define MACH_PORT_QLIMIT_MAX MACH_PORT_QLIMIT_LARGE 325 + 326 + typedef struct mach_port_limits { 327 + mach_port_msgcount_t mpl_qlimit; /* number of msgs */ 328 + } mach_port_limits_t; 329 + 330 + typedef integer_t *mach_port_info_t; /* varying array of natural_t */ 331 + 332 + /* Flavors for mach_port_get/set_attributes() */ 333 + typedef int mach_port_flavor_t; 334 + #define MACH_PORT_LIMITS_INFO 1 /* uses mach_port_status_t */ 335 + #define MACH_PORT_RECEIVE_STATUS 2 /* uses mach_port_limits_t */ 336 + #define MACH_PORT_DNREQUESTS_SIZE 3 /* info is int */ 337 + 338 + #define MACH_PORT_LIMITS_INFO_COUNT ((natural_t) \ 339 + (sizeof(mach_port_limits_t)/sizeof(natural_t))) 340 + #define MACH_PORT_RECEIVE_STATUS_COUNT ((natural_t) \ 341 + (sizeof(mach_port_status_t)/sizeof(natural_t))) 342 + #define MACH_PORT_DNREQUESTS_SIZE_COUNT 1 343 + 344 + /* 345 + * Structure used to pass information about port allocation requests. 346 + * Must be padded to 64-bits total length. 347 + */ 348 + typedef struct mach_port_qos { 349 + unsigned int name:1; /* name given */ 350 + unsigned int prealloc:1; /* prealloced message */ 351 + boolean_t pad1:30; 352 + natural_t len; 353 + } mach_port_qos_t; 354 + 355 + #if !__DARWIN_UNIX03 && !defined(_NO_PORT_T_FROM_MACH) 356 + /* 357 + * Mach 3.0 renamed everything to have mach_ in front of it. 358 + * These types and macros are provided for backward compatibility 359 + * but are deprecated. 360 + */ 361 + typedef mach_port_t port_t; 362 + typedef mach_port_name_t port_name_t; 363 + typedef mach_port_name_t *port_name_array_t; 364 + 365 + #define PORT_NULL ((port_t) 0) 366 + #define PORT_DEAD ((port_t) ~0) 367 + #define PORT_VALID(name) \ 368 + ((port_t)(name) != PORT_NULL && (port_t)(name) != PORT_DEAD) 369 + 370 + #endif /* !__DARWIN_UNIX03 && !_NO_PORT_T_FROM_MACH */ 371 + 372 + #endif /* _MACH_PORT_H_ */
+99
libmac/xnu/mach/vm_attributes.h
··· 1 + /* 2 + * Copyright (c) 2000-2002 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * Mach Operating System 33 + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University 34 + * All Rights Reserved. 35 + * 36 + * Permission to use, copy, modify and distribute this software and its 37 + * documentation is hereby granted, provided that both the copyright 38 + * notice and this permission notice appear in all copies of the 39 + * software, derivative works or modified versions, and any portions 40 + * thereof, and that both notices appear in supporting documentation. 41 + * 42 + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 + * 46 + * Carnegie Mellon requests users of this software to return to 47 + * 48 + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 + * School of Computer Science 50 + * Carnegie Mellon University 51 + * Pittsburgh PA 15213-3890 52 + * 53 + * any improvements or extensions that they make and grant Carnegie Mellon 54 + * the rights to redistribute these changes. 55 + */ 56 + /* 57 + */ 58 + /* 59 + * File: mach/vm_attributes.h 60 + * Author: Alessandro Forin 61 + * 62 + * Virtual memory attributes definitions. 63 + * 64 + * These definitions are in addition to the machine-independent 65 + * ones (e.g. protection), and are only selectively supported 66 + * on specific machine architectures. 67 + * 68 + */ 69 + 70 + #ifndef _MACH_VM_ATTRIBUTES_H_ 71 + #define _MACH_VM_ATTRIBUTES_H_ 72 + 73 + /* 74 + * Types of machine-dependent attributes 75 + */ 76 + typedef unsigned int vm_machine_attribute_t; 77 + 78 + #define MATTR_CACHE 1 /* cachability */ 79 + #define MATTR_MIGRATE 2 /* migrability */ 80 + #define MATTR_REPLICATE 4 /* replicability */ 81 + 82 + /* 83 + * Values for the above, e.g. operations on attribute 84 + */ 85 + typedef int vm_machine_attribute_val_t; 86 + 87 + #define MATTR_VAL_OFF 0 /* (generic) turn attribute off */ 88 + #define MATTR_VAL_ON 1 /* (generic) turn attribute on */ 89 + #define MATTR_VAL_GET 2 /* (generic) return current value */ 90 + 91 + #define MATTR_VAL_CACHE_FLUSH 6 /* flush from all caches */ 92 + #define MATTR_VAL_DCACHE_FLUSH 7 /* flush from data caches */ 93 + #define MATTR_VAL_ICACHE_FLUSH 8 /* flush from instruction caches */ 94 + #define MATTR_VAL_CACHE_SYNC 9 /* sync I+D caches */ 95 + #define MATTR_VAL_CACHE_SYNC 9 /* sync I+D caches */ 96 + 97 + #define MATTR_VAL_GET_INFO 10 /* get page info (stats) */ 98 + 99 + #endif /* _MACH_VM_ATTRIBUTES_H_ */
+78
libmac/xnu/mach/vm_behavior.h
··· 1 + /* 2 + * Copyright (c) 2000-2002 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * File: mach/vm_behavior.h 33 + * 34 + * Virtual memory map behavior definitions. 35 + * 36 + */ 37 + 38 + #ifndef _MACH_VM_BEHAVIOR_H_ 39 + #define _MACH_VM_BEHAVIOR_H_ 40 + 41 + /* 42 + * Types defined: 43 + * 44 + * vm_behavior_t behavior codes. 45 + */ 46 + 47 + typedef int vm_behavior_t; 48 + 49 + /* 50 + * Enumeration of valid values for vm_behavior_t. 51 + * These describe expected page reference behavior for 52 + * for a given range of virtual memory. For implementation 53 + * details see vm/vm_fault.c 54 + */ 55 + 56 + 57 + /* 58 + * The following behaviors affect the memory region's future behavior 59 + * and are stored in the VM map entry data structure. 60 + */ 61 + #define VM_BEHAVIOR_DEFAULT ((vm_behavior_t) 0) /* default */ 62 + #define VM_BEHAVIOR_RANDOM ((vm_behavior_t) 1) /* random */ 63 + #define VM_BEHAVIOR_SEQUENTIAL ((vm_behavior_t) 2) /* forward sequential */ 64 + #define VM_BEHAVIOR_RSEQNTL ((vm_behavior_t) 3) /* reverse sequential */ 65 + 66 + /* 67 + * The following "behaviors" affect the memory region only at the time of the 68 + * call and are not stored in the VM map entry. 69 + */ 70 + #define VM_BEHAVIOR_WILLNEED ((vm_behavior_t) 4) /* will need in near future */ 71 + #define VM_BEHAVIOR_DONTNEED ((vm_behavior_t) 5) /* dont need in near future */ 72 + #define VM_BEHAVIOR_FREE ((vm_behavior_t) 6) /* free memory without write-back */ 73 + #define VM_BEHAVIOR_ZERO_WIRED_PAGES ((vm_behavior_t) 7) /* zero out the wired pages of an entry if it is being deleted without unwiring them first */ 74 + #define VM_BEHAVIOR_REUSABLE ((vm_behavior_t) 8) 75 + #define VM_BEHAVIOR_REUSE ((vm_behavior_t) 9) 76 + #define VM_BEHAVIOR_CAN_REUSE ((vm_behavior_t) 10) 77 + 78 + #endif /*_MACH_VM_BEHAVIOR_H_*/
+89
libmac/xnu/mach/vm_inherit.h
··· 1 + /* 2 + * Copyright (c) 2000-2002 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * Mach Operating System 33 + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University 34 + * All Rights Reserved. 35 + * 36 + * Permission to use, copy, modify and distribute this software and its 37 + * documentation is hereby granted, provided that both the copyright 38 + * notice and this permission notice appear in all copies of the 39 + * software, derivative works or modified versions, and any portions 40 + * thereof, and that both notices appear in supporting documentation. 41 + * 42 + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 + * 46 + * Carnegie Mellon requests users of this software to return to 47 + * 48 + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 + * School of Computer Science 50 + * Carnegie Mellon University 51 + * Pittsburgh PA 15213-3890 52 + * 53 + * any improvements or extensions that they make and grant Carnegie Mellon 54 + * the rights to redistribute these changes. 55 + */ 56 + /* 57 + */ 58 + /* 59 + * File: mach/vm_inherit.h 60 + * Author: Avadis Tevanian, Jr., Michael Wayne Young 61 + * 62 + * Virtual memory map inheritance definitions. 63 + * 64 + */ 65 + 66 + #ifndef _MACH_VM_INHERIT_H_ 67 + #define _MACH_VM_INHERIT_H_ 68 + 69 + /* 70 + * Types defined: 71 + * 72 + * vm_inherit_t inheritance codes. 73 + */ 74 + 75 + typedef unsigned int vm_inherit_t; /* might want to change this */ 76 + 77 + /* 78 + * Enumeration of valid values for vm_inherit_t. 79 + */ 80 + 81 + #define VM_INHERIT_SHARE ((vm_inherit_t) 0) /* share with child */ 82 + #define VM_INHERIT_COPY ((vm_inherit_t) 1) /* copy into child */ 83 + #define VM_INHERIT_NONE ((vm_inherit_t) 2) /* absent from child */ 84 + #define VM_INHERIT_DONATE_COPY ((vm_inherit_t) 3) /* copy and delete */ 85 + 86 + #define VM_INHERIT_DEFAULT VM_INHERIT_COPY 87 + #define VM_INHERIT_LAST_VALID VM_INHERIT_NONE 88 + 89 + #endif /* _MACH_VM_INHERIT_H_ */
+148
libmac/xnu/mach/vm_prot.h
··· 1 + /* 2 + * Copyright (c) 2000-2002 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * Mach Operating System 33 + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University 34 + * All Rights Reserved. 35 + * 36 + * Permission to use, copy, modify and distribute this software and its 37 + * documentation is hereby granted, provided that both the copyright 38 + * notice and this permission notice appear in all copies of the 39 + * software, derivative works or modified versions, and any portions 40 + * thereof, and that both notices appear in supporting documentation. 41 + * 42 + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 + * 46 + * Carnegie Mellon requests users of this software to return to 47 + * 48 + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 + * School of Computer Science 50 + * Carnegie Mellon University 51 + * Pittsburgh PA 15213-3890 52 + * 53 + * any improvements or extensions that they make and grant Carnegie Mellon 54 + * the rights to redistribute these changes. 55 + */ 56 + /* 57 + */ 58 + /* 59 + * File: mach/vm_prot.h 60 + * Author: Avadis Tevanian, Jr., Michael Wayne Young 61 + * 62 + * Virtual memory protection definitions. 63 + * 64 + */ 65 + 66 + #ifndef _MACH_VM_PROT_H_ 67 + #define _MACH_VM_PROT_H_ 68 + 69 + /* 70 + * Types defined: 71 + * 72 + * vm_prot_t VM protection values. 73 + */ 74 + 75 + typedef int vm_prot_t; 76 + 77 + /* 78 + * Protection values, defined as bits within the vm_prot_t type 79 + */ 80 + 81 + #define VM_PROT_NONE ((vm_prot_t) 0x00) 82 + 83 + #define VM_PROT_READ ((vm_prot_t) 0x01) /* read permission */ 84 + #define VM_PROT_WRITE ((vm_prot_t) 0x02) /* write permission */ 85 + #define VM_PROT_EXECUTE ((vm_prot_t) 0x04) /* execute permission */ 86 + 87 + /* 88 + * The default protection for newly-created virtual memory 89 + */ 90 + 91 + #define VM_PROT_DEFAULT (VM_PROT_READ|VM_PROT_WRITE) 92 + 93 + /* 94 + * The maximum privileges possible, for parameter checking. 95 + */ 96 + 97 + #define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE) 98 + 99 + /* 100 + * An invalid protection value. 101 + * Used only by memory_object_lock_request to indicate no change 102 + * to page locks. Using -1 here is a bad idea because it 103 + * looks like VM_PROT_ALL and then some. 104 + */ 105 + 106 + #define VM_PROT_NO_CHANGE ((vm_prot_t) 0x08) 107 + 108 + /* 109 + * When a caller finds that he cannot obtain write permission on a 110 + * mapped entry, the following flag can be used. The entry will 111 + * be made "needs copy" effectively copying the object (using COW), 112 + * and write permission will be added to the maximum protections 113 + * for the associated entry. 114 + */ 115 + 116 + #define VM_PROT_COPY ((vm_prot_t) 0x10) 117 + 118 + 119 + /* 120 + * Another invalid protection value. 121 + * Used only by memory_object_data_request upon an object 122 + * which has specified a copy_call copy strategy. It is used 123 + * when the kernel wants a page belonging to a copy of the 124 + * object, and is only asking the object as a result of 125 + * following a shadow chain. This solves the race between pages 126 + * being pushed up by the memory manager and the kernel 127 + * walking down the shadow chain. 128 + */ 129 + 130 + #define VM_PROT_WANTS_COPY ((vm_prot_t) 0x10) 131 + 132 + #ifdef PRIVATE 133 + /* 134 + * The caller wants this memory region treated as if it had a valid 135 + * code signature. 136 + */ 137 + 138 + #define VM_PROT_TRUSTED ((vm_prot_t) 0x20) 139 + #endif /* PRIVATE */ 140 + 141 + /* 142 + * Another invalid protection value. 143 + * Indicates that the other protection bits are to be applied as a mask 144 + * against the actual protection bits of the map entry. 145 + */ 146 + #define VM_PROT_IS_MASK ((vm_prot_t) 0x40) 147 + 148 + #endif /* _MACH_VM_PROT_H_ */
+322
libmac/xnu/mach/vm_region.h
··· 1 + /* 2 + * Copyright (c) 2000-2006 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * File: mach/vm_region.h 33 + * 34 + * Define the attributes of a task's memory region 35 + * 36 + */ 37 + 38 + #ifndef _MACH_VM_REGION_H_ 39 + #define _MACH_VM_REGION_H_ 40 + 41 + #include <mach/boolean.h> 42 + #include <mach/vm_prot.h> 43 + #include <mach/vm_inherit.h> 44 + #include <mach/vm_behavior.h> 45 + #include <mach/vm_types.h> 46 + #include <mach/message.h> 47 + #include <mach/machine/vm_param.h> 48 + #include <mach/machine/vm_types.h> 49 + #include <mach/memory_object_types.h> 50 + 51 + #include <sys/cdefs.h> 52 + 53 + #pragma pack(4) 54 + 55 + // LP64todo: all the current tools are 32bit, obviously never worked for 64b 56 + // so probably should be a real 32b ID vs. ptr. 57 + // Current users just check for equality 58 + typedef uint32_t vm32_object_id_t; 59 + 60 + /* 61 + * Types defined: 62 + * 63 + * vm_region_info_t memory region attributes 64 + */ 65 + 66 + #define VM_REGION_INFO_MAX (1024) 67 + typedef int *vm_region_info_t; 68 + typedef int *vm_region_info_64_t; 69 + typedef int *vm_region_recurse_info_t; 70 + typedef int *vm_region_recurse_info_64_t; 71 + typedef int vm_region_flavor_t; 72 + typedef int vm_region_info_data_t[VM_REGION_INFO_MAX]; 73 + 74 + #define VM_REGION_BASIC_INFO_64 9 75 + struct vm_region_basic_info_64 { 76 + vm_prot_t protection; 77 + vm_prot_t max_protection; 78 + vm_inherit_t inheritance; 79 + boolean_t shared; 80 + boolean_t reserved; 81 + memory_object_offset_t offset; 82 + vm_behavior_t behavior; 83 + unsigned short user_wired_count; 84 + }; 85 + typedef struct vm_region_basic_info_64 *vm_region_basic_info_64_t; 86 + typedef struct vm_region_basic_info_64 vm_region_basic_info_data_64_t; 87 + 88 + #define VM_REGION_BASIC_INFO_COUNT_64 ((mach_msg_type_number_t) \ 89 + (sizeof(vm_region_basic_info_data_64_t)/sizeof(int))) 90 + 91 + /* 92 + * Passing VM_REGION_BASIC_INFO to vm_region_64 93 + * automatically converts it to a VM_REGION_BASIC_INFO_64. 94 + * Please use that explicitly instead. 95 + */ 96 + #define VM_REGION_BASIC_INFO 10 97 + 98 + /* 99 + * This is the legacy basic info structure. It is 100 + * deprecated because it passes only a 32-bit memory object 101 + * offset back - too small for many larger objects (e.g. files). 102 + */ 103 + struct vm_region_basic_info { 104 + vm_prot_t protection; 105 + vm_prot_t max_protection; 106 + vm_inherit_t inheritance; 107 + boolean_t shared; 108 + boolean_t reserved; 109 + uint32_t offset; /* too small for a real offset */ 110 + vm_behavior_t behavior; 111 + unsigned short user_wired_count; 112 + }; 113 + 114 + typedef struct vm_region_basic_info *vm_region_basic_info_t; 115 + typedef struct vm_region_basic_info vm_region_basic_info_data_t; 116 + 117 + #define VM_REGION_BASIC_INFO_COUNT ((mach_msg_type_number_t) \ 118 + (sizeof(vm_region_basic_info_data_t)/sizeof(int))) 119 + 120 + #define VM_REGION_EXTENDED_INFO 11 121 + 122 + #define SM_COW 1 123 + #define SM_PRIVATE 2 124 + #define SM_EMPTY 3 125 + #define SM_SHARED 4 126 + #define SM_TRUESHARED 5 127 + #define SM_PRIVATE_ALIASED 6 128 + #define SM_SHARED_ALIASED 7 129 + #define SM_LARGE_PAGE 8 130 + 131 + /* 132 + * For submap info, the SM flags above are overlayed when a submap 133 + * is encountered. The field denotes whether or not machine level mapping 134 + * information is being shared. PTE's etc. When such sharing is taking 135 + * place the value returned is SM_TRUESHARED otherwise SM_PRIVATE is passed 136 + * back. 137 + */ 138 + 139 + struct vm_region_extended_info { 140 + vm_prot_t protection; 141 + unsigned int user_tag; 142 + unsigned int pages_resident; 143 + unsigned int pages_shared_now_private; 144 + unsigned int pages_swapped_out; 145 + unsigned int pages_dirtied; 146 + unsigned int ref_count; 147 + unsigned short shadow_depth; 148 + unsigned char external_pager; 149 + unsigned char share_mode; 150 + }; 151 + 152 + typedef struct vm_region_extended_info *vm_region_extended_info_t; 153 + typedef struct vm_region_extended_info vm_region_extended_info_data_t; 154 + 155 + #define VM_REGION_EXTENDED_INFO_COUNT ((mach_msg_type_number_t) \ 156 + (sizeof(vm_region_extended_info_data_t)/sizeof(int))) 157 + 158 + 159 + #define VM_REGION_TOP_INFO 12 160 + 161 + struct vm_region_top_info { 162 + unsigned int obj_id; 163 + unsigned int ref_count; 164 + unsigned int private_pages_resident; 165 + unsigned int shared_pages_resident; 166 + unsigned char share_mode; 167 + }; 168 + 169 + typedef struct vm_region_top_info *vm_region_top_info_t; 170 + typedef struct vm_region_top_info vm_region_top_info_data_t; 171 + 172 + #define VM_REGION_TOP_INFO_COUNT ((mach_msg_type_number_t) \ 173 + (sizeof(vm_region_top_info_data_t)/sizeof(int))) 174 + 175 + 176 + 177 + /* 178 + * vm_region_submap_info will return information on a submap or object. 179 + * The user supplies a nesting level on the call. When a walk of the 180 + * user's map is done and a submap is encountered, the nesting count is 181 + * checked. If the nesting count is greater than 1 the submap is entered and 182 + * the offset relative to the address in the base map is examined. If the 183 + * nesting count is zero, the information on the submap is returned. 184 + * The caller may thus learn about a submap and its contents by judicious 185 + * choice of the base map address and nesting count. The nesting count 186 + * allows penetration of recursively mapped submaps. If a submap is 187 + * encountered as a mapped entry of another submap, the caller may bump 188 + * the nesting count and call vm_region_recurse again on the target address 189 + * range. The "is_submap" field tells the caller whether or not a submap 190 + * has been encountered. 191 + * 192 + * Object only fields are filled in through a walking of the object shadow 193 + * chain (where one is present), and a walking of the resident page queue. 194 + * 195 + */ 196 + 197 + struct vm_region_submap_info { 198 + vm_prot_t protection; /* present access protection */ 199 + vm_prot_t max_protection; /* max avail through vm_prot */ 200 + vm_inherit_t inheritance;/* behavior of map/obj on fork */ 201 + uint32_t offset; /* offset into object/map */ 202 + unsigned int user_tag; /* user tag on map entry */ 203 + unsigned int pages_resident; /* only valid for objects */ 204 + unsigned int pages_shared_now_private; /* only for objects */ 205 + unsigned int pages_swapped_out; /* only for objects */ 206 + unsigned int pages_dirtied; /* only for objects */ 207 + unsigned int ref_count; /* obj/map mappers, etc */ 208 + unsigned short shadow_depth; /* only for obj */ 209 + unsigned char external_pager; /* only for obj */ 210 + unsigned char share_mode; /* see enumeration */ 211 + boolean_t is_submap; /* submap vs obj */ 212 + vm_behavior_t behavior; /* access behavior hint */ 213 + vm32_object_id_t object_id; /* obj/map name, not a handle */ 214 + unsigned short user_wired_count; 215 + }; 216 + 217 + typedef struct vm_region_submap_info *vm_region_submap_info_t; 218 + typedef struct vm_region_submap_info vm_region_submap_info_data_t; 219 + 220 + #define VM_REGION_SUBMAP_INFO_COUNT ((mach_msg_type_number_t) \ 221 + (sizeof(vm_region_submap_info_data_t)/sizeof(int))) 222 + 223 + struct vm_region_submap_info_64 { 224 + vm_prot_t protection; /* present access protection */ 225 + vm_prot_t max_protection; /* max avail through vm_prot */ 226 + vm_inherit_t inheritance;/* behavior of map/obj on fork */ 227 + memory_object_offset_t offset; /* offset into object/map */ 228 + unsigned int user_tag; /* user tag on map entry */ 229 + unsigned int pages_resident; /* only valid for objects */ 230 + unsigned int pages_shared_now_private; /* only for objects */ 231 + unsigned int pages_swapped_out; /* only for objects */ 232 + unsigned int pages_dirtied; /* only for objects */ 233 + unsigned int ref_count; /* obj/map mappers, etc */ 234 + unsigned short shadow_depth; /* only for obj */ 235 + unsigned char external_pager; /* only for obj */ 236 + unsigned char share_mode; /* see enumeration */ 237 + boolean_t is_submap; /* submap vs obj */ 238 + vm_behavior_t behavior; /* access behavior hint */ 239 + vm32_object_id_t object_id; /* obj/map name, not a handle */ 240 + unsigned short user_wired_count; 241 + }; 242 + 243 + typedef struct vm_region_submap_info_64 *vm_region_submap_info_64_t; 244 + typedef struct vm_region_submap_info_64 vm_region_submap_info_data_64_t; 245 + 246 + #define VM_REGION_SUBMAP_INFO_COUNT_64 ((mach_msg_type_number_t) \ 247 + (sizeof(vm_region_submap_info_data_64_t)/sizeof(int))) 248 + 249 + struct vm_region_submap_short_info_64 { 250 + vm_prot_t protection; /* present access protection */ 251 + vm_prot_t max_protection; /* max avail through vm_prot */ 252 + vm_inherit_t inheritance;/* behavior of map/obj on fork */ 253 + memory_object_offset_t offset; /* offset into object/map */ 254 + unsigned int user_tag; /* user tag on map entry */ 255 + unsigned int ref_count; /* obj/map mappers, etc */ 256 + unsigned short shadow_depth; /* only for obj */ 257 + unsigned char external_pager; /* only for obj */ 258 + unsigned char share_mode; /* see enumeration */ 259 + boolean_t is_submap; /* submap vs obj */ 260 + vm_behavior_t behavior; /* access behavior hint */ 261 + vm32_object_id_t object_id; /* obj/map name, not a handle */ 262 + unsigned short user_wired_count; 263 + }; 264 + 265 + typedef struct vm_region_submap_short_info_64 *vm_region_submap_short_info_64_t; 266 + typedef struct vm_region_submap_short_info_64 vm_region_submap_short_info_data_64_t; 267 + 268 + #define VM_REGION_SUBMAP_SHORT_INFO_COUNT_64 ((mach_msg_type_number_t) \ 269 + (sizeof(vm_region_submap_short_info_data_64_t)/sizeof(int))) 270 + 271 + 272 + struct mach_vm_read_entry { 273 + mach_vm_address_t address; 274 + mach_vm_size_t size; 275 + }; 276 + 277 + struct vm_read_entry { 278 + vm_address_t address; 279 + vm_size_t size; 280 + }; 281 + 282 + #if VM32_SUPPORT 283 + struct vm32_read_entry { 284 + vm32_address_t address; 285 + vm32_size_t size; 286 + }; 287 + #endif 288 + 289 + 290 + #define VM_MAP_ENTRY_MAX (256) 291 + 292 + typedef struct mach_vm_read_entry mach_vm_read_entry_t[VM_MAP_ENTRY_MAX]; 293 + typedef struct vm_read_entry vm_read_entry_t[VM_MAP_ENTRY_MAX]; 294 + #if VM32_SUPPORT 295 + typedef struct vm32_read_entry vm32_read_entry_t[VM_MAP_ENTRY_MAX]; 296 + #endif 297 + 298 + #pragma pack() 299 + 300 + 301 + #define VM_PAGE_INFO_MAX 302 + typedef int *vm_page_info_t; 303 + typedef int vm_page_info_data_t[VM_PAGE_INFO_MAX]; 304 + typedef int vm_page_info_flavor_t; 305 + 306 + #define VM_PAGE_INFO_BASIC 1 307 + struct vm_page_info_basic { 308 + int disposition; 309 + int ref_count; 310 + vm_object_id_t object_id; 311 + memory_object_offset_t offset; 312 + int depth; 313 + int __pad; /* pad to 64-bit boundary */ 314 + }; 315 + typedef struct vm_page_info_basic *vm_page_info_basic_t; 316 + typedef struct vm_page_info_basic vm_page_info_basic_data_t; 317 + 318 + #define VM_PAGE_INFO_BASIC_COUNT ((mach_msg_type_number_t) \ 319 + (sizeof(vm_page_info_basic_data_t)/sizeof(int))) 320 + 321 + 322 + #endif /*_MACH_VM_REGION_H_*/
+80
libmac/xnu/mach/vm_sync.h
··· 1 + /* 2 + * Copyright (c) 2000-2002 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + */ 31 + /* 32 + * Mach Operating System 33 + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University 34 + * All Rights Reserved. 35 + * 36 + * Permission to use, copy, modify and distribute this software and its 37 + * documentation is hereby granted, provided that both the copyright 38 + * notice and this permission notice appear in all copies of the 39 + * software, derivative works or modified versions, and any portions 40 + * thereof, and that both notices appear in supporting documentation. 41 + * 42 + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 + * 46 + * Carnegie Mellon requests users of this software to return to 47 + * 48 + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 + * School of Computer Science 50 + * Carnegie Mellon University 51 + * Pittsburgh PA 15213-3890 52 + * 53 + * any improvements or extensions that they make and grant Carnegie Mellon 54 + * the rights to redistribute these changes. 55 + */ 56 + /* 57 + * File: mach/vm_sync.h 58 + * 59 + * Virtual memory synchronisation definitions. 60 + * 61 + */ 62 + 63 + #ifndef _MACH_VM_SYNC_H_ 64 + #define _MACH_VM_SYNC_H_ 65 + 66 + typedef unsigned vm_sync_t; 67 + 68 + /* 69 + * Synchronization flags, defined as bits within the vm_sync_t type 70 + */ 71 + 72 + #define VM_SYNC_ASYNCHRONOUS ((vm_sync_t) 0x01) 73 + #define VM_SYNC_SYNCHRONOUS ((vm_sync_t) 0x02) 74 + #define VM_SYNC_INVALIDATE ((vm_sync_t) 0x04) 75 + #define VM_SYNC_KILLPAGES ((vm_sync_t) 0x08) 76 + #define VM_SYNC_DEACTIVATE ((vm_sync_t) 0x10) 77 + #define VM_SYNC_CONTIGUOUS ((vm_sync_t) 0x20) 78 + #define VM_SYNC_REUSABLEPAGES ((vm_sync_t) 0x40) 79 + 80 + #endif /* _MACH_VM_SYNC_H_ */
+146
libmac/xnu/mach/vm_types.h
··· 1 + /* 2 + * Copyright (c) 2000-2004 Apple Computer, 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 + /* 29 + * @OSF_COPYRIGHT@ 30 + * 31 + */ 32 + #ifndef _MACH_VM_TYPES_H_ 33 + #define _MACH_VM_TYPES_H_ 34 + 35 + #include <mach/port.h> 36 + #include <mach/machine/vm_types.h> 37 + 38 + #include <stdint.h> 39 + 40 + typedef vm_offset_t pointer_t; 41 + typedef vm_offset_t vm_address_t; 42 + 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 + */ 49 + typedef uint64_t addr64_t; /* Basic effective address */ 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 + */ 61 + typedef uint32_t reg64_t; 62 + 63 + /* 64 + * To minimize the use of 64-bit fields, we keep some physical 65 + * addresses (that are page aligned) as 32-bit page numbers. 66 + * This limits the physical address space to 16TB of RAM. 67 + */ 68 + typedef uint32_t ppnum_t; /* Physical page number */ 69 + #define PPNUM_MAX UINT32_MAX 70 + 71 + 72 + #ifdef KERNEL_PRIVATE 73 + 74 + #include <sys/cdefs.h> 75 + 76 + #ifndef MACH_KERNEL_PRIVATE 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 + */ 83 + __BEGIN_DECLS 84 + 85 + struct pmap ; 86 + struct _vm_map ; 87 + struct vm_object ; 88 + 89 + __END_DECLS 90 + 91 + #endif /* MACH_KERNEL_PRIVATE */ 92 + 93 + typedef struct pmap *pmap_t; 94 + typedef struct _vm_map *vm_map_t; 95 + typedef struct vm_object *vm_object_t; 96 + typedef struct vm_object_fault_info *vm_object_fault_info_t; 97 + 98 + #define PMAP_NULL ((pmap_t) 0) 99 + #define VM_OBJECT_NULL ((vm_object_t) 0) 100 + 101 + #else /* KERNEL_PRIVATE */ 102 + 103 + typedef mach_port_t vm_map_t; 104 + 105 + #endif /* KERNEL_PRIVATE */ 106 + 107 + #define VM_MAP_NULL ((vm_map_t) 0) 108 + 109 + /* 110 + * Evolving definitions, likely to change. 111 + */ 112 + 113 + typedef uint64_t vm_object_offset_t; 114 + typedef uint64_t vm_object_size_t; 115 + 116 + #ifdef KERNEL_PRIVATE 117 + 118 + #ifndef MACH_KERNEL_PRIVATE 119 + 120 + __BEGIN_DECLS 121 + 122 + struct upl ; 123 + struct vm_map_copy ; 124 + struct vm_named_entry ; 125 + 126 + __END_DECLS 127 + 128 + #endif /* MACH_KERNEL_PRIVATE */ 129 + 130 + typedef struct upl *upl_t; 131 + typedef struct vm_map_copy *vm_map_copy_t; 132 + typedef struct vm_named_entry *vm_named_entry_t; 133 + 134 + #define VM_MAP_COPY_NULL ((vm_map_copy_t) 0) 135 + 136 + #else /* KERNEL_PRIVATE */ 137 + 138 + typedef mach_port_t upl_t; 139 + typedef mach_port_t vm_named_entry_t; 140 + 141 + #endif /* KERNEL_PRIVATE */ 142 + 143 + #define UPL_NULL ((upl_t) 0) 144 + #define VM_NAMED_ENTRY_NULL ((vm_named_entry_t) 0) 145 + 146 + #endif /* _MACH_VM_TYPES_H_ */