mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] arm: ARM64 doen't provide the armlinux_ functions
@ 2018-02-21  9:53 Lucas Stach
  2018-02-21  9:53 ` [PATCH 2/3] lib: add weak clz/ctz functions Lucas Stach
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Lucas Stach @ 2018-02-21  9:53 UTC (permalink / raw)
  To: barebox

Those set parameters specific to the older ARM Linux implementation.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 arch/arm/include/asm/armlinux.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/armlinux.h b/arch/arm/include/asm/armlinux.h
index 5c39200a0c33..135f11b860ce 100644
--- a/arch/arm/include/asm/armlinux.h
+++ b/arch/arm/include/asm/armlinux.h
@@ -5,7 +5,7 @@
 #include <asm/setup.h>
 #include <asm/secure.h>
 
-#if defined CONFIG_ARM_LINUX
+#if defined CONFIG_ARM_LINUX && defined CONFIG_CPU_32
 void armlinux_set_bootparams(void *params);
 void armlinux_set_architecture(int architecture);
 void armlinux_set_revision(unsigned int);
-- 
2.16.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/3] lib: add weak clz/ctz functions
  2018-02-21  9:53 [PATCH 1/3] arm: ARM64 doen't provide the armlinux_ functions Lucas Stach
@ 2018-02-21  9:53 ` Lucas Stach
  2018-02-21  9:53 ` [PATCH 3/3] at91sam9263ek: don't build legacy init when OFDEVICE is enabled Lucas Stach
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Lucas Stach @ 2018-02-21  9:53 UTC (permalink / raw)
  To: barebox

This is a copy of the Linux kernel implementation. This adds weak
functions for the clz and ctz gcc builtins. Normally GCC will map
those builtins to CPU instructions directly, but for CPUs where those
are unavailable, we need to provide a fallback implementation.

Fixes build of the zlib decompressor on ARMv4 CPUs.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 lib/Makefile  |  1 +
 lib/clz_ctz.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
 create mode 100644 lib/clz_ctz.c

diff --git a/lib/Makefile b/lib/Makefile
index a6a32e0d1fd2..29cad3501f0c 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -64,3 +64,4 @@ obj-y			+= list_sort.o
 obj-y			+= int_sqrt.o
 obj-y			+= parseopt.o
 obj-y			+= find_bit.o
+obj-y			+= clz_ctz.o
diff --git a/lib/clz_ctz.c b/lib/clz_ctz.c
new file mode 100644
index 000000000000..b5ac7f447ac1
--- /dev/null
+++ b/lib/clz_ctz.c
@@ -0,0 +1,59 @@
+/*
+ * lib/clz_ctz.c
+ *
+ * Copyright (C) 2013 Chanho Min <chanho.min@lge.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.
+ * The functions in this file aren't called directly, but are required by
+ * GCC builtins such as __builtin_ctz, and therefore they can't be removed
+ * despite appearing unreferenced in kernel source.
+ *
+ * __c[lt]z[sd]i2 can be overridden by linking arch-specific versions.
+ */
+
+#include <linux/bitops.h>
+#include <linux/kernel.h>
+
+int __weak __ctzsi2(int val);
+int __weak __ctzsi2(int val)
+{
+	return __ffs(val);
+}
+
+int __weak __clzsi2(int val);
+int __weak __clzsi2(int val)
+{
+	return 32 - fls(val);
+}
+
+int __weak __clzdi2(long val);
+int __weak __ctzdi2(long val);
+#if BITS_PER_LONG == 32
+
+int __weak __clzdi2(long val)
+{
+	return 32 - fls((int)val);
+}
+
+int __weak __ctzdi2(long val)
+{
+	return __ffs((u32)val);
+}
+
+#elif BITS_PER_LONG == 64
+
+int __weak __clzdi2(long val)
+{
+	return 64 - fls64((u64)val);
+}
+
+int __weak __ctzdi2(long val)
+{
+	return __ffs64((u64)val);
+}
+
+#else
+#error BITS_PER_LONG not 32 or 64
+#endif
-- 
2.16.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/3] at91sam9263ek: don't build legacy init when OFDEVICE is enabled
  2018-02-21  9:53 [PATCH 1/3] arm: ARM64 doen't provide the armlinux_ functions Lucas Stach
  2018-02-21  9:53 ` [PATCH 2/3] lib: add weak clz/ctz functions Lucas Stach
@ 2018-02-21  9:53 ` Lucas Stach
  2018-02-21 10:26 ` [PATCH 1/3] arm: ARM64 doen't provide the armlinux_ functions Roland Hieber
  2018-02-26 12:00 ` Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Lucas Stach @ 2018-02-21  9:53 UTC (permalink / raw)
  To: barebox

The DT enabled build will fail when trying to reference the legacy
init funtions.

Fixes: b467c262b5a7 (at91sam9263ek: enable DT support)
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
Is this the correct fix?
---
 arch/arm/boards/at91sam9263ek/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/at91sam9263ek/Makefile b/arch/arm/boards/at91sam9263ek/Makefile
index 7af6fab8e108..66083a239e75 100644
--- a/arch/arm/boards/at91sam9263ek/Makefile
+++ b/arch/arm/boards/at91sam9263ek/Makefile
@@ -1,4 +1,6 @@
-obj-$(CONFIG_AT91_BOOTSTRAP) += init.o
+ifeq ($(CONFIG_OFDEVICE),)
+obj-y += init.o
+endif
 obj-$(CONFIG_OF_DEVICE) += of_init.o
 
 lwl-y += lowlevel_init.o
-- 
2.16.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] arm: ARM64 doen't provide the armlinux_ functions
  2018-02-21  9:53 [PATCH 1/3] arm: ARM64 doen't provide the armlinux_ functions Lucas Stach
  2018-02-21  9:53 ` [PATCH 2/3] lib: add weak clz/ctz functions Lucas Stach
  2018-02-21  9:53 ` [PATCH 3/3] at91sam9263ek: don't build legacy init when OFDEVICE is enabled Lucas Stach
@ 2018-02-21 10:26 ` Roland Hieber
  2018-02-26 12:00 ` Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Roland Hieber @ 2018-02-21 10:26 UTC (permalink / raw)
  To: barebox

I guess the subject should contain a "doesn't"? :-)

On 21.02.2018 10:53, Lucas Stach wrote:
> Those set parameters specific to the older ARM Linux implementation.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>   arch/arm/include/asm/armlinux.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/include/asm/armlinux.h b/arch/arm/include/asm/armlinux.h
> index 5c39200a0c33..135f11b860ce 100644
> --- a/arch/arm/include/asm/armlinux.h
> +++ b/arch/arm/include/asm/armlinux.h
> @@ -5,7 +5,7 @@
>   #include <asm/setup.h>
>   #include <asm/secure.h>
>   
> -#if defined CONFIG_ARM_LINUX
> +#if defined CONFIG_ARM_LINUX && defined CONFIG_CPU_32
>   void armlinux_set_bootparams(void *params);
>   void armlinux_set_architecture(int architecture);
>   void armlinux_set_revision(unsigned int);
> 

-- 
Pengutronix e.K.                  | Roland Hieber               |
Industrial Linux Solutions        | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim | Phone: +49-5121-206917-5086 |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] arm: ARM64 doen't provide the armlinux_ functions
  2018-02-21  9:53 [PATCH 1/3] arm: ARM64 doen't provide the armlinux_ functions Lucas Stach
                   ` (2 preceding siblings ...)
  2018-02-21 10:26 ` [PATCH 1/3] arm: ARM64 doen't provide the armlinux_ functions Roland Hieber
@ 2018-02-26 12:00 ` Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2018-02-26 12:00 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox

On Wed, Feb 21, 2018 at 10:53:32AM +0100, Lucas Stach wrote:
> Those set parameters specific to the older ARM Linux implementation.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  arch/arm/include/asm/armlinux.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/include/asm/armlinux.h b/arch/arm/include/asm/armlinux.h
> index 5c39200a0c33..135f11b860ce 100644
> --- a/arch/arm/include/asm/armlinux.h
> +++ b/arch/arm/include/asm/armlinux.h
> @@ -5,7 +5,7 @@
>  #include <asm/setup.h>
>  #include <asm/secure.h>
>  
> -#if defined CONFIG_ARM_LINUX
> +#if defined CONFIG_ARM_LINUX && defined CONFIG_CPU_32
>  void armlinux_set_bootparams(void *params);
>  void armlinux_set_architecture(int architecture);
>  void armlinux_set_revision(unsigned int);
> -- 
> 2.16.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-02-26 12:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-21  9:53 [PATCH 1/3] arm: ARM64 doen't provide the armlinux_ functions Lucas Stach
2018-02-21  9:53 ` [PATCH 2/3] lib: add weak clz/ctz functions Lucas Stach
2018-02-21  9:53 ` [PATCH 3/3] at91sam9263ek: don't build legacy init when OFDEVICE is enabled Lucas Stach
2018-02-21 10:26 ` [PATCH 1/3] arm: ARM64 doen't provide the armlinux_ functions Roland Hieber
2018-02-26 12:00 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox