1 | /* Copyright (C) 2009 Clozure Associates */ |
---|
2 | /* Copyright (C) 1994-2001 Digitool, Inc */ |
---|
3 | /* This file is part of Clozure CL. */ |
---|
4 | |
---|
5 | /* Clozure CL is licensed under the terms of the Lisp Lesser GNU Public */ |
---|
6 | /* License , known as the LLGPL and distributed with Clozure CL as the */ |
---|
7 | /* file "LICENSE". The LLGPL consists of a preamble and the LGPL, */ |
---|
8 | /* which is distributed with Clozure CL as the file "LGPL". Where these */ |
---|
9 | /* conflict, the preamble takes precedence. */ |
---|
10 | |
---|
11 | /* Clozure CL is referenced in the preamble as the "LIBRARY." */ |
---|
12 | |
---|
13 | /* The LLGPL is also available online at */ |
---|
14 | /* http://opensource.franz.com/preamble.html */ |
---|
15 | |
---|
16 | |
---|
17 | .syntax unified |
---|
18 | .arm |
---|
19 | |
---|
20 | include(lisp.s) |
---|
21 | |
---|
22 | _beginfile |
---|
23 | |
---|
24 | /* Force data from r0, size r1 into the icache */ |
---|
25 | _exportfn(C(flush_cache_lines)) |
---|
26 | __ifdef(`LINUX') |
---|
27 | __(add r1,r1,r0) |
---|
28 | __(mov r2,#0) /* options. Pass as 0 until we know better */ |
---|
29 | __(mov r12,r7) /* preserve r7 ; r12 saved by syscall */ |
---|
30 | __(mov r7,#0x0f0000) /* __ARM_NR_cacheflush */ |
---|
31 | __(add r7,r7,#2) |
---|
32 | __(svc #0) |
---|
33 | __(mov r7,r12) |
---|
34 | __endif |
---|
35 | __ifdef(`DARWIN') |
---|
36 | __(mov r3,#0) |
---|
37 | __(mov r12,#0x80000000) |
---|
38 | __(svc #0) |
---|
39 | __endif |
---|
40 | __(bx lr) |
---|
41 | |
---|
42 | _exportfn(C(touch_page)) |
---|
43 | __(str r0,[r0,#0]) |
---|
44 | __(mov r1,#0) |
---|
45 | __(str r1,[r0,#0]) |
---|
46 | __(mov r0,#1) |
---|
47 | .globl C(touch_page_end) |
---|
48 | C(touch_page_end): |
---|
49 | __(bx lr) |
---|
50 | _endfn |
---|
51 | |
---|
52 | _exportfn(C(current_stack_pointer)) |
---|
53 | __(mov r0,sp) |
---|
54 | __(bx lr) |
---|
55 | _endfn |
---|
56 | |
---|
57 | _exportfn(C(count_leading_zeros)) |
---|
58 | __(clz r0,r0) |
---|
59 | __(bx lr) |
---|
60 | _endfn |
---|
61 | |
---|
62 | _exportfn(C(noop)) |
---|
63 | __(bx lr) |
---|
64 | _endfn |
---|
65 | |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | /* Atomically store new value (r2) in *r0, if old value == expected (r1). */ |
---|
71 | /* Return actual old value. */ |
---|
72 | .globl C(arm_architecture_version) |
---|
73 | _exportfn(C(store_conditional)) |
---|
74 | 0: __(ldrex r3,[r0]) |
---|
75 | __(cmp r3,r1) |
---|
76 | __(bne 1f) |
---|
77 | __(strex ip,r2,[r0]) |
---|
78 | __(cmp ip,#0) |
---|
79 | __(bne 0b) |
---|
80 | __(b 2f) |
---|
81 | 1: __(adr ip,3f) |
---|
82 | __(ldr ip,[ip]) |
---|
83 | __(ldr ip,[ip]) |
---|
84 | __(cmp ip,#7) |
---|
85 | __(blt 2f) |
---|
86 | .long 0xf57ff01f |
---|
87 | 2: __(mov r0,r3) |
---|
88 | __(bx lr) |
---|
89 | 3: .long C(arm_architecture_version) |
---|
90 | _endfn |
---|
91 | |
---|
92 | /* Atomically store new_value(r1) in *r0 ; return previous contents */ |
---|
93 | /* of *r0. */ |
---|
94 | |
---|
95 | _exportfn(C(atomic_swap)) |
---|
96 | __(mov r2,r0) |
---|
97 | 0: __(ldrex r0,[r2]) |
---|
98 | __(strex r3,r1,[r2]) |
---|
99 | __(cmp r3,#0) |
---|
100 | __(bne 0b) |
---|
101 | __(bx lr) |
---|
102 | _endfn |
---|
103 | |
---|
104 | /* Logior the value in *r0 with the value in r1 (presumably a bitmask with exactly 1 */ |
---|
105 | /* bit set.) Return non-zero if any of the bits in that bitmask were already set. */ |
---|
106 | |
---|
107 | _exportfn(C(atomic_ior)) |
---|
108 | __(stmdb sp!,{r4,lr}) |
---|
109 | 0: __(ldrex r2,[r0]) |
---|
110 | __(orr r3,r2,r1) |
---|
111 | __(strex r4,r3,[r0]) |
---|
112 | __(cmp r4,#0) |
---|
113 | __(bne 0b) |
---|
114 | __(mov r0,r2) |
---|
115 | __(ldmia sp!,{r4,pc}) |
---|
116 | _endfn |
---|
117 | |
---|
118 | |
---|
119 | /* Logand the value in *r0 with the value in r1 (presumably a bitmask with exactly 1 */ |
---|
120 | /* bit set.) Return the value now in *r0 (for some value of "now" */ |
---|
121 | |
---|
122 | _exportfn(C(atomic_and)) |
---|
123 | 0: __(ldrex r2,[r0]) |
---|
124 | __(and r2,r2,r1) |
---|
125 | __(strex r3,r2,[r0]) |
---|
126 | __(cmp r3,#0) |
---|
127 | __(bne 0b) |
---|
128 | __(mov r0,r2) |
---|
129 | __(bx lr) |
---|
130 | _endfn |
---|
131 | |
---|
132 | |
---|
133 | __ifdef(`DARWIN') |
---|
134 | _exportfn(C(enable_fp_exceptions)) |
---|
135 | __(.long 0) |
---|
136 | __(bx lr) |
---|
137 | _endfn |
---|
138 | |
---|
139 | _exportfn(C(disable_fp_exceptions)) |
---|
140 | __(.long 0) |
---|
141 | __(bx lr) |
---|
142 | _endfn |
---|
143 | |
---|
144 | _exportfn(C(pseudo_sigreturn)) |
---|
145 | __(uuo_pseudo_sigreturn()) |
---|
146 | __(b C(pseudo_sigreturn)) |
---|
147 | _endfn |
---|
148 | __endif |
---|
149 | |
---|
150 | _exportfn(C(save_fp_context)) |
---|
151 | __(uuo_debug_trap(al)) |
---|
152 | _endfn |
---|
153 | _exportfn(C(restore_fp_context)) |
---|
154 | __(uuo_debug_trap(al)) |
---|
155 | _endfn |
---|
156 | _exportfn(C(put_vector_registers)) |
---|
157 | __(uuo_debug_trap(al)) |
---|
158 | _endfn |
---|
159 | _exportfn(C(get_vector_registers)) |
---|
160 | __(uuo_debug_trap(al)) |
---|
161 | _endfn |
---|
162 | |
---|
163 | __ifdef(`ANDROID') |
---|
164 | _exportfn(rt_sigprocmask) |
---|
165 | __(stmdb sp!,{r7,lr}) |
---|
166 | __(mov r7,#175) |
---|
167 | __(svc #0) |
---|
168 | __(ldmia sp!,{r7,pc}) |
---|
169 | _endfn |
---|
170 | __endif |
---|
171 | |
---|
172 | |
---|
173 | __ifdef(`DARWIN') |
---|
174 | /* divide the 64-bit unsigned integer in r0/r1 by the 64-bit unsigned |
---|
175 | integer in r2/r3; return the 64-bit quotient in r0/r1 and the 64-bit |
---|
176 | remainder in r2/r3. Implement this in terms of the libgcc function: |
---|
177 | |
---|
178 | unsigned long long __udivti3 (unsigned long long a, |
---|
179 | unsigned long long b, |
---|
180 | unsigned long long *c) |
---|
181 | */ |
---|
182 | _exportfn(C(__aeabi_uldivmod)) |
---|
183 | __(stmdb sp!,{r7,lr}) |
---|
184 | __(mov r7,sp) |
---|
185 | __(sub sp,sp,#8) |
---|
186 | __(mov ip,sp) |
---|
187 | __(push1(ip,sp)) |
---|
188 | __(push1(ip,sp)) |
---|
189 | __(bl C(__udivmoddi4)) |
---|
190 | __(add sp,sp,#8) |
---|
191 | __(ldmia sp!,{r2,r3}) |
---|
192 | __(ldmia sp!,{r7,pc}) |
---|
193 | _endfn |
---|
194 | __endif |
---|
195 | |
---|
196 | _exportfn(call_handler_on_main_stack) |
---|
197 | __(ldr ip,[sp]) |
---|
198 | __(mov lr,r3) |
---|
199 | __(mov sp,r1) |
---|
200 | __(bx ip) |
---|
201 | _endfn |
---|
202 | |
---|
203 | /* zero N (r1) dnodes, starting at the dnode-aligned address in r0 */ |
---|
204 | _exportfn(C(zero_dnodes)) |
---|
205 | __(cmp r1,#0) |
---|
206 | __(adr r2,2f) |
---|
207 | __(fldd d0,[r2,#0]) |
---|
208 | __(b 1f) |
---|
209 | 0: __(subs r1,r1,#1) |
---|
210 | __(fstd d0,[r0]) |
---|
211 | __(add r0,r0,#dnode_size) |
---|
212 | 1: __(bne 0b) |
---|
213 | __(bx lr) |
---|
214 | .align 3 |
---|
215 | 2: .long 0 |
---|
216 | .long 0 |
---|
217 | _endfn |
---|
218 | |
---|
219 | _exportfn(C(feature_check)) |
---|
220 | .globl C(feature_check_ldrex) |
---|
221 | .globl C(feature_check_clrex) |
---|
222 | .globl C(feature_check_fpu) |
---|
223 | C(feature_check_fpu): |
---|
224 | __(fcmpd d15,d15) |
---|
225 | C(feature_check_ldrex): |
---|
226 | __(ldrex r2,[sp]) |
---|
227 | C(feature_check_clrex): |
---|
228 | __(.long 0xf57ff01f) /* clrex */ |
---|
229 | __(bx lr) |
---|
230 | _endfn |
---|
231 | _endfile |
---|
232 | |
---|