From 36071b8eb8f9141c423d8e1af62121d35fb93507 Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Fri, 9 Jun 2023 17:47:05 +0200 Subject: [PATCH] [v1.04][ARM] Add support for M2 Pro --- src/arm/midr.c | 24 ++++++++++++++++++++++-- src/arm/soc.c | 3 +++ src/arm/socs.h | 3 +++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/arm/midr.c b/src/arm/midr.c index c3dc4ba..133fb82 100644 --- a/src/arm/midr.c +++ b/src/arm/midr.c @@ -351,9 +351,29 @@ struct cpuInfo* get_cpu_info_mach(struct cpuInfo* cpu) { cpu->peak_performance = get_peak_performance(cpu); } else if(cpu_family == CPUFAMILY_ARM_AVALANCHE_BLIZZARD) { - // Just the "normal" M2 exists for now cpu->num_cpus = 2; - fill_cpu_info_avalanche_blizzard(cpu, 4, 4); + // Now detect the M2 version + uint32_t cpu_subfamily = get_sys_info_by_name("hw.cpusubfamily"); + if(cpu_subfamily == CPUSUBFAMILY_ARM_HG) { + // Apple M2 + fill_cpu_info_avalanche_blizzard(cpu, 4, 4); + } + else if(cpu_subfamily == CPUSUBFAMILY_ARM_HS) { + // Apple M2 Pro. Detect number of cores + uint32_t physicalcpu = get_sys_info_by_name("hw.physicalcpu"); + if(physicalcpu == 10 || physicalcpu == 12) { + // M2 Pro (or Max?) + fill_cpu_info_avalanche_blizzard(cpu, physicalcpu-4, 4); + } + else { + printBug("Found invalid physical cpu number: %d", physicalcpu); + return NULL; + } + } + else { + printBug("Found invalid cpu_subfamily: 0x%.8X", cpu_subfamily); + return NULL; + } cpu->soc = get_soc(); cpu->peak_performance = get_peak_performance(cpu); } diff --git a/src/arm/soc.c b/src/arm/soc.c index 48a15c1..c0465bf 100644 --- a/src/arm/soc.c +++ b/src/arm/soc.c @@ -765,6 +765,9 @@ struct system_on_chip* guess_soc_apple(struct system_on_chip* soc) { if(cpu_subfamily == CPUSUBFAMILY_ARM_HG) { fill_soc(soc, "M2", SOC_APPLE_M2, 5); } + else if(cpu_subfamily == CPUSUBFAMILY_ARM_HS) { + fill_soc(soc, "M2 Pro", SOC_APPLE_M2_PRO, 5); + } else { printBug("Found invalid cpu_subfamily: 0x%.8X", cpu_subfamily); soc->soc_vendor = SOC_VENDOR_UNKNOWN; diff --git a/src/arm/socs.h b/src/arm/socs.h index 7fdeb75..2178652 100644 --- a/src/arm/socs.h +++ b/src/arm/socs.h @@ -259,6 +259,9 @@ enum { SOC_APPLE_M1_MAX, SOC_APPLE_M1_ULTRA, SOC_APPLE_M2, + SOC_APPLE_M2_PRO, + SOC_APPLE_M2_MAX, + SOC_APPLE_M2_ULTRA, // ALLWINNER SOC_ALLWINNER_A10, SOC_ALLWINNER_A13,