mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Suzuki K Poulose <suzuki.poulose@arm.com>
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 <suzuki.poulose@arm.com>
Subject: [sample] A sample program for MRS emulation
Date: Wed, 30 Nov 2016 15:15:01 +0000	[thread overview]
Message-ID: <1480518901-18544-11-git-send-email-suzuki.poulose@arm.com> (raw)
In-Reply-To: <1480518901-18544-1-git-send-email-suzuki.poulose@arm.com>

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 <suzuki.poulose@arm.com>
 *
 * 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 <stdio.h>

#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;
}

  parent reply	other threads:[~2016-11-30 15:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-30 15:14 [PATCH v2 0/9] arm64: Expose CPUID registers via emulation Suzuki K Poulose
2016-11-30 15:14 ` [PATCH v2 1/9] arm64: cpufeature: treat unknown fields as RES0 Suzuki K Poulose
2016-11-30 15:14 ` [PATCH v2 2/9] arm64: cpufeature: remove explicit RAZ fields Suzuki K Poulose
2016-11-30 15:14 ` [PATCH v2 3/9] arm64: cpufeature: Cleanup feature bit tables Suzuki K Poulose
2016-11-30 15:14 ` [PATCH v2 4/9] arm64: cpufeature: Document the rules of safe value for features Suzuki K Poulose
2016-11-30 15:14 ` [PATCH v2 5/9] arm64: cpufeature: Define helpers for sys_reg id Suzuki K Poulose
2016-11-30 15:14 ` [PATCH v2 6/9] arm64: Add helper to decode register from instruction Suzuki K Poulose
2016-11-30 15:14 ` [PATCH v2 7/9] arm64: cpufeature: Track user visible fields Suzuki K Poulose
2016-11-30 15:14 ` [PATCH v2 8/9] arm64: cpufeature: Expose CPUID registers by emulation Suzuki K Poulose
2016-11-30 15:15 ` [PATCH v2 9/9] arm64: Documentation - Expose CPU feature registers Suzuki K Poulose
2016-11-30 15:15 ` Suzuki K Poulose [this message]
2016-11-30 16:27   ` [sample] A sample program for MRS emulation Dave Martin
2017-01-03 15:37     ` Suzuki K Poulose

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1480518901-18544-11-git-send-email-suzuki.poulose@arm.com \
    --to=suzuki.poulose@arm.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=aph@redhat.com \
    --cc=catalin.marinas@arm.com \
    --cc=dave.martin@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=ryan.arnold@linaro.org \
    --cc=sid@reserved-bit.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®