From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161125AbcK3PQz (ORCPT ); Wed, 30 Nov 2016 10:16:55 -0500 Received: from foss.arm.com ([217.140.101.70]:49532 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933851AbcK3PPn (ORCPT ); Wed, 30 Nov 2016 10:15:43 -0500 From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, aph@redhat.com, will.deacon@arm.com, ryan.arnold@linaro.org, sid@reserved-bit.com, adhemerval.zanella@linaro.org, mark.rutland@arm.com, marc.zyngier@arm.com, Suzuki K Poulose Subject: [sample] A sample program for MRS emulation Date: Wed, 30 Nov 2016 15:15:01 +0000 Message-Id: <1480518901-18544-11-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480518901-18544-1-git-send-email-suzuki.poulose@arm.com> References: <1480518901-18544-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Here is a sample program which demonstrates how to use mrs emulation to fetch the ID registers. ----8>---- /* * Sample program to demonstrate the MRS emulation * ABI. * Copyright (C) 2015-2016, ARM Ltd * * Author: Suzuki K Poulose * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include #define get_cpu_ftr(id) ({ \ unsigned long long __val; \ asm("mrs %0, "#id : "=r" (__val)); \ printf("%-20s: 0x%016lx\n", #id, __val); \ }) int main() { get_cpu_ftr(ID_AA64ISAR0_EL1); get_cpu_ftr(ID_AA64ISAR1_EL1); get_cpu_ftr(ID_AA64MMFR0_EL1); get_cpu_ftr(ID_AA64MMFR1_EL1); get_cpu_ftr(ID_AA64PFR0_EL1); get_cpu_ftr(ID_AA64PFR1_EL1); get_cpu_ftr(ID_AA64DFR0_EL1); get_cpu_ftr(ID_AA64DFR1_EL1); get_cpu_ftr(MIDR_EL1); get_cpu_ftr(MPIDR_EL1); get_cpu_ftr(REVIDR_EL1); return 0; }