1 /* 2 * Copyright (c) 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 * Data structures that reveal the CPU topology of the system. This header is 30 * used to contain the API which is kernel private for now, since things are 31 * constantly evolving and kexts that depend on it could break unexpectedly. 32 * It should not be included directly but instead is included from 33 * machine_routines.h 34 */ 35 36 #ifndef _ARM_CPU_TOPOLOGY_H_ 37 #define _ARM_CPU_TOPOLOGY_H_ 38 39 #include <stdint.h> 40 __BEGIN_DECLS 41 42 typedef struct ml_topology_cpu { 43 unsigned int cpu_id; 44 uint32_t phys_id; 45 unsigned int cluster_id; 46 unsigned int die_id; 47 cluster_type_t cluster_type; 48 uint32_t l2_access_penalty; /* unused */ 49 uint32_t l2_cache_size; 50 uint32_t l2_cache_id; 51 uint32_t l3_cache_size; 52 uint32_t l3_cache_id; 53 vm_offset_t cpu_IMPL_regs; 54 uint64_t cpu_IMPL_pa; 55 uint64_t cpu_IMPL_len; 56 vm_offset_t cpu_UTTDBG_regs; 57 uint64_t cpu_UTTDBG_pa; 58 uint64_t cpu_UTTDBG_len; 59 vm_offset_t coresight_regs; 60 uint64_t coresight_pa; 61 uint64_t coresight_len; 62 unsigned int die_cluster_id; 63 unsigned int cluster_core_id; 64 } ml_topology_cpu_t; 65 66 typedef struct ml_topology_cluster { 67 unsigned int cluster_id; 68 cluster_type_t cluster_type; 69 unsigned int num_cpus; 70 unsigned int first_cpu_id; 71 uint64_t cpu_mask; 72 unsigned int die_id; 73 unsigned int die_cluster_id; 74 vm_offset_t acc_IMPL_regs; 75 uint64_t acc_IMPL_pa; 76 uint64_t acc_IMPL_len; 77 vm_offset_t cpm_IMPL_regs; 78 uint64_t cpm_IMPL_pa; 79 uint64_t cpm_IMPL_len; 80 } ml_topology_cluster_t; 81 82 // Bump this version number any time any ml_topology_* struct changes in a 83 // way that is likely to break kexts, so that users can check whether their 84 // headers are compatible with the running kernel 85 #define CPU_TOPOLOGY_VERSION 1 86 87 typedef struct ml_topology_info { 88 unsigned int version; 89 unsigned int num_cpus; 90 unsigned int max_cpu_id; 91 unsigned int num_clusters; 92 unsigned int max_cluster_id; 93 unsigned int max_die_id; 94 ml_topology_cpu_t *cpus; 95 ml_topology_cluster_t *clusters; 96 ml_topology_cpu_t *boot_cpu; 97 ml_topology_cluster_t *boot_cluster; 98 unsigned int chip_revision; 99 unsigned int cluster_types; 100 unsigned int cluster_type_num_cpus[MAX_CPU_TYPES]; 101 unsigned int cluster_type_num_clusters[MAX_CPU_TYPES]; 102 unsigned int cluster_power_down; 103 } ml_topology_info_t; 104 105 /*! 106 * @function ml_get_topology_info 107 * @result A pointer to the read-only topology struct. Does not need to be freed. Returns NULL 108 * if the struct hasn't been initialized or the feature is unsupported. 109 */ 110 const ml_topology_info_t *ml_get_topology_info(void); 111 112 __END_DECLS 113 114 #endif /* _ARM_CPU_TOPOLOGY_H_ */ 115