]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ARMv7: Add support for the ThumbEE state saving/restoring
authorCatalin Marinas <catalin.marinas@arm.com>
Fri, 18 Apr 2008 21:43:06 +0000 (22:43 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 18 Apr 2008 21:43:06 +0000 (22:43 +0100)
This patch adds the detection and handling of the ThumbEE extension on
ARMv7 CPUs.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm/kernel/Makefile
arch/arm/kernel/asm-offsets.c
arch/arm/kernel/thumbee.c [new file with mode: 0644]
arch/arm/mm/Kconfig
include/asm-arm/hwcap.h
include/asm-arm/thread_info.h

index 00d44c6fbfe94be02a5c2aaa0aad6388aaa960a9..d5be3f7ac0e3b504c97ba9c7e0f1a1c000b78fe9 100644 (file)
@@ -22,6 +22,7 @@ obj-$(CONFIG_KEXEC)           += machine_kexec.o relocate_kernel.o
 obj-$(CONFIG_KPROBES)          += kprobes.o kprobes-decode.o
 obj-$(CONFIG_ATAGS_PROC)       += atags.o
 obj-$(CONFIG_OABI_COMPAT)      += sys_oabi-compat.o
+obj-$(CONFIG_ARM_THUMBEE)      += thumbee.o
 
 obj-$(CONFIG_CRUNCH)           += crunch.o crunch-bits.o
 AFLAGS_crunch-bits.o           := -Wa,-mcpu=ep9312
index 3278e713c32a106f191a0f925ecf2252d89c5c90..6604b474cfd74c5cd9d05314f812416f658313ae 100644 (file)
@@ -58,6 +58,9 @@ int main(void)
   DEFINE(TI_TP_VALUE,          offsetof(struct thread_info, tp_value));
   DEFINE(TI_FPSTATE,           offsetof(struct thread_info, fpstate));
   DEFINE(TI_VFPSTATE,          offsetof(struct thread_info, vfpstate));
+#ifdef CONFIG_ARM_THUMBEE
+  DEFINE(TI_THUMBEE_STATE,     offsetof(struct thread_info, thumbee_state));
+#endif
 #ifdef CONFIG_IWMMXT
   DEFINE(TI_IWMMXT_STATE,      offsetof(struct thread_info, fpstate.iwmmxt));
 #endif
diff --git a/arch/arm/kernel/thumbee.c b/arch/arm/kernel/thumbee.c
new file mode 100644 (file)
index 0000000..df3f6b7
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * arch/arm/kernel/thumbee.c
+ *
+ * Copyright (C) 2008 ARM Limited
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+
+#include <asm/thread_notify.h>
+
+/*
+ * Access to the ThumbEE Handler Base register
+ */
+static inline unsigned long teehbr_read()
+{
+       unsigned long v;
+       asm("mrc        p14, 6, %0, c1, c0, 0\n" : "=r" (v));
+       return v;
+}
+
+static inline void teehbr_write(unsigned long v)
+{
+       asm("mcr        p14, 6, %0, c1, c0, 0\n" : : "r" (v));
+}
+
+static int thumbee_notifier(struct notifier_block *self, unsigned long cmd, void *t)
+{
+       struct thread_info *thread = t;
+
+       switch (cmd) {
+       case THREAD_NOTIFY_FLUSH:
+               thread->thumbee_state = 0;
+               break;
+       case THREAD_NOTIFY_SWITCH:
+               current_thread_info()->thumbee_state = teehbr_read();
+               teehbr_write(thread->thumbee_state);
+               break;
+       }
+
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block thumbee_notifier_block = {
+       .notifier_call  = thumbee_notifier,
+};
+
+static int __init thumbee_init(void)
+{
+       unsigned long pfr0;
+       unsigned int cpu_arch = cpu_architecture();
+
+       if (cpu_arch < CPU_ARCH_ARMv7)
+               return 0;
+
+       /* processor feature register 0 */
+       asm("mrc        p15, 0, %0, c0, c1, 0\n" : "=r" (pfr0));
+       if ((pfr0 & 0x0000f000) != 0x00001000)
+               return 0;
+
+       printk(KERN_INFO "ThumbEE CPU extension supported.\n");
+       elf_hwcap |= HWCAP_THUMBEE;
+       thread_register_notifier(&thumbee_notifier_block);
+
+       return 0;
+}
+
+late_initcall(thumbee_init);
index 76348f060f27473b71c71de0086ff70cf6ad26d7..084fe8de3efe98e893352ae93959aa61fe80274c 100644 (file)
@@ -572,6 +572,13 @@ config ARM_THUMB
 
          If you don't know what this all is, saying Y is a safe choice.
 
+config ARM_THUMBEE
+       bool "Enable ThumbEE CPU extension"
+       depends on CPU_V7
+       help
+         Say Y here if you have a CPU with the ThumbEE extension and code to
+         make use of it. Say N for code that can run on CPUs without ThumbEE.
+
 config CPU_BIG_ENDIAN
        bool "Build big-endian kernel"
        depends on ARCH_SUPPORTS_BIG_ENDIAN
index 01a1391d3014a15baca81894c32836d8bca15e3b..81f4c899a555b5949df821f313af262ba5303c49 100644 (file)
@@ -15,6 +15,7 @@
 #define HWCAP_JAVA     256
 #define HWCAP_IWMMXT   512
 #define HWCAP_CRUNCH   1024
+#define HWCAP_THUMBEE  2048
 
 #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
 /*
index 41784357a2040a8c9636d035c522a50ce941b8f2..f5a6647863114ccfe5fa8f88a8bab88ce29b48aa 100644 (file)
@@ -62,6 +62,9 @@ struct thread_info {
        struct crunch_state     crunchstate;
        union fp_state          fpstate __attribute__((aligned(8)));
        union vfp_state         vfpstate;
+#ifdef CONFIG_ARM_THUMBEE
+       unsigned long           thumbee_state;  /* ThumbEE Handler Base register */
+#endif
        struct restart_block    restart_block;
 };