diff options
Diffstat (limited to 'libc/sysdeps/linux/microblaze')
24 files changed, 841 insertions, 291 deletions
diff --git a/libc/sysdeps/linux/microblaze/Makefile b/libc/sysdeps/linux/microblaze/Makefile index a7a832b24..338abc086 100644 --- a/libc/sysdeps/linux/microblaze/Makefile +++ b/libc/sysdeps/linux/microblaze/Makefile @@ -1,67 +1,25 @@ # Makefile for uClibc # -# Copyright (C) 2001,2002 NEC Corporation -# Copyright (C) 2001,2002 Miles Bader <miles@gnu.org> +# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org> # -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - -TOPDIR=../../../../ -include $(TOPDIR)Rules.mak - -#FIXME -- this arch should include its own crti.S and crtn.S -UCLIBC_CTOR_DTOR=n - -CFLAGS += -I.. -ASFLAGS += -I.. -D__ASSEMBLER -DASM_GLOBAL_DIRECTIVE=.globl - -TARGET_MACHINE_TYPE=$(shell $(CC) -dumpmachine) - -CRT_SRC := crt0.S -CRT_OBJ := crt0.o crt1.o -CTOR_TARGETS := $(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o - -SSRC := setjmp.S __longjmp.S vfork.S -SOBJ := $(patsubst %.S,%.o, $(SSRC)) - -CSRC := mmap.c syscall.c clone.c -COBJ := $(patsubst %.c,%.o, $(CSRC)) - -OBJS := $(SOBJ) $(COBJ) - -OBJ_LIST := ../../../obj.sysdeps.$(TARGET_ARCH) - -all: $(OBJ_LIST) $(CTOR_TARGETS) - -$(OBJ_LIST): $(OBJS) $(CRT_OBJ) - $(STRIPTOOL) -x -R .note -R .comment $^ - $(INSTALL) -d $(TOPDIR)lib/ - cp $(CRT_OBJ) $(TOPDIR)lib/ - echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $@ - -$(CRT_OBJ): $(CRT_SRC) - $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o - -$(SOBJ): %.o : %.S - $(CC) $(ASFLAGS) -c $< -o $@ - -$(COBJ): %.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - -ifeq ($(UCLIBC_CTOR_DTOR),y) -$(TOPDIR)lib/crti.o: crti.S - $(INSTALL) -d $(TOPDIR)lib/ - $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@ - -$(TOPDIR)lib/crtn.o: crtn.S - $(INSTALL) -d $(TOPDIR)lib/ - $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@ -else -$(CTOR_TARGETS): - $(INSTALL) -d $(TOPDIR)lib/ - $(AR) $(ARFLAGS) $@ -endif +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU Library General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your option) any +# later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more +# details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -headers: +top_srcdir=../../../../ +top_builddir=../../../../ +all: objs -clean: - $(RM) *.o *~ core +include $(top_builddir)Rules.mak +include Makefile.arch +include $(top_srcdir)Makerules diff --git a/libc/sysdeps/linux/microblaze/Makefile.arch b/libc/sysdeps/linux/microblaze/Makefile.arch new file mode 100644 index 000000000..ecbd80141 --- /dev/null +++ b/libc/sysdeps/linux/microblaze/Makefile.arch @@ -0,0 +1,14 @@ +# Makefile for uClibc +# +# Copyright (C) 2001,2002 NEC Corporation +# Copyright (C) 2001,2002 Miles Bader <miles@gnu.org> +# +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + +CSRC := mmap.c clone.c fixdfsi.c + +SSRC := setjmp.S __longjmp.S vfork.S + +ARCH_HEADERS := floatlib.h + +include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch diff --git a/libc/sysdeps/linux/microblaze/__longjmp.S b/libc/sysdeps/linux/microblaze/__longjmp.S index 2752f0bd3..c4423bec5 100644 --- a/libc/sysdeps/linux/microblaze/__longjmp.S +++ b/libc/sysdeps/linux/microblaze/__longjmp.S @@ -16,30 +16,34 @@ #define _ASM #include <bits/setjmp.h> -#include <clinkage.h> +#include <libc-symbols.h> .text -C_ENTRY(__longjmp): + .globl C_SYMBOL_NAME(__longjmp) + .align 4 +C_SYMBOL_NAME(__longjmp): /* load registers from memory to r5 (arg0) */ lwi r1, r5, 0 lwi r15, r5, 4 - lwi r18, r5, 8 - lwi r19, r5, 12 - lwi r20, r5, 16 - lwi r21, r5, 20 - lwi r22, r5, 24 - lwi r23, r5, 28 - lwi r24, r5, 32 - lwi r25, r5, 36 - lwi r26, r5, 40 - lwi r27, r5, 44 - lwi r28, r5, 48 - lwi r29, r5, 52 - lwi r30, r5, 56 + lwi r2, r5, 8 + lwi r13, r5, 12 + lwi r18, r5, 16 + lwi r19, r5, 20 + lwi r20, r5, 24 + lwi r21, r5, 28 + lwi r22, r5, 32 + lwi r23, r5, 36 + lwi r24, r5, 40 + lwi r25, r5, 44 + lwi r26, r5, 48 + lwi r27, r5, 52 + lwi r28, r5, 56 + lwi r29, r5, 60 + lwi r30, r5, 64 + lwi r31, r5, 68 addi r3, r0, 1 /* return val */ rtsd r15, 8 /* normal return */ nop -C_END(__longjmp) libc_hidden_def(__longjmp) diff --git a/libc/sysdeps/linux/microblaze/bits/fcntl.h b/libc/sysdeps/linux/microblaze/bits/fcntl.h index bb6727ad8..44e8f3f5b 100644 --- a/libc/sysdeps/linux/microblaze/bits/fcntl.h +++ b/libc/sysdeps/linux/microblaze/bits/fcntl.h @@ -23,6 +23,9 @@ #include <sys/types.h> +#ifdef __USE_GNU +# include <bits/uio.h> +#endif /* open/fcntl - O_SYNC is only implemented on blocks devices and on files located on an ext2 file system */ @@ -42,11 +45,11 @@ #define O_ASYNC 020000 #ifdef __USE_GNU -# define O_DIRECTORY 040000 /* Must be a directory. */ -# define O_NOFOLLOW 0100000 /* Do not follow links. */ -# define O_DIRECT 0200000 /* Direct disk access. */ -# define O_NOATIME 01000000 /* Do not set atime. */ -# define O_CLOEXEC 02000000 /* set close_on_exec */ +# define O_DIRECTORY 0200000 /* Must be a directory. */ +# define O_NOFOLLOW 0400000 /* Do not follow links. */ +# define O_DIRECT 040000 /* Direct disk access. */ +# define O_NOATIME 01000000 /* Do not set atime. */ +# define O_CLOEXEC 02000000 /* set close_on_exec */ #endif /* For now Linux has synchronisity options for data and read operations. @@ -58,7 +61,7 @@ #endif #ifdef __USE_LARGEFILE64 -# define O_LARGEFILE 0400000 +# define O_LARGEFILE 0100000 #endif /* Values for the second argument to `fcntl'. */ @@ -96,6 +99,8 @@ # define F_NOTIFY 1026 /* Request notfications on a directory. */ # define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with close-on-exit set on new fd. */ +# define F_SETPIPE_SZ 1031 /* Set of pipe page size array */ +# define F_GETPIPE_SZ 1032 /* Get of pipe page size array */ #endif /* For F_[GET|SET]FL. */ diff --git a/libc/sysdeps/linux/microblaze/bits/kernel_stat.h b/libc/sysdeps/linux/microblaze/bits/kernel_stat.h index de35488bd..2c5eb28af 100644 --- a/libc/sysdeps/linux/microblaze/bits/kernel_stat.h +++ b/libc/sysdeps/linux/microblaze/bits/kernel_stat.h @@ -9,50 +9,44 @@ struct kernel_stat { - __kernel_dev_t st_dev; - __kernel_ino_t st_ino; - __kernel_mode_t st_mode; - __kernel_nlink_t st_nlink; - __kernel_uid_t st_uid; - __kernel_gid_t st_gid; - __kernel_dev_t st_rdev; - __kernel_off_t st_size; - unsigned long st_blksize; - unsigned long st_blocks; - struct timespec st_atim; - struct timespec st_mtim; - struct timespec st_ctim; - unsigned long __unused4; - unsigned long __unused5; + unsigned long st_dev; /* Device. */ + unsigned long st_ino; /* File serial number. */ + unsigned int st_mode; /* File mode. */ + unsigned int st_nlink; /* Link count. */ + unsigned int st_uid; /* User ID of the file's owner. */ + unsigned int st_gid; /* Group ID of the file's group. */ + unsigned long st_rdev; /* Device number, if device. */ + unsigned long __pad1; + long st_size; /* Size of file, in bytes. */ + int st_blksize; /* Optimal block size for I/O. */ + int __pad2; + long st_blocks; /* Number 512-byte blocks allocated. */ + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; + unsigned int __unused4; + unsigned int __unused5; }; struct kernel_stat64 { - __kernel_dev_t st_dev; - unsigned long __unused0; - unsigned long __unused1; - - __kernel_ino64_t st_ino; - - __kernel_mode_t st_mode; - __kernel_nlink_t st_nlink; - - __kernel_uid_t st_uid; - __kernel_gid_t st_gid; - - __kernel_dev_t st_rdev; - unsigned long __unused2; - unsigned long __unused3; - - __kernel_loff_t st_size; - unsigned long st_blksize; - - unsigned long __unused4; /* future possible st_blocks high bits */ - unsigned long st_blocks; /* Number 512-byte blocks allocated. */ - - struct timespec st_atim; - struct timespec st_mtim; - struct timespec st_ctim; + unsigned long long st_dev; /* Device. */ + unsigned long long st_ino; /* File serial number. */ + unsigned int st_mode; /* File mode. */ + unsigned int st_nlink; /* Link count. */ + unsigned int st_uid; /* User ID of the file's owner. */ + unsigned int st_gid; /* Group ID of the file's group. */ + unsigned long long st_rdev; /* Device number, if device. */ + unsigned long long __pad1; + long long st_size; /* Size of file, in bytes. */ + int st_blksize; /* Optimal block size for I/O. */ + int __pad2; + long long st_blocks; /* Number 512-byte blocks allocated. */ + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; + unsigned int __unused4; + unsigned int __unused5; }; #endif /* _BITS_STAT_STRUCT_H */ diff --git a/libc/sysdeps/linux/microblaze/bits/kernel_types.h b/libc/sysdeps/linux/microblaze/bits/kernel_types.h index 1ca2dae30..2a7057502 100644 --- a/libc/sysdeps/linux/microblaze/bits/kernel_types.h +++ b/libc/sysdeps/linux/microblaze/bits/kernel_types.h @@ -13,18 +13,17 @@ * Microblaze port by John Williams */ -#ifndef __MICROBLAZE_POSIX_TYPES_H__ -#define __MICROBLAZE_POSIX_TYPES_H__ +#ifndef _ASM_MICROBLAZE_POSIX_TYPES_H +#define _ASM_MICROBLAZE_POSIX_TYPES_H -typedef unsigned int __kernel_dev_t; +typedef unsigned long __kernel_dev_t; typedef unsigned long __kernel_ino_t; -typedef unsigned long long __kernel_ino64_t; -typedef unsigned int __kernel_mode_t; -typedef unsigned int __kernel_nlink_t; +//typedef unsigned long long __kernel_ino64_t; +typedef unsigned short __kernel_mode_t; +typedef unsigned long __kernel_nlink_t; typedef long __kernel_off_t; -typedef long long __kernel_loff_t; typedef int __kernel_pid_t; -typedef unsigned short __kernel_ipc_pid_t; +typedef int __kernel_ipc_pid_t; typedef unsigned int __kernel_uid_t; typedef unsigned int __kernel_gid_t; typedef unsigned int __kernel_size_t; @@ -33,6 +32,8 @@ typedef int __kernel_ptrdiff_t; typedef long __kernel_time_t; typedef long __kernel_suseconds_t; typedef long __kernel_clock_t; +typedef int __kernel_timer_t; +typedef int __kernel_clockid_t; typedef int __kernel_daddr_t; typedef char * __kernel_caddr_t; typedef unsigned short __kernel_uid16_t; @@ -40,9 +41,13 @@ typedef unsigned short __kernel_gid16_t; typedef unsigned int __kernel_uid32_t; typedef unsigned int __kernel_gid32_t; -typedef unsigned short __kernel_old_uid_t; -typedef unsigned short __kernel_old_gid_t; -typedef __kernel_dev_t __kernel_old_dev_t; +typedef unsigned int __kernel_old_uid_t; +typedef unsigned int __kernel_old_gid_t; +typedef unsigned int __kernel_old_dev_t; + +#ifdef __GNUC__ +typedef long long __kernel_loff_t; +#endif typedef struct { #ifdef __USE_ALL @@ -52,4 +57,4 @@ typedef struct { #endif } __kernel_fsid_t; -#endif /* __MICROBLAZE_POSIX_TYPES_H__ */ +#endif /* _ASM_MICROBLAZE_POSIX_TYPES_H */ diff --git a/libc/sysdeps/linux/microblaze/bits/poll.h b/libc/sysdeps/linux/microblaze/bits/poll.h index f7a739315..78ee877c0 100644 --- a/libc/sysdeps/linux/microblaze/bits/poll.h +++ b/libc/sysdeps/linux/microblaze/bits/poll.h @@ -29,10 +29,10 @@ #ifdef __USE_XOPEN /* These values are defined in XPG4.2. */ -# define POLLRDNORM 0x040 /* Normal data may be read. */ -# define POLLRDBAND 0x080 /* Priority data may be read. */ -# define POLLWRNORM POLLOUT /* Writing now will not block. */ -# define POLLWRBAND 0x100 /* Priority data may be written. */ +# define POLLRDNORM 0x0040 /* Normal data may be read. */ +# define POLLRDBAND 0x0080 /* Priority data may be read. */ +# define POLLWRNORM 0x0100 /* Writing now will not block. */ +# define POLLWRBAND 0x0200 /* Priority data may be written. */ #endif /* Event types always implicitly polled for. These bits need not be set in diff --git a/libc/sysdeps/linux/microblaze/bits/setjmp.h b/libc/sysdeps/linux/microblaze/bits/setjmp.h index d966efd2b..0c0573cd7 100644 --- a/libc/sysdeps/linux/microblaze/bits/setjmp.h +++ b/libc/sysdeps/linux/microblaze/bits/setjmp.h @@ -28,12 +28,16 @@ typedef struct /* Link pointer. */ void *__lp; - /* Callee-saved registers r18-r30. */ - int __regs[13]; + /* SDA pointers */ + void *__SDA; + void *__SDA2; + + /* Callee-saved registers r18-r31. */ + int __regs[14]; } __jmp_buf[1]; #endif -#define JB_SIZE (4 * 15) +#define JB_SIZE (4 * 18) /* Test if longjmp to JMPBUF would unwind the frame containing a local variable at ADDRESS. */ diff --git a/libc/sysdeps/linux/microblaze/bits/stackinfo.h b/libc/sysdeps/linux/microblaze/bits/stackinfo.h new file mode 100644 index 000000000..819e81974 --- /dev/null +++ b/libc/sysdeps/linux/microblaze/bits/stackinfo.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This file contains a bit of information about the stack allocation + of the processor. */ + +#ifndef _STACKINFO_H +#define _STACKINFO_H 1 + +/* On microblaze the stack grows down. */ +#define _STACK_GROWS_DOWN 1 + +#endif /* stackinfo.h */ diff --git a/libc/sysdeps/linux/microblaze/bits/syscalls.h b/libc/sysdeps/linux/microblaze/bits/syscalls.h index b21851333..f4bdc4522 100644 --- a/libc/sysdeps/linux/microblaze/bits/syscalls.h +++ b/libc/sysdeps/linux/microblaze/bits/syscalls.h @@ -4,12 +4,54 @@ # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead." #endif -#include <features.h> -/* Do something very evil for now. Until we create our own syscall - * macros, short circuit bits/sysnum.h and use asm/unistd.h instead */ -#warning "fixme -- add arch specific syscall macros.h" -#include <asm/unistd.h> +#ifndef __ASSEMBLER__ -#endif /* _BITS_SYSCALLS_H */ +#include <errno.h> + +#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ + ({ \ + register int __ret __asm__("r3"); \ + register int _scno __asm__("r12") = name; \ + LOAD_ARGS_##nr (args); \ + __asm__ __volatile__("brki r14, 0x8" \ + : "=r" (__ret) \ + : "r"(_scno) ASM_ARGS_##nr \ + : __SYSCALL_CLOBBERS ); \ + __ret; \ + }) + +#define INTERNAL_SYSCALL_ERROR_P(val, err) \ + ((unsigned int)(val) >= 0xfffff001U) +#define LOAD_ARGS_0() do { } while(0) +#define ASM_ARGS_0 +#define LOAD_ARGS_1(a1) \ + register int _a1 __asm__("r5") = (int)(a1); \ + LOAD_ARGS_0() +#define ASM_ARGS_1 ASM_ARGS_0, "r"(_a1) +#define LOAD_ARGS_2(a1, a2) \ + register int _a2 __asm__("r6") = (int)(a2); \ + LOAD_ARGS_1(a1) +#define ASM_ARGS_2 ASM_ARGS_1, "r"(_a2) +#define LOAD_ARGS_3(a1, a2, a3) \ + register int _a3 __asm__("r7") = (int)(a3); \ + LOAD_ARGS_2(a1, a2) +#define ASM_ARGS_3 ASM_ARGS_2, "r"(_a3) +#define LOAD_ARGS_4(a1, a2, a3, a4) \ + register int _a4 __asm__("r8") = (int)(a4); \ + LOAD_ARGS_3(a1, a2, a3) +#define ASM_ARGS_4 ASM_ARGS_3, "r"(_a4) +#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \ + register int _a5 __asm__("r9") = (int)(a5); \ + LOAD_ARGS_4(a1, a2, a3, a4) +#define ASM_ARGS_5 ASM_ARGS_4, "r"(_a5) +#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \ + register int _a6 __asm__("r10") = (int)(a6); \ + LOAD_ARGS_5(a1, a2, a3, a4, a5) +#define ASM_ARGS_6 ASM_ARGS_5, "r"(_a6) + +#define __SYSCALL_CLOBBERS "r4", "r14", "cc", "memory" + +#endif /* __ASSEMBLER__ */ +#endif /* _BITS_SYSCALLS_H */ diff --git a/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h b/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h index 2a9422e23..86d00084c 100644 --- a/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h +++ b/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h @@ -10,7 +10,7 @@ #undef __UCLIBC_ABORT_INSTRUCTION__ /* can your target use syscall6() for mmap ? */ -#undef __UCLIBC_MMAP_HAS_6_ARGS__ +#define __UCLIBC_MMAP_HAS_6_ARGS__ /* does your target use syscall4() for truncate64 ? (32bit arches only) */ #undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__ @@ -22,7 +22,7 @@ #undef __UCLIBC_HANDLE_OLDER_RLIMIT__ /* does your target have an asm .set ? */ -#define __UCLIBC_HAVE_ASM_SET_DIRECTIVE__ +#undef __UCLIBC_HAVE_ASM_SET_DIRECTIVE__ /* define if target doesn't like .global */ #undef __UCLIBC_ASM_GLOBAL_DIRECTIVE__ diff --git a/libc/sysdeps/linux/microblaze/bits/uClibc_page.h b/libc/sysdeps/linux/microblaze/bits/uClibc_page.h new file mode 100644 index 000000000..8fc81ae32 --- /dev/null +++ b/libc/sysdeps/linux/microblaze/bits/uClibc_page.h @@ -0,0 +1,41 @@ +/* Copyright (C) 2004 Erik Andersen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Supply an architecture specific value for PAGE_SIZE and friends. */ + +#ifndef _UCLIBC_PAGE_H +#define _UCLIBC_PAGE_H + +#include <linux/autoconf.h> + +#if defined(CONFIG_MICROBLAZE_32K_PAGES) +#define PAGE_SHIFT 15 +#elif defined(CONFIG_MICROBLAZE_16K_PAGES) +#define PAGE_SHIFT 14 +#elif defined(CONFIG_MICROBLAZE_8K_PAGES) +#define PAGE_SHIFT 13 +#elif defined(CONFIG_MICROBLAZE_4K_PAGES) +#define PAGE_SHIFT 12 +#else +#warning Missing CONFIG_MICROBLAZE_nnK_PAGES, assuming 4K +#define PAGE_SHIFT 12 +#endif + +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) + +#endif /* _UCLIBC_PAGE_H */ diff --git a/libc/sysdeps/linux/microblaze/clinkage.h b/libc/sysdeps/linux/microblaze/clinkage.h deleted file mode 100644 index a9beffc96..000000000 --- a/libc/sysdeps/linux/microblaze/clinkage.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * libc/sysdeps/linux/microblaze/clinkage.h -- Macros for C symbols in assembler - * - * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au> - * Copyright (C) 2001 NEC Corporation - * Copyright (C) 2001 Miles Bader <miles@gnu.org> - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License. See the file COPYING.LIB in the main - * directory of this archive for more details. - * - * Written by Miles Bader <miles@gnu.org> - */ - -#include <asm/clinkage.h> diff --git a/libc/sysdeps/linux/microblaze/clone.c b/libc/sysdeps/linux/microblaze/clone.c index a47ee8c68..d92100865 100644 --- a/libc/sysdeps/linux/microblaze/clone.c +++ b/libc/sysdeps/linux/microblaze/clone.c @@ -1,52 +1,47 @@ /* - * libc/sysdeps/linux/microblaze/clone.c -- `clone' syscall for linux/microblaze + * Copyright (C) 2004 Atmel Corporation * - * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au> - * Copyright (C) 2002,03 NEC Electronics Corporation - * Copyright (C) 2002,03 Miles Bader <miles@gnu.org> - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License. See the file COPYING.LIB in the main - * directory of this archive for more details. - * - * Written by Miles Bader <miles@gnu.org> - * Microblaze port by John Williams + * This file is subject to the terms and conditions of the GNU Lesser General + * Public License. See the file "COPYING.LIB" in the main directory of this + * archive for more details. */ - +#include <sched.h> #include <errno.h> #include <sys/syscall.h> +#include <unistd.h> -int -clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg) +int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg, ...) { - register unsigned long rval __asm__ (SYSCALL_RET) = -EINVAL; + int rval = -EINVAL; + if (fn && child_stack) + rval = INTERNAL_SYSCALL(clone, 0, 2, flags, child_stack); + + if (rval == 0) + { + int exitCode = fn(arg); + rval = INTERNAL_SYSCALL(exit, 0, 1, exitCode); + } - if (fn && child_stack) - { - register unsigned long syscall __asm__ (SYSCALL_NUM); - register unsigned long arg0 __asm__ (SYSCALL_ARG0); - register unsigned long arg1 __asm__ (SYSCALL_ARG1); + return rval; +} - /* Clone this thread. */ - arg0 = flags; - arg1 = (unsigned long)child_stack; - syscall = __NR_clone; - __asm__ __volatile__ ("bralid r17, trap;nop;" - : "=r" (rval), "=r" (syscall) - : "1" (syscall), "r" (arg0), "r" (arg1) - : SYSCALL_CLOBBERS); +#ifdef __NR_clone2 +int +__clone2(int (*fn)(void *arg), void *child_stack, size_t stack_size, + int flags, void *arg, ...) +{ + int rval = -EINVAL; + if (fn && child_stack) + { + rval = INTERNAL_SYSCALL(clone2, 0, 3, flags, child_stack, stack_size); + } - if (rval == 0) - /* In child thread, call FN and exit. */ + if (rval == 0) { - arg0 = (*fn) (arg); - syscall = __NR_exit; - __asm__ __volatile__ ("bralid r17, trap;nop;" - : "=r" (rval), "=r" (syscall) - : "1" (syscall), "r" (arg0) - : SYSCALL_CLOBBERS); + int exitCode = fn(arg); + rval = INTERNAL_SYSCALL(exit, 0, 1, exitCode); } - } - __syscall_return (int, rval); + return rval; } +#endif diff --git a/libc/sysdeps/linux/microblaze/crt1.S b/libc/sysdeps/linux/microblaze/crt1.S new file mode 100644 index 000000000..e9564cfba --- /dev/null +++ b/libc/sysdeps/linux/microblaze/crt1.S @@ -0,0 +1,61 @@ +/* + * libc/sysdeps/linux/microblaze/crt1.S -- Initial program entry point for linux/microblaze + * + * Copyright (C) 2009 Meyer Sound Laboratories + * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au> + * Copyright (C) 2001,2002 NEC Corporation + * Copyright (C) 2001,2002 Miles Bader <miles@gnu.org> + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License. See the file COPYING.LIB in the main + * directory of this archive for more details. + * + * Written by Miles Bader <miles@gnu.org> + */ + +#include <libc-symbols.h> + +/* Upon entry, the stack contains the following data: + argc, argv[0], ..., argv[argc-1], 0, envp[0], ..., 0 +*/ + + .text + .globl C_SYMBOL_NAME(_start) + .align 4 +C_SYMBOL_NAME(_start): + + /* Load SDAs */ + la r2, r0, C_SYMBOL_NAME(_SDA2_BASE_) /* in the original source r2 was SDA, and r13 was SDA2, no idea why */ + la r13, r0, C_SYMBOL_NAME(_SDA_BASE_) + + /* + Preparing arguments for uClibc's startup routine. + The routine has 6 arguments, so 5 of them are placed + into registers, one on the stack + */ + + la r5, r0, C_SYMBOL_NAME(main) /* Arg 1: main() */ + lw r6, r0, r1 /* Arg 2: argc */ + addi r7, r1, 4 /* Arg 3: argv */ + la r8, r0, _init /* Arg 4: init */ + la r9, r0, _fini /* Arg 5: fini */ + addk r10,r0,r0 /* Arg 6: rtld_fini = NULL */ + + + /* Reserve space for __uClibc_main to save parameters + (Microblaze ABI stack calling convention) + and for stack_end argument to __uClibc_main */ + add r3, r1, r0 + addi r1, r1, -32 + + /* tail-call uClibc's startup routine */ + brid C_SYMBOL_NAME(__uClibc_main) + swi r3, r1, 28 /* Arg 7: stack end [DELAY SLOT] */ + +/* Define a symbol for the first piece of initialized data. */ + .data + .globl __data_start +__data_start: + .long 0 + .weak data_start + data_start = __data_start diff --git a/libc/sysdeps/linux/microblaze/crti.S b/libc/sysdeps/linux/microblaze/crti.S new file mode 100644 index 000000000..e00396897 --- /dev/null +++ b/libc/sysdeps/linux/microblaze/crti.S @@ -0,0 +1,41 @@ +/* + * libc/sysdeps/linux/microblaze/crti.S -- init/fini entry code for microblaze + * (baselined with gcc 4.1.2) + * + * Copyright (C) 2010 Digital Design Corporation + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License. See the file COPYING.LIB in the main + * directory of this archive for more details. + */ + +#define END_INIT +#define END_FINI +#define ALIGN +#include <libc-symbols.h> + +/*@HEADER_ENDS*/ + + .section .init + .align 2 + .globl _init +_init: + addik r1, r1, -32 + swi r19, r1, 28 + addk r19, r1, r0 + swi r15, r1, 0 + + ALIGN + END_INIT + + .section .fini + .align 2 + .globl _fini +_fini: + addik r1, r1, -32 + swi r19, r1, 28 + addk r19, r1, r0 + swi r15, r1, 0 + + ALIGN + END_FINI diff --git a/libc/sysdeps/linux/microblaze/crtn.S b/libc/sysdeps/linux/microblaze/crtn.S new file mode 100644 index 000000000..da8c920ef --- /dev/null +++ b/libc/sysdeps/linux/microblaze/crtn.S @@ -0,0 +1,45 @@ +/* + * libc/sysdeps/linux/microblaze/crtn.S -- init/fini exit code for microblaze + * (baselined with gcc 4.1.2) + * + * Copyright (C) 2010 Digital Design Corporation + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License. See the file COPYING.LIB in the main + * directory of this archive for more details. + */ + +#define END_INIT +#define END_FINI +#define ALIGN +#include <libc-symbols.h> + + .section .init + .align 2 + .globl _init + .ent _init + + lwi r15, r1, 0 + lwi r19, r1, 28 + rtsd r15, 8 + addik r1, r1, 32 # Delay slot + + .end _init +$Lfe2: + .size _init,$Lfe2-_init + + .section .fini + .align 2 + .globl _fini + .ent |