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 #if HAS_MTE 45 uint16_t csi_mte_size:15, 46 csi_mte_has_data:1; 47 #else /* HAS_MTE */ 48 uint16_t csi_unused; 49 #endif /* HAS_MTE */ 50 } __attribute__((packed)); 51 52 struct c_segment_info { 53 uint32_t csi_mysegno; 54 uint32_t csi_creation_ts; 55 uint32_t csi_swappedin_ts; 56 int32_t csi_bytes_unused; 57 int32_t csi_bytes_used; 58 uint32_t csi_populated_offset; 59 60 uint32_t csi_state: 4, 61 csi_swappedin: 1, 62 csi_on_minor_compact_q: 1, 63 csi_has_donated_pages: 1, 64 csi_reserved: 25; 65 int csi_slot_var_array_len;/* max is 1024 so this can be short in needed */ 66 uint32_t csi_decompressions_since_swapin; 67 uint16_t csi_slots_used; 68 uint16_t csi_slots_len; /* count of csi_slots */ 69 struct c_slot_info csi_slots[0]; 70 } __attribute__((packed)); 71 72 #define VM_C_SEGMENT_INFO_MAGIC 'C002' 73 #if HAS_MTE 74 #define VM_C_SEGMENT_INFO_MAGIC_WITH_TAGS 'C103' 75 #endif /* HAS_MTE */ 76 77 /* 78 * vm_map_info_hdr and vm_map_entry_info are used for output of ### 79 * a starting header gives the number of entries that follow, the every entry in the vm_map 80 * is represented by a vm_map_entry_info 81 */ 82 struct vm_map_info_hdr { 83 int vmi_nentries; 84 } __attribute__((packed)); 85 86 struct vm_map_entry_info { 87 vm_map_offset_t vmei_start; /* start address */ 88 vm_map_offset_t vmei_end; /* end address */ 89 unsigned long long 90 /* vm_tag_t */ vmei_alias:12, /* entry VM tag */ 91 /* vm_object_offset_t*/ vmei_offset:(64 - 12); /* offset into object */ 92 uint32_t vmei_is_sub_map: 1, 93 vmei_is_compressor_pager: 1, 94 vmei_protection: 3; 95 uint32_t vmei_slot_mapping_count; 96 int slot_mappings[0]; 97 } __attribute__((packed)); 98 99 #define VM_MAP_ENTRY_INFO_MAGIC 'S001' 100 101 #endif /* PRIVATE */ 102