summaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-core
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@kernel.crashing.org>2020-07-21 10:53:19 -0500
committerMark Hatle <mark.hatle@kernel.crashing.org>2020-08-14 11:56:33 -0500
commit8138cf33a5d2900bbd44259af9776b78f23763a7 (patch)
tree04792e71c54f4052e51c7939d16750bd2317abd3 /meta-microblaze/recipes-core
parent557ab11ff5be82548b5fd97e9c75b3e9b7524414 (diff)
downloadmeta-xilinx-8138cf33a5d2900bbd44259af9776b78f23763a7.tar.gz
meta-microblaze: Rename recipes-microblaze to match oe-core
Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
Diffstat (limited to 'meta-microblaze/recipes-core')
-rw-r--r--meta-microblaze/recipes-core/newlib/files/0001-Patch-microblaze-Add-config-microblaze.mt-for-target.patch91
-rw-r--r--meta-microblaze/recipes-core/newlib/files/0002-Patch-microblaze-Modified-_exceptional_handler.patch25
-rw-r--r--meta-microblaze/recipes-core/newlib/files/0003-LOCAL-Add-missing-declarations-for-xil_printf-to-std.patch28
-rw-r--r--meta-microblaze/recipes-core/newlib/files/0004-Local-deleting-the-xil_printf.c-file-as-now-it-part-.patch304
-rw-r--r--meta-microblaze/recipes-core/newlib/files/0005-Local-deleting-the-xil_printf.o-from-MAKEFILE.patch25
-rw-r--r--meta-microblaze/recipes-core/newlib/files/0006-MB-X-intial-commit.patch194
-rw-r--r--meta-microblaze/recipes-core/newlib/files/0007-Patch-Microblaze-newlib-port-for-microblaze-m64-flag.patch1137
-rw-r--r--meta-microblaze/recipes-core/newlib/files/0008-fixing-the-bug-in-crt-files-added-addlik-instead-of-.patch102
-rw-r--r--meta-microblaze/recipes-core/newlib/files/0009-Added-MB-64-support-to-strcmp-strcpy-strlen-files.patch227
-rw-r--r--meta-microblaze/recipes-core/newlib/files/0010-Patch-MicroBlaze-typos-in-string-functions-microblaz.patch87
-rw-r--r--meta-microblaze/recipes-core/newlib/files/0011-Removing-the-Assembly-implementation-of-64bit-string.patch332
-rw-r--r--meta-microblaze/recipes-core/newlib/libgloss_3.3.%.bbappend6
-rw-r--r--meta-microblaze/recipes-core/newlib/microblaze-newlib.inc15
-rw-r--r--meta-microblaze/recipes-core/newlib/newlib_3.3.%.bbappend7
14 files changed, 2580 insertions, 0 deletions
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
new file mode 100644
index 00000000..950e0b30
--- /dev/null
+++ b/meta-microblaze/recipes-core/newlib/files/0001-Patch-microblaze-Add-config-microblaze.mt-for-target.patch
@@ -0,0 +1,91 @@
1From 4926aec8897dc574d442e5a87b2576ab80046b10 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 23 Jan 2017 15:27:25 +0530
4Subject: [PATCH 01/11] [Patch, microblaze]: Add config/microblaze.mt for
5 target_makefile_frag Mirror MIPS method of creating copy of default.mt which
6 drops the compilation of generic sbrk.c to instead continue using the
7 microblaze provided version.
8
9[Libgloss]
10
11Changelog
12
132013-07-15 David Holsgrove <david.holsgrove@xilinx.com>
14
15 * config/microblaze.mt: New file.
16 * microblaze/configure.in: Switch default.mt to microblaze.mt.
17 * microblaze/configure: Likewise.
18
19Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
20---
21 libgloss/config/microblaze.mt | 30 ++++++++++++++++++++++++++++++
22 libgloss/microblaze/configure | 2 +-
23 libgloss/microblaze/configure.in | 2 +-
24 3 files changed, 32 insertions(+), 2 deletions(-)
25 create mode 100644 libgloss/config/microblaze.mt
26
27diff --git a/libgloss/config/microblaze.mt b/libgloss/config/microblaze.mt
28new file mode 100644
29index 0000000..e8fb922
30--- /dev/null
31+++ b/libgloss/config/microblaze.mt
32@@ -0,0 +1,30 @@
33+#
34+# Match default.mt to compile generic objects but continue building
35+# MicroBlaze specific sbrk.c
36+#
37+close.o: ${srcdir}/../close.c
38+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
39+fstat.o: ${srcdir}/../fstat.c
40+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
41+getpid.o: ${srcdir}/../getpid.c
42+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
43+isatty.o: ${srcdir}/../isatty.c
44+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
45+kill.o: ${srcdir}/../kill.c
46+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
47+lseek.o: ${srcdir}/../lseek.c
48+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
49+open.o: ${srcdir}/../open.c
50+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
51+print.o: ${srcdir}/../print.c
52+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
53+putnum.o: ${srcdir}/../putnum.c
54+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
55+read.o: ${srcdir}/../read.c
56+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
57+stat.o: ${srcdir}/../stat.c
58+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
59+unlink.o: ${srcdir}/../unlink.c
60+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
61+write.o: ${srcdir}/../write.c
62+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
63diff --git a/libgloss/microblaze/configure b/libgloss/microblaze/configure
64index 9b2bc7a..01f0fb2 100644
65--- a/libgloss/microblaze/configure
66+++ b/libgloss/microblaze/configure
67@@ -2020,7 +2020,7 @@ LIB_AM_PROG_AS
68
69
70 host_makefile_frag=${srcdir}/../config/default.mh
71-target_makefile_frag=${srcdir}/../config/default.mt
72+target_makefile_frag=${srcdir}/../config/microblaze.mt
73
74 host_makefile_frag_path=$host_makefile_frag
75
76diff --git a/libgloss/microblaze/configure.in b/libgloss/microblaze/configure.in
77index 77aa769..5d179fd 100644
78--- a/libgloss/microblaze/configure.in
79+++ b/libgloss/microblaze/configure.in
80@@ -35,7 +35,7 @@ LIB_AM_PROG_AS
81 AC_SUBST(bsp_prefix)
82
83 host_makefile_frag=${srcdir}/../config/default.mh
84-target_makefile_frag=${srcdir}/../config/default.mt
85+target_makefile_frag=${srcdir}/../config/microblaze.mt
86
87 dnl We have to assign the same value to other variables because autoconf
88 dnl doesn't provide a mechanism to substitute a replacement keyword with
89--
902.7.4
91
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
new file mode 100644
index 00000000..51785d9a
--- /dev/null
+++ b/meta-microblaze/recipes-core/newlib/files/0002-Patch-microblaze-Modified-_exceptional_handler.patch
@@ -0,0 +1,25 @@
1From ee559eb522edcb793e4df62f61849748445a056e Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 23 Jan 2017 15:30:02 +0530
4Subject: [PATCH 02/11] [Patch, microblaze]: Modified _exceptional_handler
5 Modified the _exceptional_handler to support the changes made in GCC related
6 to Superviosry call
7
8Signed-off-by:Nagaraju Mekala<nmekala@xilix.com>
9---
10 libgloss/microblaze/_exception_handler.S | 1 -
11 1 file changed, 1 deletion(-)
12
13diff --git a/libgloss/microblaze/_exception_handler.S b/libgloss/microblaze/_exception_handler.S
14index 59385ad..7a91a78 100644
15--- a/libgloss/microblaze/_exception_handler.S
16+++ b/libgloss/microblaze/_exception_handler.S
17@@ -36,5 +36,4 @@
18 .type _exception_handler, @function
19
20 _exception_handler:
21- addi r11,r11,8
22 bra r11
23--
242.7.4
25
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
new file mode 100644
index 00000000..21c55800
--- /dev/null
+++ b/meta-microblaze/recipes-core/newlib/files/0003-LOCAL-Add-missing-declarations-for-xil_printf-to-std.patch
@@ -0,0 +1,28 @@
1From 829dcc7967bd2a99b583fba1129ae71dbe8335ff Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 23 Jan 2017 15:39:45 +0530
4Subject: [PATCH 03/11] [LOCAL]: Add missing declarations for xil_printf to
5 stdio.h for inclusion in toolchain and use in c++ apps
6
7Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
8---
9 newlib/libc/include/stdio.h | 3 +++
10 1 file changed, 3 insertions(+)
11
12diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h
13index 164d95b..7bb729c 100644
14--- a/newlib/libc/include/stdio.h
15+++ b/newlib/libc/include/stdio.h
16@@ -245,6 +245,9 @@ int sprintf (char *__restrict, const char *__restrict, ...)
17 _ATTRIBUTE ((__format__ (__printf__, 2, 3)));
18 int remove (const char *);
19 int rename (const char *, const char *);
20+void xil_printf (const char*, ...);
21+void putnum (unsigned int );
22+void print (const char* );
23 #ifdef _COMPILING_NEWLIB
24 int _rename (const char *, const char *);
25 #endif
26--
272.7.4
28
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
new file mode 100644
index 00000000..f56f6187
--- /dev/null
+++ b/meta-microblaze/recipes-core/newlib/files/0004-Local-deleting-the-xil_printf.c-file-as-now-it-part-.patch
@@ -0,0 +1,304 @@
1From 379f231f0afb5e10cd82bc6346e4a6776df3e21e Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 23 Jan 2017 15:42:11 +0530
4Subject: [PATCH 04/11] [Local]: deleting the xil_printf.c file as now it part
5 of BSP
6
7---
8 libgloss/microblaze/xil_printf.c | 284 ---------------------------------------
9 1 file changed, 284 deletions(-)
10 delete mode 100644 libgloss/microblaze/xil_printf.c
11
12diff --git a/libgloss/microblaze/xil_printf.c b/libgloss/microblaze/xil_printf.c
13deleted file mode 100644
14index f18ee84..0000000
15--- a/libgloss/microblaze/xil_printf.c
16+++ /dev/null
17@@ -1,284 +0,0 @@
18-/* Copyright (c) 1995-2013 Xilinx, Inc. All rights reserved.
19- *
20- * Redistribution and use in source and binary forms, with or without
21- * modification, are permitted provided that the following conditions are
22- * met:
23- *
24- * 1. Redistributions source code must retain the above copyright notice,
25- * this list of conditions and the following disclaimer.
26- *
27- * 2. Redistributions in binary form must reproduce the above copyright
28- * notice, this list of conditions and the following disclaimer in the
29- * documentation and/or other materials provided with the distribution.
30- *
31- * 3. Neither the name of Xilinx nor the names of its contributors may be
32- * used to endorse or promote products derived from this software without
33- * specific prior written permission.
34- *
35- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
36- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
37- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
38- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39- * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
41- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
42- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
43- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
44- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46- */
47-
48-#include <ctype.h>
49-#include <string.h>
50-#include <stdarg.h>
51-
52-extern void outbyte (char);
53-
54-/*----------------------------------------------------*/
55-/* Use the following parameter passing structure to */
56-/* make xil_printf re-entrant. */
57-/*----------------------------------------------------*/
58-typedef struct params_s {
59- int len;
60- int num1;
61- int num2;
62- char pad_character;
63- int do_padding;
64- int left_flag;
65-} params_t;
66-
67-/*---------------------------------------------------*/
68-/* The purpose of this routine is to output data the */
69-/* same as the standard printf function without the */
70-/* overhead most run-time libraries involve. Usually */
71-/* the printf brings in many kilobytes of code and */
72-/* that is unacceptable in most embedded systems. */
73-/*---------------------------------------------------*/
74-
75-typedef char* charptr;
76-typedef int (*func_ptr)(int c);
77-
78-/*---------------------------------------------------*/
79-/* */
80-/* This routine puts pad characters into the output */
81-/* buffer. */
82-/* */
83-static void padding( const int l_flag, params_t *par)
84-{
85- int i;
86-
87- if (par->do_padding && l_flag && (par->len < par->num1))
88- for (i=par->len; i<par->num1; i++)
89- outbyte( par->pad_character);
90-}
91-
92-/*---------------------------------------------------*/
93-/* */
94-/* This routine moves a string to the output buffer */
95-/* as directed by the padding and positioning flags. */
96-/* */
97-static void outs( charptr lp, params_t *par)
98-{
99- /* pad on left if needed */
100- par->len = strlen( lp);
101- padding( !(par->left_flag), par);
102-
103- /* Move string to the buffer */
104- while (*lp && (par->num2)--)
105- outbyte( *lp++);
106-
107- /* Pad on right if needed */
108- /* CR 439175 - elided next stmt. Seemed bogus. */
109- /* par->len = strlen( lp); */
110- padding( par->left_flag, par);
111-}
112-
113-/*---------------------------------------------------*/
114-/* */
115-/* This routine moves a number to the output buffer */
116-/* as directed by the padding and positioning flags. */
117-/* */
118-
119-static void outnum( const long n, const long base, params_t *par)
120-{
121- charptr cp;
122- int negative;
123- char outbuf[32];
124- const char digits[] = "0123456789ABCDEF";
125- unsigned long num;
126-
127- /* Check if number is negative */
128- if (base == 10 && n < 0L) {
129- negative = 1;
130- num = -(n);
131- }
132- else{
133- num = (n);
134- negative = 0;
135- }
136-
137- /* Build number (backwards) in outbuf */
138- cp = outbuf;
139- do {
140- *cp++ = digits[(int)(num % base)];
141- } while ((num /= base) > 0);
142- if (negative)
143- *cp++ = '-';
144- *cp-- = 0;
145-
146- /* Move the converted number to the buffer and */
147- /* add in the padding where needed. */
148- par->len = strlen(outbuf);
149- padding( !(par->left_flag), par);
150- while (cp >= outbuf)
151- outbyte( *cp--);
152- padding( par->left_flag, par);
153-}
154-
155-/*---------------------------------------------------*/
156-/* */
157-/* This routine gets a number from the format */
158-/* string. */
159-/* */
160-static int getnum( charptr* linep)
161-{
162- int n;
163- charptr cp;
164-
165- n = 0;
166- cp = *linep;
167- while (isdigit(*cp))
168- n = n*10 + ((*cp++) - '0');
169- *linep = cp;
170- return(n);
171-}
172-
173-/*---------------------------------------------------*/
174-/* */
175-/* This routine operates just like a printf/sprintf */
176-/* routine. It outputs a set of data under the */
177-/* control of a formatting string. Not all of the */
178-/* standard C format control are supported. The ones */
179-/* provided are primarily those needed for embedded */
180-/* systems work. Primarily the floaing point */
181-/* routines are omitted. Other formats could be */
182-/* added easily by following the examples shown for */
183-/* the supported formats. */
184-/* */
185-
186-/* void esp_printf( const func_ptr f_ptr,
187- const charptr ctrl1, ...) */
188-void xil_printf( const charptr ctrl1, ...)
189-{
190-
191- int long_flag;
192- int dot_flag;
193-
194- params_t par;
195-
196- char ch;
197- va_list argp;
198- charptr ctrl = ctrl1;
199-
200- va_start( argp, ctrl1);
201-
202- for ( ; *ctrl; ctrl++) {
203-
204- /* move format string chars to buffer until a */
205- /* format control is found. */
206- if (*ctrl != '%') {
207- outbyte(*ctrl);
208- continue;
209- }
210-
211- /* initialize all the flags for this format. */
212- dot_flag = long_flag = par.left_flag = par.do_padding = 0;
213- par.pad_character = ' ';
214- par.num2=32767;
215-
216- try_next:
217- ch = *(++ctrl);
218-
219- if (isdigit(ch)) {
220- if (dot_flag)
221- par.num2 = getnum(&ctrl);
222- else {
223- if (ch == '0')
224- par.pad_character = '0';
225-
226- par.num1 = getnum(&ctrl);
227- par.do_padding = 1;
228- }
229- ctrl--;
230- goto try_next;
231- }
232-
233- switch (tolower(ch)) {
234- case '%':
235- outbyte( '%');
236- continue;
237-
238- case '-':
239- par.left_flag = 1;
240- break;
241-
242- case '.':
243- dot_flag = 1;
244- break;
245-
246- case 'l':
247- long_flag = 1;
248- break;
249-
250- case 'd':
251- if (long_flag || ch == 'D') {
252- outnum( va_arg(argp, long), 10L, &par);
253- continue;
254- }
255- else {
256- outnum( va_arg(argp, int), 10L, &par);
257- continue;
258- }
259- case 'x':
260- outnum((long)va_arg(argp, int), 16L, &par);
261- continue;
262-
263- case 's':
264- outs( va_arg( argp, charptr), &par);
265- continue;
266-
267- case 'c':
268- outbyte( va_arg( argp, int));
269- continue;
270-
271- case '\\':
272- switch (*ctrl) {
273- case 'a':
274- outbyte( 0x07);
275- break;
276- case 'h':
277- outbyte( 0x08);
278- break;
279- case 'r':
280- outbyte( 0x0D);
281- break;
282- case 'n':
283- outbyte( 0x0D);
284- outbyte( 0x0A);
285- break;
286- default:
287- outbyte( *ctrl);
288- break;
289- }
290- ctrl++;
291- break;
292-
293- default:
294- continue;
295- }
296- goto try_next;
297- }
298- va_end( argp);
299-}
300-
301-/*---------------------------------------------------*/
302--
3032.7.4
304
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
new file mode 100644
index 00000000..6e32e177
--- /dev/null
+++ b/meta-microblaze/recipes-core/newlib/files/0005-Local-deleting-the-xil_printf.o-from-MAKEFILE.patch
@@ -0,0 +1,25 @@
1From 96e6a596356fa605bbe00f7f69afb52f80329eb6 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 23 Jan 2017 15:44:17 +0530
4Subject: [PATCH 05/11] [Local]: deleting the xil_printf.o from MAKEFILE
5
6---
7 libgloss/microblaze/Makefile.in | 2 +-
8 1 file changed, 1 insertion(+), 1 deletion(-)
9
10diff --git a/libgloss/microblaze/Makefile.in b/libgloss/microblaze/Makefile.in
11index fe04a08..32aafda 100644
12--- a/libgloss/microblaze/Makefile.in
13+++ b/libgloss/microblaze/Makefile.in
14@@ -81,7 +81,7 @@ GENOBJS = fstat.o getpid.o isatty.o kill.o lseek.o print.o putnum.o stat.o unlin
15 open.o close.o read.o write.o
16 OBJS = ${GENOBJS} sbrk.o timer.o _exception_handler.o _hw_exception_handler.o \
17 _interrupt_handler.o _program_clean.o _program_init.o \
18- xil_malloc.o xil_sbrk.o xil_printf.o
19+ xil_malloc.o xil_sbrk.o
20 SCRIPTS = xilinx.ld
21
22 # Tiny Linux BSP.
23--
242.7.4
25
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
new file mode 100644
index 00000000..18b78f09
--- /dev/null
+++ b/meta-microblaze/recipes-core/newlib/files/0006-MB-X-intial-commit.patch
@@ -0,0 +1,194 @@
1From bb9e95aa1da6c1f8974702685db9b8486210ac5c Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 27 Jul 2018 16:10:36 +0530
4Subject: [PATCH 06/11] MB-X intial commit
5
6---
7 libgloss/microblaze/crt0.S | 2 +-
8 libgloss/microblaze/crt1.S | 2 +-
9 libgloss/microblaze/crt2.S | 2 +-
10 libgloss/microblaze/crt3.S | 2 +-
11 libgloss/microblaze/crt4.S | 2 +-
12 libgloss/microblaze/crtinit.S | 4 ++--
13 libgloss/microblaze/pgcrtinit.S | 4 ++--
14 libgloss/microblaze/sim-crtinit.S | 4 ++--
15 libgloss/microblaze/sim-pgcrtinit.S | 4 ++--
16 newlib/libc/machine/microblaze/strcmp.c | 8 ++++----
17 10 files changed, 17 insertions(+), 17 deletions(-)
18
19diff --git a/libgloss/microblaze/crt0.S b/libgloss/microblaze/crt0.S
20index b39ea90..865a8c2 100644
21--- a/libgloss/microblaze/crt0.S
22+++ b/libgloss/microblaze/crt0.S
23@@ -84,7 +84,7 @@ _vector_hw_exception:
24 _start1:
25 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
26 la r2, r0, _SDA2_BASE_
27- la r1, r0, _stack-16 /* 16 bytes (4 words are needed by crtinit for args and link reg */
28+ la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
29
30 brlid r15, _crtinit /* Initialize BSS and run program */
31 nop
32diff --git a/libgloss/microblaze/crt1.S b/libgloss/microblaze/crt1.S
33index 20323ff..a8bf749 100644
34--- a/libgloss/microblaze/crt1.S
35+++ b/libgloss/microblaze/crt1.S
36@@ -75,7 +75,7 @@ _vector_hw_exception:
37 _start:
38 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
39 la r2, r0, _SDA2_BASE_
40- la r1, r0, _stack-16 /* 16 bytes (4 words are needed by crtinit for args and link reg */
41+ la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
42
43 brlid r15, _crtinit /* Initialize BSS and run program */
44 nop
45diff --git a/libgloss/microblaze/crt2.S b/libgloss/microblaze/crt2.S
46index e3fb15b..34d9f95 100644
47--- a/libgloss/microblaze/crt2.S
48+++ b/libgloss/microblaze/crt2.S
49@@ -73,7 +73,7 @@ _vector_hw_exception:
50 _start:
51 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
52 la r2, r0, _SDA2_BASE_
53- la r1, r0, _stack-16 /* 16 bytes (4 words are needed by crtinit for args and link reg */
54+ la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
55
56 brlid r15, _crtinit /* Initialize BSS and run program */
57 nop
58diff --git a/libgloss/microblaze/crt3.S b/libgloss/microblaze/crt3.S
59index 452ea52..ebcf207 100644
60--- a/libgloss/microblaze/crt3.S
61+++ b/libgloss/microblaze/crt3.S
62@@ -59,7 +59,7 @@
63 _start:
64 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
65 la r2, r0, _SDA2_BASE_
66- la r1, r0, _stack-16 /* 16 bytes (4 words are needed by crtinit for args and link reg */
67+ la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
68
69 brlid r15, _crtinit /* Initialize BSS and run program */
70 nop
71diff --git a/libgloss/microblaze/crt4.S b/libgloss/microblaze/crt4.S
72index 475acec..4cf0b01 100644
73--- a/libgloss/microblaze/crt4.S
74+++ b/libgloss/microblaze/crt4.S
75@@ -59,7 +59,7 @@
76 _start:
77 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
78 la r2, r0, _SDA2_BASE_
79- la r1, r0, _stack-16 /* 16 bytes (4 words are needed by crtinit for args and link reg */
80+ la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
81
82 brlid r15, _crtinit /* Initialize BSS and run program */
83 nop
84diff --git a/libgloss/microblaze/crtinit.S b/libgloss/microblaze/crtinit.S
85index 78eb76d..86c6dfc 100644
86--- a/libgloss/microblaze/crtinit.S
87+++ b/libgloss/microblaze/crtinit.S
88@@ -33,7 +33,7 @@
89 .ent _crtinit
90 .type _crtinit, @function
91 _crtinit:
92- addi r1, r1, -20 /* Save Link register */
93+ addi r1, r1, -40 /* Save Link register */
94 swi r15, r1, 0
95
96 addi r6, r0, __sbss_start /* clear SBSS */
97@@ -82,6 +82,6 @@ _crtinit:
98
99 addik r3, r19, 0 /* Restore return value */
100 rtsd r15, 8
101- addi r1, r1, 20
102+ addi r1, r1, 40
103 .end _crtinit
104
105diff --git a/libgloss/microblaze/pgcrtinit.S b/libgloss/microblaze/pgcrtinit.S
106index fca1bc4..2593082 100644
107--- a/libgloss/microblaze/pgcrtinit.S
108+++ b/libgloss/microblaze/pgcrtinit.S
109@@ -33,7 +33,7 @@
110 .ent _crtinit
111
112 _crtinit:
113- addi r1, r1, -20 /* Save Link register */
114+ addi r1, r1, -40 /* Save Link register */
115 swi r15, r1, 0
116
117 addi r6, r0, __sbss_start /* clear SBSS */
118@@ -87,6 +87,6 @@ _crtinit:
119 lw r15, r1, r0 /* Return back to CRT */
120 addik r3, r19, 0 /* Restore return value */
121 rtsd r15, 8
122- addi r1, r1, 20
123+ addi r1, r1, 40
124 .end _crtinit
125
126diff --git a/libgloss/microblaze/sim-crtinit.S b/libgloss/microblaze/sim-crtinit.S
127index d2f59fe..74586d9 100644
128--- a/libgloss/microblaze/sim-crtinit.S
129+++ b/libgloss/microblaze/sim-crtinit.S
130@@ -39,7 +39,7 @@
131 .ent _crtinit
132
133 _crtinit:
134- addi r1, r1, -20 /* Save Link register */
135+ addi r1, r1, -40 /* Save Link register */
136 swi r15, r1, 0
137
138 brlid r15, _program_init /* Initialize the program */
139@@ -64,6 +64,6 @@ _crtinit:
140 lw r15, r1, r0 /* Return back to CRT */
141 addik r3, r19, 0 /* Restore return value */
142 rtsd r15, 8
143- addi r1, r1, 20
144+ addi r1, r1, 40
145 .end _crtinit
146
147diff --git a/libgloss/microblaze/sim-pgcrtinit.S b/libgloss/microblaze/sim-pgcrtinit.S
148index 3c6ba83..82ebcca 100644
149--- a/libgloss/microblaze/sim-pgcrtinit.S
150+++ b/libgloss/microblaze/sim-pgcrtinit.S
151@@ -39,7 +39,7 @@
152 .ent _crtinit
153
154 _crtinit:
155- addi r1, r1, -20 /* Save Link register */
156+ addi r1, r1, -40 /* Save Link register */
157 swi r15, r1, 0
158
159 brlid r15, _program_init /* Initialize the program */
160@@ -67,6 +67,6 @@ _crtinit:
161
162 lw r15, r1, r0 /* Return back to CRT */
163 rtsd r15, 8
164- addi r1, r1, 20
165+ addi r1, r1, 40
166 .end _crtinit
167
168diff --git a/newlib/libc/machine/microblaze/strcmp.c b/newlib/libc/machine/microblaze/strcmp.c
169index 434195e..3119d82 100644
170--- a/newlib/libc/machine/microblaze/strcmp.c
171+++ b/newlib/libc/machine/microblaze/strcmp.c
172@@ -96,15 +96,15 @@ strcmp (const char *s1,
173
174 return (*(unsigned char *) s1) - (*(unsigned char *) s2);
175 #else
176- unsigned long *a1;
177- unsigned long *a2;
178+ unsigned int *a1;
179+ unsigned int *a2;
180
181 /* If s1 or s2 are unaligned, then compare bytes. */
182 if (!UNALIGNED (s1, s2))
183 {
184 /* If s1 and s2 are word-aligned, compare them a word at a time. */
185- a1 = (unsigned long*)s1;
186- a2 = (unsigned long*)s2;
187+ a1 = (unsigned int*)s1;
188+ a2 = (unsigned int*)s2;
189 while (*a1 == *a2)
190 {
191 /* To get here, *a1 == *a2, thus if we find a null in *a1,
192--
1932.7.4
194
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
new file mode 100644
index 00000000..c62a9919
--- /dev/null
+++ b/meta-microblaze/recipes-core/newlib/files/0007-Patch-Microblaze-newlib-port-for-microblaze-m64-flag.patch
@@ -0,0 +1,1137 @@
1From eab8d664224d134b2c4d638d9c6bebb84ae777ad Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 11 Sep 2018 14:32:20 +0530
4Subject: [PATCH 07/11] [Patch, Microblaze]: newlib port for microblaze m64
5 flag...
6
7Conflicts:
8 libgloss/microblaze/_hw_exception_handler.S
9 libgloss/microblaze/_interrupt_handler.S
10---
11 libgloss/microblaze/_exception_handler.S | 6 +-
12 libgloss/microblaze/_hw_exception_handler.S | 7 +-
13 libgloss/microblaze/_interrupt_handler.S | 7 +-
14 libgloss/microblaze/_program_clean.S | 6 +-
15 libgloss/microblaze/_program_init.S | 6 +-
16 libgloss/microblaze/crt0.S | 53 ++++++++++--
17 libgloss/microblaze/crt1.S | 54 +++++++++++--
18 libgloss/microblaze/crt2.S | 52 ++++++++++--
19 libgloss/microblaze/crt3.S | 32 +++++++-
20 libgloss/microblaze/crt4.S | 37 +++++++--
21 libgloss/microblaze/crtinit.S | 120 ++++++++++++++++++++--------
22 libgloss/microblaze/linux-crt0.S | 60 +++++++++++---
23 libgloss/microblaze/linux-syscalls.S | 15 +++-
24 libgloss/microblaze/pgcrtinit.S | 59 +++++++++++++-
25 libgloss/microblaze/sim-crtinit.S | 31 +++++++
26 libgloss/microblaze/sim-pgcrtinit.S | 31 +++++++
27 newlib/libc/machine/microblaze/longjmp.S | 45 +++++++++--
28 newlib/libc/machine/microblaze/setjmp.S | 33 +++++++-
29 18 files changed, 563 insertions(+), 91 deletions(-)
30
31diff --git a/libgloss/microblaze/_exception_handler.S b/libgloss/microblaze/_exception_handler.S
32index 7a91a78..0fdff3f 100644
33--- a/libgloss/microblaze/_exception_handler.S
34+++ b/libgloss/microblaze/_exception_handler.S
35@@ -30,7 +30,11 @@
36 */
37
38 .text
39- .align 2
40+#ifdef __arch64__
41+ .align 3
42+#else
43+ .align 2
44+#endif
45 .weakext _exception_handler
46 .ent _exception_handler
47 .type _exception_handler, @function
48diff --git a/libgloss/microblaze/_hw_exception_handler.S b/libgloss/microblaze/_hw_exception_handler.S
49index 47df945..b951a63 100644
50--- a/libgloss/microblaze/_hw_exception_handler.S
51+++ b/libgloss/microblaze/_hw_exception_handler.S
52@@ -32,8 +32,11 @@
53 .text
54 .weakext _hw_exception_handler # HW Exception Handler Label
55 .type _hw_exception_handler, %function
56- .align 2
57-
58+#ifdef __arch64__
59+ .align 3
60+#else
61+ .align 2
62+#endif
63 _hw_exception_handler:
64 rted r17, 0
65 nop
66diff --git a/libgloss/microblaze/_interrupt_handler.S b/libgloss/microblaze/_interrupt_handler.S
67index 5bb7329..a0ef92d 100644
68--- a/libgloss/microblaze/_interrupt_handler.S
69+++ b/libgloss/microblaze/_interrupt_handler.S
70@@ -32,8 +32,11 @@
71 .text
72 .weakext _interrupt_handler # Interrupt Handler Label
73 .type _interrupt_handler, %function
74- .align 2
75-
76+#ifdef __arch64__
77+ .align 3
78+#else
79+ .align 2
80+#endif
81 _interrupt_handler:
82 rtid r14, 0
83 nop
84diff --git a/libgloss/microblaze/_program_clean.S b/libgloss/microblaze/_program_clean.S
85index c460594..0d55d8a 100644
86--- a/libgloss/microblaze/_program_clean.S
87+++ b/libgloss/microblaze/_program_clean.S
88@@ -33,7 +33,11 @@
89 #
90
91 .text
92- .align 2
93+#ifdef __arch64__
94+ .align 3
95+#else
96+ .align 2
97+#endif
98 .globl _program_clean
99 .ent _program_clean
100 _program_clean:
101diff --git a/libgloss/microblaze/_program_init.S b/libgloss/microblaze/_program_init.S
102index 0daa42e..862ef78 100644
103--- a/libgloss/microblaze/_program_init.S
104+++ b/libgloss/microblaze/_program_init.S
105@@ -32,7 +32,11 @@
106 # Dummy file to be replaced by LibGen
107
108 .text
109- .align 2
110+#ifdef __arch64__
111+ .align 3
112+#else
113+ .align 2
114+#endif
115 .globl _program_init
116 .ent _program_init
117 _program_init:
118diff --git a/libgloss/microblaze/crt0.S b/libgloss/microblaze/crt0.S
119index 865a8c2..e4df73b 100644
120--- a/libgloss/microblaze/crt0.S
121+++ b/libgloss/microblaze/crt0.S
122@@ -54,7 +54,11 @@
123
124 .globl _start
125 .section .vectors.reset, "ax"
126- .align 2
127+#ifdef __arch64__
128+ .align 3
129+#else
130+ .align 2
131+#endif
132 .ent _start
133 .type _start, @function
134 _start:
135@@ -62,36 +66,64 @@ _start:
136 .end _start
137
138 .section .vectors.sw_exception, "ax"
139+#ifdef __arch64__
140+ .align 3
141+#else
142 .align 2
143+#endif
144 _vector_sw_exception:
145 brai _exception_handler
146
147 .section .vectors.interrupt, "ax"
148+#ifdef __arch64__
149+ .align 3
150+#else
151 .align 2
152+#endif
153+
154 _vector_interrupt:
155 brai _interrupt_handler
156
157 .section .vectors.hw_exception, "ax"
158+#ifdef __arch64__
159+ .align 3
160+#else
161 .align 2
162+#endif
163+
164 _vector_hw_exception:
165 brai _hw_exception_handler
166
167 .section .text
168 .globl _start1
169+#ifdef __arch64__
170+ .align 3
171+#else
172 .align 2
173+#endif
174+
175 .ent _start1
176 .type _start1, @function
177 _start1:
178+#ifdef __arch64__
179+ lli r13, r0, _SDA_BASE_
180+ lli r2, r0, _SDA2_BASE_
181+ lli r1, r0, _stack-32
182+ brealid r15, _crtinit
183+ nop
184+ addlik r5, r3, 0
185+ brealid r15, exit
186+ nop
187+#else
188 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
189 la r2, r0, _SDA2_BASE_
190 la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
191-
192 brlid r15, _crtinit /* Initialize BSS and run program */
193 nop
194
195- brlid r15, exit /* Call exit with the return value of main */
196- addik r5, r3, 0
197-
198+ brlid r15, exit /* Call exit with the return value of main */
199+ addik r5, r3, 0
200+#endif
201 /* Control does not reach here */
202 .end _start1
203
204@@ -101,9 +133,18 @@ _start1:
205 Our simple _exit
206 */
207 .globl _exit
208+#ifdef __arch64__
209+ .align 3
210+#else
211 .align 2
212+#endif
213+
214 .ent _exit
215 .type _exit, @function
216 _exit:
217- bri 0
218+#ifdef __arch64__
219+ breai 0
220+#else
221+ bri 0
222+#endif
223 .end _exit
224diff --git a/libgloss/microblaze/crt1.S b/libgloss/microblaze/crt1.S
225index a8bf749..b24eeb5 100644
226--- a/libgloss/microblaze/crt1.S
227+++ b/libgloss/microblaze/crt1.S
228@@ -53,36 +53,67 @@
229
230
231 .section .vectors.sw_exception, "ax"
232- .align 2
233+#ifdef __arch64__
234+ .align 3
235+#else
236+ .align 2
237+#endif
238+
239 _vector_sw_exception:
240 brai _exception_handler
241
242 .section .vectors.interrupt, "ax"
243- .align 2
244+#ifdef __arch64__
245+ .align 3
246+#else
247+ .align 2
248+#endif
249+
250 _vector_interrupt:
251 brai _interrupt_handler
252
253 .section .vectors.hw_exception, "ax"
254- .align 2
255+#ifdef __arch64__
256+ .align 3
257+#else
258+ .align 2
259+#endif
260+
261 _vector_hw_exception:
262 brai _hw_exception_handler
263
264 .section .text
265 .globl _start
266- .align 2
267+#ifdef __arch64__
268+ .align 3
269+#else
270+ .align 2
271+#endif
272+
273 .ent _start
274 .type _start, @function
275 _start:
276+#ifdef __arch64__
277+ lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
278+ lli r2, r0, _SDA2_BASE_
279+ lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
280+
281+ brealid r15, _crtinit /* Initialize BSS and run program */
282+ nop
283+ addlik r5, r3, 0
284+ brealid r15, exit
285+ nop
286+#else
287 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
288 la r2, r0, _SDA2_BASE_
289- la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
290+ la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
291
292 brlid r15, _crtinit /* Initialize BSS and run program */
293 nop
294
295 brlid r15, exit /* Call exit with the return value of main */
296 addik r5, r3, 0
297-
298+#endif
299 /* Control does not reach here */
300 .end _start
301
302@@ -92,11 +123,18 @@ _start:
303 Our simple _exit
304 */
305 .globl _exit
306- .align 2
307+#ifdef __arch64__
308+ .align 3
309+#else
310+ .align 2
311+#endif
312 .ent _exit
313 .type _exit, @function
314 _exit:
315+#ifdef __arch64__
316+ addl r3, r0, r5
317+#else
318 add r3, r0, r5
319+#endif
320 brki r16, 0x4 /* Return to hook in XMDSTUB */
321 .end _exit
322-
323diff --git a/libgloss/microblaze/crt2.S b/libgloss/microblaze/crt2.S
324index 34d9f95..ae4c89e 100644
325--- a/libgloss/microblaze/crt2.S
326+++ b/libgloss/microblaze/crt2.S
327@@ -51,26 +51,56 @@
328 */
329
330 .section .vectors.sw_exception, "ax"
331- .align 2
332+#ifdef __arch64__
333+ .align 3
334+#else
335+ .align 2
336+#endif
337+
338 _vector_sw_exception:
339 brai _exception_handler
340
341 .section .vectors.interrupt, "ax"
342- .align 2
343+#ifdef __arch64__
344+ .align 3
345+#else
346+ .align 2
347+#endif
348+
349 _vector_interrupt:
350 brai _interrupt_handler
351
352 .section .vectors.hw_exception, "ax"
353- .align 2
354+#ifdef __arch64__
355+ .align 3
356+#else
357+ .align 2
358+#endif
359+
360 _vector_hw_exception:
361 brai _hw_exception_handler
362
363 .section .text
364 .globl _start
365- .align 2
366+#ifdef __arch64__
367+ .align 3
368+#else
369+ .align 2
370+#endif
371+
372 .ent _start
373 .type _start, @function
374 _start:
375+#ifdef __arch64__
376+ lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
377+ lli r2, r0, _SDA2_BASE_
378+ lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
379+ brealid r15, _crtinit /* Initialize BSS and run program */
380+ nop
381+ addlik r5, r3, 0
382+ brealid r15, exit
383+ nop
384+#else
385 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
386 la r2, r0, _SDA2_BASE_
387 la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
388@@ -80,7 +110,7 @@ _start:
389
390 brlid r15, exit /* Call exit with the return value of main */
391 addik r5, r3, 0
392-
393+#endif
394 /* Control does not reach here */
395
396 .end _start
397@@ -90,9 +120,17 @@ _start:
398 Our simple _exit
399 */
400 .globl _exit
401- .align 2
402+#ifdef __arch64__
403+ .align 3
404+#else
405+ .align 2
406+#endif
407 .ent _exit
408 .type _exit, @function
409 _exit:
410- bri 0
411+#ifdef __arch64__
412+ breai 0
413+#else
414+ bri 0
415+#endif
416 .end _exit
417diff --git a/libgloss/microblaze/crt3.S b/libgloss/microblaze/crt3.S
418index ebcf207..a8bc783 100644
419--- a/libgloss/microblaze/crt3.S
420+++ b/libgloss/microblaze/crt3.S
421@@ -53,10 +53,26 @@
422
423 .section .text
424 .globl _start
425- .align 2
426+#ifdef __arch64__
427+ .align 3
428+#else
429+ .align 2
430+#endif
431 .ent _start
432 .type _start, @function
433 _start:
434+#ifdef __arch64__
435+ lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
436+ lli r2, r0, _SDA2_BASE_
437+ lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
438+
439+ brealid r15, _crtinit /* Initialize BSS and run program */
440+ nop
441+
442+ addlik r5, r3, 0
443+ brealid r15, exit /* Call exit with the return value of main */
444+ nop
445+#else
446 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
447 la r2, r0, _SDA2_BASE_
448 la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
449@@ -66,7 +82,7 @@ _start:
450
451 brlid r15, exit /* Call exit with the return value of main */
452 addik r5, r3, 0
453-
454+#endif
455 /* Control does not reach here */
456 .end _start
457
458@@ -76,9 +92,17 @@ _start:
459 Our simple _exit
460 */
461 .globl _exit
462- .align 2
463+#ifdef __arch64__
464+ .align 3
465+#else
466+ .align 2
467+#endif
468 .ent _exit
469 .type _exit, @function
470 _exit:
471- bri 0
472+#ifdef __arch64__
473+ breai 0
474+#else
475+ bri 0
476+#endif
477 .end _exit
478diff --git a/libgloss/microblaze/crt4.S b/libgloss/microblaze/crt4.S
479index 4cf0b01..54ba473 100644
480--- a/libgloss/microblaze/crt4.S
481+++ b/libgloss/microblaze/crt4.S
482@@ -53,10 +53,27 @@
483
484 .section .text
485 .globl _start
486- .align 2
487+#ifdef __arch64__
488+ .align 3
489+#else
490+ .align 2
491+#endif
492+
493 .ent _start
494 .type _start, @function
495 _start:
496+#ifdef __arch64__
497+ lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
498+ lli r2, r0, _SDA2_BASE_
499+ lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
500+
501+ brealid r15, _crtinit /* Initialize BSS and run program */
502+ nop
503+
504+ addlik r5, r3, 0
505+ brealid r15, exit /* Call exit with the return value of main */
506+ nop
507+#else
508 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
509 la r2, r0, _SDA2_BASE_
510 la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
511@@ -68,19 +85,27 @@ _start:
512 addik r5, r3, 0
513
514 /* Control does not reach here */
515-
516+#endif
517 .end _start
518
519-
520 /*
521 _exit
522 Our simple _exit
523 */
524 .globl _exit
525- .align 2
526+#ifdef __arch64__
527+ .align 3
528+#else
529+ .align 2
530+#endif
531 .ent _exit
532 .type _exit, @function
533 _exit:
534- brlid r15,elf_process_exit
535- nop
536+#ifdef __arch64__
537+ brealid r15,elf_process_exit
538+ nop
539+#else
540+ brlid r15,elf_process_exit
541+ nop
542+#endif
543 .end _exit
544diff --git a/libgloss/microblaze/crtinit.S b/libgloss/microblaze/crtinit.S
545index 86c6dfc..8541175 100644
546--- a/libgloss/microblaze/crtinit.S
547+++ b/libgloss/microblaze/crtinit.S
548@@ -29,59 +29,115 @@
549 */
550
551 .globl _crtinit
552+#ifdef __arch64__
553+ .align 3
554+#else
555 .align 2
556+#endif
557 .ent _crtinit
558 .type _crtinit, @function
559 _crtinit:
560- addi r1, r1, -40 /* Save Link register */
561- swi r15, r1, 0
562+#ifdef __arch64__
563+ addli r1, r1, -40 /* Save Link register */
564+ sli r15, r1, 0
565
566- addi r6, r0, __sbss_start /* clear SBSS */
567- addi r7, r0, __sbss_end
568- rsub r18, r6, r7
569- blei r18, .Lendsbss
570+ addli r6, r0, __sbss_start /* clear SBSS */
571+ addli r7, r0, __sbss_end
572+ rsubl r18, r6, r7
573+ bealei r18, .Lendsbss
574
575 .Lloopsbss:
576- swi r0, r6, 0
577- addi r6, r6, 4
578- rsub r18, r6, r7
579- bgti r18, .Lloopsbss
580+ sli r0, r6, 0
581+ addli r6, r6, 4
582+ rsubl r18, r6, r7
583+ beagti r18, .Lloopsbss
584 .Lendsbss:
585-
586- addi r6, r0, __bss_start /* clear BSS */
587- addi r7, r0, __bss_end
588- rsub r18, r6, r7
589- blei r18, .Lendbss
590+ addli r6, r0, __bss_start /* clear BSS */
591+ addli r7, r0, __bss_end
592+ rsubl r18, r6, r7
593+ bealei r18, .Lendbss
594 .Lloopbss:
595- swi r0, r6, 0
596- addi r6, r6, 4
597- rsub r18, r6, r7
598- bgti r18, .Lloopbss
599+ sli r0, r6, 0
600+ addli r6, r6, 4
601+ rsubl r18, r6, r7
602+ beagti r18, .Lloopbss
603 .Lendbss:
604
605- brlid r15, _program_init /* Initialize the program */
606+ brealid r15, _program_init /* Initialize the program */
607+ nop
608+ brealid r15, __init /* Invoke language initialization functions */
609+ nop
610+
611+ addli r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
612+ addli r7, r0, 0
613+ addli r5, r0, 0
614+ brealid r15, main /* Execute the program */
615 nop
616+ addlik r19, r3, 0 /* Save return value */
617+
618+ brealid r15, __fini /* Invoke language cleanup functions */
619+ nop
620+
621+ brealid r15, _program_clean /* Cleanup the program */
622+ nop
623+
624+ ll r15, r1, r0 /* Return back to CRT */
625+
626+ addlik r3, r19, 0 /* Restore return value */
627+ addli r1, r1, 40
628+ rtsd r15, 8
629+ nop
630+#else
631+ addi r1, r1, -40 /* Save Link register */
632+ swi r15, r1, 0
633+
634+ addi r6, r0, __sbss_start /* clear SBSS */
635+ addi r7, r0, __sbss_end
636+ rsub r18, r6, r7
637+ blei r18, .Lendsbss
638+
639+.Lloopsbss:
640+ swi r0, r6, 0
641+ addi r6, r6, 4
642+ rsub r18, r6, r7
643+ bgti r18, .Lloopsbss
644+.Lendsbss:
645+
646+ addi r6, r0, __bss_start /* clear BSS */
647+ addi r7, r0, __bss_end
648+ rsub r18, r6, r7
649+ blei r18, .Lendbss
650+.Lloopbss:
651+ swi r0, r6, 0
652+ addi r6, r6, 4
653+ rsub r18, r6, r7
654+ bgti r18, .Lloopbss
655+.Lendbss:
656+
657+ brlid r15, _program_init /* Initialize the program */
658+ nop
659
660 brlid r15, __init /* Invoke language initialization functions */
661 nop
662-
663- addi r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
664- addi r7, r0, 0
665- brlid r15, main /* Execute the program */
666- addi r5, r0, 0
667+
668+ addi r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
669+ addi r7, r0, 0
670+ brlid r15, main /* Execute the program */
671+ addi r5, r0, 0
672
673 addik r19, r3, 0 /* Save return value */
674-
675+
676 brlid r15, __fini /* Invoke language cleanup functions */
677 nop
678-
679- brlid r15, _program_clean /* Cleanup the program */
680- nop
681
682- lw r15, r1, r0 /* Return back to CRT */
683+ brlid r15, _program_clean /* Cleanup the program */
684+ nop
685+
686+ lw r15, r1, r0 /* Return back to CRT */
687
688 addik r3, r19, 0 /* Restore return value */
689- rtsd r15, 8
690- addi r1, r1, 40
691+ rtsd r15, 8
692+ addi r1, r1, 40
693+#endif
694 .end _crtinit
695
696diff --git a/libgloss/microblaze/linux-crt0.S b/libgloss/microblaze/linux-crt0.S
697index 8650bb5..503439b 100644
698--- a/libgloss/microblaze/linux-crt0.S
699+++ b/libgloss/microblaze/linux-crt0.S
700@@ -18,26 +18,50 @@
701 .ent _start
702 .type _start, @function
703 _start:
704- la r13, r0, _SDA_BASE_
705- la r2, r0, _SDA2_BASE_
706+#ifdef __arch64__
707+ lli r13, r0, _SDA_BASE_
708+ lli r2, r0, _SDA2_BASE_
709
710- brlid r15, __init
711+ brealid r15, __init
712 nop
713
714- lwi r5, r1, 0
715- addik r6, r1, 4
716+ lli r5, r1, 0
717+ addlik r6, r1, 4
718
719 # Add argc * 4.
720- addk r7, r5, r5
721- addk r7, r7, r7
722+ addlk r7, r5, r5
723+ addlk r7, r7, r7
724
725- brlid r15, main
726 # Now add 4 + r1 (i.e r6) in the delayslot.
727- addk r7, r7, r6
728+ addlk r7, r7, r6
729+ brealid r15, main
730+ nop
731+ addlik r5, r3, 0
732+ brealid r15, exit
733+ nop
734+ .size _start, . - _start
735+#else
736+ la r13, r0, _SDA_BASE_
737+ la r2, r0, _SDA2_BASE_
738+
739+ brlid r15, __init
740+ nop
741+
742+ lwi r5, r1, 0
743+ addik r6, r1, 4
744
745- brlid r15, exit
746+ # Add argc * 4.
747+ addk r7, r5, r5
748+ addk r7, r7, r7
749+
750+ brlid r15, main
751+ # Now add 4 + r1 (i.e r6) in the delayslot.
752+ addk r7, r7, r6
753+
754+ brlid r15, exit
755 addik r5, r3, 0
756- .size _start, . - _start
757+ .size _start, . - _start
758+#endif
759 .end _start
760
761 /* Replacement for the GCC provided crti.S. This one avoids the
762@@ -45,14 +69,28 @@ _start:
763 insn exceptions when running in user-space). */
764 .section .init, "ax"
765 .global __init
766+#ifdef __arch64__
767+ .align 3
768+__init:
769+ addlik r1, r1, -8
770+ sl r15, r0, r1
771+#else
772 .align 2
773 __init:
774 addik r1, r1, -8
775 sw r15, r0, r1
776
777+#endif
778 .section .fini, "ax"
779 .global __fini
780+#ifdef __arch64__
781+ .align 3
782+__fini:
783+ addlik r1, r1, -8
784+ sl r15, r0, r1
785+#else
786 .align 2
787 __fini:
788 addik r1, r1, -8
789 sw r15, r0, r1
790+#endif
791diff --git a/libgloss/microblaze/linux-syscalls.S b/libgloss/microblaze/linux-syscalls.S
792index 506de78..8594f13 100644
793--- a/libgloss/microblaze/linux-syscalls.S
794+++ b/libgloss/microblaze/linux-syscalls.S
795@@ -20,8 +20,9 @@
796 #define GLOBAL(name) .global name; FUNC(name)
797 #define SIZE(name) .size name, .-name
798
799+#ifdef __arch64__
800 # define SYSCALL_BODY(name) \
801- addik r12, r0, SYS_ ## name; \
802+ addlik r12, r0, SYS_ ## name; \
803 brki r14, 8; \
804 rtsd r15, 8; \
805 nop;
806@@ -31,6 +32,18 @@
807 SYSCALL_BODY(name); \
808 SIZE(_ ## name)
809
810+#else
811+# define SYSCALL_BODY(name) \
812+ addik r12, r0, SYS_ ## name; \
813+ brki r14, 8; \
814+ rtsd r15, 8; \
815+ nop;
816+
817+# define SYSCALL(name) \
818+ GLOBAL(_ ## name); \
819+ SYSCALL_BODY(name); \
820+ SIZE(_ ## name)
821+#endif
822 SYSCALL(brk)
823 SYSCALL(exit)
824 SYSCALL(read)
825diff --git a/libgloss/microblaze/pgcrtinit.S b/libgloss/microblaze/pgcrtinit.S
826index 2593082..638dbd3 100644
827--- a/libgloss/microblaze/pgcrtinit.S
828+++ b/libgloss/microblaze/pgcrtinit.S
829@@ -29,10 +29,66 @@
830
831
832 .globl _crtinit
833+#ifdef __arch64__
834+ .align 3
835+#else
836 .align 2
837+#endif
838 .ent _crtinit
839
840 _crtinit:
841+#ifdef __arch64__
842+
843+ addli r1, r1, -40 /* Save Link register */
844+ sli r15, r1, 0
845+
846+ addli r6, r0, __sbss_start /* clear SBSS */
847+ addli r7, r0, __sbss_end
848+ rsubl r18, r6, r7
849+ bealei r18, .Lendsbss
850+.Lloopsbss:
851+ sli r0, r6, 0
852+ addli r6, r6, 4
853+ rsubl r18, r6, r7
854+ beagti r18, .Lloopsbss
855+.Lendsbss:
856+
857+ addli r6, r0, __bss_start /* clear BSS */
858+ addli r7, r0, __bss_end
859+ rsubl r18, r6, r7
860+ bealei r18, .Lendbss
861+.Lloopbss:
862+ sli r0, r6, 0
863+ addli r6, r6, 4
864+ rsubl r18, r6, r7
865+ beagti r18, .Lloopbss
866+.Lendbss:
867+
868+ brealid r15, _program_init /* Initialize the program */
869+ nop
870+ brealid r15, _profile_init /* Initialize profiling library */
871+ nop
872+ brealid r15, __init /* Invoke language initialization functions */
873+ nop
874+ addli r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
875+ addli r7, r0, 0
876+ addli r5, r0, 0
877+ brealid r15, main /* Execute the program */
878+ nop
879+ addlik r19, r3, 0 /* Save return value */
880+
881+ brealid r15, __fini /* Invoke language cleanup functions */
882+ nop
883+ brealid r15, _profile_clean /* Cleanup profiling library */
884+ nop
885+ brealid r15, _program_clean /* Cleanup the program */
886+ nop
887+ ll r15, r1, r0 /* Return back to CRT */
888+ addlik r3, r19, 0 /* Restore return value */
889+ addli r1, r1, 40
890+ rtsd r15, 8
891+ nop
892+#else
893 addi r1, r1, -40 /* Save Link register */
894 swi r15, r1, 0
895
896@@ -86,7 +142,8 @@ _crtinit:
897
898 lw r15, r1, r0 /* Return back to CRT */
899 addik r3, r19, 0 /* Restore return value */
900- rtsd r15, 8
901+ rtsd r15, 8
902 addi r1, r1, 40
903+#endif
904 .end _crtinit
905
906diff --git a/libgloss/microblaze/sim-crtinit.S b/libgloss/microblaze/sim-crtinit.S
907index 74586d9..9892cb0 100644
908--- a/libgloss/microblaze/sim-crtinit.S
909+++ b/libgloss/microblaze/sim-crtinit.S
910@@ -35,10 +35,39 @@
911 #
912
913 .globl _crtinit
914+#ifdef __arch64__
915+ .align 3
916+#else
917 .align 2
918+#endif
919 .ent _crtinit
920
921 _crtinit:
922+#ifdef __arch64__
923+ addli r1, r1, -40 /* Save Link register */
924+ sli r15, r1, 0
925+
926+ brealid r15, _program_init /* Initialize the program */
927+ nop
928+ brealid r15, __init /* Invoke language initialization functions */
929+ nop
930+ addli r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
931+ addli r7, r0, 0
932+ addli r5, r0, 0
933+ brealid r15, main /* Execute the program */
934+ nop
935+ addlik r19, r3, 0 /* Save return value */
936+
937+ brealid r15, __fini /* Invoke language cleanup functions */
938+ nop
939+ brealid r15, _program_clean /* Cleanup the program */
940+ nop
941+ ll r15, r1, r0 /* Return back to CRT */
942+ addlik r3, r19, 0 /* Restore return value */
943+ addli r1, r1, 40
944+ rtsd r15, 8
945+ nop
946+#else
947 addi r1, r1, -40 /* Save Link register */
948 swi r15, r1, 0
949
950@@ -63,7 +92,9 @@ _crtinit:
951
952 lw r15, r1, r0 /* Return back to CRT */
953 addik r3, r19, 0 /* Restore return value */
954+
955 rtsd r15, 8
956 addi r1, r1, 40
957+#endif
958 .end _crtinit
959
960diff --git a/libgloss/microblaze/sim-pgcrtinit.S b/libgloss/microblaze/sim-pgcrtinit.S
961index 82ebcca..939f537 100644
962--- a/libgloss/microblaze/sim-pgcrtinit.S
963+++ b/libgloss/microblaze/sim-pgcrtinit.S
964@@ -35,10 +35,40 @@
965 #
966
967 .globl _crtinit
968+#ifdef __arch64__
969+ .align 3
970+#else
971 .align 2
972+#endif
973 .ent _crtinit
974
975 _crtinit:
976+#ifdef __arch64__
977+ addli r1, r1, -40 /* Save Link register */
978+ sli r15, r1, 0
979+
980+ brealid r15, _program_init /* Initialize the program */
981+ nop
982+ brealid r15, _profile_init /* Initialize profiling library */
983+ nop
984+ brealid r15, __init /* Invoke language initialization functions */
985+ nop
986+ addli r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
987+ addli r7, r0, 0
988+ addli r5, r0, 0
989+ brealid r15, main /* Execute the program */
990+ nop
991+ brealid r15, __fini /* Invoke language cleanup functions */
992+ nop
993+ brealid r15, _profile_clean /* Cleanup profiling library */
994+ nop
995+ brealid r15, _program_clean /* Cleanup the program */
996+ nop
997+ ll r15, r1, r0 /* Return back to CRT */
998+ addli r1, r1, 40
999+ rtsd r15, 8
1000+ nop
1001+#else
1002 addi r1, r1, -40 /* Save Link register */
1003 swi r15, r1, 0
1004
1005@@ -68,5 +98,6 @@ _crtinit:
1006 lw r15, r1, r0 /* Return back to CRT */
1007 rtsd r15, 8
1008 addi r1, r1, 40
1009+#endif
1010 .end _crtinit
1011
1012diff --git a/newlib/libc/machine/microblaze/longjmp.S b/newlib/libc/machine/microblaze/longjmp.S
1013index f972bbd..5ed1c26 100644
1014--- a/newlib/libc/machine/microblaze/longjmp.S
1015+++ b/newlib/libc/machine/microblaze/longjmp.S
1016@@ -51,16 +51,46 @@
1017
1018 .globl longjmp
1019 .section .text
1020-.align 2
1021+#ifdef __arch64__
1022+.align 3
1023+#else
1024+.align 2
1025+#endif
1026 .ent longjmp
1027 longjmp:
1028+#ifdef __arch64__
1029+ lli r1, r5, 0
1030+ lli r13, r5, 4
1031+ lli r14, r5, 8
1032+ lli r15, r5, 12
1033+ lli r16, r5, 16
1034+ lli r17, r5, 20
1035+ lli r18, r5, 24
1036+ lli r19, r5, 28
1037+ lli r20, r5, 32
1038+ lli r21, r5, 36
1039+ lli r22, r5, 40
1040+ lli r23, r5, 44
1041+ lli r24, r5, 48
1042+ lli r25, r5, 52
1043+ lli r26, r5, 56
1044+ lli r27, r5, 60
1045+ lli r28, r5, 64
1046+ lli r29, r5, 68
1047+ lli r30, r5, 72
1048+ lli r31, r5, 76
1049+
1050+ or r3, r0, r6
1051+ rtsd r15, 8
1052+ nop
1053+#else
1054 lwi r1, r5, 0
1055 lwi r13, r5, 4
1056 lwi r14, r5, 8
1057- lwi r15, r5, 12
1058+ lwi r15, r5, 12
1059 lwi r16, r5, 16
1060 lwi r17, r5, 20
1061- lwi r18, r5, 24
1062+ lwi r18, r5, 24
1063 lwi r19, r5, 28
1064 lwi r20, r5, 32
1065 lwi r21, r5, 36
1066@@ -69,12 +99,13 @@ longjmp:
1067 lwi r24, r5, 48
1068 lwi r25, r5, 52
1069 lwi r26, r5, 56
1070- lwi r27, r5, 60
1071- lwi r28, r5, 64
1072- lwi r29, r5, 68
1073+ lwi r27, r5, 60
1074+ lwi r28, r5, 64
1075+ lwi r29, r5, 68
1076 lwi r30, r5, 72
1077- lwi r31, r5, 76
1078+ lwi r31, r5, 76
1079
1080 rtsd r15, 8
1081 or r3, r0, r6
1082+#endif
1083 .end longjmp
1084diff --git a/newlib/libc/machine/microblaze/setjmp.S b/newlib/libc/machine/microblaze/setjmp.S
1085index cdd87c7..971862b 100644
1086--- a/newlib/libc/machine/microblaze/setjmp.S
1087+++ b/newlib/libc/machine/microblaze/setjmp.S
1088@@ -50,9 +50,39 @@
1089
1090 .globl setjmp
1091 .section .text
1092-.align 2
1093+#ifdef __arch64__
1094+.align 3
1095+#else
1096+.align 2
1097+#endif
1098 .ent setjmp
1099 setjmp:
1100+#ifdef __arch64__
1101+ sli r1, r5, 0
1102+ sli r13, r5, 4
1103+ sli r14, r5, 8
1104+ sli r15, r5, 12
1105+ sli r16, r5, 16
1106+ sli r17, r5, 20
1107+ sli r18, r5, 24
1108+ sli r19, r5, 28
1109+ sli r20, r5, 32
1110+ sli r21, r5, 36
1111+ sli r22, r5, 40
1112+ sli r23, r5, 44
1113+ sli r24, r5, 48
1114+ sli r25, r5, 52
1115+ sli r26, r5, 56
1116+ sli r27, r5, 60
1117+ sli r28, r5, 64
1118+ sli r29, r5, 68
1119+ sli r30, r5, 72
1120+ sli r31, r5, 76
1121+
1122+ or r3, r0, r0
1123+ rtsd r15, 8
1124+ nop
1125+#else
1126 swi r1, r5, 0
1127 swi r13, r5, 4
1128 swi r14, r5, 8
1129@@ -76,4 +106,5 @@ setjmp:
1130
1131 rtsd r15, 8
1132 or r3, r0, r0
1133+#endif
1134 .end setjmp
1135--
11362.7.4
1137
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
new file mode 100644
index 00000000..9f27cd60
--- /dev/null
+++ b/meta-microblaze/recipes-core/newlib/files/0008-fixing-the-bug-in-crt-files-added-addlik-instead-of-.patch
@@ -0,0 +1,102 @@
1From 1c7a9150b63089baf3f63c64bf3dbb4d73c814f5 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 28 Sep 2018 12:07:43 +0530
4Subject: [PATCH 08/11] fixing the bug in crt files, added addlik instead of
5 lli insn
6
7---
8 libgloss/microblaze/crt0.S | 6 +++---
9 libgloss/microblaze/crt1.S | 6 +++---
10 libgloss/microblaze/crt2.S | 6 +++---
11 libgloss/microblaze/crt3.S | 6 +++---
12 libgloss/microblaze/crt4.S | 6 +++---
13 5 files changed, 15 insertions(+), 15 deletions(-)
14
15diff --git a/libgloss/microblaze/crt0.S b/libgloss/microblaze/crt0.S
16index e4df73b..25e7c4a 100644
17--- a/libgloss/microblaze/crt0.S
18+++ b/libgloss/microblaze/crt0.S
19@@ -106,9 +106,9 @@ _vector_hw_exception:
20 .type _start1, @function
21 _start1:
22 #ifdef __arch64__
23- lli r13, r0, _SDA_BASE_
24- lli r2, r0, _SDA2_BASE_
25- lli r1, r0, _stack-32
26+ addlik r13, r0, _SDA_BASE_
27+ addlik r2, r0, _SDA2_BASE_
28+ addlik r1, r0, _stack-32
29 brealid r15, _crtinit
30 nop
31 addlik r5, r3, 0
32diff --git a/libgloss/microblaze/crt1.S b/libgloss/microblaze/crt1.S
33index b24eeb5..38440c9 100644
34--- a/libgloss/microblaze/crt1.S
35+++ b/libgloss/microblaze/crt1.S
36@@ -94,9 +94,9 @@ _vector_hw_exception:
37 .type _start, @function
38 _start:
39 #ifdef __arch64__
40- lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
41- lli r2, r0, _SDA2_BASE_
42- lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
43+ addlik r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
44+ addlik r2, r0, _SDA2_BASE_
45+ addlik r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
46
47 brealid r15, _crtinit /* Initialize BSS and run program */
48 nop
49diff --git a/libgloss/microblaze/crt2.S b/libgloss/microblaze/crt2.S
50index ae4c89e..352927d 100644
51--- a/libgloss/microblaze/crt2.S
52+++ b/libgloss/microblaze/crt2.S
53@@ -92,9 +92,9 @@ _vector_hw_exception:
54 .type _start, @function
55 _start:
56 #ifdef __arch64__
57- lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
58- lli r2, r0, _SDA2_BASE_
59- lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
60+ addlik r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
61+ addlik r2, r0, _SDA2_BASE_
62+ addlik r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
63 brealid r15, _crtinit /* Initialize BSS and run program */
64 nop
65 addlik r5, r3, 0
66diff --git a/libgloss/microblaze/crt3.S b/libgloss/microblaze/crt3.S
67index a8bc783..bc32cda 100644
68--- a/libgloss/microblaze/crt3.S
69+++ b/libgloss/microblaze/crt3.S
70@@ -62,9 +62,9 @@
71 .type _start, @function
72 _start:
73 #ifdef __arch64__
74- lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
75- lli r2, r0, _SDA2_BASE_
76- lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
77+ addlik r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
78+ addlik r2, r0, _SDA2_BASE_
79+ addlik r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
80
81 brealid r15, _crtinit /* Initialize BSS and run program */
82 nop
83diff --git a/libgloss/microblaze/crt4.S b/libgloss/microblaze/crt4.S
84index 54ba473..a25c847 100644
85--- a/libgloss/microblaze/crt4.S
86+++ b/libgloss/microblaze/crt4.S
87@@ -63,9 +63,9 @@
88 .type _start, @function
89 _start:
90 #ifdef __arch64__
91- lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
92- lli r2, r0, _SDA2_BASE_
93- lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
94+ addlik r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
95+ addlik r2, r0, _SDA2_BASE_
96+ addlik r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
97
98 brealid r15, _crtinit /* Initialize BSS and run program */
99 nop
100--
1012.7.4
102
diff --git a/meta-microblaze/recipes-core/newlib/files/0009-Added-MB-64-support-to-strcmp-strcpy-strlen-files.patch b/meta-microblaze/recipes-core/newlib/files/0009-Added-MB-64-support-to-strcmp-strcpy-strlen-files.patch
new file mode 100644
index 00000000..38508b55
--- /dev/null
+++ b/meta-microblaze/recipes-core/newlib/files/0009-Added-MB-64-support-to-strcmp-strcpy-strlen-files.patch
@@ -0,0 +1,227 @@
1From 19d7b2a34f3c69d62f570ac9d0f6bc3cd584b496 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Thu, 14 Mar 2019 18:16:32 +0530
4Subject: [PATCH 09/11] Added MB-64 support to strcmp/strcpy/strlen files
5
6---
7 newlib/libc/machine/microblaze/strcmp.c | 61 ++++++++++++++++++++++++++++++++-
8 newlib/libc/machine/microblaze/strcpy.c | 57 ++++++++++++++++++++++++++++++
9 newlib/libc/machine/microblaze/strlen.c | 38 ++++++++++++++++++++
10 3 files changed, 155 insertions(+), 1 deletion(-)
11
12diff --git a/newlib/libc/machine/microblaze/strcmp.c b/newlib/libc/machine/microblaze/strcmp.c
13index 3119d82..dac64da 100644
14--- a/newlib/libc/machine/microblaze/strcmp.c
15+++ b/newlib/libc/machine/microblaze/strcmp.c
16@@ -133,6 +133,65 @@ strcmp (const char *s1,
17
18 #include "mb_endian.h"
19
20+#ifdef __arch64__
21+ asm volatile (" \n\
22+ orl r9, r0, r0 /* Index register */\n\
23+check_alignment: \n\
24+ andli r3, r5, 3 \n\
25+ andli r4, r6, 3 \n\
26+ beanei r3, try_align_args \n\
27+ beanei r4, regular_strcmp /* At this point we don't have a choice */ \n\
28+cmp_loop: \n"
29+ LOAD4BYTES("r3", "r5", "r9")
30+ LOAD4BYTES("r4", "r6", "r9")
31+" \n\
32+ pcmplbf r7, r3, r0 /* See if there is Null byte */ \n\
33+ beanei r7, end_cmp_loop /* IF yes (r7 > 0) use byte compares in end_cmp_loop */ \n\
34+ cmplu r7, r4, r3 /* ELSE compare whole word */ \n\
35+ beanei r7, end_cmp \n\
36+ addlik r9, r9, 4 /* delay slot */ \n\
37+ breaid cmp_loop \n\
38+ nop /* delay slot */ \n\
39+end_cmp_loop: \n\
40+ lbu r3, r5, r9 /* byte compare loop */ \n\
41+ lbu r4, r6, r9 \n\
42+ cmplu r7, r4, r3 /* Compare bytes */ \n\
43+ beanei r7, end_cmp_early \n\
44+ addlik r9, r9, 1 /* delay slot */ \n\
45+ beaneid r3, end_cmp_loop /* If reached null on one string, terminate */ \n\
46+ nop \n\
47+end_cmp_early: \n\
48+ or r3, r0, r7 /* delay slot */ \n\
49+ rtsd r15, 8 \n\
50+ nop \n\
51+try_align_args: \n\
52+ xorl r7, r4, r3 \n\
53+ beanei r7, regular_strcmp /* cannot align args */ \n\
54+ rsublik r10, r3, 4 /* Number of initial bytes to align */ \n\
55+align_loop: \n\
56+ lbu r3, r5, r9 \n\
57+ lbu r4, r6, r9 \n\
58+ cmpu r7, r4, r3 \n\
59+ beanei r7, end_cmp \n\
60+ beaeqi r3, end_cmp \n\
61+ addlik r10, r10, -1 \n\
62+ addlik r9, r9, 1 \n\
63+ beaeqid r10, cmp_loop \n\
64+ nop \n\
65+ breai align_loop \n\
66+regular_strcmp: \n\
67+ lbu r3, r5, r9 \n\
68+ lbu r4, r6, r9 \n\
69+ cmplu r7, r4, r3 \n\
70+ beanei r7, end_cmp \n\
71+ beaeqi r3, end_cmp \n\
72+ breaid regular_strcmp \n\
73+ addlik r9, r9, 1 \n\
74+end_cmp: \n\
75+ or r3, r0, r7 \n\
76+ rtsd r15, 8 \n\
77+ nop /* Return strcmp result */");
78+#else
79 asm volatile (" \n\
80 or r9, r0, r0 /* Index register */\n\
81 check_alignment: \n\
82@@ -181,11 +240,11 @@ regular_strcmp:
83 bnei r7, end_cmp \n\
84 beqi r3, end_cmp \n\
85 brid regular_strcmp \n\
86- addik r9, r9, 1 \n\
87 end_cmp: \n\
88 rtsd r15, 8 \n\
89 or r3, r0, r7 /* Return strcmp result */");
90
91+#endif
92 #endif /* ! HAVE_HW_PCMP */
93 }
94
95diff --git a/newlib/libc/machine/microblaze/strcpy.c b/newlib/libc/machine/microblaze/strcpy.c
96index 62072fa..6dbc60d 100644
97--- a/newlib/libc/machine/microblaze/strcpy.c
98+++ b/newlib/libc/machine/microblaze/strcpy.c
99@@ -125,6 +125,62 @@ strcpy (char *__restrict dst0,
100 #else
101
102 #include "mb_endian.h"
103+#ifdef __arch64__
104+
105+ asm volatile (" \n\
106+ orl r9, r0, r0 /* Index register */ \n\
107+check_alignment: \n\
108+ andli r3, r5, 3 \n\
109+ andli r4, r6, 3 \n\
110+ beanei r3, try_align_args \n\
111+ beanei r4, regular_strcpy /* At this point we dont have a choice */ \n\
112+cpy_loop: \n"
113+ LOAD4BYTES("r3", "r6", "r9")
114+" \n\
115+ pcmplbf r4, r0, r3 \n\
116+ beanei r4, cpy_bytes /* If r4 != 0, then null present within string */\n"
117+ STORE4BYTES("r3", "r5", "r9")
118+" \n\
119+ addlik r9, r9, 4 \n\
120+ breaid cpy_loop \n\
121+ nop \n\
122+cpy_bytes: \n\
123+ lbu r3, r6, r9 \n\
124+ sb r3, r5, r9 \n\
125+ addlik r4, r4, -1 \n\
126+ addlik r9, r9, 1 /* delay slot */\n\
127+ beaneid r4, cpy_bytes \n\
128+ nop \n\
129+cpy_null: \n\
130+ orl r3, r0, r5 /* Return strcpy result */\n\
131+ rtsd r15, 8 \n\
132+ nop \n\
133+try_align_args: \n\
134+ xorl r7, r4, r3 \n\
135+ beanei r7, regular_strcpy /* cannot align args */\n\
136+ rsublik r10, r3, 4 /* Number of initial bytes to align */\n\
137+align_loop: \n\
138+ lbu r3, r6, r9 \n\
139+ sb r3, r5, r9 \n\
140+ addlik r10, r10, -1 \n\
141+ beaeqid r3, end_cpy /* Break if we have seen null character */\n\
142+ nop \n\
143+ addlik r9, r9, 1 \n\
144+ beaneid r10, align_loop \n\
145+ nop \n\
146+ breai cpy_loop \n\
147+regular_strcpy: \n\
148+ lbu r3, r6, r9 \n\
149+ sb r3, r5, r9 \n\
150+ addlik r9, r9, 1 \n\
151+ beaneid r3, regular_strcpy \n\
152+ nop \n\
153+end_cpy: \n\
154+ orl r3, r0, r5 \n\
155+ rtsd r15, 8 \n\
156+ nop /* Return strcpy result */");
157+
158+#else
159
160 asm volatile (" \n\
161 or r9, r0, r0 /* Index register */ \n\
162@@ -171,6 +227,7 @@ regular_strcpy: \n\
163 end_cpy: \n\
164 rtsd r15, 8 \n\
165 or r3, r0, r5 /* Return strcpy result */");
166+#endif
167 #endif /* ! HAVE_HW_PCMP */
168 }
169
170diff --git a/newlib/libc/machine/microblaze/strlen.c b/newlib/libc/machine/microblaze/strlen.c
171index acb4464..c04fa4f 100644
172--- a/newlib/libc/machine/microblaze/strlen.c
173+++ b/newlib/libc/machine/microblaze/strlen.c
174@@ -116,6 +116,43 @@ strlen (const char *str)
175
176 #include "mb_endian.h"
177
178+#ifdef __arch64__
179+ asm volatile (" \n\
180+ orl r9, r0, r0 /* Index register */ \n\
181+check_alignment: \n\
182+ andli r3, r5, 3 \n\
183+ beanei r3, align_arg \n\
184+len_loop: \n"
185+ LOAD4BYTES("r3", "r5", "r9")
186+" \n\
187+ pcmplbf r4, r3, r0 \n\
188+ beanei r4, end_len \n\
189+ addik r9, r9, 4 \n\
190+ breaid len_loop \n\
191+ nop \n\
192+end_len: \n\
193+ lbu r3, r5, r9 \n\
194+ beaeqi r3, done_len \n\
195+ addik r9, r9, 1 \n\
196+ breaid end_len \n\
197+ nop \n\
198+done_len: \n\
199+ orl r3, r0, r9 /* Return len */ \n\
200+ rtsd r15, 8 \n\
201+ nop \n\
202+align_arg: \n\
203+ rsublik r10, r3, 4 \n\
204+align_loop: \n\
205+ lbu r3, r5, r9 \n\
206+ addlik r10, r10, -1 \n\
207+ beaeqid r3, done_len \n\
208+ nop \n\
209+ addlik r9, r9, 1 \n\
210+ beaneid r10, align_loop \n\
211+ nop \n\
212+ breai len_loop");
213+
214+#else
215 asm volatile (" \n\
216 or r9, r0, r0 /* Index register */ \n\
217 check_alignment: \n\
218@@ -146,5 +183,6 @@ align_loop: \n\
219 addik r9, r9, 1 \n\
220 bri len_loop");
221
222+#endif
223 #endif /* ! HAVE_HW_PCMP */
224 }
225--
2262.7.4
227
diff --git a/meta-microblaze/recipes-core/newlib/files/0010-Patch-MicroBlaze-typos-in-string-functions-microblaz.patch b/meta-microblaze/recipes-core/newlib/files/0010-Patch-MicroBlaze-typos-in-string-functions-microblaz.patch
new file mode 100644
index 00000000..d1f19a74
--- /dev/null
+++ b/meta-microblaze/recipes-core/newlib/files/0010-Patch-MicroBlaze-typos-in-string-functions-microblaz.patch
@@ -0,0 +1,87 @@
1From 70281e45fa433ec854f60b43fef019ebc8ca0649 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 3 Apr 2019 11:52:50 +0530
4Subject: [PATCH 10/11] [Patch,MicroBlaze] : typos in string functions
5 microblaze 64 bit port.fixed the issues.
6
7---
8 newlib/libc/machine/microblaze/strcmp.c | 12 +++++++-----
9 newlib/libc/machine/microblaze/strlen.c | 4 ++--
10 2 files changed, 9 insertions(+), 7 deletions(-)
11
12diff --git a/newlib/libc/machine/microblaze/strcmp.c b/newlib/libc/machine/microblaze/strcmp.c
13index dac64da..acfe4cd 100644
14--- a/newlib/libc/machine/microblaze/strcmp.c
15+++ b/newlib/libc/machine/microblaze/strcmp.c
16@@ -135,7 +135,7 @@ strcmp (const char *s1,
17
18 #ifdef __arch64__
19 asm volatile (" \n\
20- orl r9, r0, r0 /* Index register */\n\
21+ orl r9, r0, r0 /* Index register */ \n\
22 check_alignment: \n\
23 andli r3, r5, 3 \n\
24 andli r4, r6, 3 \n\
25@@ -161,7 +161,7 @@ end_cmp_loop:
26 beaneid r3, end_cmp_loop /* If reached null on one string, terminate */ \n\
27 nop \n\
28 end_cmp_early: \n\
29- or r3, r0, r7 /* delay slot */ \n\
30+ orl r3, r0, r7 /* delay slot */ \n\
31 rtsd r15, 8 \n\
32 nop \n\
33 try_align_args: \n\
34@@ -171,7 +171,7 @@ try_align_args:
35 align_loop: \n\
36 lbu r3, r5, r9 \n\
37 lbu r4, r6, r9 \n\
38- cmpu r7, r4, r3 \n\
39+ cmplu r7, r4, r3 \n\
40 beanei r7, end_cmp \n\
41 beaeqi r3, end_cmp \n\
42 addlik r10, r10, -1 \n\
43@@ -185,10 +185,11 @@ regular_strcmp:
44 cmplu r7, r4, r3 \n\
45 beanei r7, end_cmp \n\
46 beaeqi r3, end_cmp \n\
47- breaid regular_strcmp \n\
48 addlik r9, r9, 1 \n\
49+ breaid regular_strcmp \n\
50+ nop \n\
51 end_cmp: \n\
52- or r3, r0, r7 \n\
53+ orl r3, r0, r7 \n\
54 rtsd r15, 8 \n\
55 nop /* Return strcmp result */");
56 #else
57@@ -240,6 +241,7 @@ regular_strcmp:
58 bnei r7, end_cmp \n\
59 beqi r3, end_cmp \n\
60 brid regular_strcmp \n\
61+ addik r9, r9, 1 \n\
62 end_cmp: \n\
63 rtsd r15, 8 \n\
64 or r3, r0, r7 /* Return strcmp result */");
65diff --git a/newlib/libc/machine/microblaze/strlen.c b/newlib/libc/machine/microblaze/strlen.c
66index c04fa4f..b6f2d3c 100644
67--- a/newlib/libc/machine/microblaze/strlen.c
68+++ b/newlib/libc/machine/microblaze/strlen.c
69@@ -127,13 +127,13 @@ len_loop: \n"
70 " \n\
71 pcmplbf r4, r3, r0 \n\
72 beanei r4, end_len \n\
73- addik r9, r9, 4 \n\
74+ addlik r9, r9, 4 \n\
75 breaid len_loop \n\
76 nop \n\
77 end_len: \n\
78 lbu r3, r5, r9 \n\
79 beaeqi r3, done_len \n\
80- addik r9, r9, 1 \n\
81+ addlik r9, r9, 1 \n\
82 breaid end_len \n\
83 nop \n\
84 done_len: \n\
85--
862.7.4
87
diff --git a/meta-microblaze/recipes-core/newlib/files/0011-Removing-the-Assembly-implementation-of-64bit-string.patch b/meta-microblaze/recipes-core/newlib/files/0011-Removing-the-Assembly-implementation-of-64bit-string.patch
new file mode 100644
index 00000000..c8d13af0
--- /dev/null
+++ b/meta-microblaze/recipes-core/newlib/files/0011-Removing-the-Assembly-implementation-of-64bit-string.patch
@@ -0,0 +1,332 @@
1From b35b582ef3f6575447097585174302fde1761078 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Wed, 24 Apr 2019 23:29:21 +0530
4Subject: [PATCH 11/11] Removing the Assembly implementation of 64bit string
5 function. Revisit in next release and fix it
6
7---
8 newlib/libc/machine/microblaze/mb_endian.h | 4 ++
9 newlib/libc/machine/microblaze/strcmp.c | 93 ++++++++++--------------------
10 newlib/libc/machine/microblaze/strcpy.c | 82 ++++++++------------------
11 newlib/libc/machine/microblaze/strlen.c | 59 +++++++------------
12 4 files changed, 81 insertions(+), 157 deletions(-)
13
14diff --git a/newlib/libc/machine/microblaze/mb_endian.h b/newlib/libc/machine/microblaze/mb_endian.h
15index fb217ec..17772c8 100644
16--- a/newlib/libc/machine/microblaze/mb_endian.h
17+++ b/newlib/libc/machine/microblaze/mb_endian.h
18@@ -8,8 +8,12 @@
19 #ifdef __LITTLE_ENDIAN__
20 #define LOAD4BYTES(rD,rA,rB) "\tlwr\t" rD ", " rA ", " rB "\n"
21 #define STORE4BYTES(rD,rA,rB) "\tswr\t" rD ", " rA ", " rB "\n"
22+#define LOAD8BYTES(rD,rA,rB) "\tllr\t" rD ", " rA ", " rB "\n"
23+#define STORE8BYTES(rD,rA,rB) "\tslr\t" rD ", " rA ", " rB "\n"
24 #else
25 #define LOAD4BYTES(rD,rA,rB) "\tlw\t" rD ", " rA ", " rB "\n"
26 #define STORE4BYTES(rD,rA,rB) "\tsw\t" rD ", " rA ", " rB "\n"
27+#define LOAD8BYTES(rD,rA,rB) "\tll\t" rD ", " rA ", " rB "\n"
28+#define STORE8BYTES(rD,rA,rB) "\tsl\t" rD ", " rA ", " rB "\n"
29 #endif
30 #endif
31diff --git a/newlib/libc/machine/microblaze/strcmp.c b/newlib/libc/machine/microblaze/strcmp.c
32index acfe4cd..e34c64a 100644
33--- a/newlib/libc/machine/microblaze/strcmp.c
34+++ b/newlib/libc/machine/microblaze/strcmp.c
35@@ -129,70 +129,42 @@ strcmp (const char *s1,
36 return (*(unsigned char *) s1) - (*(unsigned char *) s2);
37 #endif /* not PREFER_SIZE_OVER_SPEED */
38
39+#elif __arch64__
40+ unsigned int *a1;
41+ unsigned int *a2;
42+
43+ /* If s1 or s2 are unaligned, then compare bytes. */
44+ if (!UNALIGNED (s1, s2))
45+ {
46+ /* If s1 and s2 are word-aligned, compare them a word at a time. */
47+ a1 = (unsigned int*)s1;
48+ a2 = (unsigned int*)s2;
49+ while (*a1 == *a2)
50+ {
51+ /* To get here, *a1 == *a2, thus if we find a null in *a1,
52+ then the strings must be equal, so return zero. */
53+ if (DETECTNULL (*a1))
54+ return 0;
55+
56+ a1++;
57+ a2++;
58+ }
59+
60+ /* A difference was detected in last few bytes of s1, so search bytewise */
61+ s1 = (char*)a1;
62+ s2 = (char*)a2;
63+ }
64+
65+ while (*s1 != '\0' && *s1 == *s2)
66+ {
67+ s1++;
68+ s2++;
69+ }
70+ return (*(unsigned char *) s1) - (*(unsigned char *) s2);
71 #else
72
73 #include "mb_endian.h"
74
75-#ifdef __arch64__
76- asm volatile (" \n\
77- orl r9, r0, r0 /* Index register */ \n\
78-check_alignment: \n\
79- andli r3, r5, 3 \n\
80- andli r4, r6, 3 \n\
81- beanei r3, try_align_args \n\
82- beanei r4, regular_strcmp /* At this point we don't have a choice */ \n\
83-cmp_loop: \n"
84- LOAD4BYTES("r3", "r5", "r9")
85- LOAD4BYTES("r4", "r6", "r9")
86-" \n\
87- pcmplbf r7, r3, r0 /* See if there is Null byte */ \n\
88- beanei r7, end_cmp_loop /* IF yes (r7 > 0) use byte compares in end_cmp_loop */ \n\
89- cmplu r7, r4, r3 /* ELSE compare whole word */ \n\
90- beanei r7, end_cmp \n\
91- addlik r9, r9, 4 /* delay slot */ \n\
92- breaid cmp_loop \n\
93- nop /* delay slot */ \n\
94-end_cmp_loop: \n\
95- lbu r3, r5, r9 /* byte compare loop */ \n\
96- lbu r4, r6, r9 \n\
97- cmplu r7, r4, r3 /* Compare bytes */ \n\
98- beanei r7, end_cmp_early \n\
99- addlik r9, r9, 1 /* delay slot */ \n\
100- beaneid r3, end_cmp_loop /* If reached null on one string, terminate */ \n\
101- nop \n\
102-end_cmp_early: \n\
103- orl r3, r0, r7 /* delay slot */ \n\
104- rtsd r15, 8 \n\
105- nop \n\
106-try_align_args: \n\
107- xorl r7, r4, r3 \n\
108- beanei r7, regular_strcmp /* cannot align args */ \n\
109- rsublik r10, r3, 4 /* Number of initial bytes to align */ \n\
110-align_loop: \n\
111- lbu r3, r5, r9 \n\
112- lbu r4, r6, r9 \n\
113- cmplu r7, r4, r3 \n\
114- beanei r7, end_cmp \n\
115- beaeqi r3, end_cmp \n\
116- addlik r10, r10, -1 \n\
117- addlik r9, r9, 1 \n\
118- beaeqid r10, cmp_loop \n\
119- nop \n\
120- breai align_loop \n\
121-regular_strcmp: \n\
122- lbu r3, r5, r9 \n\
123- lbu r4, r6, r9 \n\
124- cmplu r7, r4, r3 \n\
125- beanei r7, end_cmp \n\
126- beaeqi r3, end_cmp \n\
127- addlik r9, r9, 1 \n\
128- breaid regular_strcmp \n\
129- nop \n\
130-end_cmp: \n\
131- orl r3, r0, r7 \n\
132- rtsd r15, 8 \n\
133- nop /* Return strcmp result */");
134-#else
135 asm volatile (" \n\
136 or r9, r0, r0 /* Index register */\n\
137 check_alignment: \n\
138@@ -246,7 +218,6 @@ end_cmp:
139 rtsd r15, 8 \n\
140 or r3, r0, r7 /* Return strcmp result */");
141
142-#endif
143 #endif /* ! HAVE_HW_PCMP */
144 }
145
146diff --git a/newlib/libc/machine/microblaze/strcpy.c b/newlib/libc/machine/microblaze/strcpy.c
147index 6dbc60d..ddb6922 100644
148--- a/newlib/libc/machine/microblaze/strcpy.c
149+++ b/newlib/libc/machine/microblaze/strcpy.c
150@@ -121,67 +121,36 @@ strcpy (char *__restrict dst0,
151 ;
152 return dst0;
153 #endif /* not PREFER_SIZE_OVER_SPEED */
154+#elif __arch64__
155+ char *dst = dst0;
156+ const char *src = src0;
157+ long *aligned_dst;
158+ const long *aligned_src;
159
160-#else
161+ /* If SRC or DEST is unaligned, then copy bytes. */
162+ if (!UNALIGNED (src, dst))
163+ {
164+ aligned_dst = (long*)dst;
165+ aligned_src = (long*)src;
166
167-#include "mb_endian.h"
168-#ifdef __arch64__
169+ /* SRC and DEST are both "long int" aligned, try to do "long int"
170+ sized copies. */
171+ while (!DETECTNULL(*aligned_src))
172+ {
173+ *aligned_dst++ = *aligned_src++;
174+ }
175
176- asm volatile (" \n\
177- orl r9, r0, r0 /* Index register */ \n\
178-check_alignment: \n\
179- andli r3, r5, 3 \n\
180- andli r4, r6, 3 \n\
181- beanei r3, try_align_args \n\
182- beanei r4, regular_strcpy /* At this point we dont have a choice */ \n\
183-cpy_loop: \n"
184- LOAD4BYTES("r3", "r6", "r9")
185-" \n\
186- pcmplbf r4, r0, r3 \n\
187- beanei r4, cpy_bytes /* If r4 != 0, then null present within string */\n"
188- STORE4BYTES("r3", "r5", "r9")
189-" \n\
190- addlik r9, r9, 4 \n\
191- breaid cpy_loop \n\
192- nop \n\
193-cpy_bytes: \n\
194- lbu r3, r6, r9 \n\
195- sb r3, r5, r9 \n\
196- addlik r4, r4, -1 \n\
197- addlik r9, r9, 1 /* delay slot */\n\
198- beaneid r4, cpy_bytes \n\
199- nop \n\
200-cpy_null: \n\
201- orl r3, r0, r5 /* Return strcpy result */\n\
202- rtsd r15, 8 \n\
203- nop \n\
204-try_align_args: \n\
205- xorl r7, r4, r3 \n\
206- beanei r7, regular_strcpy /* cannot align args */\n\
207- rsublik r10, r3, 4 /* Number of initial bytes to align */\n\
208-align_loop: \n\
209- lbu r3, r6, r9 \n\
210- sb r3, r5, r9 \n\
211- addlik r10, r10, -1 \n\
212- beaeqid r3, end_cpy /* Break if we have seen null character */\n\
213- nop \n\
214- addlik r9, r9, 1 \n\
215- beaneid r10, align_loop \n\
216- nop \n\
217- breai cpy_loop \n\
218-regular_strcpy: \n\
219- lbu r3, r6, r9 \n\
220- sb r3, r5, r9 \n\
221- addlik r9, r9, 1 \n\
222- beaneid r3, regular_strcpy \n\
223- nop \n\
224-end_cpy: \n\
225- orl r3, r0, r5 \n\
226- rtsd r15, 8 \n\
227- nop /* Return strcpy result */");
228+ dst = (char*)aligned_dst;
229+ src = (char*)aligned_src;
230+ }
231
232-#else
233+ while (*dst++ = *src++)
234+ ;
235+ return dst0;
236+
237+#else
238
239+#include "mb_endian.h"
240 asm volatile (" \n\
241 or r9, r0, r0 /* Index register */ \n\
242 check_alignment: \n\
243@@ -227,7 +196,6 @@ regular_strcpy: \n\
244 end_cpy: \n\
245 rtsd r15, 8 \n\
246 or r3, r0, r5 /* Return strcpy result */");
247-#endif
248 #endif /* ! HAVE_HW_PCMP */
249 }
250
251diff --git a/newlib/libc/machine/microblaze/strlen.c b/newlib/libc/machine/microblaze/strlen.c
252index b6f2d3c..9407539 100644
253--- a/newlib/libc/machine/microblaze/strlen.c
254+++ b/newlib/libc/machine/microblaze/strlen.c
255@@ -112,47 +112,29 @@ strlen (const char *str)
256 return str - start;
257 #endif /* not PREFER_SIZE_OVER_SPEED */
258
259-#else
260-
261-#include "mb_endian.h"
262+#elif __arch64__
263+ const char *start = str;
264+ unsigned long *aligned_addr;
265
266-#ifdef __arch64__
267- asm volatile (" \n\
268- orl r9, r0, r0 /* Index register */ \n\
269-check_alignment: \n\
270- andli r3, r5, 3 \n\
271- beanei r3, align_arg \n\
272-len_loop: \n"
273- LOAD4BYTES("r3", "r5", "r9")
274-" \n\
275- pcmplbf r4, r3, r0 \n\
276- beanei r4, end_len \n\
277- addlik r9, r9, 4 \n\
278- breaid len_loop \n\
279- nop \n\
280-end_len: \n\
281- lbu r3, r5, r9 \n\
282- beaeqi r3, done_len \n\
283- addlik r9, r9, 1 \n\
284- breaid end_len \n\
285- nop \n\
286-done_len: \n\
287- orl r3, r0, r9 /* Return len */ \n\
288- rtsd r15, 8 \n\
289- nop \n\
290-align_arg: \n\
291- rsublik r10, r3, 4 \n\
292-align_loop: \n\
293- lbu r3, r5, r9 \n\
294- addlik r10, r10, -1 \n\
295- beaeqid r3, done_len \n\
296- nop \n\
297- addlik r9, r9, 1 \n\
298- beaneid r10, align_loop \n\
299- nop \n\
300- breai len_loop");
301+ if (!UNALIGNED (str))
302+ {
303+ /* If the string is word-aligned, we can check for the presence of
304+ a null in each word-sized block. */
305+ aligned_addr = (unsigned long*)str;
306+ while (!DETECTNULL (*aligned_addr))
307+ aligned_addr++;
308
309+ /* Once a null is detected, we check each byte in that block for a
310+ precise position of the null. */
311+ str = (char*)aligned_addr;
312+ }
313+
314+ while (*str)
315+ str++;
316+ return str - start;
317 #else
318+
319+#include "mb_endian.h"
320 asm volatile (" \n\
321 or r9, r0, r0 /* Index register */ \n\
322 check_alignment: \n\
323@@ -183,6 +165,5 @@ align_loop: \n\
324 addik r9, r9, 1 \n\
325 bri len_loop");
326
327-#endif
328 #endif /* ! HAVE_HW_PCMP */
329 }
330--
3312.7.4
332
diff --git a/meta-microblaze/recipes-core/newlib/libgloss_3.3.%.bbappend b/meta-microblaze/recipes-core/newlib/libgloss_3.3.%.bbappend
new file mode 100644
index 00000000..3dee0f06
--- /dev/null
+++ b/meta-microblaze/recipes-core/newlib/libgloss_3.3.%.bbappend
@@ -0,0 +1,6 @@
1require microblaze-newlib.inc
2
3do_configure_prepend_microblaze() {
4 # hack for microblaze, which needs xilinx.ld to literally do any linking (its hard coded in its LINK_SPEC)
5 export CC="${CC} -L${S}/libgloss/microblaze"
6}
diff --git a/meta-microblaze/recipes-core/newlib/microblaze-newlib.inc b/meta-microblaze/recipes-core/newlib/microblaze-newlib.inc
new file mode 100644
index 00000000..c3b6acdc
--- /dev/null
+++ b/meta-microblaze/recipes-core/newlib/microblaze-newlib.inc
@@ -0,0 +1,15 @@
1# Add MicroBlaze Patches
2FILESEXTRAPATHS_append_microblaze := ":${THISDIR}/files"
3SRC_URI_append_microblaze = " \
4 file://0001-Patch-microblaze-Add-config-microblaze.mt-for-target.patch \
5 file://0002-Patch-microblaze-Modified-_exceptional_handler.patch \
6 file://0003-LOCAL-Add-missing-declarations-for-xil_printf-to-std.patch \
7 file://0004-Local-deleting-the-xil_printf.c-file-as-now-it-part-.patch \
8 file://0005-Local-deleting-the-xil_printf.o-from-MAKEFILE.patch \
9 file://0006-MB-X-intial-commit.patch \
10 file://0007-Patch-Microblaze-newlib-port-for-microblaze-m64-flag.patch \
11 file://0008-fixing-the-bug-in-crt-files-added-addlik-instead-of-.patch \
12 file://0009-Added-MB-64-support-to-strcmp-strcpy-strlen-files.patch \
13 file://0010-Patch-MicroBlaze-typos-in-string-functions-microblaz.patch \
14 file://0011-Removing-the-Assembly-implementation-of-64bit-string.patch \
15 "
diff --git a/meta-microblaze/recipes-core/newlib/newlib_3.3.%.bbappend b/meta-microblaze/recipes-core/newlib/newlib_3.3.%.bbappend
new file mode 100644
index 00000000..d459bf19
--- /dev/null
+++ b/meta-microblaze/recipes-core/newlib/newlib_3.3.%.bbappend
@@ -0,0 +1,7 @@
1require microblaze-newlib.inc
2
3do_configure_prepend_microblaze() {
4 # hack for microblaze, which needs xilinx.ld to literally do any linking (its hard coded in its LINK_SPEC)
5 export CC="${CC} -L${S}/libgloss/microblaze"
6}
7