xref: /xnu-12377.1.9/osfmk/vm/vm_compressor_info.h (revision f6217f891ac0bb64f3d375211650a4c1ff8ca1ea) !
1 /*
2  * Copyright (c) 2000-2024 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 #pragma once
30 
31 #if PRIVATE
32 
33 #include <sys/cdefs.h>
34 #include <mach/machine/kern_return.h>
35 
36 
37 /*
38  * c_segment_info and c_slot_info are used in the serialization protocol of sysctl vm.compressor_segments
39  * one c_segment_info is dumped for every c_segment in memory, followed by a number of c_slot_info
40  * Every change to this format should increment the version number in VM_C_SEGMENT_INFO_MAGIC
41  */
42 struct c_slot_info {
43 	uint16_t       csi_size;
44 	uint16_t       csi_unused;
45 } __attribute__((packed));
46 
47 struct c_segment_info {
48 	uint32_t       csi_mysegno;
49 	uint32_t       csi_creation_ts;
50 	uint32_t       csi_swappedin_ts;
51 	int32_t        csi_bytes_unused;
52 	int32_t        csi_bytes_used;
53 	uint32_t       csi_populated_offset;
54 
55 	uint32_t       csi_state: 4,
56 	    csi_swappedin: 1,
57 	    csi_on_minor_compact_q: 1,
58 	    csi_has_donated_pages: 1,
59 	    csi_reserved: 25;
60 	int            csi_slot_var_array_len;/* max is 1024 so this can be short in needed */
61 	uint32_t       csi_decompressions_since_swapin;
62 	uint16_t       csi_slots_used;
63 	uint16_t       csi_slots_len;  /* count of csi_slots */
64 	struct c_slot_info  csi_slots[0];
65 } __attribute__((packed));
66 
67 #define VM_C_SEGMENT_INFO_MAGIC 'C002'
68 
69 /*
70  * vm_map_info_hdr and vm_map_entry_info are used for output of ###
71  * a starting header gives the number of entries that follow, the every entry in the vm_map
72  * is represented by a vm_map_entry_info
73  */
74 struct vm_map_info_hdr {
75 	int vmi_nentries;
76 } __attribute__((packed));
77 
78 struct vm_map_entry_info {
79 	vm_map_offset_t         vmei_start;          /* start address */
80 	vm_map_offset_t         vmei_end;            /* end address */
81 	unsigned long long
82 	/* vm_tag_t          */ vmei_alias:12,   /* entry VM tag */
83 	/* vm_object_offset_t*/ vmei_offset:(64 - 12); /* offset into object */
84 	uint32_t vmei_is_sub_map: 1,
85 	    vmei_is_compressor_pager: 1,
86 	    vmei_protection: 3;
87 	uint32_t vmei_slot_mapping_count;
88 	int slot_mappings[0];
89 } __attribute__((packed));
90 
91 #define VM_MAP_ENTRY_INFO_MAGIC 'S001'
92 
93 #endif /* PRIVATE */
94