numam-dpdk/config/arm/armv8_machine.py
Pavan Nikhilesh 200b88cbe0 build: detect micro-arch on ARM
Added support for detecting march and mcpu by reading midr_el1 register.
The implementer, primary part number values read can be used to figure
out the underlying arm cpu.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
2018-01-30 21:59:00 +01:00

19 lines
577 B
Python
Executable File

#!/usr/bin/python
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017 Cavium, Inc
ident = []
fname = '/sys/devices/system/cpu/cpu0/regs/identification/midr_el1'
with open(fname) as f:
content = f.read()
midr_el1 = (int(content.rstrip('\n'), 16))
ident.append(hex((midr_el1 >> 24) & 0xFF)) # Implementer
ident.append(hex((midr_el1 >> 20) & 0xF)) # Variant
ident.append(hex((midr_el1 >> 16) & 0XF)) # Architecture
ident.append(hex((midr_el1 >> 4) & 0xFFF)) # Primary Part number
ident.append(hex(midr_el1 & 0xF)) # Revision
print(' '.join(ident))