From: "H. Peter Anvin" <hpa@zytor.com>
To: linux-kernel@vger.kernel.org, klibc@zytor.com
Cc: "H. Peter Anvin" <hpa@zytor.com>
Subject: [klibc 09/31] m32r support for klibc
Date: Tue, 27 Jun 2006 22:17:09 -0700 [thread overview]
Message-ID: <klibc.200606272217.09@tazenda.hos.anvin.org> (raw)
In-Reply-To: <klibc.200606272217.00@tazenda.hos.anvin.org>
The parts of klibc specific to the m32r architecture.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
commit b8481500fe4d3475857c7f8da022d6ac640b9420
tree a66da10e8168b9c82b0306657ecffd03154f14c5
parent 2ddc0b5cb0056f213e6e279030e50c1bd223cef6
author H. Peter Anvin <hpa@zytor.com> Tue, 27 Jun 2006 20:50:39 -0700
committer H. Peter Anvin <hpa@zytor.com> Tue, 27 Jun 2006 20:50:39 -0700
usr/include/arch/m32r/klibc/archconfig.h | 14 +++++++++
usr/include/arch/m32r/klibc/archsetjmp.h | 21 +++++++++++++
usr/include/arch/m32r/klibc/archsignal.h | 14 +++++++++
usr/include/arch/m32r/klibc/archstat.h | 39 +++++++++++++++++++++++++
usr/klibc/arch/m32r/MCONFIG | 18 +++++++++++
usr/klibc/arch/m32r/Makefile.inc | 19 ++++++++++++
usr/klibc/arch/m32r/crt0.S | 24 +++++++++++++++
usr/klibc/arch/m32r/setjmp.S | 47 ++++++++++++++++++++++++++++++
usr/klibc/arch/m32r/syscall.S | 29 +++++++++++++++++++
usr/klibc/arch/m32r/sysstub.ph | 25 ++++++++++++++++
10 files changed, 250 insertions(+), 0 deletions(-)
diff --git a/usr/include/arch/m32r/klibc/archconfig.h b/usr/include/arch/m32r/klibc/archconfig.h
new file mode 100644
index 0000000..9489877
--- /dev/null
+++ b/usr/include/arch/m32r/klibc/archconfig.h
@@ -0,0 +1,14 @@
+/*
+ * include/arch/m32r/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 */
diff --git a/usr/include/arch/m32r/klibc/archsetjmp.h b/usr/include/arch/m32r/klibc/archsetjmp.h
new file mode 100644
index 0000000..d82df9c
--- /dev/null
+++ b/usr/include/arch/m32r/klibc/archsetjmp.h
@@ -0,0 +1,21 @@
+/*
+ * arch/m32r/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;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/usr/include/arch/m32r/klibc/archsignal.h b/usr/include/arch/m32r/klibc/archsignal.h
new file mode 100644
index 0000000..b753026
--- /dev/null
+++ b/usr/include/arch/m32r/klibc/archsignal.h
@@ -0,0 +1,14 @@
+/*
+ * arch/m32r/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
diff --git a/usr/include/arch/m32r/klibc/archstat.h b/usr/include/arch/m32r/klibc/archstat.h
new file mode 100644
index 0000000..09d3ade
--- /dev/null
+++ b/usr/include/arch/m32r/klibc/archstat.h
@@ -0,0 +1,39 @@
+#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 stat {
+ __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 st_blocks; /* Number 512-byte blocks allocated. */
+ unsigned long __pad4; /* future possible st_blocks high bits */
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned long long st_ino;
+};
+
+#endif
diff --git a/usr/klibc/arch/m32r/MCONFIG b/usr/klibc/arch/m32r/MCONFIG
new file mode 100644
index 0000000..2f9db0b
--- /dev/null
+++ b/usr/klibc/arch/m32r/MCONFIG
@@ -0,0 +1,18 @@
+# -*- makefile -*-
+#
+# arch/m32r/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+KLIBCOPTFLAGS = -Os
+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
+# 224 MB - normal binaries start at 0 (?)
+# (lib?)gcc on cris seems to insist on producing .init and .fini sections
+KLIBCSHAREDFLAGS = --section-start .init=0x0e000100
diff --git a/usr/klibc/arch/m32r/Makefile.inc b/usr/klibc/arch/m32r/Makefile.inc
new file mode 100644
index 0000000..794aec6
--- /dev/null
+++ b/usr/klibc/arch/m32r/Makefile.inc
@@ -0,0 +1,19 @@
+# -*- makefile -*-
+#
+# arch/m32r/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+KLIBCARCHOBJS = \
+ arch/$(KLIBCARCH)/setjmp.o \
+ arch/$(KLIBCARCH)/syscall.o \
+ libgcc/__divdi3.o \
+ libgcc/__moddi3.o \
+ libgcc/__udivdi3.o \
+ libgcc/__umoddi3.o \
+ libgcc/__udivmoddi4.o
+
+archclean:
diff --git a/usr/klibc/arch/m32r/crt0.S b/usr/klibc/arch/m32r/crt0.S
new file mode 100644
index 0000000..568e5d8
--- /dev/null
+++ b/usr/klibc/arch/m32r/crt0.S
@@ -0,0 +1,24 @@
+#
+# arch/m32r/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
+ .balign 4
+ .type _start,@function
+ .globl _start
+_start:
+ /* Save the address of the ELF argument array */
+ mv r0, sp
+
+ /* atexit() function (assume null) */
+ xor r1, r1
+
+ bl __libc_init
+
+ .size _start, .-_start
diff --git a/usr/klibc/arch/m32r/setjmp.S b/usr/klibc/arch/m32r/setjmp.S
new file mode 100644
index 0000000..02a25e7
--- /dev/null
+++ b/usr/klibc/arch/m32r/setjmp.S
@@ -0,0 +1,47 @@
+#
+# arch/m32r/setjmp.S
+#
+# setjmp/longjmp for the M32R architecture
+#
+
+#
+# The jmp_buf is assumed to contain the following, in order:
+# r8-r15
+#
+# Note that r14 is the return address register and
+# r15 is the stack pointer.
+#
+
+ .text
+ .balign 4
+ .globl setjmp
+ .type setjmp, @function
+setjmp:
+ st r8, @r0
+ st r9, @+r0
+ st r10, @+r0
+ st r11, @+r0
+ st r12, @+r0
+ st r13, @+r0
+ st r14, @+r0
+ st r15, @+r0
+ xor r0, r0
+ jmp r14
+ .size setjmp,.-setjmp
+
+ .text
+ .balign 4
+ .globl longjmp
+ .type longjmp, @function
+longjmp:
+ ld r8, @r0+
+ ld r9, @r0+
+ ld r10, @r0+
+ ld r11, @r0+
+ ld r12, @r0+
+ ld r13, @r0+
+ ld r14, @r0+
+ ld r15, @r0
+ mv r0, r1
+ jmp r14
+ .size longjmp,.-longjmp
diff --git a/usr/klibc/arch/m32r/syscall.S b/usr/klibc/arch/m32r/syscall.S
new file mode 100644
index 0000000..a20a336
--- /dev/null
+++ b/usr/klibc/arch/m32r/syscall.S
@@ -0,0 +1,29 @@
+/*
+ * arch/m32r/syscall.S
+ *
+ * r7 contains the syscall number (set by stub);
+ * r0..r3 contains arguments 0-3 per standard calling convention;
+ * r4..r5 contains arguments 4-5, but we have to get those from
+ * the stack.
+ */
+
+ .section ".text","ax"
+ .balign 4
+ .globl __syscall_common
+ .type __syscall_common,@function
+__syscall_common:
+ ld r4,@sp
+ ld r5,@(4,sp)
+ trap #2
+ cmpi r0, #-4096
+ bnc 1f
+ jmp r14
+1:
+ seth r2,#high(errno)
+ or3 r2,r2,#low(errno)
+ neg r1,r0
+ st r1,@r7
+ ldi r0,#-1
+ jmp r14
+
+ .size __syscall_common,.-__syscall_common
diff --git a/usr/klibc/arch/m32r/sysstub.ph b/usr/klibc/arch/m32r/sysstub.ph
new file mode 100644
index 0000000..98dfb9d
--- /dev/null
+++ b/usr/klibc/arch/m32r/sysstub.ph
@@ -0,0 +1,25 @@
+# -*- perl -*-
+#
+# arch/m32r/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.text\n";
+ print OUT "\t.type\t${fname},\@function\n";
+ print OUT "\t.globl\t${fname}\n";
+ print OUT "\t.balign\t4\n";
+ print OUT "${fname}:\n";
+ print OUT "\tldi\tr7,#__NR_${sname}\n";
+ print OUT "\tbra\t__syscall_common\n";
+ print OUT "\t.size ${fname},.-${fname}\n";
+ close(OUT);
+}
+
+1;
next prev parent reply other threads:[~2006-06-28 5:20 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-28 5:17 [klibc 00/31] klibc as a historyless patchset (updated and reorganized) H. Peter Anvin
2006-06-28 5:17 ` [klibc 01/31] Add klibc/kinit to MAINTAINERS file H. Peter Anvin
2006-06-28 5:17 ` [klibc 02/31] Main Makefile changes for klibc H. Peter Anvin
2006-06-28 5:17 ` [klibc 03/31] Core klibc code H. Peter Anvin
2006-06-28 5:17 ` [klibc 04/31] alpha support for klibc H. Peter Anvin
2006-06-28 15:43 ` Richard Henderson
2006-06-28 15:51 ` H. Peter Anvin
2006-06-28 5:17 ` [klibc 05/31] arm " H. Peter Anvin
2006-06-28 5:17 ` [klibc 06/31] cris " H. Peter Anvin
2006-06-28 5:17 ` [klibc 07/31] i386 " H. Peter Anvin
2006-06-28 7:37 ` Jan Engelhardt
2006-06-28 15:33 ` H. Peter Anvin
2006-06-28 16:44 ` H. Peter Anvin
2006-06-29 0:14 ` Roman Zippel
2006-06-29 0:45 ` H. Peter Anvin
2006-06-29 23:43 ` Roman Zippel
2006-06-29 23:54 ` H. Peter Anvin
2006-06-30 0:23 ` Roman Zippel
2006-06-30 1:28 ` [klibc] " Aaron Griffin
2006-06-30 13:56 ` Jan Engelhardt
2006-06-28 5:17 ` [klibc 08/31] ia64 " H. Peter Anvin
2006-06-28 5:17 ` H. Peter Anvin [this message]
2006-06-28 5:17 ` [klibc 10/31] m68k " H. Peter Anvin
2006-06-28 5:17 ` [klibc 11/31] mips " H. Peter Anvin
2006-06-28 5:17 ` [klibc 12/31] mips64 " H. Peter Anvin
2006-06-28 5:17 ` [klibc 13/31] parisc " H. Peter Anvin
2006-06-28 5:17 ` [klibc 14/31] ppc " H. Peter Anvin
2006-06-28 5:17 ` [klibc 15/31] ppc64 " H. Peter Anvin
2006-06-28 5:17 ` [klibc 16/31] s390 " H. Peter Anvin
2006-06-28 5:17 ` [klibc 17/31] sh " H. Peter Anvin
2006-06-28 5:17 ` [klibc 18/31] sparc " H. Peter Anvin
2006-06-28 5:17 ` [klibc 19/31] sparc64 " H. Peter Anvin
2006-06-28 5:17 ` [klibc 20/31] x86_64 " H. Peter Anvin
2006-06-28 5:17 ` [klibc 21/31] Simple test suite " H. Peter Anvin
2006-06-28 5:17 ` [klibc 22/31] zlib " H. Peter Anvin
2006-06-28 5:17 ` [klibc 23/31] kinit: replacement for in-kernel do_mount, ipconfig, nfsroot H. Peter Anvin
2006-06-28 5:17 ` [klibc 24/31] klibc basic build infrastructure H. Peter Anvin
2006-06-28 5:17 ` [klibc 25/31] Miscellaneous utilities for klibc H. Peter Anvin
2006-06-28 5:17 ` [klibc 26/31] dash - a small POSIX shell " H. Peter Anvin
2006-06-28 5:17 ` [klibc 27/31] A port of gzip to klibc H. Peter Anvin
2006-06-28 5:17 ` [klibc 28/31] sparc64: transmit arch-specific options to kinit via /arch.cmd H. Peter Anvin
2006-06-28 5:17 ` [klibc 29/31] sparc32: transfer arch-specific options to /arch.cmd H. Peter Anvin
2006-06-28 5:17 ` [klibc 30/31] Remove in-kernel resume-from-disk invocation code H. Peter Anvin
2006-07-05 23:40 ` Nigel Cunningham
2006-07-05 23:58 ` Joshua Hudson
2006-07-06 0:11 ` H. Peter Anvin
2006-07-06 0:37 ` Nigel Cunningham
2006-07-06 0:54 ` H. Peter Anvin
2006-07-06 1:45 ` Nigel Cunningham
2006-07-06 2:18 ` Nigel Cunningham
2006-07-06 3:11 ` H. Peter Anvin
2006-07-06 3:28 ` Nigel Cunningham
2006-07-06 10:26 ` Pavel Machek
[not found] ` <200607061028.k66AS8UB012207@smtp.micromuse.com>
2006-07-06 10:58 ` IBM spam Re: " Pavel Machek
2006-07-06 13:02 ` Sean Young
2006-07-06 8:31 ` [klibc] " maximilian attems
2006-07-06 8:37 ` H. Peter Anvin
2006-06-28 5:17 ` [klibc 31/31] Remove in-kernel root-mounting code H. Peter Anvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=klibc.200606272217.09@tazenda.hos.anvin.org \
--to=hpa@zytor.com \
--cc=klibc@zytor.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®