Kernel - Commenting changes only
[tpg/acess2.git] / Usermode / Libraries / ld-acess.so_src / arch / armv7.S.h
1 //
2 // Acess2 ARMv7 - System Calls
3 //
4
5 .globl _start
6 .extern SoMain
7 _start:
8         pop {r0}
9         ldm sp, {r1,r2,r3}
10         bl SoMain
11         
12         mov r4, r0
13
14         pop {r0,r1,r2}
15         blx r4
16         
17         b _exit
18
19 @ Stupid GCC
20 .globl __ucmpdi2
21 __ucmpdi2:
22         cmp r0, r2
23         movmi r0, #0
24         movmi pc, lr
25         movhi r0, #2
26         movhi pc, lr
27         cmp r1, r2
28         movmi r0, #0
29         movmi pc, lr
30         movhi r0, #2
31         movhi pc, lr
32         mov r0, #1
33         mov pc, lr
34
35 @ Well, can't blame it
36 @ - Clear the instruction cache
37 .globl __clear_cache
38 __clear_cache:
39         svc #0x1001
40         mov pc, lr
41
42
43 @ >r0: PC
44 @ >r1: Pointer to item count
45 @ <r0: Address
46 @ STUBBED
47 __gnu_Unwind_Find_exidx:
48         mov r0, #0
49         str r0, [r1]
50         mov pc, lr
51
52 .section .data
53 .globl _errno
54 _errno: .long   0       @ Placed in .text, to allow use of relative addressing
55 .section .text
56
57 .macro syscall0 _name, _num     
58 .globl \_name
59 \_name:
60         push {lr}
61         svc #\_num
62         @mrc p15, 0, r3, c13, c0, 2
63         ldr r3, =_errno
64         str r2, [r3]
65         pop {pc}
66 .endm
67
68 .macro syscall5 _name, _num
69 .globl \_name
70 \_name:
71         push {r4, lr}
72         ldr r4, [sp,#8]
73         svc #\_num
74         ldr r3, =_errno
75         str r2, [r3]
76         pop {r4, pc}
77 .endm
78
79 .macro syscall6 _name, _num
80 .globl \_name
81 \_name:
82         push {r4,r5,lr}
83         ldr r4, [sp,#12]
84         ldr r5, [sp,#16]
85         svc #\_num
86         ldr r3, =_errno
87         str r2, [r3]
88         pop {r4,r5,pc}
89 .endm
90
91 #define SYSCALL0(_name,_num)    syscall0 _name, _num
92 #define SYSCALL1(_name,_num)    SYSCALL0(_name, _num)
93 #define SYSCALL2(_name,_num)    SYSCALL0(_name, _num)
94 #define SYSCALL3(_name,_num)    SYSCALL0(_name, _num)
95 #define SYSCALL4(_name,_num)    SYSCALL0(_name, _num)
96 // TODO: 5/6 need special handling, because the args are on the stack
97 #define SYSCALL5(_name,_num)    syscall5 _name, _num
98 #define SYSCALL6(_name,_num)    syscall6 _name, _num
99
100 // Override the clone syscall
101 #define _exit   _exit_raw
102 #define _clone  _clone_raw
103 #include "syscalls.s.h"
104 #undef _exit
105 #undef _clone
106
107 .globl _clone
108 _clone:
109         push {r4}
110         mov r4, r1
111         svc #SYS_CLONE
112         ldr r3, =_errno
113         str r2, [r3]
114         tst r4, r4
115         beq _clone_ret
116         @ If in child, set SP
117         tst r0,r0
118         movne sp, r4
119 _clone_ret:
120         pop {r4}
121         mov pc, lr
122
123 .globl _exit
124 _exit:
125         svc #0
126         b .
127

UCC git Repository :: git.ucc.asn.au