]> git.saurik.com Git - apple/xnu.git/blame - osfmk/vm/vm_compressor_pager.h
xnu-6153.81.5.tar.gz
[apple/xnu.git] / osfmk / vm / vm_compressor_pager.h
CommitLineData
39236c6e
A
1/*
2 * Copyright (c) 2013 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 5 *
39236c6e
A
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.
0a7de745 14 *
39236c6e
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
0a7de745 17 *
39236c6e
A
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.
0a7de745 25 *
39236c6e
A
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
0a7de745 29#ifdef XNU_KERNEL_PRIVATE
39236c6e
A
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(
0a7de745
A
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);
39236c6e 45extern kern_return_t vm_compressor_pager_get(
0a7de745
A
46 memory_object_t mem_obj,
47 memory_object_offset_t offset,
48 ppnum_t ppnum,
49 int *my_fault_type,
50 int flags,
51 int *compressed_count_delta_p);
39236c6e 52
0a7de745
A
53#define C_DONT_BLOCK 0x01
54#define C_KEEP 0x02
55#define C_KDP 0x04
39236c6e 56
fe8ab488 57extern unsigned int vm_compressor_pager_state_clr(
0a7de745
A
58 memory_object_t mem_obj,
59 memory_object_offset_t offset);
39236c6e 60extern vm_external_state_t vm_compressor_pager_state_get(
0a7de745
A
61 memory_object_t mem_obj,
62 memory_object_offset_t offset);
39236c6e 63
0a7de745
A
64#define VM_COMPRESSOR_PAGER_STATE_GET(object, offset) \
65 (((object)->internal && \
66 (object)->pager != NULL && \
67 !(object)->terminating && \
68 (object)->alive) \
69 ? vm_compressor_pager_state_get((object)->pager, \
70 (offset) + (object)->paging_offset) \
39236c6e
A
71 : VM_EXTERNAL_STATE_UNKNOWN)
72
0a7de745
A
73#define VM_COMPRESSOR_PAGER_STATE_CLR(object, offset) \
74 MACRO_BEGIN \
75 if ((object)->internal && \
76 (object)->pager != NULL && \
77 !(object)->terminating && \
78 (object)->alive) { \
79 int _num_pages_cleared; \
80 _num_pages_cleared = \
81 vm_compressor_pager_state_clr( \
82 (object)->pager, \
83 (offset) + (object)->paging_offset); \
84 if (_num_pages_cleared) { \
85 vm_compressor_pager_count((object)->pager, \
86 -_num_pages_cleared, \
87 FALSE, /* shared */ \
88 (object)); \
89 } \
90 if (_num_pages_cleared && \
91 ((object)->purgable != VM_PURGABLE_DENY || \
92 (object)->vo_ledger_tag)) { \
93 /* less compressed purgeable/tagged pages */ \
94 assert(_num_pages_cleared == 1); \
95 vm_object_owner_compressed_update( \
96 (object), \
97 -_num_pages_cleared); \
98 } \
99 } \
39236c6e
A
100 MACRO_END
101
fe8ab488 102extern void vm_compressor_pager_transfer(
0a7de745
A
103 memory_object_t dst_mem_obj,
104 memory_object_offset_t dst_offset,
105 memory_object_t src_mem_obj,
106 memory_object_offset_t src_offset);
fe8ab488 107extern memory_object_offset_t vm_compressor_pager_next_compressed(
0a7de745
A
108 memory_object_t mem_obj,
109 memory_object_offset_t offset);
fe8ab488 110
39236c6e
A
111extern void vm_compressor_init(void);
112extern int vm_compressor_put(ppnum_t pn, int *slot, void **current_chead, char *scratch_buf);
113extern int vm_compressor_get(ppnum_t pn, int *slot, int flags);
fe8ab488
A
114extern int vm_compressor_free(int *slot, int flags);
115extern unsigned int vm_compressor_pager_reap_pages(memory_object_t mem_obj, int flags);
fe8ab488
A
116extern unsigned int vm_compressor_pager_get_count(memory_object_t mem_obj);
117extern void vm_compressor_pager_count(memory_object_t mem_obj,
0a7de745
A
118 int compressed_count_delta,
119 boolean_t shared_lock,
120 vm_object_t object);
3e170ce0 121
0a7de745 122extern void vm_compressor_transfer(int *dst_slot_p, int *src_slot_p);
39236c6e 123
3e170ce0
A
124#if CONFIG_FREEZE
125extern kern_return_t vm_compressor_pager_relocate(memory_object_t mem_obj, memory_object_offset_t mem_offset, void **current_chead);
126extern kern_return_t vm_compressor_relocate(void **current_chead, int *src_slot_p);
127extern void vm_compressor_finished_filling(void **current_chead);
128#endif /* CONFIG_FREEZE */
129
0a7de745 130#endif /* _VM_VM_COMPRESSOR_PAGER_H_ */
39236c6e 131
0a7de745 132#endif /* XNU_KERNEL_PRIVATE */