OSDN Git Service

Wire up
authorYoshinori Sato <ysato@sa76r4.localdomain>
Fri, 2 Jan 2015 17:06:40 +0000 (02:06 +0900)
committerYoshinori Sato <ysato@sa76r4.localdomain>
Fri, 2 Jan 2015 17:06:40 +0000 (02:06 +0900)
libc/sysdeps/linux/h8300/Makefile
libc/sysdeps/linux/h8300/bits/fcntl.h
libc/sysdeps/linux/h8300/bits/syscalls.h
libc/sysdeps/linux/h8300/crt1.S [moved from libc/sysdeps/linux/h8300/crt0.S with 66% similarity]
libc/sysdeps/linux/h8300/crti.S
libc/sysdeps/linux/h8300/crtn.S

index 2ab4ee6..fb2237a 100644 (file)
@@ -14,8 +14,8 @@ endif
 #FIXME -- this arch should include its own crti.S and crtn.S
 UCLIBC_CTOR_DTOR=n
 
-CRT_SRC := crt0.S
-CRT_OBJ := crt0.o crt1.o
+CRT_SRC := crt1.S
+CRT_OBJ := crt1.o
 CTOR_TARGETS := $(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
 
 SSRC := __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S vfork.S
index 45deec4..08b6327 100644 (file)
@@ -13,8 +13,9 @@
    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, see
-   <http://www.gnu.org/licenses/>.  */
+   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.  */
 
 #ifndef        _FCNTL_H
 # error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -22,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 */
 
 #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_NOFOLLOW    0400000 /* Do not follow links.  */
+# 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.
@@ -93,8 +99,6 @@
 # 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 pipe page size array.  */
-# define F_GETPIPE_SZ  1032    /* Get pipe page size array.  */
 #endif
 
 /* For F_[GET|SET]FL.  */
index 5867ed6..dce0036 100644 (file)
-/* Unlike the asm/unistd.h kernel header file (which this is partly based on),
- * this file must be able to cope with PIC and non-PIC code.  For some arches
- * there is no difference.  For x86 (which has far too few registers) there is
- * a difference.   Regardless, including asm/unistd.h is hereby officially
- * forbidden.  Don't do it.  It is bad for you.
- */
+#ifndef _BITS_SYSCALLS_H
+#define _BITS_SYSCALLS_H
 #ifndef _SYSCALL_H
 # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
 #endif
 
-#define __syscall_return(type, res) \
-do { \
-       if ((unsigned long)(res) >= (unsigned long)(-125)) { \
-       /* avoid using res which is declared to be in register d0; \
-          errno might expand to a function call and clobber it.  */ \
-               int __err = -(res); \
-               errno = __err; \
-               res = -1; \
-       } \
-       return (type) (res); \
-} while (0)
+#ifndef __ASSEMBLER__
 
-#define _syscall0(type, name)                                                  \
-type name(void)                                                                        \
-{                                                                              \
-  register long __res __asm__("er0");                                          \
-  __asm__ __volatile__ ("mov.l %1,er0\n\t"                                     \
-                       "trapa  #0\n\t"                                         \
-                       : "=r" (__res)                                          \
-                       : "ir" (__NR_##name)                                    \
-                       : "cc");                                                \
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                       \
-    errno = -__res;                                                            \
-    __res = -1;                                                                        \
-  }                                                                            \
-  return (type)__res;                                                          \
-}
+#include <errno.h>
 
-#define _syscall1(type, name, atype, a)                                                \
-type name(atype a)                                                             \
-{                                                                              \
-  register long __res __asm__("er0");                                          \
-  __asm__ __volatile__ ("mov.l %2, er1\n\t"                                    \
-                       "mov.l  %1, er0\n\t"                                    \
-                       "trapa  #0\n\t"                                         \
-                       : "=r" (__res)                                          \
-                       : "ir" (__NR_##name),                                   \
-                         "g" ((long)a)                                         \
-                       : "cc", "er1");                                 \
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                       \
-    errno = -__res;                                                            \
-    __res = -1;                                                                        \
-  }                                                                            \
-  return (type)__res;                                                          \
-}
+#define ASMFMT_0()
+#define ASMFMT_1(arg1)                         \
+       , "g" ((unsigned long)arg1)
+#define ASMFMT_2(arg1, arg2)                   \
+       , "g" ((unsigned long)arg1), "g" ((unsigned long)arg2)
+#define ASMFMT_3(arg1, arg2, arg3)             \
+       , "g" ((unsigned long)arg1), "g" ((unsigned long)arg2), "g" ((unsigned long)arg3)
+#define ASMFMT_4(arg1, arg2, arg3, arg4)                       \
+       , "g" ((unsigned long)arg1), "g" ((unsigned long)arg2), "g" ((unsigned long)arg3), "g" ((unsigned long)arg4)
+#define ASMFMT_5(arg1, arg2, arg3, arg4, arg5)                 \
+       , "g" (arg1), "g" (arg2), "g" (arg3), "g" (arg4)/*, "g" (arg5)*/
+#define ASMFMT_6(arg1, arg2, arg3, arg4, arg5, arg6)                           \
+       , "g" (arg1), "g" (arg2), "g" (arg3), "g" (arg4)/*, "g" (arg5), "g" (arg6)*/
 
-#define _syscall2(type, name, atype, a, btype, b)                              \
-type name(atype a, btype b)                                                    \
-{                                                                              \
-  register long __res __asm__("er0");                                          \
-  __asm__ __volatile__ ("mov.l %3, er2\n\t"                                    \
-                       "mov.l  %2, er1\n\t"                                    \
-                       "mov.l  %1, er0\n\t"                                    \
-                       "trapa  #0\n\t"                                         \
-                       : "=r" (__res)                                          \
-                       : "ir" (__NR_##name),                                   \
-                         "g" ((long)a),                                        \
-                         "g" ((long)b)                                         \
-                       : "cc", "er1", "er2");                          \
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                       \
-    errno = -__res;                                                            \
-    __res = -1;                                                                        \
-  }                                                                            \
-  return (type)__res;                                                          \
-}
+#define SUBSTITUTE_ARGS_0 \
+       "mov.l %1, er0\n\t"
+#define SUBSTITUTE_ARGS_1 \
+       "mov.l %2, er1\n\t" \
+       "mov.l %1, er0\n\t"
+#define SUBSTITUTE_ARGS_2 \
+       "mov.l %3, er2\n\t" \
+       "mov.l %2, er1\n\t" \
+       "mov.l %1, er0\n\t"
+#define SUBSTITUTE_ARGS_3 \
+       "mov.l %4, er3\n\t" \
+       "mov.l %3, er2\n\t" \
+       "mov.l %2, er1\n\t" \
+       "mov.l %1, er0\n\t"
+#define SUBSTITUTE_ARGS_4 \
+       "mov.l %5, er4\n\t" \
+       "mov.l %4, er3\n\t" \
+       "mov.l %3, er2\n\t" \
+       "mov.l %2, er1\n\t" \
+       "mov.l %1, er0\n\t"
+#define SUBSTITUTE_ARGS_5 \
+       /*"mov.l %6, er5\n\t"*/                 \
+       "mov.l %5, er4\n\t" \
+       "mov.l %4, er3\n\t" \
+       "mov.l %3, er2\n\t" \
+       "mov.l %2, er1\n\t" \
+       "mov.l %1, er0\n\t"
+#define SUBSTITUTE_ARGS_6 \
+       /*"mov.l %7, er6\n\t"*/                 \
+       /*"mov.l %6, er5\n\t"*/                 \
+       "mov.l %5, er4\n\t" \
+       "mov.l %4, er3\n\t" \
+       "mov.l %3, er2\n\t" \
+       "mov.l %2, er1\n\t" \
+       "mov.l %1, er0\n\t"
 
-#define _syscall3(type, name, atype, a, btype, b, ctype, c)                    \
-type name(atype a, btype b, ctype c)                                           \
-{                                                                              \
-  register long __res __asm__("er0");                                          \
-  __asm__ __volatile__ ("mov.l %4, er3\n\t"                                    \
-                       "mov.l  %3, er2\n\t"                                    \
-                       "mov.l  %2, er1\n\t"                                    \
-                       "mov.l  %1, er0\n\t"                                    \
-                       "trapa  #0\n\t"                                         \
-                       : "=r" (__res)                                          \
-                       : "ir" (__NR_##name),                                   \
-                         "g" ((long)a),                                        \
-                         "g" ((long)b),                                        \
-                         "g" ((long)c)                                         \
-                       : "cc", "er1", "er2", "er3");                   \
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                       \
-    errno = -__res;                                                            \
-    __res = -1;                                                                        \
-  }                                                                            \
-  return (type)__res;                                                          \
-}
+/* The _NCS variant allows non-constant syscall numbers.  */
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
+  ({                                                                           \
+    register long int er0 __asm__ ("er0");                             \
+    __asm__ __volatile__ ( \
+               SUBSTITUTE_ARGS_##nr                            \
+               "trapa #0"                                              \
+                 : "=r" (er0)                                          \
+               : "ir" (name) ASMFMT_##nr(args)                         \
+                 : "memory"                                                    \
+    );                                                                         \
+    (int) er0;                                                         \
+   }) \
+)
 
-#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d)          \
-type name(atype a, btype b, ctype c, dtype d)                                  \
-{                                                                              \
-  register long __res __asm__("er0");                                          \
-  __asm__ __volatile__ ("mov.l %5, er4\n\t"                                    \
-                       "mov.l  %4, er3\n\t"                                    \
-                       "mov.l  %3, er2\n\t"                                    \
-                       "mov.l  %2, er1\n\t"                                    \
-                       "mov.l  %1, er0\n\t"                                    \
-                       "trapa  #0\n\t"                                         \
-                       : "=r" (__res)                                          \
-                       : "ir" (__NR_##name),                                   \
-                         "g" ((long)a),                                        \
-                         "g" ((long)b),                                        \
-                         "g" ((long)c),                                        \
-                         "g" ((long)d)                                         \
-                       : "cc", "er1", "er2", "er3", "er4");                    \
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                       \
-    errno = -__res;                                                            \
-    __res = -1;                                                                        \
-  }                                                                            \
-  return (type)__res;                                                          \
-}
-
-#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e)        \
-type name(atype a, btype b, ctype c, dtype d, etype e)                         \
-{                                                                              \
-  register long __res __asm__("er0");                                          \
-  __asm__ __volatile__ ( \
-                        "mov.l  er5,@-sp\n\t"                                   \
-                       "mov.l  %5, er4\n\t"                                    \
-                       "mov.l  %4, er3\n\t"                                    \
-                       "mov.l  %3, er2\n\t"                                    \
-                       "mov.l  %2, er1\n\t"                                    \
-                       "mov.l  %1, er0\n\t"                                    \
-                       "mov.l  %6, er5\n\t"                                    \
-                       "trapa  #0\n\t"                                         \
-                       "mov.l  @sp+,er5\n\t"                                   \
-                       : "=r" (__res)                                          \
-                       : "ir" (__NR_##name),                                   \
-                         "g" ((long)a),                                        \
-                         "g" ((long)b),                                        \
-                         "g" ((long)c),                                        \
-                         "g" ((long)d),                                        \
-                         "m" ((long)e)                                         \
-                       : "cc", "er1", "er2", "er3", "er4");                    \
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                       \
-    errno = -__res;                                                            \
-    __res = -1;                                                                        \
-  }                                                                            \
-  return (type)__res;                                                          \
-}
+#endif /* __ASSEMBLER__ */
+#endif /* _BITS_SYSCALLS_H */
 
similarity index 66%
rename from libc/sysdeps/linux/h8300/crt0.S
rename to libc/sysdeps/linux/h8300/crt1.S
index be6768d..342910e 100644 (file)
@@ -28,17 +28,39 @@ not, see <http://www.gnu.org/licenses/>.  */
 #else
        .h8300h
 #endif
+/*     
+void __uClibc_main(int (*main)(int, char **, char **), int argc,
+                    char **argv, void (*app_init)(void), void (*app_fini)(void),
+                    void (*rtld_fini)(void),void *stack_end attribute_unused)
+*/
        .text
 
 _start: /* put here so that references to _start work with elf-PIC */
 
-       mov.l   @(0,sp),er0     /* argc */
-       mov.l   @(4,sp),er1     /* argv */
-       mov.l   @(8,sp),er2     /* envp */
+       mov.l   @sp+,er1        /* argc */
+       mov.l   @sp+,er2        /* argv */
+       add.l   #4,sp
+       
 #if !defined(__PIC__)
-       jsr     @___uClibc_main
+       mov.l   sp, @-sp
+       sub.l   er0,er0
+       mov.l   er0,@-sp
+       mov.l   #_fini,er0
+       mov.l   er0,@-sp
+       mov.l   #_init,er0
+       mov.l   er0,@-sp
+       mov.l   #main,er0
+       jsr     @__uClibc_main
 #else
-       mov.l   @(___uClibc_main@GOTOFF,er5),er3
+       mov.l   sp, @-sp
+       sub.l   er0,er0
+       mov.l   er0,@-sp
+       mov.l   @(_fini@GOTOFF,er5),er0
+       mov.l   er0,@-sp
+       mov.l   @(_init@GOTOFF,er5),er0
+       mov.l   er0,@-sp
+       mov.l   @(main@GOTOFF,er5),er0
+       mov.l   @(__uClibc_main@GOTOFF,er5),er3
        jsr     @er3
 #endif
 
@@ -61,9 +83,9 @@ empty_func:
 
 /* Define a symbol for the first piece of initialized data.  */
        .data
-       .globl __data_start
-__data_start:
+       .globl _data_start
+_data_start:
        .long 0
        .weak data_start
-       data_start = __data_start
+       data_start = _data_start
 
index 270df27..cc6afe9 100644 (file)
@@ -10,8 +10,8 @@
        .section .init
 ; #NO_APP
        .align 1
-       .global __init
-__init:
+       .global _init
+_init:
        mov.l   er6,@-er7
        mov.l   er7,er6
 ; #APP
@@ -20,8 +20,8 @@ __init:
        .section .fini
 ; #NO_APP
        .align 1
-       .global __fini
-__fini:
+       .global _fini
+_fini:
        mov.l   er6,@-er7
        mov.l   er7,er6
 ; #APP
index 8f9fa1f..a390704 100644 (file)
@@ -10,7 +10,7 @@
        .section .init
 ; #NO_APP
        .align 1
-       .global __init
+       .global _init
 ; #NO_APP
        mov.l   @er7+,er6
        rts
@@ -19,7 +19,7 @@
        .section .fini
 ; #NO_APP
        .align 1
-       .global __fini
+       .global _fini
 ; #NO_APP
        mov.l   @er7+,er6
        rts