summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libc/sysdeps/linux/sparc/Makefile6
-rw-r--r--libc/sysdeps/linux/sparc/__longjmp.S92
-rw-r--r--libc/sysdeps/linux/sparc/bits/select.h7
-rw-r--r--libc/sysdeps/linux/sparc/crt0.S90
-rw-r--r--libc/sysdeps/linux/sparc/fork.c35
-rw-r--r--libc/sysdeps/linux/sparc/setjmp.S53
-rw-r--r--libc/sysdeps/linux/sparc/sysdep.h134
-rw-r--r--libc/sysdeps/linux/sparc/vfork.S30
8 files changed, 445 insertions, 2 deletions
diff --git a/libc/sysdeps/linux/sparc/Makefile b/libc/sysdeps/linux/sparc/Makefile
index d7490d43d..fdc802b89 100644
--- a/libc/sysdeps/linux/sparc/Makefile
+++ b/libc/sysdeps/linux/sparc/Makefile
@@ -28,10 +28,12 @@ ASFLAGS=$(CFLAGS)
CRT0=crt0.S
CRT0_OBJ=$(patsubst %.S,%.o, $(CRT0))
-SSRC=
+SSRC=__longjmp.S setjmp.S vfork.S
+#SSRC=__longjmp.S _start.S setjmp.S vfork.S
SOBJS=$(patsubst %.S,%.o, $(SSRC))
-CSRC=
+CSRC=fork.c ptrace.c
+#CSRC=fork.c ptrace.c
COBJS=$(patsubst %.c,%.o, $(CSRC))
OBJS=$(SOBJS) $(MOBJ) $(COBJS)
diff --git a/libc/sysdeps/linux/sparc/__longjmp.S b/libc/sysdeps/linux/sparc/__longjmp.S
new file mode 100644
index 000000000..d0f8c73be
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/__longjmp.S
@@ -0,0 +1,92 @@
+/* Copyright (C) 1991, 93, 96, 97, 98, 99, 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. */
+
+/* Code taken from glibc/sysdeps/sparc/sparc32/ (glibc 2.2.2) */
+
+//#include "sysdep.h"
+#include <sysdep.h>
+
+#define _ASM 1
+#define _SETJMP_H
+#include <bits/setjmp.h>
+#define ENV(base,reg) [%base + (reg * 4)]
+#define ST_FLUSH_WINDOWS 3
+#define RW_FP [%fp + 0x48]
+
+ENTRY(__longjmp)
+ /* Store our arguments in global registers so we can still
+ use them while unwinding frames and their register windows. */
+
+ ld ENV(o0,JB_FP), %g3 /* Cache target FP in register %g3. */
+ mov %o0, %g1 /* ENV in %g1 */
+ orcc %o1, %g0, %g2 /* VAL in %g2 */
+ be,a 0f /* Branch if zero; else skip delay slot. */
+ mov 1, %g2 /* Delay slot only hit if zero: VAL = 1. */
+0:
+ xor %fp, %g3, %o0
+ add %fp, 512, %o1
+ andncc %o0, 4095, %o0
+ bne thread
+ //bne LOC(thread)
+ cmp %o1, %g3
+ bl thread
+ //bl LOC(thread)
+
+ /* Now we will loop, unwinding the register windows up the stack
+ until the restored %fp value matches the target value in %g3. */
+
+//LOC(loop):
+loop:
+ cmp %fp, %g3 /* Have we reached the target frame? */
+ bl,a loop /* Loop while current fp is below target. */
+ //bl,a LOC(loop) /* Loop while current fp is below target. */
+ restore /* Unwind register window in delay slot. */
+ be,a found /* Better have hit it exactly. */
+ //be,a LOC(found) /* Better have hit it exactly. */
+ ld ENV(g1,JB_SP), %o0 /* Delay slot: extract target SP. */
+
+thread:
+//LOC(thread):
+ /*
+ * Do a "flush register windows trap". The trap handler in the
+ * kernel writes all the register windows to their stack slots, and
+ * marks them all as invalid (needing to be sucked up from the
+ * stack when used). This ensures that all information needed to
+ * unwind to these callers is in memory, not in the register
+ * windows.
+ */
+ ta ST_FLUSH_WINDOWS
+ ld ENV(g1,JB_PC), %o7 /* Set return PC. */
+ ld ENV(g1,JB_SP), %fp /* Set saved SP on restore below. */
+ sub %fp, 64, %sp /* Allocate a register frame. */
+ st %g3, RW_FP /* Set saved FP on restore below. */
+ retl
+ restore %g2, 0, %o0 /* Restore values from above register frame. */
+
+found:
+//LOC(found):
+ /* We have unwound register windows so %fp matches the target. */
+ mov %o0, %sp /* OK, install new SP. */
+
+//LOC(sp_ok):
+sp_ok:
+ ld ENV(g1,JB_PC), %o0 /* Extract target return PC. */
+ jmp %o0 + 8 /* Return there. */
+ mov %g2, %o0 /* Delay slot: set return value. */
+
+END(__longjmp)
diff --git a/libc/sysdeps/linux/sparc/bits/select.h b/libc/sysdeps/linux/sparc/bits/select.h
index 4513135af..f5a181092 100644
--- a/libc/sysdeps/linux/sparc/bits/select.h
+++ b/libc/sysdeps/linux/sparc/bits/select.h
@@ -20,6 +20,13 @@
# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
#endif
+/* For some reason, this wants to use the definitions from
+ /include/asm/posix_types.h So we have to undef some symbols :
+*/
+#undef __FD_ZERO
+#undef __FD_SET
+#undef __FD_CLR
+#undef __FD_ISSET
/* We don't use `memset' because this would require a prototype and
the array isn't too big. */
diff --git a/libc/sysdeps/linux/sparc/crt0.S b/libc/sysdeps/linux/sparc/crt0.S
new file mode 100644
index 000000000..7910131db
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/crt0.S
@@ -0,0 +1,90 @@
+/*
+ * xrt0.s for ERC32.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU 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 General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 675
+ * Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+/* code taken from leonccs 1.0 leon/src/libio/crt0.S
+ I don't know if this is available anymore, now that LECCS
+ is out. And I'm not sure if this source is in the LECCS distro :(
+*/
+
+ .text
+! Original :
+! .global __start, _main
+! uC-libc version :
+ .global _start
+ .global __uClibc_main
+
+! Start the real-time clock with a tick of 14 clocks
+!
+
+_start:
+
+ save %sp, -64, %sp
+
+ /* clear the bss */
+
+ sethi %hi(edata),%g2
+ or %g2,%lo(edata),%g2 ! g2 = start of bss
+ sethi %hi(_end),%g3
+ or %g3,%lo(_end),%g3 ! g3 = end of bss
+ mov %g0,%g1 ! so std has two zeros
+zerobss:
+ std %g0,[%g2]
+ add %g2,8,%g2
+ cmp %g2,%g3
+ bleu,a zerobss
+ nop
+
+ /* move data segment to proper location */
+
+relocd:
+ set (_endtext),%g2 ! g2 = start of data in aout file
+ set (_environ),%g4 ! g4 = start of where data should go
+ set (_edata),%g3 ! g3 = end of where data should go
+ subcc %g3, %g4, %g5 ! g5 = length of data
+
+ subcc %g4, %g2, %g0 ! need to relocate data ?
+ ble initok
+ ld [%g4], %g6
+! subcc %g6, 1, %g0
+! be initok
+mvdata:
+ subcc %g5, 8, %g5
+ ldd [%g2 + %g5], %g6
+ bg mvdata
+ std %g6, [%g4 + %g5]
+
+initok:
+
+! call _main
+ call __uClibc_main
+ nop
+! Should not return from uClibc main()
+! ret
+! nop
+
+ .seg "data"
+ .global .bdata
+.bdata:
+ .align 8
+ .global _environ ! first symbol in sdata
+_environ:
+ .word 1
+
+
+
diff --git a/libc/sysdeps/linux/sparc/fork.c b/libc/sysdeps/linux/sparc/fork.c
new file mode 100644
index 000000000..af56d3675
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/fork.c
@@ -0,0 +1,35 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * fork for uClibc
+ *
+ * Copyright (C) 2000 by Lineo, inc. Written by Erik Andersen
+ * <andersen@lineo.com>, <andersee@debian.org>
+ *
+ * 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
+ *
+ */
+
+#include <errno.h>
+#include <features.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+#ifndef __HAS_NO_MMU__
+
+//#define __NR_fork 2
+#include <unistd.h>
+_syscall0(pid_t, fork);
+
+#endif
diff --git a/libc/sysdeps/linux/sparc/setjmp.S b/libc/sysdeps/linux/sparc/setjmp.S
new file mode 100644
index 000000000..8f279ca5d
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/setjmp.S
@@ -0,0 +1,53 @@
+/* Copyright (C) 1991, 93, 94, 96, 97, 98 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. */
+
+/* Code taken from glibc2.2.2/sysdeps/sparc/sparc32/setjmp.S */
+
+#include <sysdep.h>
+#include <sys/trap.h>
+
+#define _ASM 1
+#define _SETJMP_H
+#include <bits/setjmp.h>
+
+ENTRY(_setjmp)
+ b 1f
+ set 0, %o1
+END(_setjmp)
+
+ENTRY(setjmp)
+ set 1, %o1
+END(setjmp)
+
+ENTRY (__sigsetjmp)
+1:
+ /* Save our PC, SP and FP. Save the signal mask if requested with
+ a tail-call for simplicity; it always returns zero. */
+ ta ST_FLUSH_WINDOWS
+
+ st %o7, [%o0 + (JB_PC * 4)]
+ st %sp, [%o0 + (JB_SP * 4)]
+ st %fp, [%o0 + (JB_FP * 4)]
+
+ mov %o7, %g1
+ call __sigjmp_save
+ mov %g1, %o7
+END(__sigsetjmp)
+
+//weak_extern(_setjmp)
+//weak_extern(setjmp)
diff --git a/libc/sysdeps/linux/sparc/sysdep.h b/libc/sysdeps/linux/sparc/sysdep.h
new file mode 100644
index 000000000..015dd6e1b
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/sysdep.h
@@ -0,0 +1,134 @@
+/* Copyright (C) 1991, 1992 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., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#include <sys/syscall.h>
+
+/* Not that using a `PASTE' macro loses. */
+#ifdef __STDC__
+
+#ifdef __ELF__
+
+#define SYSCALL_WEAK_ALIAS(alias,orig) \
+ .weak alias; \
+ alias=__libc_##orig
+
+/*
+#ifdef _POSIX_THREADS
+*/
+
+#if 1
+
+#ifdef PTHREAD_KERNEL
+
+/* Use the regular ELF conventions about underscores, and provide the
+ weak symbol, as required */
+#define SYSCALL__(name,args) PSEUDO (__machdep_sys_##name, name, args) \
+.weak machdep_sys_##name; \
+ machdep_sys_##name = __machdep_sys_##name; \
+.type __machdep_sys_##name,@function; \
+.type machdep_sys_##name,@function; \
+.L__machdep_sys_##name##end: .size __machdep_sys_##name,.L__machdep_sys_##name##end - __machdep_sys_##name
+
+#define SYSCALL(name,args) PSEUDO (__machdep_sys_##name, name, args) \
+.weak machdep_sys_##name; \
+ machdep_sys_##name = __machdep_sys_##name; \
+.type __machdep_sys_##name,@function; \
+.type machdep_sys_##name,@function; \
+.L__machdep_sys_##name##end: .size __machdep_sys_##name,.L__machdep_sys_##name##end - __machdep_sys_##name
+
+#else /* PTHREAD_KERNEL */
+
+/* Use the regular ELF conventions about underscores, and provide the
+ weak symbol, as required */
+#define SYSCALL__(name,args) PSEUDO (__libc_##name, name, args) \
+.weak __##name; \
+.weak name; \
+ __##name = __libc_##name; \
+ name = __libc_##name; \
+.type __libc_##name,@function; \
+.type name,@function; \
+.type __##name,@function; \
+.L__libc_##name##end: .size __libc_##name,.L__libc_##name##end - __libc_##name
+
+#define SYSCALL(name,args) PSEUDO (__libc_##name, name, args) \
+.weak name; \
+ name = __libc_##name; \
+.type __libc_##name,@function; \
+.type name,@function; \
+.L__libc_##name##end: .size __libc_##name,.L__libc_##name##end - __libc_##name
+
+#endif /* PTHREAD_KERNEL */
+
+#else /* _POSIX_THREADS */
+
+/* Use the regular ELF conventions about underscores, and provide the
+ weak symbol, as required */
+#define SYSCALL__(name,args) PSEUDO (__libc_##name, name, args) \
+.weak name; \
+ __##name = __libc_##name; \
+ name = __libc_##name; \
+.type __libc_##name,@function; \
+.type name,@function; \
+.type __##name,@function; \
+.L__libc_##name##end: .size __libc_##name,.L__libc_##name##end - __libc_##name
+
+#define SYSCALL(name,args) PSEUDO (__libc_##name, name, args) \
+ name = __libc_##name; \
+.type __libc_##name,@function; \
+.type name,@function; \
+.L__libc_##name##end: .size __libc_##name,.L__libc_##name##end - __libc_##name
+
+#endif /* _POSIX_THREADS */
+
+#else /* __ELF__ */
+
+#define SYSCALL_WEAK_ALIAS(alias,orig)
+
+/* Regular a.out definition */
+#define SYSCALL__(name,args) PSEUDO (__##name, name, args)
+#define SYSCALL(name,args) PSEUDO (name, name, args)
+
+#endif /* __ELF__ */
+
+#else /* __STDC__ */
+
+#define SYSCALL__(name,args) PSEUDO (__/**/name, name, args)
+#define SYSCALL(name,args) PSEUDO (name, name, args)
+
+#endif /* __STDC__ */
+
+/* Machine-dependent sysdep.h files are expected to define the macro
+ PSEUDO (function_name, syscall_name) to emit assembly code to define the
+ C-callable function FUNCTION_NAME to do system call SYSCALL_NAME.
+ r0 and r1 are the system call outputs. movl should be defined as
+ an instruction such that "movl r1, r0" works. ret should be defined
+ as the return instruction. */
+
+
+#if !defined(HAVE_GNU_LD) && !defined (__ELF__)
+#define ___errno _errno
+#endif
+
+#define HAVE_SYSCALLS
+
+#define ENTRY(name)
+ .global name;
+ .align 4;
+
+#define END(name)
+ .size name,.-name;
diff --git a/libc/sysdeps/linux/sparc/vfork.S b/libc/sysdeps/linux/sparc/vfork.S
new file mode 100644
index 000000000..336dfdd59
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/vfork.S
@@ -0,0 +1,30 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jj@ultra.linux.cz>, 1999.
+
+ 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. */
+
+/* Code taken from glibc2.2.2/sysdeps/unix/sysv/linux/sparc/vfork.S */
+
+#include <sysdep.h>
+
+PSEUDO (__vfork, vfork, 0)
+ sub %o1, 1, %o1
+ retl
+ and %o0, %o1, %o0
+
+PSEUDO_END (__vfork)
+weak_alias (__vfork, vfork)