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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [libgloss/] [d30v/] [syscalls.c] - Blame information for rev 56

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 56 joel
/*
2
 * syscalls.c -- provide system call support via trap 31
3
 *
4
 * Copyright (c) 1997 Cygnus Support
5
 *
6
 * The authors hereby grant permission to use, copy, modify, distribute,
7
 * and license this software and its documentation for any purpose, provided
8
 * that existing copyright notices are retained in all copies and that this
9
 * notice is included verbatim in any distributions. No written agreement,
10
 * license, or royalty fee is required for any of the authorized uses.
11
 * Modifications to this software may be copyrighted by their authors
12
 * and need not follow the licensing terms described here, provided that
13
 * the new terms are clearly indicated on the first page of each file where
14
 * they apply.
15
 *
16
 * Read bytes, using simulator trap 31.
17
 */
18
 
19
#include <stdlib.h>
20
#include "syscall.h"
21
 
22
extern int *__errno(), errno;
23
 
24
__asm__ (
25
"       .globl  __syscall
26
        .type   __syscall,@function
27
__syscall:
28
        trap    31              || nop
29
        cmpge   f0,r2,0         -> jmp/tx       link
30
        bra     __set_errno
31
        .size   __syscall,.-__syscall
32
");
33
 
34
int
35
__set_errno (int new_errno)
36
{
37
  errno = new_errno;
38
  *(__errno)() = errno;
39
  return -1;
40
}
41
 
42
void
43
_exit (int status)
44
{
45
  __syscall (status, 0, 0, 0, SYS_exit);
46
}
47
 
48
int
49
open (const char *filename, int flags, int mode)
50
{
51
  return __syscall (filename, flags, mode, 0, SYS_open);
52
}
53
 
54
int
55
close (int filedes)
56
{
57
  return __syscall (filedes, 0, 0, 0, SYS_close);
58
}
59
 
60
int
61
read (int filedes, void *buffer, size_t length)
62
{
63
  return __syscall (filedes, buffer, length, 0, SYS_read);
64
}
65
 
66
int
67
write (int filedes, void *buffer, size_t length)
68
{
69
  return __syscall (filedes, buffer, length, 0, SYS_write);
70
}
71
 
72
long
73
lseek (int filedes, long offset, int whence)
74
{
75
  return __syscall (filedes, offset, whence, 0, SYS_lseek);
76
}
77
 
78
int
79
unlink (const char *filename)
80
{
81
  return __syscall (filename, 0, 0, 0, SYS_unlink);
82
}
83
 
84
int
85
getpid (void)
86
{
87
  return __syscall (0, 0, 0, 0, SYS_getpid);
88
}
89
 
90
int
91
kill (int signal, int pid)
92
{
93
  return __syscall (signal, pid, 0, 0, SYS_kill);
94
}
95
 
96
int
97
fstat (int filedes, void *info)
98
{
99
  return __syscall (filedes, info, 0, 0, SYS_fstat);
100
}
101
 
102
int
103
__argvlen (void)
104
{
105
  return __syscall (0, 0, 0, 0, SYS_argvlen);
106
}
107
 
108
int
109
__argv (void)
110
{
111
  return __syscall (0, 0, 0, 0, SYS_argv);
112
}
113
 
114
int
115
chdir (char *dir)
116
{
117
  return __syscall (dir, 0, 0, 0, SYS_chdir);
118
}
119
 
120
int
121
stat (const char *filename, void *info)
122
{
123
  return __syscall (filename, info, 0, 0, SYS_stat);
124
}
125
 
126
int
127
chmod (const char *filename, int mode)
128
{
129
  return __syscall (filename, mode, 0, 0, SYS_chmod);
130
}
131
 
132
int
133
utime (const char *filename, void *packet)
134
{
135
  return __syscall (filename, packet, 0, 0, SYS_utime);
136
}
137
 
138
time_t
139
time (time_t *time_ptr)
140
{
141
  time_t result;
142
  result = (time_t) __syscall (time_ptr, 0, 0, 0, SYS_time);
143
  if (time_ptr != NULL)
144
    *time_ptr = result;
145
  return result;
146
}

powered by: WebSVN 2.1.0

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