From 677eb9f98fa6afc485c4c6afcf8b17dcee723f77 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 25 May 2001 01:30:16 +0000 Subject: Update for the SH port from Jean-Yves Avenard --- libc/sysdeps/linux/sh/Makefile | 4 +- libc/sysdeps/linux/sh/_mmap.c | 45 +++++++++++++++ libc/sysdeps/linux/sh/crt0.S | 40 ++++++++----- libc/sysdeps/linux/sh/longjmp.c | 49 +++++++--------- libc/sysdeps/linux/sh/vfork.S | 123 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 218 insertions(+), 43 deletions(-) create mode 100644 libc/sysdeps/linux/sh/vfork.S (limited to 'libc/sysdeps/linux/sh') diff --git a/libc/sysdeps/linux/sh/Makefile b/libc/sysdeps/linux/sh/Makefile index f36dca0fa..d39d3bf40 100644 --- a/libc/sysdeps/linux/sh/Makefile +++ b/libc/sysdeps/linux/sh/Makefile @@ -32,10 +32,10 @@ TARGET_MACHINE_TYPE=$(shell $(CC) -dumpmachine) CRT0=crt0.S CRT0_OBJ=$(patsubst %.S,%.o, $(CRT0)) -SSRC=setjmp.S bsd-setjmp.S bsd-_setjmp.S __longjmp.S +SSRC=setjmp.S bsd-setjmp.S bsd-_setjmp.S __longjmp.S vfork.S SOBJS=$(patsubst %.S,%.o, $(SSRC)) -CSRC=vfork.c _mmap.c longjmp.c jmp-unwind.c +CSRC=_mmap.c longjmp.c COBJS=$(patsubst %.c,%.o, $(CSRC)) OBJS=$(SOBJS) $(MOBJ) $(COBJS) diff --git a/libc/sysdeps/linux/sh/_mmap.c b/libc/sysdeps/linux/sh/_mmap.c index cee3be3dc..3b68e094d 100644 --- a/libc/sysdeps/linux/sh/_mmap.c +++ b/libc/sysdeps/linux/sh/_mmap.c @@ -1,6 +1,49 @@ +/* Copyright (C) 2001 Hewlett-Packard + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Library General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more + details. + + You should have received a copy of the GNU Library General Public License + along with this program; if not, write to the Free Software Foundation, Inc., + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Derived in part from the Linux-8086 C library, the GNU C Library, and several + other sundry sources. Files within this library are copyright by their + respective copyright holders. +*/ + #include #include +#ifdef HIOS + +#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6,arg6) \ +type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \ +{ \ +register long __sc3 __asm__ ("r3") = __NR_##name; \ +register long __sc4 __asm__ ("r4") = (long) arg1; \ +register long __sc5 __asm__ ("r5") = (long) arg2; \ +register long __sc6 __asm__ ("r6") = (long) arg3; \ +register long __sc7 __asm__ ("r7") = (long) arg4; \ +register long __sc0 __asm__ ("r0") = (long) arg5; \ +register long __sc1 __asm__ ("r1") = (long) arg6; \ +__asm__ __volatile__ ("trapa #0x2E" \ + : "=z" (__sc0) \ + : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \ + "r" (__sc3), "r" (__sc1) \ + : "memory" ); \ +__syscall_return(type,__sc0); \ +} + +#else // HIOS + #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6,arg6) \ type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \ { \ @@ -19,6 +62,8 @@ __asm__ __volatile__ ("trapa #0x15" \ __syscall_return(type,__sc0); \ } +#endif // HIOS + _syscall6(__ptr_t, mmap, __ptr_t, addr, size_t, len, int, prot, int, flags, int, fd, __off_t, offset); diff --git a/libc/sysdeps/linux/sh/crt0.S b/libc/sysdeps/linux/sh/crt0.S index 7808ffd34..af1577814 100644 --- a/libc/sysdeps/linux/sh/crt0.S +++ b/libc/sysdeps/linux/sh/crt0.S @@ -2,22 +2,24 @@ Copyright (C) 1999 Free Software Foundation, Inc. Copyright (C) 2001 Hewlett-Packard Australia - This file is part of the GNU C Library. + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Library General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) any + later version. - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more + details. - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + You should have received a copy of the GNU Library General Public License + along with this program; if not, write to the Free Software Foundation, Inc., + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + Derived in part from the Linux-8086 C library, the GNU C Library, and several + other sundry sources. Files within this library are copyright by their + respective copyright holders. +*/ /* This is the canonical entry point, usually the first thing in the text segment. @@ -60,6 +62,15 @@ _start: shll2 r6 add r5,r6 + ! Clear BSS area + mov.l 3f, r1 + add #4, r1 + mov.l 4f, r2 + mov #0, r0 +9: cmp/hs r2, r1 + bf/s 9b ! while (r1 < r2) + mov.l r0,@-r2 + /* call main */ mov.l L_main,r1 jsr @r1 @@ -72,6 +83,9 @@ _start: .align 2 +3: .long __bss_start +4: .long _end + L_main: .long __uClibc_main diff --git a/libc/sysdeps/linux/sh/longjmp.c b/libc/sysdeps/linux/sh/longjmp.c index fd2a2079c..5395d5568 100644 --- a/libc/sysdeps/linux/sh/longjmp.c +++ b/libc/sysdeps/linux/sh/longjmp.c @@ -1,43 +1,36 @@ /* Copyright (C) 1991, 92, 94, 95, 97, 98, 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - + Copyright (C) 2001 Hewlett-Packard Australia + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Library General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more + details. + + You should have received a copy of the GNU Library General Public License + along with this program; if not, write to the Free Software Foundation, Inc., + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Derived in part from the Linux-8086 C library, the GNU C Library, and several + other sundry sources. Files within this library are copyright by their + respective copyright holders. +*/ + #include #include #include -#if 0 -extern void _longjmp_unwind (jmp_buf env, int val); -#endif -extern void __longjmp(__jmp_buf __env, int __val) - __attribute__ ((__noreturn__)); - /* Set the signal mask to the one specified in ENV, and jump to the position specified in ENV, causing the setjmp call there to return VAL, or 1 if VAL is 0. */ void __uClibc_siglongjmp (sigjmp_buf env, int val) { -#if 0 - /* Perform any cleanups needed by the frames being unwound. */ - _longjmp_unwind (env, val); -#endif - if (env[0].__mask_was_saved) /* Restore the saved signal mask. */ (void) __sigprocmask (SIG_SETMASK, &env[0].__saved_mask, diff --git a/libc/sysdeps/linux/sh/vfork.S b/libc/sysdeps/linux/sh/vfork.S new file mode 100644 index 000000000..6b20cc3bb --- /dev/null +++ b/libc/sysdeps/linux/sh/vfork.S @@ -0,0 +1,123 @@ +/* Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 2001 Hewlett-Packard Australia + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU Library General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more + details. + + You should have received a copy of the GNU Library General Public License + along with this program; if not, write to the Free Software Foundation, Inc., + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Derived in part from the Linux-8086 C library, the GNU C Library, and several + other sundry sources. Files within this library are copyright by their + respective copyright holders. +*/ + +#include +#define _ERRNO_H 1 +#include + +/* Clone the calling process, but without copying the whole address space. + The calling process is suspended until the new process exits or is + replaced by a call to `execve'. Return -1 for errors, 0 to the new process, + and the process ID of the new process to the old process. */ + +.global errno + +ENTRY (__vfork) + + mov.l @r15+,r3 // pop value from the stack + mov.l .L5,r1 + mov.l r3,@r1 // save it in .sav_stack + + mov.w .L3, r3 + +#ifdef HIOS + trapa #0x28 +#else + trapa #0x10 +#endif + + mov r0, r1 +// 12 arithmetic shifts for the crappy sh2, because shad doesn't exist! + shar r1 + shar r1 + shar r1 + shar r1 + shar r1 + shar r1 + shar r1 + shar r1 + shar r1 + shar r1 + shar r1 + shar r1 + +// mov #-12, r2 +// shad r2, r1 + not r1, r1 // r1=0 means r0 = -1 to -4095 + tst r1, r1 // i.e. error in linux + bf 1f + mov.w .L1, r1 + cmp/eq r1, r0 + bt 2f + mov.l .L2, r1 + jmp @r1 + mov r0, r4 + + .align 4 + +1: + mov.l .L5,r1 + mov.l @r1,r3 // get it from .sav_stack + mov.l r3,@-r15 // restore value to the stack + + rts + nop + + .align 4 + +2: +__syscall_error: + /* Store it in errno... */ + mov.l .L4, r1 + mov.l r0, @r1 + + mov.l .L5,r1 + mov.l @r1,r3 // get it from .sav_stack + mov.l r3,@-r15 // restore value to the stack + + /* And just kick back a -1. */ + rts + mov #-1, r0 + + .align 4 +.L1: + .word -ENOSYS +.L3: + .word 190 //__NR_vfork + + .align 4 // Shouldn't be necessary as previously with have two words +.L2: + .long __syscall_error + +.L4: .long errno + +.L5: .long .sav_stack + + .data + + .align 4 + +.sav_stack: //area to temporary save the stach + .long 0 + +.weak vfork +vfork = __vfork -- cgit v1.2.3