OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [sys/] [arm/] [syscalls.c] - Diff between revs 39 and 56

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 39 Rev 56
Line 1... Line 1...
 
/* Support files for GNU libc.  Files in the system namespace go here.
 
   Files in the C namespace (ie those that do not start with an
 
   underscore) go in .c.  */
 
 
#include <_ansi.h>
#include <_ansi.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#include <sys/fcntl.h>
#include <stdio.h>
#include <stdio.h>
#include <time.h>
#include <time.h>
#include <sys/time.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/times.h>
#include <errno.h>
#include <errno.h>
 
#include <reent.h>
#include "swi.h"
#include "swi.h"
 
 
 
/* following is copied from libc/stdio/local.h to check std streams */
 
extern void   _EXFUN(__sinit,(struct _reent *));
 
#define CHECK_INIT(fp) \
 
  do                                    \
 
    {                                   \
 
      if ((fp)->_data == 0)             \
 
        (fp)->_data = _REENT;           \
 
      if (!(fp)->_data->__sdidinit)     \
 
        __sinit ((fp)->_data);          \
 
    }                                   \
 
  while (0)
 
 
/* Adjust our internal handles to stay away from std* handles */
/* Adjust our internal handles to stay away from std* handles */
#define FILE_HANDLE_OFFSET (0x20)
#define FILE_HANDLE_OFFSET (0x20)
 
 
 
static int std_files_checked;
static int monitor_stdin;
static int monitor_stdin;
static int monitor_stdout;
static int monitor_stdout;
static int monitor_stderr;
static int monitor_stderr;
 
 
/* Struct used to keep track of the file position, just so we
/* Struct used to keep track of the file position, just so we
Line 55... Line 73...
 
 
/* Function to convert std(in|out|err) handles to internal versions */
/* Function to convert std(in|out|err) handles to internal versions */
static int
static int
remap_handle (int fh)
remap_handle (int fh)
{
{
 
  if (!std_files_checked)
 
    {
 
       CHECK_INIT(stdin);
 
       CHECK_INIT(stdout);
 
       CHECK_INIT(stderr);
 
       std_files_checked = 1;
 
    }
  if (fh == __sfileno (stdin))
  if (fh == __sfileno (stdin))
    return monitor_stdin;
    return monitor_stdin;
  if (fh == __sfileno (stdout))
  if (fh == __sfileno (stdout))
    return monitor_stdout;
    return monitor_stdout;
  if (fh == __sfileno (stderr))
  if (fh == __sfileno (stderr))
Line 71... Line 96...
initialise_monitor_handles (void)
initialise_monitor_handles (void)
{
{
  int i;
  int i;
 
 
#ifdef ARM_RDI_MONITOR
#ifdef ARM_RDI_MONITOR
  int block[3];
  int volatile block[3];
 
 
  block[0] = (int) ":tt";
  block[0] = (int) ":tt";
  block[2] = 3;     /* length of filename */
  block[2] = 3;     /* length of filename */
  block[1] = 0;     /* mode "r" */
  block[1] = 0;     /* mode "r" */
  monitor_stdin = do_AngelSWI (AngelSWI_Reason_Open, block);
  monitor_stdin = do_AngelSWI (AngelSWI_Reason_Open, block);
Line 341... Line 366...
  return fh >= 0 ? fh + FILE_HANDLE_OFFSET : error (fh);
  return fh >= 0 ? fh + FILE_HANDLE_OFFSET : error (fh);
}
}
 
 
int
int
_open (const char *path,
_open (const char *path,
       int flags,...)
       int          flags,
 
       ...)
{
{
  return wrap (_swiopen (path, flags));
  return wrap (_swiopen (path, flags));
}
}
 
 
int
int
Line 369... Line 395...
{
{
  return wrap (_swiclose (file));
  return wrap (_swiclose (file));
}
}
 
 
void
void
_exit (n)
_exit (int n)
{
{
 
  /* FIXME: return code is thrown away */
 
 
#ifdef ARM_RDI_MONITOR
#ifdef ARM_RDI_MONITOR
  do_AngelSWI (AngelSWI_Reason_ReportException,
  do_AngelSWI (AngelSWI_Reason_ReportException,
              (void *) ADP_Stopped_ApplicationExit);
              (void *) ADP_Stopped_ApplicationExit);
#else
#else
  asm ("swi %a0" :: "i" (SWI_Exit));
  asm ("swi %a0" :: "i" (SWI_Exit));
#endif
#endif
}
}
 
 
void
 
abort ()
 
{
 
#ifdef ARM_RDI_MONITOR
 
  do_AngelSWI (AngelSWI_Reason_ReportException,
 
              (void *) ADP_Stopped_RunTimeError);
 
#else
 
 asm ("mov r0,#17\nswi %a0" :: "i" (SWI_Exit));
 
#endif
 
}
 
 
 
int
int
_kill (n, m)
_kill (int n, int m)
{
{
#ifdef ARM_RDI_MONITOR
#ifdef ARM_RDI_MONITOR
  do_AngelSWI (AngelSWI_Reason_ReportException,
  do_AngelSWI (AngelSWI_Reason_ReportException,
              (void *) ADP_Stopped_ApplicationExit);
              (void *) ADP_Stopped_ApplicationExit);
#else
#else
  asm ("swi %a0" :: "i" (SWI_Exit));
  asm ("swi %a0" :: "i" (SWI_Exit));
#endif
#endif
}
}
 
 
int
int
_getpid (n)
_getpid (int n)
{
{
  return 1;
  return 1;
}
}
 
 
register char *stack_ptr asm ("sp");
register char *stack_ptr asm ("sp");
 
 
caddr_t
caddr_t
_sbrk (int incr)
_sbrk (int incr)
{
{
  extern char end asm ("__end__");      /* Defined by the linker */
  extern char   end asm ("end");        /* Defined by the linker */
  static char *heap_end;
  static char *heap_end;
  char *prev_heap_end;
  char *prev_heap_end;
 
 
  if (heap_end == NULL)
  if (heap_end == NULL)
    {
 
      heap_end = & end;
      heap_end = & end;
    }
 
 
 
  prev_heap_end = heap_end;
  prev_heap_end = heap_end;
 
 
  if (heap_end + incr > stack_ptr)
  if (heap_end + incr > stack_ptr)
    {
    {
Line 443... Line 458...
  st->st_mode = S_IFCHR;
  st->st_mode = S_IFCHR;
  return 0;
  return 0;
}
}
 
 
int
int
_unlink ()
_link (void)
{
{
  return -1;
  return -1;
}
}
 
 
isatty (fd)
int
     int fd;
_unlink (void)
{
{
  return 1;
  return -1;
}
}
 
 
_raise ()
void
 
_raise (void)
{
{
}
}
 
 
int
int
_gettimeofday (struct timeval *tp, struct timezone *tzp)
_gettimeofday (struct timeval *tp, struct timezone *tzp)
Line 506... Line 522...
      tp->tms_utime=timeval;    /* user time */
      tp->tms_utime=timeval;    /* user time */
      tp->tms_stime=0;           /* system time */
      tp->tms_stime=0;           /* system time */
      tp->tms_cutime=0;          /* user time, children */
      tp->tms_cutime=0;          /* user time, children */
      tp->tms_cstime=0;          /* system time, children */
      tp->tms_cstime=0;          /* system time, children */
    }
    }
 
 
  return timeval;
  return timeval;
};
};
 
 
#if 0
 
int
 
_stat (const char *path, struct stat *st)
 
{
 
  asm ("swi %a0" :: "i" (SWI_Stat));
 
}
 
 
 
int
 
_chmod (const char *path, short mode)
 
{
 
  asm ("swi %a0" :: "i" (SWI_Chmod));
 
}
 
 
 
int
isatty (int fd)
_chown (const char *path, short owner, short group)
 
{
{
  asm ("swi %a0" :: "i" (SWI_Chown));
  return 1;
}
 
 
 
int
 
_utime (path, times)
 
     const char *path;
 
     char *times;
 
{
 
  asm ("swi %a0" :: "i" (SWI_Utime));
 
}
 
 
 
int
 
_fork ()
 
{
 
  asm ("swi %a0" :: "i" (SWI_Fork));
 
}
 
 
 
int
 
_wait (statusp)
 
     int *statusp;
 
{
 
  asm ("swi %a0" :: "i" (SWI_Wait));
 
}
 
 
 
int
 
_execve (const char *path, char *const argv[], char *const envp[])
 
{
 
  return _trap3 (SYS_execve, path, argv, envp);
 
}
 
 
 
int
 
_execv (const char *path, char *const argv[])
 
{
 
  return _trap3 (SYS_execv, path, argv);
 
}
 
 
 
int
 
_pipe (int *fd)
 
{
 
  return _trap3 (SYS_pipe, fd);
 
}
}
#endif
 
 
 
alarm()
 
{
 
}
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.