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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [libgloss/] [d30v/] [syscalls.c] - Diff between revs 158 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 158 Rev 816
/*
/*
 * syscalls.c -- provide system call support via trap 31
 * syscalls.c -- provide system call support via trap 31
 *
 *
 * Copyright (c) 1997 Cygnus Support
 * Copyright (c) 1997 Cygnus Support
 *
 *
 * The authors hereby grant permission to use, copy, modify, distribute,
 * The authors hereby grant permission to use, copy, modify, distribute,
 * and license this software and its documentation for any purpose, provided
 * and license this software and its documentation for any purpose, provided
 * that existing copyright notices are retained in all copies and that this
 * that existing copyright notices are retained in all copies and that this
 * notice is included verbatim in any distributions. No written agreement,
 * notice is included verbatim in any distributions. No written agreement,
 * license, or royalty fee is required for any of the authorized uses.
 * license, or royalty fee is required for any of the authorized uses.
 * Modifications to this software may be copyrighted by their authors
 * Modifications to this software may be copyrighted by their authors
 * and need not follow the licensing terms described here, provided that
 * and need not follow the licensing terms described here, provided that
 * the new terms are clearly indicated on the first page of each file where
 * the new terms are clearly indicated on the first page of each file where
 * they apply.
 * they apply.
 *
 *
 * Read bytes, using simulator trap 31.
 * Read bytes, using simulator trap 31.
 */
 */
 
 
#include <stdlib.h>
#include <stdlib.h>
#include <time.h>
#include <time.h>
#include "syscall.h"
#include "syscall.h"
 
 
extern int *__errno(), errno;
extern int *__errno(), errno;
 
 
__asm__ (
__asm__ (
"       .globl  __syscall                                       \n\
"       .globl  __syscall                                       \n\
        .type   __syscall,@function                             \n\
        .type   __syscall,@function                             \n\
__syscall:                                                      \n\
__syscall:                                                      \n\
        trap    31              || nop                          \n\
        trap    31              || nop                          \n\
        cmpge   f0,r2,0         -> jmp/tx       link            \n\
        cmpge   f0,r2,0         -> jmp/tx       link            \n\
        bra     __set_errno                                     \n\
        bra     __set_errno                                     \n\
        .size   __syscall,.-__syscall                           \n\
        .size   __syscall,.-__syscall                           \n\
");
");
 
 
int
int
__set_errno (int new_errno)
__set_errno (int new_errno)
{
{
  errno = new_errno;
  errno = new_errno;
  *(__errno)() = errno;
  *(__errno)() = errno;
  return -1;
  return -1;
}
}
 
 
void
void
_exit (int status)
_exit (int status)
{
{
  __syscall (status, 0, 0, 0, SYS_exit);
  __syscall (status, 0, 0, 0, SYS_exit);
}
}
 
 
int
int
open (const char *filename, int flags, int mode)
open (const char *filename, int flags, int mode)
{
{
  return __syscall (filename, flags, mode, 0, SYS_open);
  return __syscall (filename, flags, mode, 0, SYS_open);
}
}
 
 
int
int
close (int filedes)
close (int filedes)
{
{
  return __syscall (filedes, 0, 0, 0, SYS_close);
  return __syscall (filedes, 0, 0, 0, SYS_close);
}
}
 
 
int
int
read (int filedes, void *buffer, size_t length)
read (int filedes, void *buffer, size_t length)
{
{
  return __syscall (filedes, buffer, length, 0, SYS_read);
  return __syscall (filedes, buffer, length, 0, SYS_read);
}
}
 
 
int
int
write (int filedes, void *buffer, size_t length)
write (int filedes, void *buffer, size_t length)
{
{
  return __syscall (filedes, buffer, length, 0, SYS_write);
  return __syscall (filedes, buffer, length, 0, SYS_write);
}
}
 
 
long
long
lseek (int filedes, long offset, int whence)
lseek (int filedes, long offset, int whence)
{
{
  return __syscall (filedes, offset, whence, 0, SYS_lseek);
  return __syscall (filedes, offset, whence, 0, SYS_lseek);
}
}
 
 
int
int
unlink (const char *filename)
unlink (const char *filename)
{
{
  return __syscall (filename, 0, 0, 0, SYS_unlink);
  return __syscall (filename, 0, 0, 0, SYS_unlink);
}
}
 
 
int
int
getpid (void)
getpid (void)
{
{
  return __syscall (0, 0, 0, 0, SYS_getpid);
  return __syscall (0, 0, 0, 0, SYS_getpid);
}
}
 
 
int
int
kill (int signal, int pid)
kill (int signal, int pid)
{
{
  return __syscall (signal, pid, 0, 0, SYS_kill);
  return __syscall (signal, pid, 0, 0, SYS_kill);
}
}
 
 
int
int
fstat (int filedes, void *info)
fstat (int filedes, void *info)
{
{
  return __syscall (filedes, info, 0, 0, SYS_fstat);
  return __syscall (filedes, info, 0, 0, SYS_fstat);
}
}
 
 
int
int
__argvlen (void)
__argvlen (void)
{
{
  return __syscall (0, 0, 0, 0, SYS_argvlen);
  return __syscall (0, 0, 0, 0, SYS_argvlen);
}
}
 
 
int
int
__argv (void)
__argv (void)
{
{
  return __syscall (0, 0, 0, 0, SYS_argv);
  return __syscall (0, 0, 0, 0, SYS_argv);
}
}
 
 
int
int
chdir (char *dir)
chdir (char *dir)
{
{
  return __syscall (dir, 0, 0, 0, SYS_chdir);
  return __syscall (dir, 0, 0, 0, SYS_chdir);
}
}
 
 
int
int
stat (const char *filename, void *info)
stat (const char *filename, void *info)
{
{
  return __syscall (filename, info, 0, 0, SYS_stat);
  return __syscall (filename, info, 0, 0, SYS_stat);
}
}
 
 
int
int
chmod (const char *filename, int mode)
chmod (const char *filename, int mode)
{
{
  return __syscall (filename, mode, 0, 0, SYS_chmod);
  return __syscall (filename, mode, 0, 0, SYS_chmod);
}
}
 
 
int
int
utime (const char *filename, void *packet)
utime (const char *filename, void *packet)
{
{
  return __syscall (filename, packet, 0, 0, SYS_utime);
  return __syscall (filename, packet, 0, 0, SYS_utime);
}
}
 
 
time_t
time_t
time (time_t *time_ptr)
time (time_t *time_ptr)
{
{
  time_t result;
  time_t result;
  result = (time_t) __syscall (time_ptr, 0, 0, 0, SYS_time);
  result = (time_t) __syscall (time_ptr, 0, 0, 0, SYS_time);
  if (time_ptr != NULL)
  if (time_ptr != NULL)
    *time_ptr = result;
    *time_ptr = result;
  return result;
  return result;
}
}
 
 

powered by: WebSVN 2.1.0

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