From a429a94429a21d7f46b2c7d5e1b74b59829db193 Mon Sep 17 00:00:00 2001 From: Mark Hatle Date: Thu, 2 Dec 2021 04:35:00 -0800 Subject: newlib: Update to honister version Signed-off-by: Mark Hatle --- ...blaze-Add-config-microblaze.mt-for-target.patch | 2 +- ...-microblaze-Modified-_exceptional_handler.patch | 2 +- ...issing-declarations-for-xil_printf-to-std.patch | 4 +- ...ing-the-xil_printf.c-file-as-now-it-part-.patch | 2 +- ...l-deleting-the-xil_printf.o-from-MAKEFILE.patch | 2 +- .../newlib/files/0006-MB-X-intial-commit.patch | 2 +- ...blaze-newlib-port-for-microblaze-m64-flag.patch | 2 +- ...bug-in-crt-files-added-addlik-instead-of-.patch | 2 +- ...Blaze-Added-MB-64-support-to-strcmp-strcp.patch | 2 +- ...Blaze-Removing-the-Assembly-implementatio.patch | 339 +++++++++++++++++++++ ...e-Assembly-implementation-of-64bit-string.patch | 334 -------------------- ...0011-Fixed-the-bug-in-crtinit.s-for-MB-64.patch | 2 +- ...e-microblaze-strcmp.c-Fix-missing-end-of-.patch | 26 -- .../recipes-core/newlib/microblaze-newlib.inc | 3 +- 14 files changed, 351 insertions(+), 373 deletions(-) create mode 100644 meta-microblaze/recipes-core/newlib/files/0010-Patch-MicroBlaze-Removing-the-Assembly-implementatio.patch delete mode 100644 meta-microblaze/recipes-core/newlib/files/0010-Removing-the-Assembly-implementation-of-64bit-string.patch delete mode 100644 meta-microblaze/recipes-core/newlib/files/0012-libc-machine-microblaze-strcmp.c-Fix-missing-end-of-.patch diff --git a/meta-microblaze/recipes-core/newlib/files/0001-Patch-microblaze-Add-config-microblaze.mt-for-target.patch b/meta-microblaze/recipes-core/newlib/files/0001-Patch-microblaze-Add-config-microblaze.mt-for-target.patch index 0d984e4b..14e162a5 100644 --- a/meta-microblaze/recipes-core/newlib/files/0001-Patch-microblaze-Add-config-microblaze.mt-for-target.patch +++ b/meta-microblaze/recipes-core/newlib/files/0001-Patch-microblaze-Add-config-microblaze.mt-for-target.patch @@ -1,4 +1,4 @@ -From 3be7340059deb6fd74873978ee4e435c84a15b8b Mon Sep 17 00:00:00 2001 +From 6ab9f7d24447a18a30c18c914be082fe520f0ded Mon Sep 17 00:00:00 2001 From: Mahesh Bodapati Date: Mon, 23 Jan 2017 15:27:25 +0530 Subject: [PATCH 01/11] [Patch, microblaze]: Add config/microblaze.mt for diff --git a/meta-microblaze/recipes-core/newlib/files/0002-Patch-microblaze-Modified-_exceptional_handler.patch b/meta-microblaze/recipes-core/newlib/files/0002-Patch-microblaze-Modified-_exceptional_handler.patch index 27f8a60b..d53f4b5c 100644 --- a/meta-microblaze/recipes-core/newlib/files/0002-Patch-microblaze-Modified-_exceptional_handler.patch +++ b/meta-microblaze/recipes-core/newlib/files/0002-Patch-microblaze-Modified-_exceptional_handler.patch @@ -1,4 +1,4 @@ -From f3ffd847282fa3bf676ccd05cbdcba33eea06416 Mon Sep 17 00:00:00 2001 +From 4308ef295b12159ae381cbe5e35981ee0d424967 Mon Sep 17 00:00:00 2001 From: Mahesh Bodapati Date: Mon, 23 Jan 2017 15:30:02 +0530 Subject: [PATCH 02/11] [Patch, microblaze]: Modified _exceptional_handler diff --git a/meta-microblaze/recipes-core/newlib/files/0003-LOCAL-Add-missing-declarations-for-xil_printf-to-std.patch b/meta-microblaze/recipes-core/newlib/files/0003-LOCAL-Add-missing-declarations-for-xil_printf-to-std.patch index aa257a40..3ecad637 100644 --- a/meta-microblaze/recipes-core/newlib/files/0003-LOCAL-Add-missing-declarations-for-xil_printf-to-std.patch +++ b/meta-microblaze/recipes-core/newlib/files/0003-LOCAL-Add-missing-declarations-for-xil_printf-to-std.patch @@ -1,4 +1,4 @@ -From cf8c0c5d167386aa3f8bee6feb531b451461f99c Mon Sep 17 00:00:00 2001 +From 9ec0650b1eef0bb5de18cd3cb1a179b28fbd43d3 Mon Sep 17 00:00:00 2001 From: Mahesh Bodapati Date: Mon, 23 Jan 2017 15:39:45 +0530 Subject: [PATCH 03/11] [LOCAL]: Add missing declarations for xil_printf to @@ -10,7 +10,7 @@ Signed-off-by: David Holsgrove 1 file changed, 3 insertions(+) diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h -index 164d95bca..7bb729c11 100644 +index ab18806e3..8240dd8ab 100644 --- a/newlib/libc/include/stdio.h +++ b/newlib/libc/include/stdio.h @@ -245,6 +245,9 @@ int sprintf (char *__restrict, const char *__restrict, ...) diff --git a/meta-microblaze/recipes-core/newlib/files/0004-Local-deleting-the-xil_printf.c-file-as-now-it-part-.patch b/meta-microblaze/recipes-core/newlib/files/0004-Local-deleting-the-xil_printf.c-file-as-now-it-part-.patch index 9c59e4f5..969b233c 100644 --- a/meta-microblaze/recipes-core/newlib/files/0004-Local-deleting-the-xil_printf.c-file-as-now-it-part-.patch +++ b/meta-microblaze/recipes-core/newlib/files/0004-Local-deleting-the-xil_printf.c-file-as-now-it-part-.patch @@ -1,4 +1,4 @@ -From b2e081bd0c00dce23a6824db050bbfca991d79ab Mon Sep 17 00:00:00 2001 +From 5698db8ac7c7fffe4e521d059fb67de58a4d3403 Mon Sep 17 00:00:00 2001 From: Mahesh Bodapati Date: Mon, 23 Jan 2017 15:42:11 +0530 Subject: [PATCH 04/11] [Local]: deleting the xil_printf.c file as now it part diff --git a/meta-microblaze/recipes-core/newlib/files/0005-Local-deleting-the-xil_printf.o-from-MAKEFILE.patch b/meta-microblaze/recipes-core/newlib/files/0005-Local-deleting-the-xil_printf.o-from-MAKEFILE.patch index 850a6142..c7569a34 100644 --- a/meta-microblaze/recipes-core/newlib/files/0005-Local-deleting-the-xil_printf.o-from-MAKEFILE.patch +++ b/meta-microblaze/recipes-core/newlib/files/0005-Local-deleting-the-xil_printf.o-from-MAKEFILE.patch @@ -1,4 +1,4 @@ -From 5071ea41bb6a54b8205665d307876ab0130d8825 Mon Sep 17 00:00:00 2001 +From 10bac9ca72e6648d4b7f11099aa59db11351f068 Mon Sep 17 00:00:00 2001 From: Mahesh Bodapati Date: Mon, 23 Jan 2017 15:44:17 +0530 Subject: [PATCH 05/11] [Local]: deleting the xil_printf.o from MAKEFILE diff --git a/meta-microblaze/recipes-core/newlib/files/0006-MB-X-intial-commit.patch b/meta-microblaze/recipes-core/newlib/files/0006-MB-X-intial-commit.patch index a3c1f0e0..07fe6d03 100644 --- a/meta-microblaze/recipes-core/newlib/files/0006-MB-X-intial-commit.patch +++ b/meta-microblaze/recipes-core/newlib/files/0006-MB-X-intial-commit.patch @@ -1,4 +1,4 @@ -From f5f363cd879ea60cc8fb5507e8a01533fd0c55a9 Mon Sep 17 00:00:00 2001 +From 2681743c977fb03a897994ffe7d7bdde959737d9 Mon Sep 17 00:00:00 2001 From: Nagaraju Mekala Date: Fri, 27 Jul 2018 16:10:36 +0530 Subject: [PATCH 06/11] MB-X intial commit diff --git a/meta-microblaze/recipes-core/newlib/files/0007-Patch-Microblaze-newlib-port-for-microblaze-m64-flag.patch b/meta-microblaze/recipes-core/newlib/files/0007-Patch-Microblaze-newlib-port-for-microblaze-m64-flag.patch index 55dde803..c2a53086 100644 --- a/meta-microblaze/recipes-core/newlib/files/0007-Patch-Microblaze-newlib-port-for-microblaze-m64-flag.patch +++ b/meta-microblaze/recipes-core/newlib/files/0007-Patch-Microblaze-newlib-port-for-microblaze-m64-flag.patch @@ -1,4 +1,4 @@ -From 5040f7d8abb79bf4240d0b446e2d33d26680d9fc Mon Sep 17 00:00:00 2001 +From 151b3a67b345eebb6e3e57ce4069da823f102958 Mon Sep 17 00:00:00 2001 From: Mahesh Bodapati Date: Tue, 11 Sep 2018 14:32:20 +0530 Subject: [PATCH 07/11] [Patch, Microblaze]: newlib port for microblaze m64 diff --git a/meta-microblaze/recipes-core/newlib/files/0008-fixing-the-bug-in-crt-files-added-addlik-instead-of-.patch b/meta-microblaze/recipes-core/newlib/files/0008-fixing-the-bug-in-crt-files-added-addlik-instead-of-.patch index 437d29f3..157ffa3a 100644 --- a/meta-microblaze/recipes-core/newlib/files/0008-fixing-the-bug-in-crt-files-added-addlik-instead-of-.patch +++ b/meta-microblaze/recipes-core/newlib/files/0008-fixing-the-bug-in-crt-files-added-addlik-instead-of-.patch @@ -1,4 +1,4 @@ -From 000cfdc6f16009e62c236267ce7123a9ef2380e9 Mon Sep 17 00:00:00 2001 +From b60672b856128abc38cbc4d7ea408c17227d62da Mon Sep 17 00:00:00 2001 From: Nagaraju Mekala Date: Fri, 28 Sep 2018 12:07:43 +0530 Subject: [PATCH 08/11] fixing the bug in crt files, added addlik instead of diff --git a/meta-microblaze/recipes-core/newlib/files/0009-Patch-MicroBlaze-Added-MB-64-support-to-strcmp-strcp.patch b/meta-microblaze/recipes-core/newlib/files/0009-Patch-MicroBlaze-Added-MB-64-support-to-strcmp-strcp.patch index 1d4394d3..649b6153 100644 --- a/meta-microblaze/recipes-core/newlib/files/0009-Patch-MicroBlaze-Added-MB-64-support-to-strcmp-strcp.patch +++ b/meta-microblaze/recipes-core/newlib/files/0009-Patch-MicroBlaze-Added-MB-64-support-to-strcmp-strcp.patch @@ -1,4 +1,4 @@ -From 6587a1cae28468f5a49659a39040f60e425827a7 Mon Sep 17 00:00:00 2001 +From 1080d076ac42c0173711fb3b77bc363dd89b7d35 Mon Sep 17 00:00:00 2001 From: Mahesh Bodapati Date: Tue, 17 Nov 2020 13:06:41 +0530 Subject: [PATCH 09/11] [Patch,MicroBlaze] : Added MB-64 support to diff --git a/meta-microblaze/recipes-core/newlib/files/0010-Patch-MicroBlaze-Removing-the-Assembly-implementatio.patch b/meta-microblaze/recipes-core/newlib/files/0010-Patch-MicroBlaze-Removing-the-Assembly-implementatio.patch new file mode 100644 index 00000000..4c3d7435 --- /dev/null +++ b/meta-microblaze/recipes-core/newlib/files/0010-Patch-MicroBlaze-Removing-the-Assembly-implementatio.patch @@ -0,0 +1,339 @@ +From 13e583a48d752283dc9b5dd7e2eb67f23ba61e43 Mon Sep 17 00:00:00 2001 +From: Mahesh Bodapati +Date: Tue, 9 Nov 2021 22:53:44 +0530 +Subject: [PATCH 10/11] [Patch,MicroBlaze] : Removing the Assembly + implementation of 64bit string function. + +Revisit in next release and fix it +--- + newlib/libc/machine/microblaze/mb_endian.h | 4 + + newlib/libc/machine/microblaze/strcmp.c | 95 ++++++++-------------- + newlib/libc/machine/microblaze/strcpy.c | 82 ++++++------------- + newlib/libc/machine/microblaze/strlen.c | 59 +++++--------- + 4 files changed, 82 insertions(+), 158 deletions(-) + +diff --git a/newlib/libc/machine/microblaze/mb_endian.h b/newlib/libc/machine/microblaze/mb_endian.h +index fb217ec85..17772c88f 100644 +--- a/newlib/libc/machine/microblaze/mb_endian.h ++++ b/newlib/libc/machine/microblaze/mb_endian.h +@@ -8,8 +8,12 @@ + #ifdef __LITTLE_ENDIAN__ + #define LOAD4BYTES(rD,rA,rB) "\tlwr\t" rD ", " rA ", " rB "\n" + #define STORE4BYTES(rD,rA,rB) "\tswr\t" rD ", " rA ", " rB "\n" ++#define LOAD8BYTES(rD,rA,rB) "\tllr\t" rD ", " rA ", " rB "\n" ++#define STORE8BYTES(rD,rA,rB) "\tslr\t" rD ", " rA ", " rB "\n" + #else + #define LOAD4BYTES(rD,rA,rB) "\tlw\t" rD ", " rA ", " rB "\n" + #define STORE4BYTES(rD,rA,rB) "\tsw\t" rD ", " rA ", " rB "\n" ++#define LOAD8BYTES(rD,rA,rB) "\tll\t" rD ", " rA ", " rB "\n" ++#define STORE8BYTES(rD,rA,rB) "\tsl\t" rD ", " rA ", " rB "\n" + #endif + #endif +diff --git a/newlib/libc/machine/microblaze/strcmp.c b/newlib/libc/machine/microblaze/strcmp.c +index 2cfef7388..e34c64a0c 100644 +--- a/newlib/libc/machine/microblaze/strcmp.c ++++ b/newlib/libc/machine/microblaze/strcmp.c +@@ -129,70 +129,42 @@ strcmp (const char *s1, + return (*(unsigned char *) s1) - (*(unsigned char *) s2); + #endif /* not PREFER_SIZE_OVER_SPEED */ + ++#elif __arch64__ ++ unsigned int *a1; ++ unsigned int *a2; ++ ++ /* If s1 or s2 are unaligned, then compare bytes. */ ++ if (!UNALIGNED (s1, s2)) ++ { ++ /* If s1 and s2 are word-aligned, compare them a word at a time. */ ++ a1 = (unsigned int*)s1; ++ a2 = (unsigned int*)s2; ++ while (*a1 == *a2) ++ { ++ /* To get here, *a1 == *a2, thus if we find a null in *a1, ++ then the strings must be equal, so return zero. */ ++ if (DETECTNULL (*a1)) ++ return 0; ++ ++ a1++; ++ a2++; ++ } ++ ++ /* A difference was detected in last few bytes of s1, so search bytewise */ ++ s1 = (char*)a1; ++ s2 = (char*)a2; ++ } ++ ++ while (*s1 != '\0' && *s1 == *s2) ++ { ++ s1++; ++ s2++; ++ } ++ return (*(unsigned char *) s1) - (*(unsigned char *) s2); + #else + + #include "mb_endian.h" + +-#ifdef __arch64__ +- asm volatile (" \n\ +- orl r9, r0, r0 /* Index register */ \n\ +-check_alignment: \n\ +- andli r3, r5, 3 \n\ +- andli r4, r6, 3 \n\ +- beanei r3, try_align_args \n\ +- beanei r4, regular_strcmp /* At this point we don't have a choice */ \n\ +-cmp_loop: \n" +- LOAD4BYTES("r3", "r5", "r9") +- LOAD4BYTES("r4", "r6", "r9") +-" \n\ +- pcmplbf r7, r3, r0 /* See if there is Null byte */ \n\ +- beanei r7, end_cmp_loop /* IF yes (r7 > 0) use byte compares in end_cmp_loop */ \n\ +- cmplu r7, r4, r3 /* ELSE compare whole word */ \n\ +- beanei r7, end_cmp \n\ +- addlik r9, r9, 4 /* delay slot */ \n\ +- breaid cmp_loop \n\ +- nop /* delay slot */ \n\ +-end_cmp_loop: \n\ +- lbu r3, r5, r9 /* byte compare loop */ \n\ +- lbu r4, r6, r9 \n\ +- cmplu r7, r4, r3 /* Compare bytes */ \n\ +- beanei r7, end_cmp_early \n\ +- addlik r9, r9, 1 /* delay slot */ \n\ +- beaneid r3, end_cmp_loop /* If reached null on one string, terminate */ \n\ +- nop \n\ +-end_cmp_early: \n\ +- orl r3, r0, r7 /* delay slot */ \n\ +- rtsd r15, 8 \n\ +- nop \n\ +-try_align_args: \n\ +- xorl r7, r4, r3 \n\ +- beanei r7, regular_strcmp /* cannot align args */ \n\ +- rsublik r10, r3, 4 /* Number of initial bytes to align */ \n\ +-align_loop: \n\ +- lbu r3, r5, r9 \n\ +- lbu r4, r6, r9 \n\ +- cmplu r7, r4, r3 \n\ +- beanei r7, end_cmp \n\ +- beaeqi r3, end_cmp \n\ +- addlik r10, r10, -1 \n\ +- addlik r9, r9, 1 \n\ +- beaeqid r10, cmp_loop \n\ +- nop \n\ +- breai align_loop \n\ +-regular_strcmp: \n\ +- lbu r3, r5, r9 \n\ +- lbu r4, r6, r9 \n\ +- cmplu r7, r4, r3 \n\ +- beanei r7, end_cmp \n\ +- beaeqi r3, end_cmp \n\ +- addlik r9, r9, 1 \n\ +- breaid regular_strcmp \n\ +- nop \n\ +-end_cmp: \n\ +- orl r3, r0, r7 \n\ +- rtsd r15, 8 \n\ +- nop /* Return strcmp result */"); +-#else + asm volatile (" \n\ + or r9, r0, r0 /* Index register */\n\ + check_alignment: \n\ +@@ -241,12 +213,11 @@ regular_strcmp: + bnei r7, end_cmp \n\ + beqi r3, end_cmp \n\ + brid regular_strcmp \n\ +- addik r9, r9, 1 ++ addik r9, r9, 1 \n\ + end_cmp: \n\ + rtsd r15, 8 \n\ + or r3, r0, r7 /* Return strcmp result */"); + +-#endif + #endif /* ! HAVE_HW_PCMP */ + } + +diff --git a/newlib/libc/machine/microblaze/strcpy.c b/newlib/libc/machine/microblaze/strcpy.c +index 6dbc60d77..ddb69227e 100644 +--- a/newlib/libc/machine/microblaze/strcpy.c ++++ b/newlib/libc/machine/microblaze/strcpy.c +@@ -121,67 +121,36 @@ strcpy (char *__restrict dst0, + ; + return dst0; + #endif /* not PREFER_SIZE_OVER_SPEED */ ++#elif __arch64__ ++ char *dst = dst0; ++ const char *src = src0; ++ long *aligned_dst; ++ const long *aligned_src; + +-#else ++ /* If SRC or DEST is unaligned, then copy bytes. */ ++ if (!UNALIGNED (src, dst)) ++ { ++ aligned_dst = (long*)dst; ++ aligned_src = (long*)src; + +-#include "mb_endian.h" +-#ifdef __arch64__ ++ /* SRC and DEST are both "long int" aligned, try to do "long int" ++ sized copies. */ ++ while (!DETECTNULL(*aligned_src)) ++ { ++ *aligned_dst++ = *aligned_src++; ++ } + +- asm volatile (" \n\ +- orl r9, r0, r0 /* Index register */ \n\ +-check_alignment: \n\ +- andli r3, r5, 3 \n\ +- andli r4, r6, 3 \n\ +- beanei r3, try_align_args \n\ +- beanei r4, regular_strcpy /* At this point we dont have a choice */ \n\ +-cpy_loop: \n" +- LOAD4BYTES("r3", "r6", "r9") +-" \n\ +- pcmplbf r4, r0, r3 \n\ +- beanei r4, cpy_bytes /* If r4 != 0, then null present within string */\n" +- STORE4BYTES("r3", "r5", "r9") +-" \n\ +- addlik r9, r9, 4 \n\ +- breaid cpy_loop \n\ +- nop \n\ +-cpy_bytes: \n\ +- lbu r3, r6, r9 \n\ +- sb r3, r5, r9 \n\ +- addlik r4, r4, -1 \n\ +- addlik r9, r9, 1 /* delay slot */\n\ +- beaneid r4, cpy_bytes \n\ +- nop \n\ +-cpy_null: \n\ +- orl r3, r0, r5 /* Return strcpy result */\n\ +- rtsd r15, 8 \n\ +- nop \n\ +-try_align_args: \n\ +- xorl r7, r4, r3 \n\ +- beanei r7, regular_strcpy /* cannot align args */\n\ +- rsublik r10, r3, 4 /* Number of initial bytes to align */\n\ +-align_loop: \n\ +- lbu r3, r6, r9 \n\ +- sb r3, r5, r9 \n\ +- addlik r10, r10, -1 \n\ +- beaeqid r3, end_cpy /* Break if we have seen null character */\n\ +- nop \n\ +- addlik r9, r9, 1 \n\ +- beaneid r10, align_loop \n\ +- nop \n\ +- breai cpy_loop \n\ +-regular_strcpy: \n\ +- lbu r3, r6, r9 \n\ +- sb r3, r5, r9 \n\ +- addlik r9, r9, 1 \n\ +- beaneid r3, regular_strcpy \n\ +- nop \n\ +-end_cpy: \n\ +- orl r3, r0, r5 \n\ +- rtsd r15, 8 \n\ +- nop /* Return strcpy result */"); ++ dst = (char*)aligned_dst; ++ src = (char*)aligned_src; ++ } + +-#else ++ while (*dst++ = *src++) ++ ; ++ return dst0; ++ ++#else + ++#include "mb_endian.h" + asm volatile (" \n\ + or r9, r0, r0 /* Index register */ \n\ + check_alignment: \n\ +@@ -227,7 +196,6 @@ regular_strcpy: \n\ + end_cpy: \n\ + rtsd r15, 8 \n\ + or r3, r0, r5 /* Return strcpy result */"); +-#endif + #endif /* ! HAVE_HW_PCMP */ + } + +diff --git a/newlib/libc/machine/microblaze/strlen.c b/newlib/libc/machine/microblaze/strlen.c +index b6f2d3c13..940753996 100644 +--- a/newlib/libc/machine/microblaze/strlen.c ++++ b/newlib/libc/machine/microblaze/strlen.c +@@ -112,47 +112,29 @@ strlen (const char *str) + return str - start; + #endif /* not PREFER_SIZE_OVER_SPEED */ + +-#else +- +-#include "mb_endian.h" ++#elif __arch64__ ++ const char *start = str; ++ unsigned long *aligned_addr; + +-#ifdef __arch64__ +- asm volatile (" \n\ +- orl r9, r0, r0 /* Index register */ \n\ +-check_alignment: \n\ +- andli r3, r5, 3 \n\ +- beanei r3, align_arg \n\ +-len_loop: \n" +- LOAD4BYTES("r3", "r5", "r9") +-" \n\ +- pcmplbf r4, r3, r0 \n\ +- beanei r4, end_len \n\ +- addlik r9, r9, 4 \n\ +- breaid len_loop \n\ +- nop \n\ +-end_len: \n\ +- lbu r3, r5, r9 \n\ +- beaeqi r3, done_len \n\ +- addlik r9, r9, 1 \n\ +- breaid end_len \n\ +- nop \n\ +-done_len: \n\ +- orl r3, r0, r9 /* Return len */ \n\ +- rtsd r15, 8 \n\ +- nop \n\ +-align_arg: \n\ +- rsublik r10, r3, 4 \n\ +-align_loop: \n\ +- lbu r3, r5, r9 \n\ +- addlik r10, r10, -1 \n\ +- beaeqid r3, done_len \n\ +- nop \n\ +- addlik r9, r9, 1 \n\ +- beaneid r10, align_loop \n\ +- nop \n\ +- breai len_loop"); ++ if (!UNALIGNED (str)) ++ { ++ /* If the string is word-aligned, we can check for the presence of ++ a null in each word-sized block. */ ++ aligned_addr = (unsigned long*)str; ++ while (!DETECTNULL (*aligned_addr)) ++ aligned_addr++; + ++ /* Once a null is detected, we check each byte in that block for a ++ precise position of the null. */ ++ str = (char*)aligned_addr; ++ } ++ ++ while (*str) ++ str++; ++ return str - start; + #else ++ ++#include "mb_endian.h" + asm volatile (" \n\ + or r9, r0, r0 /* Index register */ \n\ + check_alignment: \n\ +@@ -183,6 +165,5 @@ align_loop: \n\ + addik r9, r9, 1 \n\ + bri len_loop"); + +-#endif + #endif /* ! HAVE_HW_PCMP */ + } +-- +2.17.1 + diff --git a/meta-microblaze/recipes-core/newlib/files/0010-Removing-the-Assembly-implementation-of-64bit-string.patch b/meta-microblaze/recipes-core/newlib/files/0010-Removing-the-Assembly-implementation-of-64bit-string.patch deleted file mode 100644 index a63b9dfd..00000000 --- a/meta-microblaze/recipes-core/newlib/files/0010-Removing-the-Assembly-implementation-of-64bit-string.patch +++ /dev/null @@ -1,334 +0,0 @@ -From fd624fc28cbca8863f4dd75f0bc08aba58f8455e Mon Sep 17 00:00:00 2001 -From: Nagaraju -Date: Wed, 24 Apr 2019 23:29:21 +0530 -Subject: [PATCH 10/11] Removing the Assembly implementation of 64bit string - function. Revisit in next release and fix it - -Conflicts: - newlib/libc/machine/microblaze/strcmp.c ---- - newlib/libc/machine/microblaze/mb_endian.h | 4 + - newlib/libc/machine/microblaze/strcmp.c | 94 ++++++++-------------- - newlib/libc/machine/microblaze/strcpy.c | 82 ++++++------------- - newlib/libc/machine/microblaze/strlen.c | 59 +++++--------- - 4 files changed, 81 insertions(+), 158 deletions(-) - -diff --git a/newlib/libc/machine/microblaze/mb_endian.h b/newlib/libc/machine/microblaze/mb_endian.h -index fb217ec85..17772c88f 100644 ---- a/newlib/libc/machine/microblaze/mb_endian.h -+++ b/newlib/libc/machine/microblaze/mb_endian.h -@@ -8,8 +8,12 @@ - #ifdef __LITTLE_ENDIAN__ - #define LOAD4BYTES(rD,rA,rB) "\tlwr\t" rD ", " rA ", " rB "\n" - #define STORE4BYTES(rD,rA,rB) "\tswr\t" rD ", " rA ", " rB "\n" -+#define LOAD8BYTES(rD,rA,rB) "\tllr\t" rD ", " rA ", " rB "\n" -+#define STORE8BYTES(rD,rA,rB) "\tslr\t" rD ", " rA ", " rB "\n" - #else - #define LOAD4BYTES(rD,rA,rB) "\tlw\t" rD ", " rA ", " rB "\n" - #define STORE4BYTES(rD,rA,rB) "\tsw\t" rD ", " rA ", " rB "\n" -+#define LOAD8BYTES(rD,rA,rB) "\tll\t" rD ", " rA ", " rB "\n" -+#define STORE8BYTES(rD,rA,rB) "\tsl\t" rD ", " rA ", " rB "\n" - #endif - #endif -diff --git a/newlib/libc/machine/microblaze/strcmp.c b/newlib/libc/machine/microblaze/strcmp.c -index 2cfef7388..007d9e1eb 100644 ---- a/newlib/libc/machine/microblaze/strcmp.c -+++ b/newlib/libc/machine/microblaze/strcmp.c -@@ -129,70 +129,41 @@ strcmp (const char *s1, - return (*(unsigned char *) s1) - (*(unsigned char *) s2); - #endif /* not PREFER_SIZE_OVER_SPEED */ - --#else -+#elif __arch64__ -+ unsigned int *a1; -+ unsigned int *a2; - --#include "mb_endian.h" -+ /* If s1 or s2 are unaligned, then compare bytes. */ -+ if (!UNALIGNED (s1, s2)) -+ { -+ /* If s1 and s2 are word-aligned, compare them a word at a time. */ -+ a1 = (unsigned int*)s1; -+ a2 = (unsigned int*)s2; -+ while (*a1 == *a2) -+ { -+ /* To get here, *a1 == *a2, thus if we find a null in *a1, -+ then the strings must be equal, so return zero. */ -+ if (DETECTNULL (*a1)) -+ return 0; - --#ifdef __arch64__ -- asm volatile (" \n\ -- orl r9, r0, r0 /* Index register */ \n\ --check_alignment: \n\ -- andli r3, r5, 3 \n\ -- andli r4, r6, 3 \n\ -- beanei r3, try_align_args \n\ -- beanei r4, regular_strcmp /* At this point we don't have a choice */ \n\ --cmp_loop: \n" -- LOAD4BYTES("r3", "r5", "r9") -- LOAD4BYTES("r4", "r6", "r9") --" \n\ -- pcmplbf r7, r3, r0 /* See if there is Null byte */ \n\ -- beanei r7, end_cmp_loop /* IF yes (r7 > 0) use byte compares in end_cmp_loop */ \n\ -- cmplu r7, r4, r3 /* ELSE compare whole word */ \n\ -- beanei r7, end_cmp \n\ -- addlik r9, r9, 4 /* delay slot */ \n\ -- breaid cmp_loop \n\ -- nop /* delay slot */ \n\ --end_cmp_loop: \n\ -- lbu r3, r5, r9 /* byte compare loop */ \n\ -- lbu r4, r6, r9 \n\ -- cmplu r7, r4, r3 /* Compare bytes */ \n\ -- beanei r7, end_cmp_early \n\ -- addlik r9, r9, 1 /* delay slot */ \n\ -- beaneid r3, end_cmp_loop /* If reached null on one string, terminate */ \n\ -- nop \n\ --end_cmp_early: \n\ -- orl r3, r0, r7 /* delay slot */ \n\ -- rtsd r15, 8 \n\ -- nop \n\ --try_align_args: \n\ -- xorl r7, r4, r3 \n\ -- beanei r7, regular_strcmp /* cannot align args */ \n\ -- rsublik r10, r3, 4 /* Number of initial bytes to align */ \n\ --align_loop: \n\ -- lbu r3, r5, r9 \n\ -- lbu r4, r6, r9 \n\ -- cmplu r7, r4, r3 \n\ -- beanei r7, end_cmp \n\ -- beaeqi r3, end_cmp \n\ -- addlik r10, r10, -1 \n\ -- addlik r9, r9, 1 \n\ -- beaeqid r10, cmp_loop \n\ -- nop \n\ -- breai align_loop \n\ --regular_strcmp: \n\ -- lbu r3, r5, r9 \n\ -- lbu r4, r6, r9 \n\ -- cmplu r7, r4, r3 \n\ -- beanei r7, end_cmp \n\ -- beaeqi r3, end_cmp \n\ -- addlik r9, r9, 1 \n\ -- breaid regular_strcmp \n\ -- nop \n\ --end_cmp: \n\ -- orl r3, r0, r7 \n\ -- rtsd r15, 8 \n\ -- nop /* Return strcmp result */"); -+ a1++; -+ a2++; -+ } -+ -+ /* A difference was detected in last few bytes of s1, so search bytewise */ -+ s1 = (char*)a1; -+ s2 = (char*)a2; -+ } -+ -+ while (*s1 != '\0' && *s1 == *s2) -+ { -+ s1++; -+ s2++; -+ } -+ return (*(unsigned char *) s1) - (*(unsigned char *) s2); - #else -+ -+#include "mb_endian.h" - asm volatile (" \n\ - or r9, r0, r0 /* Index register */\n\ - check_alignment: \n\ -@@ -246,7 +217,6 @@ end_cmp: - rtsd r15, 8 \n\ - or r3, r0, r7 /* Return strcmp result */"); - --#endif - #endif /* ! HAVE_HW_PCMP */ - } - -diff --git a/newlib/libc/machine/microblaze/strcpy.c b/newlib/libc/machine/microblaze/strcpy.c -index 6dbc60d77..ddb69227e 100644 ---- a/newlib/libc/machine/microblaze/strcpy.c -+++ b/newlib/libc/machine/microblaze/strcpy.c -@@ -121,67 +121,36 @@ strcpy (char *__restrict dst0, - ; - return dst0; - #endif /* not PREFER_SIZE_OVER_SPEED */ -+#elif __arch64__ -+ char *dst = dst0; -+ const char *src = src0; -+ long *aligned_dst; -+ const long *aligned_src; - --#else -+ /* If SRC or DEST is unaligned, then copy bytes. */ -+ if (!UNALIGNED (src, dst)) -+ { -+ aligned_dst = (long*)dst; -+ aligned_src = (long*)src; - --#include "mb_endian.h" --#ifdef __arch64__ -+ /* SRC and DEST are both "long int" aligned, try to do "long int" -+ sized copies. */ -+ while (!DETECTNULL(*aligned_src)) -+ { -+ *aligned_dst++ = *aligned_src++; -+ } - -- asm volatile (" \n\ -- orl r9, r0, r0 /* Index register */ \n\ --check_alignment: \n\ -- andli r3, r5, 3 \n\ -- andli r4, r6, 3 \n\ -- beanei r3, try_align_args \n\ -- beanei r4, regular_strcpy /* At this point we dont have a choice */ \n\ --cpy_loop: \n" -- LOAD4BYTES("r3", "r6", "r9") --" \n\ -- pcmplbf r4, r0, r3 \n\ -- beanei r4, cpy_bytes /* If r4 != 0, then null present within string */\n" -- STORE4BYTES("r3", "r5", "r9") --" \n\ -- addlik r9, r9, 4 \n\ -- breaid cpy_loop \n\ -- nop \n\ --cpy_bytes: \n\ -- lbu r3, r6, r9 \n\ -- sb r3, r5, r9 \n\ -- addlik r4, r4, -1 \n\ -- addlik r9, r9, 1 /* delay slot */\n\ -- beaneid r4, cpy_bytes \n\ -- nop \n\ --cpy_null: \n\ -- orl r3, r0, r5 /* Return strcpy result */\n\ -- rtsd r15, 8 \n\ -- nop \n\ --try_align_args: \n\ -- xorl r7, r4, r3 \n\ -- beanei r7, regular_strcpy /* cannot align args */\n\ -- rsublik r10, r3, 4 /* Number of initial bytes to align */\n\ --align_loop: \n\ -- lbu r3, r6, r9 \n\ -- sb r3, r5, r9 \n\ -- addlik r10, r10, -1 \n\ -- beaeqid r3, end_cpy /* Break if we have seen null character */\n\ -- nop \n\ -- addlik r9, r9, 1 \n\ -- beaneid r10, align_loop \n\ -- nop \n\ -- breai cpy_loop \n\ --regular_strcpy: \n\ -- lbu r3, r6, r9 \n\ -- sb r3, r5, r9 \n\ -- addlik r9, r9, 1 \n\ -- beaneid r3, regular_strcpy \n\ -- nop \n\ --end_cpy: \n\ -- orl r3, r0, r5 \n\ -- rtsd r15, 8 \n\ -- nop /* Return strcpy result */"); -+ dst = (char*)aligned_dst; -+ src = (char*)aligned_src; -+ } - --#else -+ while (*dst++ = *src++) -+ ; -+ return dst0; -+ -+#else - -+#include "mb_endian.h" - asm volatile (" \n\ - or r9, r0, r0 /* Index register */ \n\ - check_alignment: \n\ -@@ -227,7 +196,6 @@ regular_strcpy: \n\ - end_cpy: \n\ - rtsd r15, 8 \n\ - or r3, r0, r5 /* Return strcpy result */"); --#endif - #endif /* ! HAVE_HW_PCMP */ - } - -diff --git a/newlib/libc/machine/microblaze/strlen.c b/newlib/libc/machine/microblaze/strlen.c -index b6f2d3c13..940753996 100644 ---- a/newlib/libc/machine/microblaze/strlen.c -+++ b/newlib/libc/machine/microblaze/strlen.c -@@ -112,47 +112,29 @@ strlen (const char *str) - return str - start; - #endif /* not PREFER_SIZE_OVER_SPEED */ - --#else -- --#include "mb_endian.h" -+#elif __arch64__ -+ const char *start = str; -+ unsigned long *aligned_addr; - --#ifdef __arch64__ -- asm volatile (" \n\ -- orl r9, r0, r0 /* Index register */ \n\ --check_alignment: \n\ -- andli r3, r5, 3 \n\ -- beanei r3, align_arg \n\ --len_loop: \n" -- LOAD4BYTES("r3", "r5", "r9") --" \n\ -- pcmplbf r4, r3, r0 \n\ -- beanei r4, end_len \n\ -- addlik r9, r9, 4 \n\ -- breaid len_loop \n\ -- nop \n\ --end_len: \n\ -- lbu r3, r5, r9 \n\ -- beaeqi r3, done_len \n\ -- addlik r9, r9, 1 \n\ -- breaid end_len \n\ -- nop \n\ --done_len: \n\ -- orl r3, r0, r9 /* Return len */ \n\ -- rtsd r15, 8 \n\ -- nop \n\ --align_arg: \n\ -- rsublik r10, r3, 4 \n\ --align_loop: \n\ -- lbu r3, r5, r9 \n\ -- addlik r10, r10, -1 \n\ -- beaeqid r3, done_len \n\ -- nop \n\ -- addlik r9, r9, 1 \n\ -- beaneid r10, align_loop \n\ -- nop \n\ -- breai len_loop"); -+ if (!UNALIGNED (str)) -+ { -+ /* If the string is word-aligned, we can check for the presence of -+ a null in each word-sized block. */ -+ aligned_addr = (unsigned long*)str; -+ while (!DETECTNULL (*aligned_addr)) -+ aligned_addr++; - -+ /* Once a null is detected, we check each byte in that block for a -+ precise position of the null. */ -+ str = (char*)aligned_addr; -+ } -+ -+ while (*str) -+ str++; -+ return str - start; - #else -+ -+#include "mb_endian.h" - asm volatile (" \n\ - or r9, r0, r0 /* Index register */ \n\ - check_alignment: \n\ -@@ -183,6 +165,5 @@ align_loop: \n\ - addik r9, r9, 1 \n\ - bri len_loop"); - --#endif - #endif /* ! HAVE_HW_PCMP */ - } --- -2.17.1 - diff --git a/meta-microblaze/recipes-core/newlib/files/0011-Fixed-the-bug-in-crtinit.s-for-MB-64.patch b/meta-microblaze/recipes-core/newlib/files/0011-Fixed-the-bug-in-crtinit.s-for-MB-64.patch index b6e03d42..b917a7de 100644 --- a/meta-microblaze/recipes-core/newlib/files/0011-Fixed-the-bug-in-crtinit.s-for-MB-64.patch +++ b/meta-microblaze/recipes-core/newlib/files/0011-Fixed-the-bug-in-crtinit.s-for-MB-64.patch @@ -1,4 +1,4 @@ -From e0e6f5367eede4292d31c3dd901425bcd251595a Mon Sep 17 00:00:00 2001 +From 8c312a38bae2a32ebad15e258e71e82781638f19 Mon Sep 17 00:00:00 2001 From: Nagaraju Date: Tue, 14 Jan 2020 22:32:30 +0530 Subject: [PATCH 11/11] Fixed the bug in crtinit.s for MB-64 diff --git a/meta-microblaze/recipes-core/newlib/files/0012-libc-machine-microblaze-strcmp.c-Fix-missing-end-of-.patch b/meta-microblaze/recipes-core/newlib/files/0012-libc-machine-microblaze-strcmp.c-Fix-missing-end-of-.patch deleted file mode 100644 index c92942fc..00000000 --- a/meta-microblaze/recipes-core/newlib/files/0012-libc-machine-microblaze-strcmp.c-Fix-missing-end-of-.patch +++ /dev/null @@ -1,26 +0,0 @@ -From c2a8d7e6326a309221e4a287517a4920d33aa674 Mon Sep 17 00:00:00 2001 -From: Mark Hatle -Date: Mon, 30 Nov 2020 18:26:47 -0800 -Subject: [PATCH] libc/machine/microblaze/strcmp.c: Fix missing end of line - -Signed-off-by: Mark Hatle ---- - newlib/libc/machine/microblaze/strcmp.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/newlib/libc/machine/microblaze/strcmp.c b/newlib/libc/machine/microblaze/strcmp.c -index 007d9e1eb..5d13d64ab 100644 ---- a/newlib/libc/machine/microblaze/strcmp.c -+++ b/newlib/libc/machine/microblaze/strcmp.c -@@ -212,7 +212,7 @@ regular_strcmp: - bnei r7, end_cmp \n\ - beqi r3, end_cmp \n\ - brid regular_strcmp \n\ -- addik r9, r9, 1 -+ addik r9, r9, 1 \n\ - end_cmp: \n\ - rtsd r15, 8 \n\ - or r3, r0, r7 /* Return strcmp result */"); --- -2.17.1 - diff --git a/meta-microblaze/recipes-core/newlib/microblaze-newlib.inc b/meta-microblaze/recipes-core/newlib/microblaze-newlib.inc index f3ae4975..a32bb1d1 100644 --- a/meta-microblaze/recipes-core/newlib/microblaze-newlib.inc +++ b/meta-microblaze/recipes-core/newlib/microblaze-newlib.inc @@ -10,9 +10,8 @@ SRC_URI:append:microblaze = " \ file://0007-Patch-Microblaze-newlib-port-for-microblaze-m64-flag.patch \ file://0008-fixing-the-bug-in-crt-files-added-addlik-instead-of-.patch \ file://0009-Patch-MicroBlaze-Added-MB-64-support-to-strcmp-strcp.patch \ - file://0010-Removing-the-Assembly-implementation-of-64bit-string.patch \ + file://0010-Patch-MicroBlaze-Removing-the-Assembly-implementatio.patch \ file://0011-Fixed-the-bug-in-crtinit.s-for-MB-64.patch \ - file://0012-libc-machine-microblaze-strcmp.c-Fix-missing-end-of-.patch \ " EXTRA_OECONF:append_xilinx-standalone:microblaze = " \ -- cgit v1.2.3-54-g00ecf