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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [ldso/] [ldso/] [m68k/] [ld_syscalls.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/*
2
 * This file contains the system call macros and syscall
3
 * numbers used by the shared library loader.
4
 */
5
 
6
#define __NR_exit                 1
7
#define __NR_read                 3
8
#define __NR_write                4
9
#define __NR_open                 5
10
#define __NR_close                6
11
#define __NR_getuid              24
12
#define __NR_geteuid             49
13
#define __NR_getgid              47
14
#define __NR_getegid             50
15
#define __NR_readlink            85
16
#define __NR_mmap                90
17
#define __NR_munmap              91
18
#define __NR_stat               106
19
#define __NR_mprotect           125
20
 
21
 
22
/* Here are the macros which define how this platform makes
23
 * system calls.  This particular variant does _not_ set
24
 * errno (note how it is disabled in __syscall_return) since
25
 * these will get called before the errno symbol is dynamicly
26
 * linked. */
27
 
28
 
29
#define __syscall_return(type, res) \
30
do { \
31
        if ((unsigned long)(res) >= (unsigned long)(-125)) { \
32
        /* avoid using res which is declared to be in register d0; \
33
           errno might expand to a function call and clobber it.  */ \
34
                /* int __err = -(res); \
35
                errno = __err; */ \
36
                res = -1; \
37
        } \
38
        return (type) (res); \
39
} while (0)
40
 
41
#define _syscall0(type, name)                                           \
42
type name(void)                                                         \
43
{                                                                       \
44
  long __res;                                                           \
45
  __asm__ __volatile__ ("movel  %1, %%d0\n\t"                           \
46
                        "trap   #0\n\t"                                 \
47
                        "movel  %%d0, %0"                               \
48
                        : "=g" (__res)                                  \
49
                        : "i" (__NR_##name)                             \
50
                        : "cc", "%d0");                                 \
51
  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                        \
52
    /* errno = -__res; */                                                       \
53
    __res = -1;                                                         \
54
  }                                                                     \
55
  return (type)__res;                                                   \
56
}
57
 
58
#define _syscall1(type, name, atype, a)                                 \
59
type name(atype a)                                                      \
60
{                                                                       \
61
  long __res;                                                           \
62
  __asm__ __volatile__ ("movel  %2, %%d1\n\t"                           \
63
                        "movel  %1, %%d0\n\t"                           \
64
                        "trap   #0\n\t"                                 \
65
                        "movel  %%d0, %0"                               \
66
                        : "=g" (__res)                                  \
67
                        : "i" (__NR_##name),                            \
68
                          "g" ((long)a)                                 \
69
                        : "cc", "%d0", "%d1");                          \
70
  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                        \
71
    /* errno = -__res; */                                                       \
72
    __res = -1;                                                         \
73
  }                                                                     \
74
  return (type)__res;                                                   \
75
}
76
 
77
#define _syscall2(type, name, atype, a, btype, b)                       \
78
type name(atype a, btype b)                                             \
79
{                                                                       \
80
  long __res;                                                           \
81
  __asm__ __volatile__ ("movel  %3, %%d2\n\t"                           \
82
                        "movel  %2, %%d1\n\t"                           \
83
                        "movel  %1, %%d0\n\t"                           \
84
                        "trap   #0\n\t"                                 \
85
                        "movel  %%d0, %0"                               \
86
                        : "=g" (__res)                                  \
87
                        : "i" (__NR_##name),                            \
88
                          "a" ((long)a),                                \
89
                          "g" ((long)b)                                 \
90
                        : "cc", "%d0", "%d1", "%d2");                   \
91
  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                        \
92
    /* errno = -__res; */                                                       \
93
    __res = -1;                                                         \
94
  }                                                                     \
95
  return (type)__res;                                                   \
96
}
97
 
98
#define _syscall3(type, name, atype, a, btype, b, ctype, c)             \
99
type name(atype a, btype b, ctype c)                                    \
100
{                                                                       \
101
  long __res;                                                           \
102
  __asm__ __volatile__ ("movel  %4, %%d3\n\t"                           \
103
                        "movel  %3, %%d2\n\t"                           \
104
                        "movel  %2, %%d1\n\t"                           \
105
                        "movel  %1, %%d0\n\t"                           \
106
                        "trap   #0\n\t"                                 \
107
                        "movel  %%d0, %0"                               \
108
                        : "=g" (__res)                                  \
109
                        : "i" (__NR_##name),                            \
110
                          "a" ((long)a),                                \
111
                          "a" ((long)b),                                \
112
                          "g" ((long)c)                                 \
113
                        : "cc", "%d0", "%d1", "%d2", "%d3");            \
114
  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                        \
115
    /* errno = -__res; */                                                       \
116
    __res = -1;                                                         \
117
  }                                                                     \
118
  return (type)__res;                                                   \
119
}
120
 
121
#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d)   \
122
type name(atype a, btype b, ctype c, dtype d)                           \
123
{                                                                       \
124
  long __res;                                                           \
125
  __asm__ __volatile__ ("movel  %5, %%d4\n\t"                           \
126
                        "movel  %4, %%d3\n\t"                           \
127
                        "movel  %3, %%d2\n\t"                           \
128
                        "movel  %2, %%d1\n\t"                           \
129
                        "movel  %1, %%d0\n\t"                           \
130
                        "trap   #0\n\t"                                 \
131
                        "movel  %%d0, %0"                               \
132
                        : "=g" (__res)                                  \
133
                        : "i" (__NR_##name),                            \
134
                          "a" ((long)a),                                \
135
                          "a" ((long)b),                                \
136
                          "a" ((long)c),                                \
137
                          "g" ((long)d)                                 \
138
                        : "cc", "%d0", "%d1", "%d2", "%d3",             \
139
                          "%d4");                                       \
140
  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                        \
141
    /* errno = -__res; */                                                       \
142
    __res = -1;                                                         \
143
  }                                                                     \
144
  return (type)__res;                                                   \
145
}
146
 
147
#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e)\
148
type name(atype a, btype b, ctype c, dtype d, etype e)                  \
149
{                                                                       \
150
  long __res;                                                           \
151
  __asm__ __volatile__ ("movel  %6, %%d5\n\t"                           \
152
                        "movel  %5, %%d4\n\t"                           \
153
                        "movel  %4, %%d3\n\t"                           \
154
                        "movel  %3, %%d2\n\t"                           \
155
                        "movel  %2, %%d1\n\t"                           \
156
                        "movel  %1, %%d0\n\t"                           \
157
                        "trap   #0\n\t"                                 \
158
                        "movel  %%d0, %0"                               \
159
                        : "=g" (__res)                                  \
160
                        : "i" (__NR_##name),                            \
161
                          "a" ((long)a),                                \
162
                          "a" ((long)b),                                \
163
                          "a" ((long)c),                                \
164
                          "a" ((long)d),                                \
165
                          "g" ((long)e)                                 \
166
                        : "cc", "%d0", "%d1", "%d2", "%d3",             \
167
                          "%d4", "%d5");                                \
168
  if ((unsigned long)(__res) >= (unsigned long)(-125)) {                        \
169
    /* errno = -__res; */                                                       \
170
    __res = -1;                                                         \
171
  }                                                                     \
172
  return (type)__res;                                                   \
173
}
174
 

powered by: WebSVN 2.1.0

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