diff options
author | Catalin Marinas <catalin.marinas@arm.com> | 2008-04-18 17:43:06 -0400 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2008-04-18 17:43:06 -0400 |
commit | d7f864be8323e5394040e2877594645b0e7da85d (patch) | |
tree | 55ecf960706be9a4ee0c7804c57c7f5d30e0f1f7 | |
parent | 05dda977f2574c3341abef9b74c27d2b362e1e3a (diff) |
ARMv7: Add support for the ThumbEE state saving/restoring
This patch adds the detection and handling of the ThumbEE extension on
ARMv7 CPUs.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r-- | arch/arm/kernel/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/kernel/asm-offsets.c | 3 | ||||
-rw-r--r-- | arch/arm/kernel/thumbee.c | 81 | ||||
-rw-r--r-- | arch/arm/mm/Kconfig | 7 | ||||
-rw-r--r-- | include/asm-arm/hwcap.h | 1 | ||||
-rw-r--r-- | include/asm-arm/thread_info.h | 3 |
6 files changed, 96 insertions, 0 deletions
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index 00d44c6fbfe9..d5be3f7ac0e3 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile | |||
@@ -22,6 +22,7 @@ obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o | |||
22 | obj-$(CONFIG_KPROBES) += kprobes.o kprobes-decode.o | 22 | obj-$(CONFIG_KPROBES) += kprobes.o kprobes-decode.o |
23 | obj-$(CONFIG_ATAGS_PROC) += atags.o | 23 | obj-$(CONFIG_ATAGS_PROC) += atags.o |
24 | obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o | 24 | obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o |
25 | obj-$(CONFIG_ARM_THUMBEE) += thumbee.o | ||
25 | 26 | ||
26 | obj-$(CONFIG_CRUNCH) += crunch.o crunch-bits.o | 27 | obj-$(CONFIG_CRUNCH) += crunch.o crunch-bits.o |
27 | AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312 | 28 | AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312 |
diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c index 3278e713c32a..6604b474cfd7 100644 --- a/arch/arm/kernel/asm-offsets.c +++ b/arch/arm/kernel/asm-offsets.c | |||
@@ -58,6 +58,9 @@ int main(void) | |||
58 | DEFINE(TI_TP_VALUE, offsetof(struct thread_info, tp_value)); | 58 | DEFINE(TI_TP_VALUE, offsetof(struct thread_info, tp_value)); |
59 | DEFINE(TI_FPSTATE, offsetof(struct thread_info, fpstate)); | 59 | DEFINE(TI_FPSTATE, offsetof(struct thread_info, fpstate)); |
60 | DEFINE(TI_VFPSTATE, offsetof(struct thread_info, vfpstate)); | 60 | DEFINE(TI_VFPSTATE, offsetof(struct thread_info, vfpstate)); |
61 | #ifdef CONFIG_ARM_THUMBEE | ||
62 | DEFINE(TI_THUMBEE_STATE, offsetof(struct thread_info, thumbee_state)); | ||
63 | #endif | ||
61 | #ifdef CONFIG_IWMMXT | 64 | #ifdef CONFIG_IWMMXT |
62 | DEFINE(TI_IWMMXT_STATE, offsetof(struct thread_info, fpstate.iwmmxt)); | 65 | DEFINE(TI_IWMMXT_STATE, offsetof(struct thread_info, fpstate.iwmmxt)); |
63 | #endif | 66 | #endif |
diff --git a/arch/arm/kernel/thumbee.c b/arch/arm/kernel/thumbee.c new file mode 100644 index 000000000000..df3f6b7ebcea --- /dev/null +++ b/arch/arm/kernel/thumbee.c | |||
@@ -0,0 +1,81 @@ | |||
1 | /* | ||
2 | * arch/arm/kernel/thumbee.c | ||
3 | * | ||
4 | * Copyright (C) 2008 ARM Limited | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/init.h> | ||
22 | |||
23 | #include <asm/thread_notify.h> | ||
24 | |||
25 | /* | ||
26 | * Access to the ThumbEE Handler Base register | ||
27 | */ | ||
28 | static inline unsigned long teehbr_read() | ||
29 | { | ||
30 | unsigned long v; | ||
31 | asm("mrc p14, 6, %0, c1, c0, 0\n" : "=r" (v)); | ||
32 | return v; | ||
33 | } | ||
34 | |||
35 | static inline void teehbr_write(unsigned long v) | ||
36 | { | ||
37 | asm("mcr p14, 6, %0, c1, c0, 0\n" : : "r" (v)); | ||
38 | } | ||
39 | |||
40 | static int thumbee_notifier(struct notifier_block *self, unsigned long cmd, void *t) | ||
41 | { | ||
42 | struct thread_info *thread = t; | ||
43 | |||
44 | switch (cmd) { | ||
45 | case THREAD_NOTIFY_FLUSH: | ||
46 | thread->thumbee_state = 0; | ||
47 | break; | ||
48 | case THREAD_NOTIFY_SWITCH: | ||
49 | current_thread_info()->thumbee_state = teehbr_read(); | ||
50 | teehbr_write(thread->thumbee_state); | ||
51 | break; | ||
52 | } | ||
53 | |||
54 | return NOTIFY_DONE; | ||
55 | } | ||
56 | |||
57 | static struct notifier_block thumbee_notifier_block = { | ||
58 | .notifier_call = thumbee_notifier, | ||
59 | }; | ||
60 | |||
61 | static int __init thumbee_init(void) | ||
62 | { | ||
63 | unsigned long pfr0; | ||
64 | unsigned int cpu_arch = cpu_architecture(); | ||
65 | |||
66 | if (cpu_arch < CPU_ARCH_ARMv7) | ||
67 | return 0; | ||
68 | |||
69 | /* processor feature register 0 */ | ||
70 | asm("mrc p15, 0, %0, c0, c1, 0\n" : "=r" (pfr0)); | ||
71 | if ((pfr0 & 0x0000f000) != 0x00001000) | ||
72 | return 0; | ||
73 | |||
74 | printk(KERN_INFO "ThumbEE CPU extension supported.\n"); | ||
75 | elf_hwcap |= HWCAP_THUMBEE; | ||
76 | thread_register_notifier(&thumbee_notifier_block); | ||
77 | |||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | late_initcall(thumbee_init); | ||
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig index 76348f060f27..084fe8de3efe 100644 --- a/arch/arm/mm/Kconfig +++ b/arch/arm/mm/Kconfig | |||
@@ -572,6 +572,13 @@ config ARM_THUMB | |||
572 | 572 | ||
573 | If you don't know what this all is, saying Y is a safe choice. | 573 | If you don't know what this all is, saying Y is a safe choice. |
574 | 574 | ||
575 | config ARM_THUMBEE | ||
576 | bool "Enable ThumbEE CPU extension" | ||
577 | depends on CPU_V7 | ||
578 | help | ||
579 | Say Y here if you have a CPU with the ThumbEE extension and code to | ||
580 | make use of it. Say N for code that can run on CPUs without ThumbEE. | ||
581 | |||
575 | config CPU_BIG_ENDIAN | 582 | config CPU_BIG_ENDIAN |
576 | bool "Build big-endian kernel" | 583 | bool "Build big-endian kernel" |
577 | depends on ARCH_SUPPORTS_BIG_ENDIAN | 584 | depends on ARCH_SUPPORTS_BIG_ENDIAN |
diff --git a/include/asm-arm/hwcap.h b/include/asm-arm/hwcap.h index 01a1391d3014..81f4c899a555 100644 --- a/include/asm-arm/hwcap.h +++ b/include/asm-arm/hwcap.h | |||
@@ -15,6 +15,7 @@ | |||
15 | #define HWCAP_JAVA 256 | 15 | #define HWCAP_JAVA 256 |
16 | #define HWCAP_IWMMXT 512 | 16 | #define HWCAP_IWMMXT 512 |
17 | #define HWCAP_CRUNCH 1024 | 17 | #define HWCAP_CRUNCH 1024 |
18 | #define HWCAP_THUMBEE 2048 | ||
18 | 19 | ||
19 | #if defined(__KERNEL__) && !defined(__ASSEMBLY__) | 20 | #if defined(__KERNEL__) && !defined(__ASSEMBLY__) |
20 | /* | 21 | /* |
diff --git a/include/asm-arm/thread_info.h b/include/asm-arm/thread_info.h index 41784357a204..f5a664786311 100644 --- a/include/asm-arm/thread_info.h +++ b/include/asm-arm/thread_info.h | |||
@@ -62,6 +62,9 @@ struct thread_info { | |||
62 | struct crunch_state crunchstate; | 62 | struct crunch_state crunchstate; |
63 | union fp_state fpstate __attribute__((aligned(8))); | 63 | union fp_state fpstate __attribute__((aligned(8))); |
64 | union vfp_state vfpstate; | 64 | union vfp_state vfpstate; |
65 | #ifdef CONFIG_ARM_THUMBEE | ||
66 | unsigned long thumbee_state; /* ThumbEE Handler Base register */ | ||
67 | #endif | ||
65 | struct restart_block restart_block; | 68 | struct restart_block restart_block; |
66 | }; | 69 | }; |
67 | 70 | ||