Skip to contentSkip to conversation

sh 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 34/43 sh support for klibc

The parts of klibc specific to the sh architecture.

---
commit 94473ed85b00ec45ff8ee6cac62f60a368ff4534
tree 5c09fdd824962cba83c198ac1dd077045d2cb0b1
parent 418ab99cc64fed344e2d3e446208f48655cccb31
author H. Peter Anvin <[email protected]> Sun, 25 Jun 2006 16:58:44 -0700 committer H. Peter Anvin <[email protected]> Sun, 25 Jun 2006 16:58:44 -0700

 usr/include/arch/sh/klibc/archconfig.h |   14 +++++++
 usr/include/arch/sh/klibc/archsetjmp.h |   22 +++++++++++
 usr/include/arch/sh/klibc/archsignal.h |   14 +++++++
 usr/include/arch/sh/klibc/archstat.h   |   38 +++++++++++++++++++
 usr/include/arch/sh/klibc/archsys.h    |   12 ++++++
 usr/klibc/arch/sh/MCONFIG              |   18 +++++++++
 usr/klibc/arch/sh/Makefile.inc         |   15 ++++++++
 usr/klibc/arch/sh/crt0.S               |   27 ++++++++++++++
 usr/klibc/arch/sh/setjmp.S             |   64 ++++++++++++++++++++++++++++++++
 usr/klibc/arch/sh/syscall.S            |   35 ++++++++++++++++++
 usr/klibc/arch/sh/sysstub.ph           |   34 +++++++++++++++++
 11 files changed, 293 insertions(+), 0 deletions(-)
usr/include/arch/sh/klibc/archconfig.h new file +14 -0
new file mode 100644
index 0000000..9c9e3d8
@@ -0,0 +1,14 @@
+/*
+ * include/arch/sh/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
+
+/* All defaults */
+
+#endif				/* _KLIBC_ARCHCONFIG_H */
usr/include/arch/sh/klibc/archsetjmp.h new file +22 -0
new file mode 100644
index 0000000..bb97167
@@ -0,0 +1,22 @@
+/*
+ * arch/sh/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+	unsigned long __r8;
+	unsigned long __r9;
+	unsigned long __r10;
+	unsigned long __r11;
+	unsigned long __r12;
+	unsigned long __r13;
+	unsigned long __r14;
+	unsigned long __r15;
+	unsigned long __pr;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif				/* _KLIBC_ARCHSETJMP_H */
usr/include/arch/sh/klibc/archsignal.h new file +14 -0
new file mode 100644
index 0000000..8e48e51
@@ -0,0 +1,14 @@
+/*
+ * arch/sh/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+#include <asm/signal.h>
+/* No special stuff for this architecture */
+
+#endif
usr/include/arch/sh/klibc/archstat.h new file +38 -0
new file mode 100644
index 0000000..f4c65ea
@@ -0,0 +1,38 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#include <klibc/stathelp.h>
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ */
+struct stat64 {
+	__stdev64	(st_dev);
+	unsigned char	__pad0[4];
+
+	unsigned long	st_ino;
+	unsigned int	st_mode;
+	unsigned int	st_nlink;
+
+	unsigned long	st_uid;
+	unsigned long	st_gid;
+
+	__stdev64	(st_rdev);
+	unsigned char	__pad3[4];
+
+	long long	st_size;
+	unsigned long	st_blksize;
+
+	unsigned long long st_blocks;
+
+	struct timespec	st_atim;
+	struct timespec st_mtim;
+	struct timespec st_ctim;
+
+	unsigned long	__unused1;
+	unsigned long	__unused2;
+};
+
+#endif
usr/include/arch/sh/klibc/archsys.h new file +12 -0
new file mode 100644
index 0000000..4a077fa
@@ -0,0 +1,12 @@
+/*
+ * arch/sh/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif				/* _KLIBC_ARCHSYS_H */
usr/klibc/arch/sh/MCONFIG new file +18 -0
new file mode 100644
index 0000000..f0106e1
@@ -0,0 +1,18 @@
+# -*- makefile -*-
+#
+# arch/sh/MCONFIG
+#
+# Special rules for this architecture.  Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHREGFLAGS = -m4 -mno-implicit-fp
+KLIBCOPTFLAGS     = -Os -fomit-frame-pointer
+KLIBCBITSIZE      = 32
+
+# 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
+# 2 MB -- the normal starting point for text is 4 MB.
+KLIBCSHAREDFLAGS	= -Ttext 0x00200200
usr/klibc/arch/sh/Makefile.inc new file +15 -0
new file mode 100644
index 0000000..ccabfa4
@@ -0,0 +1,15 @@
+# -*- makefile -*-
+#
+# arch/sh/Makefile.inc
+#
+# Special rules for this architecture.  Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHOBJS = arch/sh/setjmp.o \
+	   arch/sh/syscall.o
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
+archclean:
usr/klibc/arch/sh/crt0.S new file +27 -0
new file mode 100644
index 0000000..7f0a649
@@ -0,0 +1,27 @@
+#
+# arch/sh/crt0.S
+#
+# Does arch-specific initialization and invokes __libc_init
+# with the appropriate arguments.
+#
+# See __static_init.c or __shared_init.c for the expected
+# arguments.
+#
+
+	.text
+	.align 2
+	.type _start,#function
+	.globl _start
+
+_start:
+	mov	r15, r4
+	mov	#0, r5
+	mov.l	1f, r0
+
+	jsr	@r0
+	 nop
+
+	.align 2
+1:	.long	__libc_init
+
+	.size _start,.-_start
usr/klibc/arch/sh/setjmp.S new file +64 -0

64 lines not on this page · raw message

usr/klibc/arch/sh/syscall.S new file +35 -0
new file mode 100644
index 0000000..41a0486
@@ -0,0 +1,35 @@
+/*
+ * arch/sh/syscall.S
+ *
+ * On sh, r3 contains the syscall number (set by generated stub);
+ * r4..r7 contain arguments 0-3 per the standard calling convention,
+ * and arguments 4-5 are passed in r0 and r1.
+ *
+ * The return value is in r3 rather than standard r0.
+ */
+
+	.section ".text.syscall","ax"
+	.align	2
+	.globl	___syscall_common
+	.type	___syscall_common,@function
+___syscall_common:
+	mov.l	@(sp),r0
+	mov.l	@(4,sp),r1
+	trapa	#0x15
+	mov.l	1f,r0
+	cmp/hs	r0,r3
+	bt/s	3f
+	  neg	r3,r4
+	mov.l	2f,r5
+	mov.l	r4,@r5
+	rts
+	  mov	#-1,r0
+3:
+	rts
+	  mov	r3,r0
+
+	.align 2
+1:	.long	-4096		/* Errno limit */
+2:	.long	errno
+
+	.size	___syscall_common,.-___syscall_common
usr/klibc/arch/sh/sysstub.ph new file +34 -0
new file mode 100644
index 0000000..ce04b73
@@ -0,0 +1,34 @@
+# -*- perl -*-
+#
+# arch/sh/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$$@) {
+    my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
+
+    open(OUT, '>', "${outputdir}/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.section\t\".text.syscall\",\"ax\"\n";
+    print OUT "\t.type\t${fname},\#function\n";
+    print OUT "\t.globl\t${fname}\n";
+    print OUT "\t.align\t2\n";
+    print OUT "${fname}:\n";
+    print OUT "\tbra\t__syscall_common\n";
+    print OUT "#if __NR_${sname} >= 128\n";
+    print OUT "\t  mov.l\t1f, r3\n";
+    print OUT "#else\n";
+    print OUT "\t  mov\t# __NR_${sname}, r3\n";
+    print OUT "#endif\n";
+    print OUT "\t.size ${fname},.-${fname}\n";
+    print OUT "\n";
+    print OUT "#if __NR_${sname} >= 128\n";
+    print OUT "\t.align\t2\n";
+    print OUT "1:\t.long\t__NR_${sname}\n";
+    print OUT "#endif\n";
+    close(OUT);
+}
+
+1;