summaryrefslogtreecommitdiffstats
path: root/usr/klibc/arch/arm/syscall.S
blob: e5b04e29ea9a83da0558278836f8e5250c71d09b (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
/*
 * arch/arm/syscall.S
 *
 * System call common handling
 */

	.type	__syscall_common,#function
	.globl	__syscall_common
#ifndef __thumb__
	/* ARM version - this is executed after the swi, unless
	   we are compiled in EABI mode */

	.balign	4
__syscall_common:
#ifdef __ARM_EABI__
	ldr	r4, [sp,#16]
	ldr	r5, [sp,#20]
	ldr	r7, [lr]
	swi	0
#endif
        cmn     r0, #4096
        rsbcs	r2, r0, #0
        ldrcs	r3, 1f
        mvncs	r0, #0
        strcs	r2, [r3]
#ifdef __ARM_EABI__
	ldmfd	sp!,{r4,r5,r7,pc}
#else
	ldmfd	sp!,{r4,r5,pc}
#endif

	.balign 4
1:
	.word	errno

#else
	/* Thumb version - must still load r4 and r5 and run swi */

	.thumb_func
	.balign	2
__syscall_common:
	mov	r7, lr
	ldr	r4, [sp,#16]
	sub	r7, #1		/* Remove the Thumb bit */
	ldr	r5, [sp,#20]
	ldrh	r7, [r7]
	swi	0
	ldr	r1, 2f
	cmp	r0, r1
	bcc	1f
	ldr	r1, 3f
	neg	r2, r0
	mov	r0, #1
	str	r2, [r1]
	neg	r0, r0
1:
	pop	{r4,r5,r7,pc}

	.balign	4
2:
	.word	-4095
3:
	.word	errno

#endif