aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/sys/d10v/trap.S
blob: 9aca429132172f99c07b133c4cf82cbb29b4f98c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#include "sys/syscall.h"

#define SYSCALL(name) \
	.global name	; \
name:			; \
	ldi	r4, SYS ## name ; \
	bra	__trap0

	.text
	.stabs	"trap.S",100,0,0,__trap0
	.stabs	"int:t(0,1)=r(0,1);-65536;65535;",128,0,0,0
	.stabs	"long int:t(0,2)=r(0,1);0020000000000;0017777777777;",128,0,0,0
	.stabs	"_trap0:F(0,1)",36,0,1,__trap0
	.stabs	"arg1:P(0,1)",64,0,1,0
	.stabs	"arg2:P(0,1)",64,0,1,1
	.stabs	"arg3:P(0,1)",64,0,1,2
	.stabs	"arg4:P(0,1)",64,0,1,3
	.stabs	"number:P(0,1)",64,0,1,4
	.global	__trap0
	.type	__trap0,@function
__trap0:
	trap	15			/* trap 15 returns result in r0, error code in r4 */
	cmpeqi	r4,0			/* is error code zero? */
	brf0t	ret			/* yes, skip setting errno */
#if __INT__==32
	st	r4,@(errno+2,r14)	/* no, set errno */
	srai	r4,15			/* sign extend high word */
	st	r4,@(errno,r14)
#else
	st	r4,@(errno,r14)	/* no, set errno */
#endif

ret:
	jmp	r13		/* return to caller */
.Ltrap0:
	.size	__trap0,.Ltrap0-__trap0
	.stabs	"",36,0,0,.Ltrap0-__trap0

#define CONCAT(a,b) a ## b
#define STRING(a) #a
#define XSTRING(a) STRING(a)
#define XSTRING2(a,b) XSTRING(CONCAT(a,b))

#if __INT__==32
#define _read _read16
#define _lseek _lseek16
#define _write _write16
#define _close _close16
#define _open _open16
#define _creat _creat16
#define _exit _exit16
#define _stat _stat16
#define _chmod _chmod16
#define _chown _chown16
#define _fork _fork16
#define _wait _wait16
#define _execve _execve16
#define _execv _execv16
#define _pipe _pipe16
#define _kill _kill16
#define _getpid _getpid16
#endif

/* Until the assembler allows semicolon as a statement separator, */
/* we cannot use the SYSCALL macro.  So expand it manually for now. */

/* #SYSCALL(_read) */
/* #SYSCALL(_lseek) */
/* #SYSCALL(_write) */
/* #SYSCALL(_close) */
/* #SYSCALL(_open) */
/* #SYSCALL(_creat) */
/* #SYSCALL(_exit) */
/* #SYSCALL(_stat) */
/* #SYSCALL(_chmod) */
/* #SYSCALL(_chown) */
/* #SYSCALL(_fork) */
/* #SYSCALL(_wait) */
/* #SYSCALL(_execve) */
/* #SYSCALL(_execv) */
/* #SYSCALL(_pipe) */
/* #SYSCALL(_getpid) */
/* #SYSCALL(_kill) */

	.global	_read
	.type	_read,@function
	.stabs	XSTRING2(_read,:F(0,1)),36,0,2,_read
	.stabs	"fd:P(0,1)",64,0,1,0
	.stabs	"ptr:P(0,1)",64,0,1,1
	.stabs	"len:P(0,1)",64,0,1,2
_read:
	ldi	r4, SYS_read
	bra	__trap0
.Lread:
	.size	_read,.-_read
	.stabs	"",36,0,0,.Lread-_read

	.global	_lseek
	.type	_lseek,@function
	.stabs	XSTRING2(_lseek,:F(0,1)),36,0,3,_lseek
	.stabs	"fd:P(0,1)",64,0,1,0
	.stabs	"offset:P(0,1)",64,0,1,2
	.stabs	"whence:p(0,1)",160,0,1,0
_lseek:
	ldi	r4, SYS_lseek
	bra	__trap0
.Llseek:
	.size	_lseek,.Llseek-_lseek
	.stabs	"",36,0,0,.Llseek-_lseek

	.global	_write
	.type	_write,@function
	.stabs	XSTRING2(_write,:F(0,1)),36,0,4,_write
	.stabs	"fd:P(0,1)",64,0,1,0
	.stabs	"ptr:P(0,1)",64,0,1,1
	.stabs	"len:P(0,1)",64,0,1,2
_write:
	ldi	r4, SYS_write
	bra	__trap0
.Lwrite:
	.size	_write,.Lwrite-_write
	.stabs	"",36,0,0,.Lwrite-_write

	.global	_close
	.type	_close,@function
	.stabs	XSTRING2(_close,:F(0,1)),36,0,5,_close
	.stabs	"fd:P(0,1)",64,0,1,0
_close:
	ldi	r4, SYS_close
	bra	__trap0
.Lclose:
	.size	_close,.Lclose-_close
	.stabs	"",36,0,0,.Lclose-_close

	.global	_open
	.type	_open,@function
	.stabs	XSTRING2(_open,:F(0,1)),36,0,6,_open
	.stabs	"name:P(0,1)",64,0,1,0
	.stabs	"flags:P(0,1)",64,0,1,1
	.stabs	"mode:P(0,1)",64,0,1,2
_open:
	ldi	r4, SYS_open
	bra	__trap0
.Lopen:
	.size	_open,.Lopen-_open
	.stabs	"",36,0,0,.Lopen-_open

	.global	_creat
	.type	_creat,@function
	.stabs	XSTRING2(_creat,:F(0,1)),36,0,7,_creat
	.stabs	"name:P(0,1)",64,0,1,0
	.stabs	"mode:P(0,1)",64,0,1,1
_creat:
	ldi	r4, SYS_creat
	bra	__trap0
.Lcreat:
	.size	_creat,.Lcreat-_creat
	.stabs	"",36,0,0,.Lcreat-_creat

	.global	_exit
	.type	_exit,@function
	.stabs	XSTRING2(_exit,:F(0,1)),36,0,8,_exit
	.stabs	"status:P(0,1)",64,0,1,0
_exit:
	ldi	r4, SYS_exit
	bra	__trap0
.Lexit:
	.size	_exit,.Lexit-_exit
	.stabs	"",36,0,0,.Lexit-_exit

	.global	_stat
	.type	_stat,@function
	.stabs	XSTRING2(_stat,:F(0,1)),36,0,9,_stat
	.stabs	"name:P(0,1)",64,0,1,0
	.stabs	"packet:P(0,1)",64,0,1,1
_stat:
	ldi	r4, SYS_stat
	bra	__trap0
.Lstat:
	.size	_stat,.Lstat-_stat
	.stabs	"",36,0,0,.Lstat-_stat

	.global	_chmod
	.type	_chmod,@function
	.stabs	XSTRING2(_chmod,:F(0,1)),36,0,10,_chmod
	.stabs	"name:P(0,1)",64,0,1,0
	.stabs	"mode:P(0,1)",64,0,1,1
_chmod:
	ldi	r4, SYS_chmod
	bra	__trap0
.Lchmod:
	.size	_chmod,.Lchmod-_chmod
	.stabs	"",36,0,0,.Lchmod-_chmod

	.global	_chown
	.type	_chown,@function
	.stabs	XSTRING2(_chown,:F(0,1)),36,0,11,_chown
	.stabs	"name:P(0,1)",64,0,1,0
	.stabs	"uid:P(0,1)",64,0,1,1
	.stabs	"gid:P(0,1)",64,0,1,2
_chown:
	ldi	r4, SYS_chown
	bra	__trap0
.Lchown:
	.size	_chown,.Lchown-_chown
	.stabs	"",36,0,0,.Lchown-_chown

	.global	_fork
	.type	_fork,@function
	.stabs	XSTRING2(_fork,:F(0,1)),36,0,12,_fork
_fork:
	ldi	r4, SYS_fork
	bra	__trap0
.Lfork:
	.size	_fork,.Lfork-_fork
	.stabs	"",36,0,0,.Lfork-_fork

	.global	_wait
	.type	_wait,@function
	.stabs	"status:P(0,1)",64,0,1,0
	.stabs	XSTRING2(_wait,:F(0,1)),36,0,13,_wait
_wait:
	ldi	r4, SYS_wait
	bra	__trap0
.Lwait:
	.size	_wait,.Lwait-_wait
	.stabs	"",36,0,0,.Lwait-_wait

	.global	_execve
	.type	_execve,@function
	.stabs	"name:P(0,1)",64,0,1,0
	.stabs	"argv:P(0,1)",64,0,1,1
	.stabs	"envp:P(0,1)",64,0,1,2
	.stabs	XSTRING2(_execve,:F(0,1)),36,0,14,_execve
_execve:
	ldi	r4, SYS_execve
	bra	__trap0
.Lexecve:
	.size	_execve,.Lexecve-_execve
	.stabs	"",36,0,0,.Lexecve-_execve

	.global	_execv
	.type	_execv,@function
	.stabs	XSTRING2(_execv,:F(0,1)),36,0,15,_execv
	.stabs	"name:P(0,1)",64,0,1,0
	.stabs	"argv:P(0,1)",64,0,1,1
_execv:
	ldi	r4, SYS_execv
	bra	__trap0
.Lexecv:
	.size	_execv,.Lexecv-_execv
	.stabs	"",36,0,0,.Lexecv-_execv

	.global	_pipe
	.type	_pipe,@function
	.stabs	XSTRING2(_pipe,:F(0,1)),36,0,16,_pipe
	.stabs	"fds:P(0,1)",64,0,1,0
_pipe:
	ldi	r4, SYS_pipe
	bra	__trap0
.Lpipe:
	.size	_pipe,.Lpipe-_pipe
	.stabs	"",36,0,0,.Lpipe-_pipe

	.global	time
	.type	time,@function
	.stabs	XSTRING2(time,:F(0,1)),36,0,17,time
	.stabs	"ptr:P(0,1)",64,0,1,0
time:
	ldi	r4, SYS_time
	bra	__trap0
.Ltime:
	.size	time,.Ltime-time
	.stabs	"",36,0,0,.Ltime-time

	.global	_kill
	.type	_kill,@function
	.stabs	XSTRING2(_kill,:F(0,1)),36,0,18,_kill
	.stabs	"pid:P(0,1)",64,0,1,0
	.stabs	"sig:P(0,1)",64,0,1,1
_kill:
	ldi	r4, SYS_kill
	bra	__trap0
.Lkill:
	.size	_kill,.Lkill-_kill
	.stabs	"",36,0,0,.Lkill-_kill

	.global	_getpid
	.type	_getpid,@function
	.stabs	XSTRING2(_getpid,:F(0,1)),36,0,19,_getpid
_getpid:
	ldi	r4, SYS_getpid
	bra	__trap0
.Lgetpid:
	.size	_getpid,.Lgetpid-_getpid
	.stabs	"",36,0,0,.Lgetpid-_getpid