s390 support for klibc
PATCH 33/43 s390 support for klibc
The parts of klibc specific to the s390 architecture.
Signed-off-by H. Peter Anvin <[email protected]>
---
commit 418ab99cc64fed344e2d3e446208f48655cccb31
tree 958352848ed34bcf1aacdf5357ba453f96e38cbb
parent 6db62c809bf46ac8a9f743513384d29fd339f877
author H. Peter Anvin <[email protected]> Sun, 25 Jun 2006 16:58:42 -0700 committer H. Peter Anvin <[email protected]> Sun, 25 Jun 2006 16:58:42 -0700
usr/include/arch/s390/klibc/archconfig.h | 15 ++++++ usr/include/arch/s390/klibc/archsetjmp.h | 26 ++++++++++ usr/include/arch/s390/klibc/archsignal.h | 14 ++++++ usr/include/arch/s390/klibc/archstat.h | 56 ++++++++++++++++++++++ usr/include/arch/s390/klibc/archsys.h | 41 ++++++++++++++++ usr/klibc/arch/s390/MCONFIG | 23 +++++++++ usr/klibc/arch/s390/Makefile.inc | 39 ++++++++++++++++ usr/klibc/arch/s390/crt0.S | 35 ++++++++++++++ usr/klibc/arch/s390/mmap.c | 75 ++++++++++++++++++++++++++++++ usr/klibc/arch/s390/setjmp.S | 66 ++++++++++++++++++++++++++ usr/klibc/arch/s390/syscall.c | 16 ++++++ usr/klibc/arch/s390/sysstub.ph | 40 ++++++++++++++++ 12 files changed, 446 insertions(+), 0 deletions(-)
usr/include/arch/s390/klibc/archconfig.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* include/arch/s390/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 + +/* Both s390 and s390x use the "32-bit" version of this structure */ +#define _KLIBC_STATFS_F_TYPE_64 0 + +#endif /* _KLIBC_ARCHCONFIG_H */
usr/include/arch/s390/klibc/archsetjmp.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* arch/s390/include/klibc/archsetjmp.h +*/ + +#ifndef _KLIBC_ARCHSETJMP_H +#define _KLIBC_ARCHSETJMP_H + +#ifndef __s390x__ + +struct __jmp_buf { +uint32_t __gregs[10 ];/* general registers r6-r15 */ +uint64_t __fpregs[2 ];/* fp registers f4 and f6 */ +}; + +#else /* __s390x__ */ + +struct __jmp_buf { +uint64_t __gregs[10 ];/* general registers r6-r15 */ +uint64_t __fpregs[4 ];/* fp registers f1, f3, f5, f7 */ +}; + +#endif /* __s390x__ */ + +typedef struct __jmp_buf jmp_buf [1 ]; + +#endif /* _SETJMP_H */
usr/include/arch/s390/klibc/archsignal.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* arch/s390/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/s390/klibc/archstat.h new file +56 -0
56 lines not on this page · raw message
usr/include/arch/s390/klibc/archsys.h new file +41 -0
41 lines not on this page · raw message
usr/klibc/arch/s390/MCONFIG new file +23 -0
@@ -0,0 +1,23 @@ +# -*- makefile -*- +# +# arch/s390/MCONFIG +# +# Special rules for this architecture. Note that this is actually +# included from the main Makefile, and that pathnames should be +# accordingly. +# + +KLIBCOPTFLAGS = -Os + +ifneq ("$(KLIBCARCH)", "s390x") + KLIBCBITSIZE = 32 + KLIBCCFLAGS += -m31 + KLIBCLDFLAGS += -m elf_s390 +else + KLIBCBITSIZE = 64 + KLIBCCFLAGS += -m64 + KLIBCLDFLAGS += -m elf64_s390 +endif + +KLIBCASMARCH = s390 +KLIBCSHAREDFLAGS = -Ttext 0x40000200
usr/klibc/arch/s390/Makefile.inc new file +39 -0
@@ -0,0 +1,39 @@ +# -*- makefile -*- +# +# arch/s390/Makefile.inc +# +# Special rules for this architecture. Note that this is actually +# included from the main Makefile, and that pathnames should be +# accordingly. +# + +ifneq ("$(KLIBCARCH)", "s390x") + +KLIBCARCHOBJS = \ + arch/$(KLIBCARCHDIR)/setjmp.o \ + arch/$(KLIBCARCHDIR)/mmap.o \ + arch/$(KLIBCARCHDIR)/syscall.o \ + libgcc/__clzsi2.o \ + libgcc/__clzdi2.o \ + libgcc/__ashldi3.o \ + libgcc/__ashrdi3.o \ + libgcc/__lshrdi3.o \ + libgcc/__divdi3.o \ + libgcc/__moddi3.o \ + libgcc/__udivdi3.o \ + libgcc/__umoddi3.o \ + libgcc/__udivmoddi4.o + +else + +KLIBCARCHOBJS = \ + arch/$(KLIBCARCHDIR)/setjmp.o \ + arch/$(KLIBCARCHDIR)/mmap.o \ + arch/$(KLIBCARCHDIR)/syscall.o + +endif + +KLIBCARCHSOOBJS = $(patsubst %.o,%.lo,$(KLIBCARCHOBJS)) + + +archclean:
usr/klibc/arch/s390/crt0.S new file +35 -0
@@ -0,0 +1,35 @@ +# +# arch/s390/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 4 + .type _start,@function + .globl _start + +#ifndef __s390x__ + +_start: + lr %r2,%r15 + lhi %r3,0 + ahi %r15,-96 + bras %r1,.L0 +.L0: + l %r1,.L1-.L0(%r1) + br %r1 +.L1: + .long __libc_init +#else + +_start: + lgr %r2,%r15 + lghi %r3,0 + aghi %r15,-160 + jg __libc_init +#endif + .size _start,.-_start
usr/klibc/arch/s390/mmap.c new file +75 -0
75 lines not on this page · raw message
usr/klibc/arch/s390/setjmp.S new file +66 -0
66 lines not on this page · raw message
usr/klibc/arch/s390/syscall.c new file +16 -0
@@ -0,0 +1,16 @@ +/* +* arch/s390/syscall.c +* +* Common error-handling path for system calls. +* The return value from __syscall_common becomes the +* return value from the system call. +*/ +#include <errno.h> + +unsigned long __syscall_common (unsigned long err) +{ +if (err <-4095UL ) +return err; + errno = -err; +return -1 ; +}
usr/klibc/arch/s390/sysstub.ph new file +40 -0
@@ -0,0 +1,40 @@ +# -*- perl -*- +# +# arch/s390/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.type ${fname},\@function\n"; + print OUT "\t.globl ${fname}\n"; + print OUT "${fname}:\n"; + print OUT ".if __NR_${sname} < 256\n"; + print OUT "\tsvc __NR_${sname}\n"; + print OUT ".else\n"; + print OUT "\tla %r1,__NR_${sname}\n"; + print OUT "\tsvc 0\n"; + print OUT ".endif\n"; + + print OUT "#ifndef __s390x__\n"; + + print OUT "\tbras %r3,1f\n"; + print OUT "\t.long __syscall_common\n"; + print OUT "1:\tl %r3,0(%r3)\n"; + print OUT "\tbr %r3\n"; + + print OUT "#else\n"; + + print OUT "\tbrasl %r3,__syscall_common\n"; + + print OUT "#endif\n"; + print OUT "\t.size ${fname},.-${fname}\n"; + close(OUT); +} + +1;