xref: /netbsd-src/sys/arch/zaurus/stand/zboot/unixsys.S (revision 274254cdae52594c1aa480a736aef78313d15c9c)
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@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
31RSYSCALL(exit)
32RSYSCALL(read)
33RSYSCALL(write)
34RSYSCALL(open)
35RSYSCALL(close)
36RSYSCALL(lseek32)
37RSYSCALL(ioctl)
38RSYSCALL(stat)
39
401:
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. */
53ENTRY(syscall)
54	swi	__NR_syscall
55	b	1b
56
57ENTRY(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
75errno:
76	.word	0
77