m68k support for klibc
PATCH 27/43 m68k support for klibc
The parts of klibc specific to the m68k architecture.
Signed-off-by H. Peter Anvin <[email protected]>
---
commit bc9b363b31d301ab94c115cccc2e079c0d318498
tree db9cf277429e2722b8c51f68897991f0759b1d02
parent 7ba219f9bcddda38ddc9010b54fd10431292f744
author H. Peter Anvin <[email protected]> Sun, 25 Jun 2006 16:58:29 -0700 committer H. Peter Anvin <[email protected]> Sun, 25 Jun 2006 16:58:29 -0700
usr/include/arch/m68k/klibc/archconfig.h | 15 ++++++++++ usr/include/arch/m68k/klibc/archsetjmp.h | 26 ++++++++++++++++++ usr/include/arch/m68k/klibc/archsignal.h | 14 ++++++++++ usr/include/arch/m68k/klibc/archstat.h | 38 +++++++++++++++++++++++++++ usr/include/arch/m68k/klibc/archsys.h | 12 ++++++++ usr/klibc/arch/m68k/MCONFIG | 11 ++++++++ usr/klibc/arch/m68k/Makefile.inc | 25 +++++++++++++++++ usr/klibc/arch/m68k/crt0.S | 27 +++++++++++++++++++ usr/klibc/arch/m68k/setjmp.S | 43 ++++++++++++++++++++++++++++++ usr/klibc/arch/m68k/syscall.S | 27 +++++++++++++++++++ usr/klibc/arch/m68k/sysstub.ph | 26 ++++++++++++++++++ usr/klibc/arch/m68k/vfork.S | 28 ++++++++++++++++++++ 12 files changed, 292 insertions(+), 0 deletions(-)
usr/include/arch/m68k/klibc/archconfig.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* include/arch/m68k/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 + +/* On m68k, sys_mmap2 uses the current page size as the shift factor */ +#define _KLIBC_MMAP2_SHIFT __getpageshift() + +#endif /* _KLIBC_ARCHCONFIG_H */
usr/include/arch/m68k/klibc/archsetjmp.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* usr/include/arch/m68k/klibc/archsetjmp.h +*/ + +#ifndef _KLIBC_ARCHSETJMP_H +#define _KLIBC_ARCHSETJMP_H + +struct __jmp_buf { +unsigned int __d2; +unsigned int __d3; +unsigned int __d4; +unsigned int __d5; +unsigned int __d6; +unsigned int __d7; +unsigned int __a2; +unsigned int __a3; +unsigned int __a4; +unsigned int __a5; +unsigned int __fp;/* a6 */ +unsigned int __sp;/* a7 */ +unsigned int __retaddr; +}; + +typedef struct __jmp_buf jmp_buf [1 ]; + +#endif /* _KLBIC_ARCHSETJMP_H */
usr/include/arch/m68k/klibc/archsignal.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* arch/m68k/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/m68k/klibc/archstat.h new file +38 -0
@@ -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 padding around dev_t's. +*/ +struct stat { +__stdev64 (st_dev); +unsigned char __pad1[2 ]; + +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[2 ]; + +long long st_size; +unsigned long st_blksize; + +unsigned long long st_blocks;/* Number 512-byte blocks allocated. */ + +struct timespec st_atim; +struct timespec st_mtim; +struct timespec st_ctim; + +unsigned long long st_ino; +}; + +#endif
usr/include/arch/m68k/klibc/archsys.h new file +12 -0
@@ -0,0 +1,12 @@ +/* +* arch/m68k/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/m68k/MCONFIG new file +11 -0
@@ -0,0 +1,11 @@ +# -*- makefile -*- +# +# arch/m68k/MCONFIG +# +# Special rules for this architecture. Note that this is actually +# included from the main Makefile, and that pathnames should be +# accordingly. +# + +KLIBCOPTFLAGS = -Os -fomit-frame-pointer +KLIBCBITSIZE = 32
usr/klibc/arch/m68k/Makefile.inc new file +25 -0
@@ -0,0 +1,25 @@ +# -*- makefile -*- +# +# arch/m68k/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 \ + arch/$(KLIBCARCH)/vfork.o + +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 +# 2816 MB - normal binaries start at 2048 MB if I read the link +# script right. Not sure if there is a fundamental reason +# to not duck below the halfway point... +KLIBCSHAREDFLAGS = -Ttext 0xb0000000 + +archclean:
usr/klibc/arch/m68k/crt0.S new file +27 -0
@@ -0,0 +1,27 @@ +# +# arch/m68k/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 +_start: + # Zero out the frame pointer to be nice to the debugger + movea.l #0,%a6 + # Save the address of the ELF argument array + move.l %a7, %d0 + # Push a zero on the stack in lieu of atexit pointer + clr.l -(%sp) + # Push ELF argument pointer on the stack + move.l %d0, -(%a7) + + jbsr __libc_init + + .size _start, .-_start
usr/klibc/arch/m68k/setjmp.S new file +43 -0
43 lines not on this page · raw message
usr/klibc/arch/m68k/syscall.S new file +27 -0
@@ -0,0 +1,27 @@ +/* + * arch/m68k/syscall.S + * + * Common tail-handling code for system calls. + * + * The arguments are on the stack; the system call number in %d0. + */ + + .text + .align 2 + .globl __syscall_common + .type __syscall_common, @function +__syscall_common: + movem.l %d2-%d6, -(%sp) /* 5 registers saved */ + movem.l 24(%sp), %d1-%d6 + trap #0 + cmpi.l #-4095, %d0 + blt.l 1f + neg.l %d0 + move.l %d0, (errno) + moveq #-1, %d0 +1: + movea.l %d0, %a0 /* Redundant return */ + movem.l (%sp)+, %d2-%d6 /* Restore registers */ + rts + + .size __syscall_common,.-__syscall_common
usr/klibc/arch/m68k/sysstub.ph new file +26 -0
@@ -0,0 +1,26 @@ +# -*- perl -*- +# +# arch/m68k/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"; + + $stype = 'common' if ( $stype eq '' ); + + print OUT "\tmove.l\t# __NR_${sname}, %d0\n"; + print OUT "\tbr\t__syscall_$stype\n"; + print OUT "\t.size ${fname},.-${fname}\n"; + close(OUT); +} + +1;
usr/klibc/arch/m68k/vfork.S new file +28 -0
@@ -0,0 +1,28 @@ +# +# usr/klibc/arch/m68k/vfork.S +# +# vfork is nasty - there must be nothing at all on the stack above +# the stack frame of the enclosing function. +# + +#include <asm/unistd.h> + + .text + .align 2 + .globl vfork + .type vfork, @function +vfork: + move.l (%sp)+, %d1 /* Return address */ + move.l # __NR_vfork, %d0 + trap #0 + move.l %d1, -(%sp) + cmpi.l #-4095, %d0 + blt.l 1f + neg.l %d0 + move.l %d0, (errno) + moveq #-1, %d0 +1: + movea.l %d0, %a0 + rts + + .size vfork, .-vfork