From 10010578bff1c8ec06766ab0861bbe1f6d37c203 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Wed, 2 Feb 2022 13:22:20 +0900 Subject: [PATCH] aarch64: Fixup cpuinfo, improve cpu-name --- apps/cpu-name.krk | 23 ++++++++++++++++++++++- kernel/vfs/procfs.c | 3 ++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/apps/cpu-name.krk b/apps/cpu-name.krk index c6255f05..b930a88b 100644 --- a/apps/cpu-name.krk +++ b/apps/cpu-name.krk @@ -22,4 +22,25 @@ for line in lines: if cpus and 'Model name' in cpus[0]: print(cpus[0]['Model name']) else if cpus and 'PartNum' in cpus[0]: - print('(ARM64)', cpus[0]['PartNum']) + # ARM + let manuf = { + 0x41: 'ARM', + 0x61: 'Apple', + } + let parts = { + 0xD02: 'Cortex-A34', + 0xD03: 'Cortex-A53', + 0xD04: 'Cortex-A35', + 0xD05: 'Cortex-A55', + 0xD07: 'Cortex-A57', + 0xD08: 'Cortex-A72', + 0xD09: 'Cortex-A73', + + # Apple stuff + 0x022: 'M1', # Icestorm core + 0x023: 'M1', # Firestorm core + } + print( + manuf.get(int(cpus[0]['Implementer']),cpus[0]['Implementer']), + parts.get(int(cpus[0]['PartNum']),cpus[0]['PartNum']) + ) diff --git a/kernel/vfs/procfs.c b/kernel/vfs/procfs.c index dfc06cdc..d3b5dd56 100644 --- a/kernel/vfs/procfs.c +++ b/kernel/vfs/procfs.c @@ -286,6 +286,7 @@ static ssize_t cpuinfo_func(fs_node_t *node, off_t offset, size_t size, uint8_t } #elif defined(__aarch64__) + /* TODO store MIDR per-cpu, so we can show different cores. */ uint64_t midr; asm volatile ("mrs %0, MIDR_EL1" : "=r"(midr)); @@ -299,7 +300,7 @@ static ssize_t cpuinfo_func(fs_node_t *node, off_t offset, size_t size, uint8_t (unsigned int)(midr >> 24) & 0xFF, (unsigned int)(midr >> 20) & 0xF, (unsigned int)(midr >> 16) & 0xF, - (unsigned int)(midr >> 4) & 0xFFFF, + (unsigned int)(midr >> 4) & 0xFFF, (unsigned int)(midr >> 0) & 0xF ); #endif