unixsys.S revision 1.1 1 /* $NetBSD: unixsys.S,v 1.1 2009/03/02 09:33:02 nonaka Exp $ */
2 /* $OpenBSD: unixsys.S,v 1.6 2005/05/24 20:38:20 uwe Exp $ */
3
4 /*
5 * Copyright (c) 2005 Uwe Stuehler <uwe (at) bsdx.de>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20 #include <machine/asm.h>
21
22 #include "compat_linux.h"
23
24 .text
25
26 #define RSYSCALL(x) \
27 ENTRY(__CONCAT(u,x)) \
28 swi __CONCAT(__NR_,x); \
29 b 1f
30
31 RSYSCALL(exit)
32 RSYSCALL(read)
33 RSYSCALL(write)
34 RSYSCALL(open)
35 RSYSCALL(close)
36 RSYSCALL(lseek32)
37 RSYSCALL(ioctl)
38 RSYSCALL(stat)
39
40 1:
41 cmn r0, #4096
42 movcc pc, lr
43 rsb r0, r0, #0
44 ldr r1, .Lerrno /* XXX clobbers arg1 */
45 str r0, [r1]
46 mvn r0, #0
47 mov pc, lr
48
49 .Lerrno:
50 .word errno
51
52 /* XXX only works for up to four arguments. */
53 ENTRY(syscall)
54 swi __NR_syscall
55 b 1b
56
57 ENTRY(uselect)
58 str r4, [sp, #-4]!
59 ldr r4, [sp, #4]
60 swi __NR_select
61 ldr r4, [sp], #4
62 cmn r0, #4096
63 movcc pc, lr
64 rsb r0, r0, #0
65 str r1, [sp, #-4]!
66 ldr r1, .Lerrno
67 str r0, [r1]
68 ldr r1, [sp], #4
69 mvn r0, #0
70 mov pc, lr
71
72 .data
73
74 .global errno
75 errno:
76 .word 0
77