1/* 2 * Copyright (c) 2013 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#ifdef XNU_KERNEL_PRIVATE 30 31#ifndef _VM_VM_COMPRESSOR_PAGER_H_ 32#define _VM_VM_COMPRESSOR_PAGER_H_ 33 34#include <mach/mach_types.h> 35#include <kern/kern_types.h> 36#include <vm/vm_external.h> 37 38extern 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); 44extern kern_return_t vm_compressor_pager_get( 45 memory_object_t mem_obj, 46 memory_object_offset_t offset, 47 ppnum_t ppnum, 48 int *my_fault_type, 49 int flags); 50 51#define C_DONT_BLOCK 0x01 52#define C_KEEP 0x02 53 54extern void vm_compressor_pager_state_clr( 55 memory_object_t mem_obj, 56 memory_object_offset_t offset); 57extern vm_external_state_t vm_compressor_pager_state_get( 58 memory_object_t mem_obj, 59 memory_object_offset_t offset); 60 61#define VM_COMPRESSOR_PAGER_STATE_GET(object, offset) \ 62 (((COMPRESSED_PAGER_IS_ACTIVE || DEFAULT_FREEZER_COMPRESSED_PAGER_IS_ACTIVE) && \ 63 (object)->internal && \ 64 (object)->pager != NULL && \ 65 !(object)->terminating && \ 66 (object)->alive) \ 67 ? vm_compressor_pager_state_get((object)->pager, \ 68 (offset) + (object)->paging_offset) \ 69 : VM_EXTERNAL_STATE_UNKNOWN) 70 71#define VM_COMPRESSOR_PAGER_STATE_CLR(object, offset) \ 72 MACRO_BEGIN \ 73 if ((COMPRESSED_PAGER_IS_ACTIVE || DEFAULT_FREEZER_COMPRESSED_PAGER_IS_ACTIVE) && \ 74 (object)->internal && \ 75 (object)->pager != NULL && \ 76 !(object)->terminating && \ 77 (object)->alive) { \ 78 vm_compressor_pager_state_clr( \ 79 (object)->pager, \ 80 (offset) + (object)->paging_offset); \ 81 } \ 82 MACRO_END 83 84extern void vm_compressor_init(void); 85extern int vm_compressor_put(ppnum_t pn, int *slot, void **current_chead, char *scratch_buf); 86extern int vm_compressor_get(ppnum_t pn, int *slot, int flags); 87extern void vm_compressor_free(int *slot); 88 89#endif /* _VM_VM_COMPRESSOR_PAGER_H_ */ 90 91#endif /* XNU_KERNEL_PRIVATE */ 92