diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-07-09 08:21:18 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-07-09 08:21:18 +0200 |
commit | 7ad77a3b86078d6a2468111c1b9986dadcccf89b (patch) | |
tree | d737bc6038372e137767d99c24c021cb964ffba1 | |
parent | 6af0422208def55bb4eb5a5a0235b48a7c815c8e (diff) | |
parent | 36c4247aabccf3ed18db52086fc9d894ee4fc5eb (diff) | |
download | barebox-7ad77a3b86078d6a2468111c1b9986dadcccf89b.tar.gz barebox-7ad77a3b86078d6a2468111c1b9986dadcccf89b.tar.xz |
Merge branch 'for-next/riscv'
-rw-r--r-- | arch/mips/Kconfig | 3 | ||||
-rw-r--r-- | arch/mips/lib/Makefile | 5 | ||||
-rw-r--r-- | arch/mips/lib/ashldi3.c | 28 | ||||
-rw-r--r-- | arch/mips/lib/ashrdi3.c | 30 | ||||
-rw-r--r-- | arch/mips/lib/libgcc.h | 29 | ||||
-rw-r--r-- | arch/mips/lib/lshrdi3.c | 28 | ||||
-rw-r--r-- | include/lib/libgcc.h | 47 | ||||
-rw-r--r-- | lib/Kconfig | 9 | ||||
-rw-r--r-- | lib/Makefile | 7 | ||||
-rw-r--r-- | lib/ashldi3.c | 44 | ||||
-rw-r--r-- | lib/ashrdi3.c | 46 | ||||
-rw-r--r-- | lib/lshrdi3.c | 45 |
12 files changed, 201 insertions, 120 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 9aedf9a77b..524375a81a 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -3,6 +3,9 @@ # config MIPS bool + select GENERIC_LIB_ASHLDI3 + select GENERIC_LIB_ASHRDI3 + select GENERIC_LIB_LSHRDI3 select HAS_KALLSYMS select HAVE_CONFIGURABLE_MEMORY_LAYOUT select HAVE_CONFIGURABLE_TEXT_BASE diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index d25d0969fc..1a049c7914 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -1,8 +1,5 @@ extra-$(CONFIG_GENERIC_LINKER_SCRIPT) += barebox.lds obj-$(CONFIG_CSRC_R4K_LIB) += csrc-r4k.o -obj-y += lshrdi3.o -obj-y += ashldi3.o -obj-y += ashrdi3.o obj-y += cpu-probe.o obj-y += traps.o obj-y += genex.o @@ -17,5 +14,3 @@ obj-$(CONFIG_CPU_MIPS64) += c-r4k.o obj-$(CONFIG_CMD_MIPS_CPUINFO) += cpuinfo.o obj-$(CONFIG_CMD_BOOTM) += bootm.o - -pbl-y += ashldi3.o diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c deleted file mode 100644 index cbdbcbb6a9..0000000000 --- a/arch/mips/lib/ashldi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <module.h> - -#include "libgcc.h" - -long long __ashldi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.low = 0; - w.s.high = (unsigned int) uu.s.low << -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.low >> bm; - - w.s.low = (unsigned int) uu.s.low << b; - w.s.high = ((unsigned int) uu.s.high << b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashldi3); diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c deleted file mode 100644 index 928d6d97ce..0000000000 --- a/arch/mips/lib/ashrdi3.c +++ /dev/null @@ -1,30 +0,0 @@ -#include <module.h> - -#include "libgcc.h" - -long long __ashrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - /* w.s.high = 1..1 or 0..0 */ - w.s.high = - uu.s.high >> 31; - w.s.low = uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__ashrdi3); diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h deleted file mode 100644 index 593e598022..0000000000 --- a/arch/mips/lib/libgcc.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __ASM_LIBGCC_H -#define __ASM_LIBGCC_H - -#include <asm/byteorder.h> - -typedef int word_type __attribute__ ((mode (__word__))); - -#ifdef __BIG_ENDIAN -struct DWstruct { - int high, low; -}; -#elif defined(__LITTLE_ENDIAN) -struct DWstruct { - int low, high; -}; -#else -#error I feel sick. -#endif - -typedef union { - struct DWstruct s; - long long ll; -} DWunion; - -long long __lshrdi3(long long u, word_type b); -long long __ashldi3(long long u, word_type b); -long long __ashrdi3(long long u, word_type b); - -#endif /* __ASM_LIBGCC_H */ diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c deleted file mode 100644 index 74a4846e97..0000000000 --- a/arch/mips/lib/lshrdi3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <module.h> - -#include "libgcc.h" - -long long __lshrdi3(long long u, word_type b) -{ - DWunion uu, w; - word_type bm; - - if (b == 0) - return u; - - uu.ll = u; - bm = 32 - b; - - if (bm <= 0) { - w.s.high = 0; - w.s.low = (unsigned int) uu.s.high >> -bm; - } else { - const unsigned int carries = (unsigned int) uu.s.high << bm; - - w.s.high = (unsigned int) uu.s.high >> b; - w.s.low = ((unsigned int) uu.s.low >> b) | carries; - } - - return w.ll; -} -EXPORT_SYMBOL(__lshrdi3); diff --git a/include/lib/libgcc.h b/include/lib/libgcc.h new file mode 100644 index 0000000000..adad27704a --- /dev/null +++ b/include/lib/libgcc.h @@ -0,0 +1,47 @@ +/* + * include/lib/libgcc.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#ifndef __LIB_LIBGCC_H +#define __LIB_LIBGCC_H + +#include <asm/byteorder.h> + +typedef int word_type __attribute__ ((mode (__word__))); + +#ifdef __BIG_ENDIAN +struct DWstruct { + int high, low; +}; +#elif defined(__LITTLE_ENDIAN) +struct DWstruct { + int low, high; +}; +#else +#error I feel sick. +#endif + +typedef union { + struct DWstruct s; + long long ll; +} DWunion; + +long long __lshrdi3(long long u, word_type b); +long long __ashldi3(long long u, word_type b); +long long __ashrdi3(long long u, word_type b); + +#endif /* __ASM_LIBGCC_H */ diff --git a/lib/Kconfig b/lib/Kconfig index 3d06655707..860d471de9 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -129,4 +129,13 @@ source lib/bootstrap/Kconfig config PRINTF_UUID bool +config GENERIC_LIB_ASHLDI3 + bool + +config GENERIC_LIB_ASHRDI3 + bool + +config GENERIC_LIB_LSHRDI3 + bool + endmenu diff --git a/lib/Makefile b/lib/Makefile index a7498288af..693945fb2c 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -65,3 +65,10 @@ obj-y += int_sqrt.o obj-y += parseopt.o obj-y += clz_ctz.o obj-$(CONFIG_CRC_CCITT) += crc-ccitt.o + +# GCC library routines +obj-$(CONFIG_GENERIC_LIB_ASHLDI3) += ashldi3.o +obj-$(CONFIG_GENERIC_LIB_ASHRDI3) += ashrdi3.o +obj-$(CONFIG_GENERIC_LIB_LSHRDI3) += lshrdi3.o + +pbl-$(CONFIG_GENERIC_LIB_ASHLDI3) += ashldi3.o diff --git a/lib/ashldi3.c b/lib/ashldi3.c new file mode 100644 index 0000000000..308464a788 --- /dev/null +++ b/lib/ashldi3.c @@ -0,0 +1,44 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <module.h> + +#include <lib/libgcc.h> + +long long notrace __ashldi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.low = 0; + w.s.high = (unsigned int) uu.s.low << -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.low >> bm; + + w.s.low = (unsigned int) uu.s.low << b; + w.s.high = ((unsigned int) uu.s.high << b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashldi3); diff --git a/lib/ashrdi3.c b/lib/ashrdi3.c new file mode 100644 index 0000000000..a55ad5289d --- /dev/null +++ b/lib/ashrdi3.c @@ -0,0 +1,46 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <module.h> + +#include <lib/libgcc.h> + +long long notrace __ashrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + /* w.s.high = 1..1 or 0..0 */ + w.s.high = + uu.s.high >> 31; + w.s.low = uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__ashrdi3); diff --git a/lib/lshrdi3.c b/lib/lshrdi3.c new file mode 100644 index 0000000000..2ca812ae73 --- /dev/null +++ b/lib/lshrdi3.c @@ -0,0 +1,45 @@ +/* + * lib/lshrdi3.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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, see the file COPYING, or write + * to the Free Software Foundation, Inc. + */ + +#include <module.h> +#include <lib/libgcc.h> + +long long notrace __lshrdi3(long long u, word_type b) +{ + DWunion uu, w; + word_type bm; + + if (b == 0) + return u; + + uu.ll = u; + bm = 32 - b; + + if (bm <= 0) { + w.s.high = 0; + w.s.low = (unsigned int) uu.s.high >> -bm; + } else { + const unsigned int carries = (unsigned int) uu.s.high << bm; + + w.s.high = (unsigned int) uu.s.high >> b; + w.s.low = ((unsigned int) uu.s.low >> b) | carries; + } + + return w.ll; +} +EXPORT_SYMBOL(__lshrdi3); |