qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Froyd <froydnj@codesourcery.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/3] linux-user: support ELF_HWCAP for PPPC
Date: Tue, 21 Apr 2009 19:32:15 -0700	[thread overview]
Message-ID: <1240367535-20081-4-git-send-email-froydnj@codesourcery.com> (raw)
In-Reply-To: <1240367535-20081-1-git-send-email-froydnj@codesourcery.com>


Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
---
 linux-user/elfload.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 6de30f4..508cb37 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -300,6 +300,64 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i
 #endif
 #define ELF_ARCH	EM_PPC
 
+/* Feature masks for the Aux Vector Hardware Capabilities (AT_HWCAP).
+   See arch/powerpc/include/asm/cputable.h.  */
+enum {
+    PPC_FEATURE_32 = 0x80000000,
+    PPC_FEATURE_64 = 0x40000000,
+    PPC_FEATURE_601_INSTR = 0x20000000,
+    PPC_FEATURE_HAS_ALTIVEC = 0x10000000,
+    PPC_FEATURE_HAS_FPU = 0x08000000,
+    PPC_FEATURE_HAS_MMU = 0x04000000,
+    PPC_FEATURE_HAS_4xxMAC = 0x02000000,
+    PPC_FEATURE_UNIFIED_CACHE = 0x01000000,
+    PPC_FEATURE_HAS_SPE = 0x00800000,
+    PPC_FEATURE_HAS_EFP_SINGLE = 0x00400000,
+    PPC_FEATURE_HAS_EFP_DOUBLE = 0x00200000,
+    PPC_FEATURE_NO_TB = 0x00100000,
+    PPC_FEATURE_POWER4 = 0x00080000,
+    PPC_FEATURE_POWER5 = 0x00040000,
+    PPC_FEATURE_POWER5_PLUS = 0x00020000,
+    PPC_FEATURE_CELL = 0x00010000,
+    PPC_FEATURE_BOOKE = 0x00008000,
+    PPC_FEATURE_SMT = 0x00004000,
+    PPC_FEATURE_ICACHE_SNOOP = 0x00002000,
+    PPC_FEATURE_ARCH_2_05 = 0x00001000,
+    PPC_FEATURE_PA6T = 0x00000800,
+    PPC_FEATURE_HAS_DFP = 0x00000400,
+    PPC_FEATURE_POWER6_EXT = 0x00000200,
+    PPC_FEATURE_ARCH_2_06 = 0x00000100,
+    PPC_FEATURE_HAS_VSX = 0x00000080,
+    PPC_FEATURE_PSERIES_PERFMON_COMPAT = 0x00000040,
+
+    PPC_FEATURE_TRUE_LE = 0x00000002,
+    PPC_FEATURE_PPC_LE = 0x00000001,
+};
+
+#define ELF_HWCAP get_elf_hwcap()
+
+static uint32_t get_elf_hwcap(void)
+{
+    CPUState *e = thread_env;
+    uint32_t features = 0;
+
+    /* We don't have to be terribly complete here; the high points are
+       Altivec/FP/SPE support.  Anything else is just a bonus.  */
+#define GET_FEATURE(flag, feature)              \
+    do {if (e->insns_flags & flag) features |= feature; } while(0)
+    GET_FEATURE(PPC_64B, PPC_FEATURE_64);
+    GET_FEATURE(PPC_FLOAT, PPC_FEATURE_HAS_FPU);
+    GET_FEATURE(PPC_ALTIVEC, PPC_FEATURE_HAS_ALTIVEC);
+    GET_FEATURE(PPC_SPE, PPC_FEATURE_HAS_SPE);
+    GET_FEATURE(PPC_SPE_SINGLE, PPC_FEATURE_HAS_EFP_SINGLE);
+    GET_FEATURE(PPC_SPE_DOUBLE, PPC_FEATURE_HAS_EFP_DOUBLE);
+    GET_FEATURE(PPC_BOOKE, PPC_FEATURE_BOOKE);
+    GET_FEATURE(PPC_405_MAC, PPC_FEATURE_HAS_4xxMAC);
+#undef GET_FEATURE
+
+    return features;
+}
+
 /*
  * We need to put in some extra aux table entries to tell glibc what
  * the cache block size is, so it can use the dcbz instruction safely.
-- 
1.6.0.5

      parent reply	other threads:[~2009-04-22  3:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-22  2:32 [Qemu-devel] [PATCH 0/3] linux-user: add ppc signal handling Nathan Froyd
2009-04-22  2:32 ` [Qemu-devel] [PATCH 1/3] target-ppc: expose cpu capability flags Nathan Froyd
2009-04-22  2:32 ` [Qemu-devel] [PATCH 2/3] linux-user: ppc signal handling Nathan Froyd
2009-04-23  1:22   ` malc
2009-04-23  1:55     ` Nathan Froyd
2009-04-23 14:44       ` malc
2009-04-23 16:11         ` Nathan Froyd
2009-04-23 23:18           ` malc
2009-04-22  2:32 ` Nathan Froyd [this message]

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=1240367535-20081-4-git-send-email-froydnj@codesourcery.com \
    --to=froydnj@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).