Home | History | Annotate | Line # | Download | only in zboot
      1 /*	$NetBSD: unixsys.S,v 1.2 2011/06/20 12:39:21 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 RSYSCALL(fstat)
     40 
     41 1:
     42 	cmn	r0, #4096
     43 	movcc	pc, lr
     44 	rsb	r0, r0, #0
     45 	ldr	r1, .Lerrno	/* XXX clobbers arg1 */
     46 	str	r0, [r1]
     47 	mvn	r0, #0
     48 	mov	pc, lr
     49 
     50 .Lerrno:
     51 	.word	errno
     52 
     53 /* XXX only works for up to four arguments. */
     54 ENTRY(syscall)
     55 	swi	__NR_syscall
     56 	b	1b
     57 
     58 ENTRY(uselect)
     59 	str	r4, [sp, #-4]!
     60 	ldr	r4, [sp, #4]
     61 	swi	__NR_select
     62 	ldr	r4, [sp], #4
     63 	cmn	r0, #4096
     64 	movcc	pc, lr
     65 	rsb	r0, r0, #0
     66 	str	r1, [sp, #-4]!
     67 	ldr	r1, .Lerrno
     68 	str	r0, [r1]
     69 	ldr	r1, [sp], #4
     70 	mvn	r0, #0
     71 	mov	pc, lr
     72 
     73 .data
     74 
     75 	.global errno
     76 errno:
     77 	.word	0
     78