2 * Copyright (c) 2013 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifdef XNU_KERNEL_PRIVATE
31 #ifndef _VM_VM_COMPRESSOR_PAGER_H_
32 #define _VM_VM_COMPRESSOR_PAGER_H_
34 #include <mach/mach_types.h>
35 #include <kern/kern_types.h>
36 #include <vm/vm_external.h>
38 extern kern_return_t
vm_compressor_pager_put(
39 memory_object_t mem_obj
,
40 memory_object_offset_t offset
,
44 int *compressed_count_delta_p
);
45 extern kern_return_t
vm_compressor_pager_get(
46 memory_object_t mem_obj
,
47 memory_object_offset_t offset
,
51 int *compressed_count_delta_p
);
53 #define C_DONT_BLOCK 0x01
56 extern unsigned int vm_compressor_pager_state_clr(
57 memory_object_t mem_obj
,
58 memory_object_offset_t offset
);
59 extern vm_external_state_t
vm_compressor_pager_state_get(
60 memory_object_t mem_obj
,
61 memory_object_offset_t offset
);
63 #define VM_COMPRESSOR_PAGER_STATE_GET(object, offset) \
64 (((COMPRESSED_PAGER_IS_ACTIVE || \
65 DEFAULT_FREEZER_COMPRESSED_PAGER_IS_ACTIVE) && \
66 (object)->internal && \
67 (object)->pager != NULL && \
68 !(object)->terminating && \
70 ? vm_compressor_pager_state_get((object)->pager, \
71 (offset) + (object)->paging_offset) \
72 : VM_EXTERNAL_STATE_UNKNOWN)
74 #define VM_COMPRESSOR_PAGER_STATE_CLR(object, offset) \
76 if ((COMPRESSED_PAGER_IS_ACTIVE || \
77 DEFAULT_FREEZER_COMPRESSED_PAGER_IS_ACTIVE) && \
78 (object)->internal && \
79 (object)->pager != NULL && \
80 !(object)->terminating && \
82 int _num_pages_cleared; \
83 _num_pages_cleared = \
84 vm_compressor_pager_state_clr( \
86 (offset) + (object)->paging_offset); \
87 if (_num_pages_cleared) { \
88 vm_compressor_pager_count((object)->pager, \
89 -_num_pages_cleared, \
93 if (_num_pages_cleared && \
94 (object)->purgable != VM_PURGABLE_DENY && \
95 (object)->vo_purgeable_owner != NULL) { \
96 /* less compressed purgeable pages */ \
97 assert(_num_pages_cleared == 1); \
98 vm_purgeable_compressed_update( \
100 -_num_pages_cleared); \
105 extern void vm_compressor_pager_transfer(
106 memory_object_t dst_mem_obj
,
107 memory_object_offset_t dst_offset
,
108 memory_object_t src_mem_obj
,
109 memory_object_offset_t src_offset
);
110 extern memory_object_offset_t
vm_compressor_pager_next_compressed(
111 memory_object_t mem_obj
,
112 memory_object_offset_t offset
);
114 extern void vm_compressor_init(void);
115 extern int vm_compressor_put(ppnum_t pn
, int *slot
, void **current_chead
, char *scratch_buf
);
116 extern int vm_compressor_get(ppnum_t pn
, int *slot
, int flags
);
117 extern int vm_compressor_free(int *slot
, int flags
);
118 extern unsigned int vm_compressor_pager_reap_pages(memory_object_t mem_obj
, int flags
);
119 extern unsigned int vm_compressor_pager_get_slots_occupied(memory_object_t mem_obj
);
120 extern unsigned int vm_compressor_pager_get_count(memory_object_t mem_obj
);
121 extern void vm_compressor_pager_count(memory_object_t mem_obj
,
122 int compressed_count_delta
,
123 boolean_t shared_lock
,
125 extern void vm_compressor_transfer(int *dst_slot_p
, int *src_slot_p
);
127 #endif /* _VM_VM_COMPRESSOR_PAGER_H_ */
129 #endif /* XNU_KERNEL_PRIVATE */