summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bf104ff)
raw | patch | inline | side by side (parent: bf104ff)
author | Albert ARIBAUD <albert.u.boot@aribaud.net> | |
Fri, 23 Oct 2015 16:06:40 +0000 (18:06 +0200) | ||
committer | Albert ARIBAUD <albert.u.boot@aribaud.net> | |
Tue, 10 Nov 2015 14:03:48 +0000 (15:03 +0100) |
When building a Thumb-1-only target with CONFIG_SYS_THUMB_BUILD,
some files fail to build, most of the time because they include
mcr instructions, which only exist for Thumb-2.
This patch introduces a Kconfig option CONFIG_THUMB2 and uses
it to select between Thumb-2 and ARM mode for the aforementioned
files.
Signed-off-by: Albert ARIBAUD <albert.u.boot@aribaud.net>
some files fail to build, most of the time because they include
mcr instructions, which only exist for Thumb-2.
This patch introduces a Kconfig option CONFIG_THUMB2 and uses
it to select between Thumb-2 and ARM mode for the aforementioned
files.
Signed-off-by: Albert ARIBAUD <albert.u.boot@aribaud.net>
12 files changed:
diff --git a/Makefile b/Makefile
index 3c21f8ddf9e902dc20bf893995b1a38f295afe35..0bd8be2f7820a0440d5136d69a981c963ba6e124 100644 (file)
--- a/Makefile
+++ b/Makefile
UBOOTINCLUDE := \
-Iinclude \
$(if $(KBUILD_SRC), -I$(srctree)/include) \
+ $(if $(CONFIG_SYS_THUMB_BUILD), $(if $(CONFIG_HAS_THUMB2),, \
+ -I$(srctree)/arch/$(ARCH)/thumb1/include),) \
-I$(srctree)/arch/$(ARCH)/include \
-include $(srctree)/include/linux/kconfig.h
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 0d756cbc55a2afa4612195ec21dec48c4d835897..5ab0254f3bbeddca640929637db3143d0bee840b 100644 (file)
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
config HAS_VBAR
bool
+config HAS_THUMB2
+ bool
+
config CPU_ARM720T
bool
config CPU_V7
bool
select HAS_VBAR
+ select HAS_THUMB2
config CPU_V7M
bool
+ select HAS_THUMB2
config CPU_PXA
bool
index 63fa159db6ad97c6d8d845f75013ae18b21429fc..fe78922170b8ffbd87bda7e9e6acdb3d9509b780 100644 (file)
obj-$(CONFIG_MX27) += mx27/
obj-$(if $(filter mxs,$(SOC)),y) += mxs/
obj-$(if $(filter spear,$(SOC)),y) += spear/
+
+# some files can only build in ARM or THUMB2, not THUMB1
+
+ifdef CONFIG_SYS_THUMB_BUILD
+ifndef CONFIG_HAS_THUMB2
+
+CFLAGS_cpu.o := -marm
+CFLAGS_cache.o := -marm
+
+endif
+endif
index e5c1a6ae6c92965e20144094a4d9af1a3fd13c9c..2839c863e82c790f2345332f8b7eb23033d96bab 100644 (file)
/*
* Stub implementations for l2 cache operations
*/
+
__weak void l2_cache_disable(void) {}
+
+#if defined CONFIG_SYS_THUMB_BUILD
+__weak void invalidate_l2_cache(void) {}
+#endif
index a836e9f2ab2838807d0a53c801b8c5f722eb5b76..1f63127bdc8af38269e0ab2ab9487dc1292641b9 100644 (file)
/*
* Invalidate L2 Cache using co-proc instruction
*/
+#ifdef CONFIG_SYS_THUMB_BUILD
+void invalidate_l2_cache(void);
+#else
static inline void invalidate_l2_cache(void)
{
unsigned int val=0;
: : "r" (val) : "cc");
isb();
}
+#endif
void l2_cache_enable(void);
void l2_cache_disable(void);
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 2bdfaba5b7e42742e8b1761155d2a9efe0b41aeb..f3db7b58cb593fdc3116b2a5cd5a9f0952780e65 100644 (file)
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS)))
extra-y += eabi_compat.o
endif
+
+# some files can only build in ARM or THUMB2, not THUMB1
+
+ifdef CONFIG_SYS_THUMB_BUILD
+ifndef CONFIG_HAS_THUMB2
+
+# for C files, just apend -marm, which will override previous -mthumb*
+
+CFLAGS_cache.o := -marm
+CFLAGS_cache-cp15.o := -marm
+
+# For .S, drop -mthumb* and other thumb-related options.
+# CFLAGS_REMOVE_* would not have an effet, so AFLAGS_REMOVE_*
+# was implemented and is used here.
+# Also, define ${target}_NO_THUMB_BUILD for these two targets
+# so that the code knows it should not use Thumb.
+
+AFLAGS_REMOVE_memset.o := -mthumb -mthumb-interwork
+AFLAGS_REMOVE_memcpy.o := -mthumb -mthumb-interwork
+AFLAGS_memset.o := -DMEMSET_NO_THUMB_BUILD
+AFLAGS_memcpy.o := -DMEMCPY_NO_THUMB_BUILD
+
+endif
+endif
diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c
index cd13db3440ddf783e0cb8089e4cd5724a90e7831..3bd87105c58bb760048f127c5e292ae9fec0362e 100644 (file)
--- a/arch/arm/lib/cache.c
+++ b/arch/arm/lib/cache.c
return next;
}
#endif /* CONFIG_SYS_NONCACHED_MEMORY */
+
+#if defined(CONFIG_SYS_THUMB_BUILD)
+void invalidate_l2_cache(void)
+{
+ unsigned int val = 0;
+
+ asm volatile("mcr p15, 1, %0, c15, c11, 0 @ invl l2 cache"
+ : : "r" (val) : "cc");
+ isb();
+}
+#endif
diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
index eeaf0035297efb010dbf14e3848e619f5f2b6d50..7d9fc0f9be400e5f934b9cf9c252aedc602515ed 100644 (file)
--- a/arch/arm/lib/memcpy.S
+++ b/arch/arm/lib/memcpy.S
#include <linux/linkage.h>
#include <asm/assembler.h>
-#ifdef CONFIG_SYS_THUMB_BUILD
+#if defined(CONFIG_SYS_THUMB_BUILD) && !defined(MEMCPY_NO_THUMB_BUILD)
#define W(instr) instr.w
#else
#define W(instr) instr
/* Prototype: void *memcpy(void *dest, const void *src, size_t n); */
.syntax unified
-#ifdef CONFIG_SYS_THUMB_BUILD
+#if defined(CONFIG_SYS_THUMB_BUILD) && !defined(MEMCPY_NO_THUMB_BUILD)
.thumb
.thumb_func
#endif
diff --git a/arch/arm/lib/memset.S b/arch/arm/lib/memset.S
index 7208f20dda4bc16b7a226a753ab5d4ad17e5eaec..df053a31d5b079a583f68a680fd95afe71afc3fd 100644 (file)
--- a/arch/arm/lib/memset.S
+++ b/arch/arm/lib/memset.S
.align 5
.syntax unified
-#ifdef CONFIG_SYS_THUMB_BUILD
+#if defined(CONFIG_SYS_THUMB_BUILD) && !defined(MEMSET_NO_THUMB_BUILD)
.thumb
.thumb_func
#endif
index 546ebcb52e589a55c2c7f002323f8b7405fa5b83..33dcad40f26d4fb21e81742493950cbb2e084853 100644 (file)
ifndef CONFIG_SKIP_LOWLEVEL_INIT
obj-y += lowlevel_init.o
endif
+
+# some files can only build in ARM or THUMB2, not THUMB1
+
+ifdef CONFIG_SYS_THUMB_BUILD
+ifndef CONFIG_HAS_THUMB2
+
+CFLAGS_cpu.o := -marm
+
+endif
+endif
diff --git a/arch/arm/thumb1/include/asm/proc-armv/system.h b/arch/arm/thumb1/include/asm/proc-armv/system.h
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Thumb-1 drop-in for the linux/include/asm-arm/proc-armv/system.h
+ *
+ * (C) Copyright 2015
+ * Albert ARIBAUD <albert.u.boot@aribaud.net>
+ *
+ * The original file does not build in Thumb mode. However, in U-Boot
+ * we don't use interrupt context, so we can redefine these as empty
+ * memory barriers, which makes Thumb-1 compiler happy.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+/*
+ * Use the same macro name as linux/include/asm-arm/proc-armv/system.h
+ * here, so that if the original ever gets included after us, it won't
+ * try to re-redefine anything.
+ */
+
+#ifndef __ASM_PROC_SYSTEM_H
+#define __ASM_PROC_SYSTEM_H
+
+/*
+ * Redefine all original macros with static inline functions containing
+ * a simple memory barrier, so that they produce the same instruction
+ * ordering constraints as their original counterparts.
+ * We use static inline functions rather than macros so that we can tell
+ * the compiler to not complain about unused arguments.
+ */
+
+static inline void local_irq_save(
+ unsigned long flags __attribute__((unused)))
+{
+ __asm__ __volatile__ ("" : : : "memory");
+}
+
+static inline void local_irq_enable(void)
+{
+ __asm__ __volatile__ ("" : : : "memory");
+}
+
+static inline void local_irq_disable(void)
+{
+ __asm__ __volatile__ ("" : : : "memory");
+}
+
+static inline void __stf(void)
+{
+ __asm__ __volatile__ ("" : : : "memory");
+}
+
+static inline void __clf(void)
+{
+ __asm__ __volatile__ ("" : : : "memory");
+}
+
+static inline void local_save_flags(
+ unsigned long flags __attribute__((unused)))
+{
+ __asm__ __volatile__ ("" : : : "memory");
+}
+
+static inline void local_irq_restore(
+ unsigned long flags __attribute__((unused)))
+{
+ __asm__ __volatile__ ("" : : : "memory");
+}
+
+#endif /* __ASM_PROC_SYSTEM_H */
index 0863a8cda205b14d54584d73f22cf3ee8de15e72..5a6ae0013c1db3963e73cd6b54bed9d0f21767e0 100644 (file)
$(obj)/%.bin: OBJCOPYFLAGS := -O binary
$(obj)/%.bin: $(obj)/% FORCE
$(call if_changed,objcopy)
+
+# some files can only build in ARM or THUMB2, not THUMB1
+
+ifdef CONFIG_SYS_THUMB_BUILD
+ifndef CONFIG_HAS_THUMB2
+
+CFLAGS_stubs.o := -marm
+
+endif
+endif