From 6041792ec6b89f5e9eae79d8addbb0f706f9addd Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 16 Jul 2013 07:48:53 +0000 Subject: [PATCH] * configure.host: Change to microblaze*. * libc/include/machine/ieeefp.h: Add __MICROBLAZEEL__. * libc/machine/microblaze/mb_endian.h: New file. * newlib/libc/machine/microblaze/strcmp.c: Add little endian support. * newlib/libc/machine/microblaze/strcpy.c: Likewise. * newlib/libc/machine/microblaze/strlen.c: Likewise. * configure.in: Change to microblaze*. * configure: Regenerate. * microblaze/xilinx.ld: Remove OUTPUT_FORMAT. --- libgloss/ChangeLog | 6 ++++++ libgloss/configure | 2 +- libgloss/configure.in | 2 +- libgloss/microblaze/xilinx.ld | 2 -- newlib/ChangeLog | 9 +++++++++ newlib/configure.host | 6 +++--- newlib/libc/include/machine/ieeefp.h | 4 ++++ newlib/libc/machine/microblaze/mb_endian.h | 15 +++++++++++++++ newlib/libc/machine/microblaze/strcmp.c | 11 +++++++---- newlib/libc/machine/microblaze/strcpy.c | 16 ++++++++++------ newlib/libc/machine/microblaze/strlen.c | 7 +++++-- 11 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 newlib/libc/machine/microblaze/mb_endian.h diff --git a/libgloss/ChangeLog b/libgloss/ChangeLog index f8a58d3c9..c3d8be16f 100644 --- a/libgloss/ChangeLog +++ b/libgloss/ChangeLog @@ -1,3 +1,9 @@ +2013-07-16 David Holsgrove + + * configure.in: Change to microblaze*. + * configure: Regenerate. + * microblaze/xilinx.ld: Remove OUTPUT_FORMAT. + 2013-07-12 Marcus Shawcroft * aarch64/cpu-init/rdimon-aem-el3.S (vectors): Page align. diff --git a/libgloss/configure b/libgloss/configure index d2cb52efe..41d91d68a 100755 --- a/libgloss/configure +++ b/libgloss/configure @@ -2504,7 +2504,7 @@ case "${target}" in subdirs="$subdirs moxie" ;; - microblaze-*-*) + microblaze*-*-*) subdirs="$subdirs microblaze" ;; diff --git a/libgloss/configure.in b/libgloss/configure.in index c571eebdc..14287e753 100644 --- a/libgloss/configure.in +++ b/libgloss/configure.in @@ -117,7 +117,7 @@ case "${target}" in moxie-*-*) AC_CONFIG_SUBDIRS([moxie]) ;; - microblaze-*-*) + microblaze*-*-*) AC_CONFIG_SUBDIRS([microblaze]) ;; mt-*-*) diff --git a/libgloss/microblaze/xilinx.ld b/libgloss/microblaze/xilinx.ld index 58594c46a..7789ea997 100644 --- a/libgloss/microblaze/xilinx.ld +++ b/libgloss/microblaze/xilinx.ld @@ -1,6 +1,4 @@ /* Default linker script, for normal executables */ -OUTPUT_FORMAT("elf32-microblaze", "", - "") /*SEARCH_DIR("/proj/fv1/gnu_builds/head/mb/release/lin/mb/microblaze-xilinx-elf/lib");*/ /*SEARCH_DIR("/proj/fv1/gnu_builds/head/mb/release/lin/mb/microblaze-xilinx-elf/lib");*/ ENTRY(_start) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 870c10a00..b50e21035 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,12 @@ +2013-07-16 David Holsgrove + + * configure.host: Change to microblaze*. + * libc/include/machine/ieeefp.h: Add __MICROBLAZEEL__. + * libc/machine/microblaze/mb_endian.h: New file. + * newlib/libc/machine/microblaze/strcmp.c: Add little endian support. + * newlib/libc/machine/microblaze/strcpy.c: Likewise. + * newlib/libc/machine/microblaze/strlen.c: Likewise. + 2013-07-09 Sabrina Ni * libc/machine/nds32/Makefile.am (lib_a_SOURCES): Add abort.c, memcpy.S, diff --git a/newlib/configure.host b/newlib/configure.host index d577ce972..e7047f060 100644 --- a/newlib/configure.host +++ b/newlib/configure.host @@ -203,7 +203,7 @@ case "${host_cpu}" in ;; mcore) ;; - microblaze) + microblaze*) machine_dir=microblaze ;; mep) @@ -479,7 +479,7 @@ case "${host}" in default_newlib_io_long_long="yes" newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES" ;; - microblaze-*-*) + microblaze*-*-*) machine_dir=microblaze ;; mips*-dec-*) @@ -696,7 +696,7 @@ case "${host}" in mcore-*-*) syscall_dir=syscalls ;; - microblaze-*-*) + microblaze*-*-*) default_newlib_io_long_long="yes" newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DSMALL_MEMORY -D_REENT_SMALL" ;; diff --git a/newlib/libc/include/machine/ieeefp.h b/newlib/libc/include/machine/ieeefp.h index 256a78171..042e7f409 100644 --- a/newlib/libc/include/machine/ieeefp.h +++ b/newlib/libc/include/machine/ieeefp.h @@ -364,7 +364,11 @@ #endif #ifdef __MICROBLAZE__ +#ifndef __MICROBLAZEEL__ #define __IEEE_BIG_ENDIAN +#else +#define __IEEE_LITTLE_ENDIAN +#endif #endif #ifdef __MSP430__ diff --git a/newlib/libc/machine/microblaze/mb_endian.h b/newlib/libc/machine/microblaze/mb_endian.h new file mode 100644 index 000000000..fb217ec85 --- /dev/null +++ b/newlib/libc/machine/microblaze/mb_endian.h @@ -0,0 +1,15 @@ +#ifndef _MB_ENDIAN_H +#define _MB_ENDIAN_H + +/* Convenience macros for loading and store 4 bytes in a byte invariant way with + * a singe instruction. Endianess affects this and we rely on MicroBlaze + * load/store reverse instructions to do the trick on little-endian systems. + */ +#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" +#else +#define LOAD4BYTES(rD,rA,rB) "\tlw\t" rD ", " rA ", " rB "\n" +#define STORE4BYTES(rD,rA,rB) "\tsw\t" rD ", " rA ", " rB "\n" +#endif +#endif diff --git a/newlib/libc/machine/microblaze/strcmp.c b/newlib/libc/machine/microblaze/strcmp.c index dbac3878f..2f0337412 100644 --- a/newlib/libc/machine/microblaze/strcmp.c +++ b/newlib/libc/machine/microblaze/strcmp.c @@ -138,16 +138,19 @@ _DEFUN (strcmp, (s1, s2), #else +#include "mb_endian.h" + asm volatile (" \n\ - or r9, r0, r0 /* Index register */ \n\ + or r9, r0, r0 /* Index register */\n\ check_alignment: \n\ andi r3, r5, 3 \n\ andi r4, r6, 3 \n\ bnei r3, try_align_args \n\ bnei r4, regular_strcmp /* At this point we don't have a choice */ \n\ -cmp_loop: \n\ - lw r3, r5, r9 \n\ - lw r4, r6, r9 \n\ +cmp_loop: \n" + LOAD4BYTES("r3", "r5", "r9") + LOAD4BYTES("r4", "r6", "r9") +" \n\ pcmpbf r7, r3, r0 /* See if there is Null byte */ \n\ bnei r7, end_cmp_loop /* IF yes (r7 > 0) use byte compares in end_cmp_loop */ \n\ cmpu r7, r4, r3 /* ELSE compare whole word */ \n\ diff --git a/newlib/libc/machine/microblaze/strcpy.c b/newlib/libc/machine/microblaze/strcpy.c index 6f0ad05e7..d5430a305 100644 --- a/newlib/libc/machine/microblaze/strcpy.c +++ b/newlib/libc/machine/microblaze/strcpy.c @@ -131,18 +131,22 @@ _DEFUN (strcpy, (dst0, src0), #else - asm volatile (" \ - or r9, r0, r0 /* Index register */ \n\ +#include "mb_endian.h" + + asm volatile (" \n\ + or r9, r0, r0 /* Index register */ \n\ check_alignment: \n\ andi r3, r5, 3 \n\ andi r4, r6, 3 \n\ bnei r3, try_align_args \n\ bnei r4, regular_strcpy /* At this point we dont have a choice */ \n\ -cpy_loop: \n\ - lw r3, r6, r9 \n\ +cpy_loop: \n" + LOAD4BYTES("r3", "r6", "r9") +" \n\ pcmpbf r4, r0, r3 \n\ - bnei r4, cpy_bytes /* If r4 != 0, then null present within string */\n\ - sw r3, r5, r9 \n\ + bnei r4, cpy_bytes /* If r4 != 0, then null present within string */\n" + STORE4BYTES("r3", "r5", "r9") +" \n\ brid cpy_loop \n\ addik r9, r9, 4 \n\ cpy_bytes: \n\ diff --git a/newlib/libc/machine/microblaze/strlen.c b/newlib/libc/machine/microblaze/strlen.c index 82eede86e..51387cd9c 100644 --- a/newlib/libc/machine/microblaze/strlen.c +++ b/newlib/libc/machine/microblaze/strlen.c @@ -120,13 +120,16 @@ _DEFUN (strlen, (str), #else +#include "mb_endian.h" + asm volatile (" \n\ or r9, r0, r0 /* Index register */ \n\ check_alignment: \n\ andi r3, r5, 3 \n\ bnei r3, align_arg \n\ -len_loop: \n\ - lw r3, r5, r9 \n\ +len_loop: \n" + LOAD4BYTES("r3", "r5", "r9") +" \n\ pcmpbf r4, r3, r0 \n\ bnei r4, end_len \n\ brid len_loop \n\