sh64-elf (SH5) port
J. Johnston
jjohnstn@redhat.com
Mon Feb 4 09:16:00 GMT 2002
Alexandre Oliva wrote:
>
> I'm a bit disappointed that I have missed 1.10.0, but this port
> wouldn't have been of much use before contributing binutils, gcc and
> the simulator, anyway. So I'm now pleased to contribute the sh64-elf
> port of newlib, for the SH5 processor. Ok to install?
>
Yes, thanks.
-- Jeff J.
> --------------------------------------------------------------------------------
> Index: newlib/ChangeLog
> from Alexandre Oliva <aoliva@redhat.com>
>
> Contribute sh64-elf.
> 2001-03-13 Alexandre Oliva <aoliva@redhat.com>
> * configure.host (newlib_cflags) [sh*-*-*]: Enable long long
> support in printf.
> 2001-01-29 Alexandre Oliva <aoliva@redhat.com>
> * libc/machine/sh/setjmp.S [SH5]: Switch to SHmedia mode before
> any labels.
> 2001-01-24 Alexandre Oliva <aoliva@redhat.com>
> * libc/sys/sh/trap.S (___trap34) [SH5]: Don't trash r2.
> 2000-12-16 Alexandre Oliva <aoliva@redhat.com>
> * libc/machine/sh/configure.in: Rework conditionals.
> * libc/machine/sh/Makefile.am: Likewise.
> * libc/machine/sh/configure, libc/machine/sh/Makefile.in: Rebuilt.
> 2000-12-01 Alexandre Oliva <aoliva@redhat.com>
> * configure.host: Match `sh*'.
> * libc/include/machine/setjmp.h: Define for SH5.
> * libc/machine/sh/configure.in: Detect SH5.
> * libc/machine/sh/configure: Rebuilt.
> * libc/machine/sh/Makefile.am: Use only setjmp.S for SH5.
> * libc/machine/sh/Makefile.in: Rebuilt.
> * libc/machine/sh/asm.h: Adjust for SH5.
> * libc/machine/sh/setjmp.S: Implement in SHmedia.
> * libc/sys/sh/crt0.S: Likewise.
> * libc/sys/sh/trap.S: Likewise.
>
> Index: newlib/configure.host
> ===================================================================
> RCS file: /home/aoliva/cygnus/uberbaum/newlib/configure.host,v
> retrieving revision 1.17
> diff -u -p -r1.17 configure.host
> --- newlib/configure.host 1 Feb 2002 18:00:39 -0000 1.17
> +++ newlib/configure.host 3 Feb 2002 01:00:23 -0000
> @@ -150,7 +150,7 @@ case "${host_cpu}" in
> powerpc*)
> machine_dir=powerpc
> ;;
> - sh)
> + sh | sh64)
> machine_dir=sh
> ;;
> sparc*)
> @@ -474,7 +474,7 @@ case "${host}" in
> syscall_dir=syscalls
> ;;
> sh*-*-*)
> - newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY"
> + newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DWANT_PRINTF_LONG_LONG"
> syscall_dir=syscalls
> ;;
> sparc-sun-sunos*)
> Index: newlib/libc/include/machine/setjmp.h
> ===================================================================
> RCS file: /home/aoliva/cygnus/uberbaum/newlib/libc/include/machine/setjmp.h,v
> retrieving revision 1.6
> diff -u -p -r1.6 setjmp.h
> --- newlib/libc/include/machine/setjmp.h 22 Dec 2001 22:47:57 -0000 1.6
> +++ newlib/libc/include/machine/setjmp.h 2 Feb 2002 04:00:47 -0000
> @@ -93,7 +93,12 @@ typedef int jmp_buf[_JBLEN];
> #endif
>
> #ifdef __sh__
> +#if __SH5__
> +#define _JBLEN 50
> +#define _JBTYPE long long
> +#else
> #define _JBLEN 20
> +#endif /* __SH5__ */
> #endif
>
> #ifdef __v800
> Index: newlib/libc/machine/sh/Makefile.am
> ===================================================================
> RCS file: /home/aoliva/cygnus/uberbaum/newlib/libc/machine/sh/Makefile.am,v
> retrieving revision 1.1.1.1
> diff -u -p -r1.1.1.1 Makefile.am
> --- newlib/libc/machine/sh/Makefile.am 17 Feb 2000 19:39:47 -0000 1.1.1.1
> +++ newlib/libc/machine/sh/Makefile.am 2 Feb 2002 04:00:47 -0000
> @@ -6,7 +6,11 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLA
>
> noinst_LIBRARIES = lib.a
>
> +if SH64
> +lib_a_SOURCES = setjmp.S
> +else
> lib_a_SOURCES = memcpy.S memset.S setjmp.S strcpy.S strcmp.S
> +endif
>
> memcpy.o: asm.h
> memset.o: asm.h
> Index: newlib/libc/machine/sh/asm.h
> ===================================================================
> RCS file: /home/aoliva/cygnus/uberbaum/newlib/libc/machine/sh/asm.h,v
> retrieving revision 1.1.1.1
> diff -u -p -r1.1.1.1 asm.h
> --- newlib/libc/machine/sh/asm.h 17 Feb 2000 19:39:47 -0000 1.1.1.1
> +++ newlib/libc/machine/sh/asm.h 2 Feb 2002 04:00:47 -0000
> @@ -5,8 +5,19 @@
> #endif
> #define _ASM_LABEL(x) x
>
> +#if __SH5__
> +# if __SH5__ == 32 && __SHMEDIA__
> +# define TEXT .section .text..SHmedia32, "ax"
> +# else
> +# define TEXT .text
> +# endif
> +
> +# define _ENTRY(name) \
> + TEXT; .align 4; .globl name; name:
> +#else
> #define _ENTRY(name) \
> .text; .align 2; .globl name; name:
> +#endif /* __SH5__ */
>
> #define ENTRY(name) \
> _ENTRY(_C_LABEL(name))
> Index: newlib/libc/machine/sh/configure.in
> ===================================================================
> RCS file: /home/aoliva/cygnus/uberbaum/newlib/libc/machine/sh/configure.in,v
> retrieving revision 1.1.1.1
> diff -u -p -r1.1.1.1 configure.in
> --- newlib/libc/machine/sh/configure.in 17 Feb 2000 19:39:47 -0000 1.1.1.1
> +++ newlib/libc/machine/sh/configure.in 2 Feb 2002 04:00:47 -0000
> @@ -9,4 +9,11 @@ AC_CONFIG_AUX_DIR(../../../..)
>
> NEWLIB_CONFIGURE(../../..)
>
> +AC_EGREP_CPP([sh5], [
> +#if __SH5__
> + sh5
> +#endif
> +], [have_sh64=yes], [have_sh64=no])
> +AM_CONDITIONAL(SH64, [test $have_sh64 = yes])
> +
> AC_OUTPUT(Makefile)
> Index: newlib/libc/machine/sh/setjmp.S
> ===================================================================
> RCS file: /home/aoliva/cygnus/uberbaum/newlib/libc/machine/sh/setjmp.S,v
> retrieving revision 1.1.1.1
> diff -u -p -r1.1.1.1 setjmp.S
> --- newlib/libc/machine/sh/setjmp.S 17 Feb 2000 19:39:47 -0000 1.1.1.1
> +++ newlib/libc/machine/sh/setjmp.S 2 Feb 2002 04:00:47 -0000
> @@ -1,6 +1,77 @@
> +/* We want to pretend we're in SHmedia mode, even when assembling for
> + SHcompact. */
> +#if __SH5__ == 32 && ! __SHMEDIA__
> +# undef __SHMEDIA__
> +# define __SHMEDIA__ 1
> +#endif
> +
> +#if __SHMEDIA__
> + .mode SHmedia
> +#endif
> +
> #include "asm.h"
>
> ENTRY(setjmp)
> +#if __SH5__
> + ptabs r18, tr0
> + gettr tr5, r5
> + gettr tr6, r6
> + gettr tr7, r7
> + st.q r2, 0*8, r18
> + st.q r2, 1*8, r10
> + st.q r2, 2*8, r11
> + st.q r2, 3*8, r12
> + st.q r2, 4*8, r13
> + st.q r2, 5*8, r14
> + st.q r2, 6*8, r15
> + st.q r2, 7*8, r28
> + st.q r2, 8*8, r29
> + st.q r2, 9*8, r30
> + st.q r2, 10*8, r31
> + st.q r2, 11*8, r32
> + st.q r2, 12*8, r33
> + st.q r2, 13*8, r34
> + st.q r2, 14*8, r35
> + st.q r2, 15*8, r44
> + st.q r2, 16*8, r45
> + st.q r2, 17*8, r46
> + st.q r2, 18*8, r47
> + st.q r2, 19*8, r48
> + st.q r2, 20*8, r49
> + st.q r2, 21*8, r50
> + st.q r2, 22*8, r51
> + st.q r2, 23*8, r52
> + st.q r2, 24*8, r53
> + st.q r2, 25*8, r54
> + st.q r2, 26*8, r55
> + st.q r2, 27*8, r56
> + st.q r2, 28*8, r57
> + st.q r2, 29*8, r58
> + st.q r2, 30*8, r59
> + st.q r2, 31*8, r5
> + st.q r2, 32*8, r6
> + st.q r2, 33*8, r7
> +#if ! __SH4_NOFPU__
> + fst.d r2, 34*8, dr12
> + fst.d r2, 35*8, dr14
> + fst.d r2, 36*8, dr36
> + fst.d r2, 37*8, dr38
> + fst.d r2, 38*8, dr40
> + fst.d r2, 39*8, dr42
> + fst.d r2, 40*8, dr44
> + fst.d r2, 41*8, dr46
> + fst.d r2, 42*8, dr48
> + fst.d r2, 43*8, dr50
> + fst.d r2, 44*8, dr52
> + fst.d r2, 45*8, dr54
> + fst.d r2, 46*8, dr56
> + fst.d r2, 47*8, dr58
> + fst.d r2, 48*8, dr60
> + fst.d r2, 49*8, dr62
> +#endif
> + movi 0, r2
> + blink tr0, r63
> +#else
> #if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
> add #(13*4),r4
> #else
> @@ -28,8 +99,70 @@ ENTRY(setjmp)
>
> rts
> mov #0,r0
> +#endif /* __SH5__ */
>
> ENTRY(longjmp)
> +#if __SH5__
> + ld.q r2, 0*8, r18
> + ptabs r18, tr0
> + ld.q r2, 1*8, r10
> + ld.q r2, 2*8, r11
> + ld.q r2, 3*8, r12
> + ld.q r2, 4*8, r13
> + ld.q r2, 5*8, r14
> + ld.q r2, 6*8, r15
> + ld.q r2, 7*8, r28
> + ld.q r2, 8*8, r29
> + ld.q r2, 9*8, r30
> + ld.q r2, 10*8, r31
> + ld.q r2, 11*8, r32
> + ld.q r2, 12*8, r33
> + ld.q r2, 13*8, r34
> + ld.q r2, 14*8, r35
> + ld.q r2, 15*8, r44
> + ld.q r2, 16*8, r45
> + ld.q r2, 17*8, r46
> + ld.q r2, 18*8, r47
> + ld.q r2, 19*8, r48
> + ld.q r2, 20*8, r49
> + ld.q r2, 21*8, r50
> + ld.q r2, 22*8, r51
> + ld.q r2, 23*8, r52
> + ld.q r2, 24*8, r53
> + ld.q r2, 25*8, r54
> + ld.q r2, 26*8, r55
> + ld.q r2, 27*8, r56
> + ld.q r2, 28*8, r57
> + ld.q r2, 29*8, r58
> + ld.q r2, 30*8, r59
> + ld.q r2, 31*8, r5
> + ld.q r2, 32*8, r6
> + ld.q r2, 33*8, r7
> + ptabs r5, tr5
> + ptabs r6, tr6
> + ptabs r7, tr7
> +#if ! __SH4_NOFPU__
> + fld.d r2, 34*8, dr12
> + fld.d r2, 35*8, dr14
> + fld.d r2, 36*8, dr36
> + fld.d r2, 37*8, dr38
> + fld.d r2, 38*8, dr40
> + fld.d r2, 39*8, dr42
> + fld.d r2, 40*8, dr44
> + fld.d r2, 41*8, dr46
> + fld.d r2, 42*8, dr48
> + fld.d r2, 43*8, dr50
> + fld.d r2, 44*8, dr52
> + fld.d r2, 45*8, dr54
> + fld.d r2, 46*8, dr56
> + fld.d r2, 47*8, dr58
> + fld.d r2, 48*8, dr60
> + fld.d r2, 49*8, dr62
> +#endif
> + movi 1, r2
> + cmvne r3, r3, r2
> + blink tr0, r63
> +#else
> mov.l @r4+,r8
> mov.l @r4+,r9
> mov.l @r4+,r10
> @@ -55,3 +188,4 @@ ENTRY(longjmp)
> movt r0
> retr4: rts
> nop
> +#endif /* __SH5__ */
> Index: newlib/libc/sys/sh/crt0.S
> ===================================================================
> RCS file: /home/aoliva/cygnus/uberbaum/newlib/libc/sys/sh/crt0.S,v
> retrieving revision 1.2
> diff -u -p -r1.2 crt0.S
> --- newlib/libc/sys/sh/crt0.S 13 Dec 2001 20:10:16 -0000 1.2
> +++ newlib/libc/sys/sh/crt0.S 2 Feb 2002 04:00:48 -0000
> @@ -1,3 +1,69 @@
> +
> +#ifdef __SH5__
> + .section .data,"aw"
> + .global ___data
> +___data:
> +
> + .section .rodata,"a"
> + .global ___rodata
> +___rodata:
> +
> +#if __SH5__ == 64
> + .section .text,"ax"
> +#define LOAD_ADDR(sym, reg) \
> + movi (sym >> 48) & 65535, reg; \
> + shori (sym >> 32) & 65535, reg; \
> + shori (sym >> 16) & 65535, reg; \
> + shori sym & 65535, reg
> +#else
> + .mode SHmedia
> + .section .text..SHmedia32,"ax"
> +#define LOAD_ADDR(sym, reg) \
> + movi (sym >> 16) & 65535, reg; \
> + shori sym & 65535, reg
> +#endif
> + .global start
> +start:
> + LOAD_ADDR (_stack, r15)
> +
> + pt/l zero_bss_loop, tr0
> + pt/l _atexit, tr1
> + pt/l _init, tr5
> + pt/l _main, tr6
> + pt/l _exit, tr7
> +
> + ! zero out bss
> + LOAD_ADDR (_edata, r0)
> + LOAD_ADDR (_end, r1)
> +zero_bss_loop:
> + stx.q r0, r63, r63
> + addi r0, 8, r0
> + bgt/l r1, r0, tr0
> +
> + LOAD_ADDR (___data, r26)
> + LOAD_ADDR (___rodata, r27)
> +
> +#if ! __SH4_NOFPU__
> + getcon cr0, r0
> + movi 1, r1
> + shlli r1, 15, r1
> + or r1, r0, r0
> + putcon r0, cr0
> +#endif
> +
> + ! arrange for exit to call fini
> + LOAD_ADDR (_fini, r2)
> + blink tr1, r18
> +
> + ! call init
> + blink tr5, r18
> +
> + ! call the mainline
> + blink tr6, r18
> +
> + ! call exit
> + blink tr7, r18
> +#else
> .section .text
> .global start
> start:
> @@ -46,6 +112,7 @@ main_k:
> .long _main
> exit_k:
> .long _exit
> +#endif
>
> #ifdef __ELF__
> .section .stack,"aw"
> Index: newlib/libc/sys/sh/trap.S
> ===================================================================
> RCS file: /home/aoliva/cygnus/uberbaum/newlib/libc/sys/sh/trap.S,v
> retrieving revision 1.1.1.1
> diff -u -p -r1.1.1.1 trap.S
> --- newlib/libc/sys/sh/trap.S 17 Feb 2000 19:39:50 -0000 1.1.1.1
> +++ newlib/libc/sys/sh/trap.S 2 Feb 2002 04:00:48 -0000
> @@ -1,3 +1,30 @@
> +#if __SH5__
> + .mode SHmedia
> +#if __SH5__ == 32 && __SHMEDIA__
> + .section .text..SHmedia32, "ax"
> +#else
> + .text
> +#endif
> + .global ___trap34
> +___trap34:
> + movi 34, r0
> + trapa r0
> + pt/l ret, tr1
> + ptabs/l r18, tr0
> + beqi r1, 0, tr1
> +#if __SH5__ == 64
> + movi ((_errno >> 48) & 65535), r0
> + shori ((_errno >> 32) & 65535), r0
> + shori ((_errno >> 16) & 65535), r0
> +#else
> + movi ((_errno >> 16) & 65535), r0
> +#endif
> + shori (_errno & 65535), r0
> + stx.l r0, r63, r1
> +ret:
> + blink tr0, r63
> +
> +#else
> .text
> .global ___trap34
> ___trap34:
> @@ -13,3 +40,4 @@ ret:
> .align 2
> perrno:
> .long _errno
> +#endif /* ! __SH5__ */
>
> --------------------------------------------------------------------------------
>
> --
> Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
> Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
> CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
> Free Software Evangelist Professional serial bug killer
More information about the Newlib
mailing list