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_COMPRESSOR_PAGER_INTERNAL_H_ 30 #define _VM_VM_COMPRESSOR_PAGER_INTERNAL_H_ 31 32 #include <sys/cdefs.h> 33 #include <vm/vm_compressor_pager_xnu.h> 34 35 __BEGIN_DECLS 36 #ifdef XNU_KERNEL_PRIVATE 37 38 extern kern_return_t vm_compressor_pager_put( 39 memory_object_t mem_obj, 40 memory_object_offset_t offset, 41 ppnum_t ppnum, 42 void **current_chead, 43 char *scratch_buf, 44 int *compressed_count_delta_p, 45 vm_compressor_options_t flags); 46 47 48 extern unsigned int vm_compressor_pager_state_clr( 49 memory_object_t mem_obj, 50 memory_object_offset_t offset); 51 extern vm_external_state_t vm_compressor_pager_state_get( 52 memory_object_t mem_obj, 53 memory_object_offset_t offset); 54 55 extern void vm_compressor_pager_transfer( 56 memory_object_t dst_mem_obj, 57 memory_object_offset_t dst_offset, 58 memory_object_t src_mem_obj, 59 memory_object_offset_t src_offset); 60 extern memory_object_offset_t vm_compressor_pager_next_compressed( 61 memory_object_t mem_obj, 62 memory_object_offset_t offset); 63 64 extern bool osenvironment_is_diagnostics(void); 65 extern void vm_compressor_init(void); 66 extern bool vm_compressor_is_slot_compressed(int *slot); 67 extern int vm_compressor_put(ppnum_t pn, int *slot, void **current_chead, char *scratch_buf, vm_compressor_options_t flags); 68 extern int vm_compressor_get(ppnum_t pn, int *slot, vm_compressor_options_t flags); 69 extern int vm_compressor_free(int *slot, vm_compressor_options_t flags); 70 71 #if CONFIG_TRACK_UNMODIFIED_ANON_PAGES 72 extern int vm_uncompressed_put(ppnum_t pn, int *slot); 73 extern int vm_uncompressed_get(ppnum_t pn, int *slot, vm_compressor_options_t flags); 74 extern int vm_uncompressed_free(int *slot, vm_compressor_options_t flags); 75 #endif /* CONFIG_TRACK_UNMODIFIED_ANON_PAGES */ 76 extern unsigned int vm_compressor_pager_reap_pages(memory_object_t mem_obj, vm_compressor_options_t flags); 77 78 extern void vm_compressor_pager_count(memory_object_t mem_obj, 79 int compressed_count_delta, 80 boolean_t shared_lock, 81 vm_object_t object); 82 83 extern void vm_compressor_transfer(int *dst_slot_p, int *src_slot_p); 84 85 #if CONFIG_FREEZE 86 extern kern_return_t vm_compressor_pager_relocate(memory_object_t mem_obj, memory_object_offset_t mem_offset, void **current_chead); 87 extern kern_return_t vm_compressor_relocate(void **current_chead, int *src_slot_p); 88 extern void vm_compressor_finished_filling(void **current_chead); 89 #endif /* CONFIG_FREEZE */ 90 91 #if DEVELOPMENT || DEBUG 92 extern kern_return_t vm_compressor_pager_inject_error(memory_object_t pager, 93 memory_object_offset_t offset); 94 extern void vm_compressor_inject_error(int *slot); 95 96 extern kern_return_t vm_compressor_pager_dump(memory_object_t mem_obj, char *buf, size_t *size, 97 bool *is_compressor, unsigned int *slot_count); 98 #endif /* DEVELOPMENT || DEBUG */ 99 100 #endif /* XNU_KERNEL_PRIVATE */ 101 __END_DECLS 102 103 #endif /* _VM_VM_COMPRESSOR_PAGER_INTERNAL_H_ */ 104