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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
; $NetBSD: arm.asm,v 1.9 2010/04/06 16:20:28 nonaka Exp $
;
; Copyright (c) 2001 The NetBSD Foundation, Inc.
; All rights reserved.
;
; This code is derived from software contributed to The NetBSD Foundation
; by UCHIYAMA Yasushi.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions
; are met:
; 1. Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; 2. Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
;
; THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
; BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
; POSSIBILITY OF SUCH DAMAGE.
;
;
;armasm.exe $(InputPath)
;arm.obj
;
; dummy buffer for WritebackDCache
EXPORT |dcachesize| [DATA]
EXPORT |dcachebuf| [DATA]
AREA |.data|, DATA
|dcachesize|
DCD 8192 ; for SA1100
|dcachebuf|
% 65536 ; max D-cache size
AREA |.text|, CODE, PIC
;
; Operation mode ops.
;
EXPORT |SetSVCMode|
|SetSVCMode| PROC
mrs r0, cpsr
bic r0, r0, #0x1f
orr r0, r0, #0x13
msr cpsr, r0
mov pc, lr
ENDP ; |SetSVCMode|
EXPORT |SetSystemMode|
|SetSystemMode| PROC
mrs r0, cpsr
orr r0, r0, #0x1f
msr cpsr, r0
mov pc, lr
ENDP ; |SetSystemMode|
;
; Interrupt ops.
;
EXPORT |DI|
|DI| PROC
mrs r0, cpsr
orr r0, r0, #0xc0
msr cpsr, r0
mov pc, lr
ENDP ; |DI|
EXPORT |EI|
|EI| PROC
mrs r0, cpsr
bic r0, r0, #0xc0
msr cpsr, r0
mov pc, lr
ENDP ; |EI|
;
; Cache ops.
;
EXPORT |InvalidateICache|
|InvalidateICache| PROC
; c7 (CRn) Cache Control Register
; c5, 0 (CRm, opcode_2) Flush I
; r0 (Rd) ignored
mcr p15, 0, r0, c7, c5, 0
mov pc, lr
ENDP ; |InvalidateICache|
EXPORT |WritebackDCache|
|WritebackDCache| PROC
ldr r0, [pc, #24] ; dcachebuf
ldr r1, [pc, #24]
ldr r1, [r1] ; dcache-size
add r1, r1, r0
|wbdc1|
ldr r2, [r0], #32 ; line-size is 32byte.
teq r1, r0
bne |wbdc1|
mov pc, lr
DCD |dcachebuf|
DCD |dcachesize|
ENDP ; |WritebackDCache|
EXPORT |InvalidateDCache|
|InvalidateDCache| PROC
; c7 (CRn) Cache Control Register
; c6, 0 (CRm, opcode_2) Flush D
; r0 (Rd) ignored
mcr p15, 0, r0, c7, c6, 0
mov pc, lr
ENDP ; |InvalidateDCache|
EXPORT |WritebackInvalidateDCache|
|WritebackInvalidateDCache| PROC
ldr r0, [pc, #28] ; dcachebuf
ldr r1, [pc, #28]
ldr r1, [r1] ; dcache-size
add r1, r1, r0
|wbidc1|
ldr r2, [r0], #32
teq r1, r0
bne |wbidc1|
mcr p15, 0, r0, c7, c6, 0
mov pc, lr
DCD |dcachebuf|
DCD |dcachesize|
ENDP ; |WritebackInvalidateDCache|
;
; WriteBuffer ops
;
EXPORT |WritebufferFlush|
|WritebufferFlush| PROC
; c7 (CRn) Cache Control Register
; c10, 4(CRm, opcode_2) Flush D
; r0 (Rd) ignored
mcr p15, 0, r0, c7, c10, 4
mov pc, lr
ENDP ; |WritebufferFlush|
;
; TLB ops.
;
EXPORT |FlushIDTLB|
|FlushIDTLB| PROC
mcr p15, 0, r0, c8, c7, 0
mov pc, lr
ENDP ; |FlushIDTLB|
EXPORT |FlushITLB|
|FlushITLB| PROC
mcr p15, 0, r0, c8, c5, 0
mov pc, lr
ENDP ; |FlushITLB|
EXPORT |FlushDTLB|
|FlushDTLB| PROC
mcr p15, 0, r0, c8, c6, 0
mov pc, lr
ENDP ; |FlushITLB|
EXPORT |FlushDTLBS|
|FlushDTLBS| PROC
mcr p15, 0, r0, c8, c6, 1
mov pc, lr
ENDP ; |FlushITLBS|
;
; CurrentProgramStatusRegister access.
;
EXPORT |GetCPSR|
|GetCPSR| PROC
mrs r0, cpsr
mov pc, lr
ENDP ; |GetCPSR|
EXPORT |SetCPSR|
|SetCPSR| PROC
msr cpsr, r0
mov pc, lr
ENDP ; |SetCPSR|
;
; SA-1100 Coprocessor15 access.
;
; Reg0 ID (R)
EXPORT |GetCop15Reg0|
|GetCop15Reg0| PROC
mrc p15, 0, r0, c0, c0, 0
; 0x4401a119 (44|01 = version 4|A11 = SA1100|9 = E stepping)
mov pc, lr
ENDP ; |GetCop15Reg0|
; Reg1 Control (R/W)
EXPORT |GetCop15Reg1|
|GetCop15Reg1| PROC
mrc p15, 0, r0, c1, c0, 0
; 0xc007327f (||...........|||..||..|..|||||||)
; 0 (1)MMU enabled
; 1 (1)Address fault enabled
; 2 (1)D-cache enabled
; 3 (1)Write-buffer enabled
; 7 (0)little-endian
; 8 (0)MMU protection (System)
; 9 (1)MMU protection (ROM)
; 12 (1)I-cache enabled
; 13 (1)Base address of interrupt vector is 0xffff0000
mov pc, lr
ENDP ; |GetCop15Reg1|
EXPORT |SetCop15Reg1|
|SetCop15Reg1| PROC
mcr p15, 0, r0, c1, c0, 0
nop
nop
nop
mov pc, lr
ENDP ; |SetCop15Reg1|
; Reg2 Translation table base (R/W)
EXPORT |GetCop15Reg2|
|GetCop15Reg2| PROC
mrc p15, 0, r0, c2, c0, 0
mov pc, lr
ENDP ; |GetCop15Reg2|
EXPORT |SetCop15Reg2|
|SetCop15Reg2| PROC
mcr p15, 0, r0, c2, c0, 0
mov pc, lr
ENDP ; |SetCop15Reg2|
; Reg3 Domain access control (R/W)
EXPORT |GetCop15Reg3|
|GetCop15Reg3| PROC
mrc p15, 0, r0, c3, c0, 0
mov pc, lr
ENDP ; |GetCop15Reg3|
EXPORT |SetCop15Reg3|
|SetCop15Reg3| PROC
mcr p15, 0, r0, c3, c0, 0
mov pc, lr
ENDP ; |SetCop15Reg3|
; Reg5 Fault status (R/W)
EXPORT |GetCop15Reg5|
|GetCop15Reg5| PROC
mrc p15, 0, r0, c5, c0, 0
mov pc, lr
ENDP ; |GetCop15Reg5|
; Reg6 Fault address (R/W)
EXPORT |GetCop15Reg6|
|GetCop15Reg6| PROC
mrc p15, 0, r0, c6, c0, 0
mov pc, lr
ENDP ; |GetCop15Reg6|
; Reg7 Cache operations (W)
; -> Cache ops
; Reg8 TLB operations (Flush) (W)
; -> TLB ops
; Reg9 Read buffer operations (W)
; Reg13 Process ID (R/W)
EXPORT |GetCop15Reg13|
|GetCop15Reg13| PROC
mrc p15, 0, r0, c13, c0, 0
mov pc, lr
ENDP ; |GetCop15Reg13|
EXPORT |SetCop15Reg13|
|SetCop15Reg13| PROC
mcr p15, 0, r0, c13, c0, 0
mov pc, lr
ENDP ; |SetCop15Reg13|
; Reg14 Breakpoint (R/W)
EXPORT |GetCop15Reg14|
|GetCop15Reg14| PROC
mrc p15, 0, r0, c14, c0, 0
mov pc, lr
ENDP ; |GetCop15Reg14|
; Reg15 Test, clock, and idle (W)
END
|