Skip to contentSkip to conversation

sparc support for klibc

PATCH In review H. Peter Anvin 1 participant 1 message Jun 26, 2006 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 35/43 sparc support for klibc

The parts of klibc specific to the sparc architecture.

---
commit 1b5c93603ed3460ed1fba9e5d453a6fa54d0ccce
tree 7fb0a134b3add408c02b470616d440ad398d86d3
parent 94473ed85b00ec45ff8ee6cac62f60a368ff4534
author H. Peter Anvin <[email protected]> Sun, 25 Jun 2006 16:58:47 -0700 committer H. Peter Anvin <[email protected]> Sun, 25 Jun 2006 16:58:47 -0700

 usr/include/arch/sparc/klibc/archconfig.h |   14 +
 usr/include/arch/sparc/klibc/archsetjmp.h |   16 ++
 usr/include/arch/sparc/klibc/archsignal.h |   24 +++
 usr/include/arch/sparc/klibc/archstat.h   |   37 ++++
 usr/include/arch/sparc/klibc/archsys.h    |   10 +
 usr/include/arch/sparc/machine/asm.h      |  191 ++++++++++++++++++++
 usr/include/arch/sparc/machine/frame.h    |  146 +++++++++++++++
 usr/include/arch/sparc/machine/trap.h     |  140 +++++++++++++++
 usr/klibc/arch/sparc/MCONFIG              |   19 ++
 usr/klibc/arch/sparc/Makefile.inc         |   48 +++++
 usr/klibc/arch/sparc/__muldi3.S           |   27 +++
 usr/klibc/arch/sparc/crt0.S               |    2 
 usr/klibc/arch/sparc/crt0i.S              |  100 +++++++++++
 usr/klibc/arch/sparc/divrem.m4            |  276 +++++++++++++++++++++++++++++
 usr/klibc/arch/sparc/pipe.S               |   30 +++
 usr/klibc/arch/sparc/setjmp.S             |   38 ++++
 usr/klibc/arch/sparc/smul.S               |  160 +++++++++++++++++
 usr/klibc/arch/sparc/syscall.S            |   19 ++
 usr/klibc/arch/sparc/sysfork.S            |   25 +++
 usr/klibc/arch/sparc/sysstub.ph           |   25 +++
 usr/klibc/arch/sparc/umul.S               |  193 ++++++++++++++++++++
 21 files changed, 1540 insertions(+), 0 deletions(-)
usr/include/arch/sparc/klibc/archconfig.h new file +14 -0
new file mode 100644
index 0000000..90a6c49
@@ -0,0 +1,14 @@
+/*
+ * include/arch/sparc/klibc/archconfig.h
+ *
+ * See include/klibc/sysconfig.h for the options that can be set in
+ * this file.
+ *
+ */
+
+#ifndef _KLIBC_ARCHCONFIG_H
+#define _KLIBC_ARCHCONFIG_H
+
+#define _KLIBC_USE_RT_SIG 1	/* Use rt_* signals */
+
+#endif				/* _KLIBC_ARCHCONFIG_H */
usr/include/arch/sparc/klibc/archsetjmp.h new file +16 -0
new file mode 100644
index 0000000..9b4d6a2
@@ -0,0 +1,16 @@
+/*
+ * arch/sparc/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+	unsigned long __sp;
+	unsigned long __fp;
+	unsigned long __pc;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif				/* _SETJMP_H */
usr/include/arch/sparc/klibc/archsignal.h new file +24 -0
new file mode 100644
index 0000000..6e845a8
@@ -0,0 +1,24 @@
+/*
+ * arch/sparc/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+#define __WANT_POSIX1B_SIGNALS__
+#include <asm/signal.h>
+
+struct sigaction {
+	__sighandler_t	sa_handler;
+	unsigned long	sa_flags;
+	void		(*sa_restorer)(void);	/* Not used by Linux/SPARC */
+	sigset_t	sa_mask;
+};
+
+/* Not actually used by the kernel... */
+#define SA_RESTORER	0x80000000
+
+#endif
usr/include/arch/sparc/klibc/archstat.h new file +37 -0
new file mode 100644
index 0000000..203d40b
@@ -0,0 +1,37 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#include <klibc/stathelp.h>
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+	__stdev64	(st_dev);
+
+	unsigned long long st_ino;
+
+	unsigned int	st_mode;
+	unsigned int	st_nlink;
+
+	unsigned int	st_uid;
+	unsigned int	st_gid;
+
+	__stdev64	(st_rdev);
+
+	unsigned char	__pad3[8];
+
+	long long	st_size;
+	unsigned int	st_blksize;
+
+	unsigned char	__pad4[8];
+	unsigned int	st_blocks;
+
+	struct timespec st_atim;
+	struct timespec st_mtim;
+	struct timespec st_ctim;
+
+	unsigned int	__unused4;
+	unsigned int	__unused5;
+};
+
+#endif
usr/include/arch/sparc/klibc/archsys.h new file +10 -0
new file mode 100644
index 0000000..a6ca545
@@ -0,0 +1,10 @@
+/*
+ * arch/sparc/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+#endif				/* _KLIBC_ARCHSYS_H */
usr/include/arch/sparc/machine/asm.h new file +191 -0

191 lines not on this page · raw message

usr/include/arch/sparc/machine/frame.h new file +146 -0

146 lines not on this page · raw message

usr/include/arch/sparc/machine/trap.h new file +140 -0

140 lines not on this page · raw message

usr/klibc/arch/sparc/MCONFIG new file +19 -0
new file mode 100644
index 0000000..9bb7592
@@ -0,0 +1,19 @@
+# -*- makefile -*-
+#
+# arch/sparc/MCONFIG
+#
+# Special rules for this architecture.  Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+KLIBCOPTFLAGS		 = -Os -m32 -mptr32
+KLIBCBITSIZE		 = 32
+KLIBCARCHREQFLAGS	+= -D__sparc32__
+
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+# Normal binaries start at 64K; the linker wants 64K alignment,
+# and call instructions have a 30-bit signed offset, << 2.
+KLIBCSHAREDFLAGS	 = -Ttext 0x40000100
usr/klibc/arch/sparc/Makefile.inc new file +48 -0

48 lines not on this page · raw message

usr/klibc/arch/sparc/__muldi3.S new file +27 -0
new file mode 100644
index 0000000..e53848a
@@ -0,0 +1,27 @@
+	.global .umul
+	.section	".text"
+	.align 4
+	.global __muldi3
+	.type	__muldi3, #function
+	.proc	017
+__muldi3:
+	save	%sp, -104, %sp
+	mov	%i1, %o0
+	call	.umul, 0
+	 mov	%i3, %o1
+	mov	%o0, %l2
+	mov	%o1, %l3
+	mov	%i1, %o0
+	call	.umul, 0
+	 mov	%i2, %o1
+	mov	%i0, %o1
+	mov	%o0, %l0
+	call	.umul, 0
+	 mov	%i3, %o0
+	mov	0, %l1
+	add	%l0, %o0, %l0
+	addcc	%l3, %l1, %i1
+	addx	%l2, %l0, %i0
+	jmp	%i7+8
+	 restore
+	.size	__muldi3, .-__muldi3
usr/klibc/arch/sparc/crt0.S new file +2 -0
new file mode 100644
index 0000000..63db188
@@ -0,0 +1,2 @@
+#define TARGET_PTR_SIZE	32
+#include "crt0i.S"
usr/klibc/arch/sparc/crt0i.S new file +100 -0

100 lines not on this page · raw message

usr/klibc/arch/sparc/divrem.m4 new file +276 -0

276 lines not on this page · raw message

usr/klibc/arch/sparc/pipe.S new file +30 -0
new file mode 100644
index 0000000..a8abf3c
@@ -0,0 +1,30 @@
+/*
+ * arch/sparc/pipe.S
+ *
+ * The pipe system call are special on sparc[64]:
+ * they return the two file descriptors in %o0 and %o1.
+ */
+
+#include <asm/unistd.h>
+
+	.globl	pipe
+	.type	pipe,#function
+       	.align	4
+pipe:
+	mov	__NR_pipe, %g1
+	or	%o0, 0, %g4
+	t	0x10
+	bcc	1f
+	  nop
+	sethi	%hi(errno), %g4
+	or	%g4, %lo(errno), %g4
+	st	%o0,[%g4]
+	retl
+	  mov	-1, %o0
+1:
+	st	%o0,[%g4]
+	st	%o1,[%g4+4]
+	retl
+	  mov	0, %o0
+
+	.size pipe,.-pipe
usr/klibc/arch/sparc/setjmp.S new file +38 -0
new file mode 100644
index 0000000..038ea78
@@ -0,0 +1,38 @@
+!
+! setjmp.S
+!
+! Basic setjmp/longjmp
+!
+! This code was based on the equivalent code in NetBSD
+!
+
+#include <machine/asm.h>
+#include <machine/trap.h>
+
+!
+! The jmp_buf contains the following entries:
+!   sp
+!   fp
+!   pc
+!
+ENTRY(setjmp)
+	st	%sp,[%o0+0]	! Callers stack pointer
+	st	%o7,[%o0+4]	! Return pc
+	st	%fp,[%o0+8]	! Frame pointer
+	retl			! Return
+	 clr	%o0		!  ...0
+
+ENTRY(longjmp)
+	sub	%sp, 64, %sp	! set up a local stack frame
+0:
+	t	ST_FLUSHWIN	! flush register windows out to memory
+	!
+	! We restore the saved stack pointer to %fp, then issue
+	! a restore instruction which will reload the register
+	! window from the stack.
+	!
+        ld      [%o0+4], %o7    /* restore return pc */
+        ld      [%o0+0], %fp    /* and stack pointer */
+
+        retl                    ! success, return %g6
+         restore        %o1, 0, %o0
usr/klibc/arch/sparc/smul.S new file +160 -0

160 lines not on this page · raw message

usr/klibc/arch/sparc/syscall.S new file +19 -0
new file mode 100644
index 0000000..c0273f7
@@ -0,0 +1,19 @@
+/*
+ * arch/sparc/syscall.S
+ *
+ * Common system-call stub; %g1 already set to syscall number
+ */
+
+	.globl	__syscall_common
+	.type	__syscall_common,#function
+       	.align	4
+__syscall_common:
+	t	0x10
+	bcc	1f
+	  sethi	%hi(errno), %g4
+	or	%g4, %lo(errno), %g4
+	st	%o0,[%g4]
+	mov	-1, %o0
+1:
+       	retl
+	  nop
usr/klibc/arch/sparc/sysfork.S new file +25 -0
new file mode 100644
index 0000000..a66c76e
@@ -0,0 +1,25 @@
+/*
+ * arch/sparc/sysfork.S
+ *
+ * The fork and vfork system calls are special on sparc[64]:
+ * they return the "other process" pid in %o0 and the
+ * "is child" flag in %o1
+ *
+ * Common system-call stub; %g1 already set to syscall number
+ */
+
+	.globl	__syscall_forkish
+	.type	__syscall_forkish,#function
+       	.align	4
+__syscall_forkish:
+	t	0x10
+	sub	%o1, 1, %o1
+	bcc,a	1f
+	  and	%o0, %o1, %o0
+	sethi	%hi(errno), %g4
+	or	%g4, %lo(errno), %g4
+	st	%o0,[%g4]
+	mov	-1, %o0
+1:
+       	retl
+	  nop
usr/klibc/arch/sparc/sysstub.ph new file +25 -0
new file mode 100644
index 0000000..d8cedb5
@@ -0,0 +1,25 @@
+# -*- perl -*-
+#
+# arch/sparc32/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$$@) {
+    my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
+
+    $stype = $stype || 'common';
+
+    open(OUT, '>', "${outputdir}/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.type ${fname},\@function\n";
+    print OUT "\t.globl ${fname}\n";
+    print OUT "${fname}:\n";
+    print OUT "\tb __syscall_${stype}\n";
+    print OUT "\t  mov\t__NR_${sname}, %g1\n";
+    print OUT "\t.size ${fname},.-${fname}\n";
+    close(OUT);
+}
+
+1;
usr/klibc/arch/sparc/umul.S new file +193 -0

193 lines not on this page · raw message