1 /* 2 * Copyright (c) 2023 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 _VM_VM_IOKIT_H_ 30 #define _VM_VM_IOKIT_H_ 31 32 #include <sys/cdefs.h> 33 #include <mach/mach_types.h> 34 #include <kern/kern_types.h> 35 #include <vm/vm_options.h> 36 37 __BEGIN_DECLS 38 39 extern kern_return_t memory_object_iopl_request( 40 ipc_port_t port, 41 memory_object_offset_t offset, 42 upl_size_t *upl_size, 43 upl_t *upl_ptr, 44 upl_page_info_array_t user_page_list, 45 unsigned int *page_list_count, 46 upl_control_flags_t *flags, 47 vm_tag_t tag); 48 49 extern uint32_t vm_tag_get_kext(vm_tag_t tag, char * name, vm_size_t namelen); 50 51 52 extern void iopl_valid_data( 53 upl_t upl_ptr, 54 vm_tag_t tag); 55 56 57 #ifdef MACH_KERNEL_PRIVATE 58 #include <vm/vm_page.h> 59 #else 60 typedef struct vm_page *vm_page_t; 61 #endif 62 63 64 extern void vm_page_set_offset(vm_page_t page, vm_object_offset_t offset); 65 extern vm_object_offset_t vm_page_get_offset(vm_page_t page); 66 extern ppnum_t vm_page_get_phys_page(vm_page_t page); 67 extern vm_page_t vm_page_get_next(vm_page_t page); 68 69 70 /* 71 * device_data_action and device_close are exported symbols 72 */ 73 extern kern_return_t device_data_action( 74 uintptr_t device_handle, 75 ipc_port_t device_pager, 76 vm_prot_t protection, 77 vm_object_offset_t offset, 78 vm_size_t size); 79 80 extern kern_return_t device_close( 81 uintptr_t device_handle); 82 83 extern boolean_t vm_swap_files_pinned(void); 84 85 extern kern_return_t vm_map_purgable_control( 86 vm_map_t map, 87 vm_map_offset_t address, 88 vm_purgable_t control, 89 int *state); 90 91 extern kern_return_t device_pager_populate_object( 92 memory_object_t device, 93 memory_object_offset_t offset, 94 ppnum_t page_num, 95 vm_size_t size); 96 extern memory_object_t device_pager_setup( 97 memory_object_t, 98 uintptr_t, 99 vm_size_t, 100 int); 101 102 extern kern_return_t vm_map_range_physical_size( 103 vm_map_t map, 104 vm_map_address_t start, 105 mach_vm_size_t size, 106 mach_vm_size_t * phys_size); 107 108 109 #if defined(__arm64__) 110 extern void vm_panic_hibernate_write_image_failed(int err); 111 #endif /* __arm64__ */ 112 113 114 extern kern_return_t mach_make_memory_entry_internal( 115 vm_map_t target_map, 116 memory_object_size_ut *size, 117 memory_object_offset_ut offset, 118 vm_prot_ut permission, 119 vm_named_entry_kernel_flags_t vmne_kflags, 120 ipc_port_t *object_handle, 121 ipc_port_t parent_handle); 122 123 extern kern_return_t 124 memory_entry_check_for_adjustment( 125 vm_map_t src_map, 126 ipc_port_t port, 127 vm_map_offset_t *overmap_start, 128 vm_map_offset_t *overmap_end); 129 130 extern kern_return_t memory_entry_purgeable_control_internal( 131 ipc_port_t entry_port, 132 vm_purgable_t control, 133 int *state); 134 135 extern kern_return_t mach_memory_entry_get_page_counts( 136 ipc_port_t entry_port, 137 unsigned int *resident_page_count, 138 unsigned int *dirty_page_count); 139 140 extern kern_return_t mach_memory_entry_phys_page_offset( 141 ipc_port_t entry_port, 142 vm_object_offset_t *offset_p); 143 144 extern kern_return_t mach_memory_entry_map_size( 145 ipc_port_t entry_port, 146 vm_map_t map, 147 memory_object_offset_ut offset, 148 memory_object_size_ut size, 149 mach_vm_size_t *map_size); 150 151 /* Enter a mapping of a memory object */ 152 extern kern_return_t vm_map_enter_mem_object_prefault( 153 vm_map_t map, 154 vm_map_offset_ut *address, 155 vm_map_size_ut size, 156 vm_map_offset_ut mask, 157 vm_map_kernel_flags_t vmk_flags, 158 ipc_port_t port, 159 vm_object_offset_ut offset, 160 vm_prot_ut cur_protection, 161 vm_prot_ut max_protection, 162 upl_page_list_ptr_t page_list, 163 unsigned int page_list_count); 164 165 166 __END_DECLS 167 168 #endif /* _VM_VM_IOKIT_H_ */ 169