1 ; $NetBSD: arm.asm,v 1.7 2008/03/08 01:50:06 rafal Exp $
3 ; Copyright (c) 2001 The NetBSD Foundation, Inc.
6 ; This code is derived from software contributed to The NetBSD Foundation
9 ; Redistribution and use in source and binary forms, with or without
10 ; modification, are permitted provided that the following conditions
12 ; 1. Redistributions of source code must retain the above copyright
13 ; notice, this list of conditions and the following disclaimer.
14 ; 2. Redistributions in binary form must reproduce the above copyright
15 ; notice, this list of conditions and the following disclaimer in the
16 ; documentation and/or other materials provided with the distribution.
18 ; THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 ; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 ; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 ; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 ; BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 ; POSSIBILITY OF SUCH DAMAGE.
32 ;armasm.exe $(InputPath)
35 ; dummy buffer for WritebackDCache
36 EXPORT |dcachebuf|
[DATA
]
41 AREA |.text|
, CODE
, PIC
54 EXPORT |SetSystemMode|
60 ENDP ; |SetSystemMode|
83 EXPORT |InvalidateICache|
84 |InvalidateICache|
PROC
85 ; c7 (CRn) Cache Control Register
86 ; c5, 0 (CRm, opcode_2) Flush I
88 mcr p15
, 0, r0
, c7
, c5
, 0
90 ENDP ; |InvalidateICache|
92 EXPORT |WritebackDCache|
93 |WritebackDCache|
PROC
94 ldr r0
, [pc
, #
16] ; dcachebuf
95 add r1
, r0
, #
8192 ; cache-size is 8Kbyte.
97 ldr r2
, [r0
], #
32 ; line-size is 32byte.
102 ENDP ; |WritebackDCache|
104 EXPORT |InvalidateDCache|
105 |InvalidateDCache|
PROC
106 ; c7 (CRn) Cache Control Register
107 ; c6, 0 (CRm, opcode_2) Flush D
109 mcr p15
, 0, r0
, c7
, c6
, 0
111 ENDP ; |InvalidateDCache|
113 EXPORT |WritebackInvalidateDCache|
114 |WritebackInvalidateDCache|
PROC
115 ldr r0
, [pc
, #
20] ; dcachebuf
121 mcr p15
, 0, r0
, c7
, c6
, 0
124 ENDP ; |WritebackInvalidateDCache|
129 EXPORT |WritebufferFlush|
130 |WritebufferFlush|
PROC
131 ; c7 (CRn) Cache Control Register
132 ; c10, 4(CRm, opcode_2) Flush D
134 mcr p15
, 0, r0
, c7
, c10
, 4
136 ENDP ; |WritebufferFlush|
143 mcr p15
, 0, r0
, c8
, c7
, 0
149 mcr p15
, 0, r0
, c8
, c5
, 0
155 mcr p15
, 0, r0
, c8
, c6
, 0
161 mcr p15
, 0, r0
, c8
, c6
, 1
166 ; CurrentProgramStatusRegister access.
181 ; SA-1100 Coprocessor15 access.
184 EXPORT |GetCop15Reg0|
186 mrc p15
, 0, r0
, c0
, c0
, 0
187 ; 0x4401a119 (44|01 = version 4|A11 = SA1100|9 = E stepping)
189 ENDP ; |GetCop15Reg0|
192 EXPORT |GetCop15Reg1|
194 mrc p15
, 0, r0
, c1
, c0
, 0
195 ; 0xc007327f (||...........|||..||..|..|||||||)
197 ; 1 (1)Address fault enabled
198 ; 2 (1)D-cache enabled
199 ; 3 (1)Write-buffer enabled
201 ; 8 (0)MMU protection (System)
202 ; 9 (1)MMU protection (ROM)
203 ; 12 (1)I-cache enabled
204 ; 13 (1)Base address of interrupt vector is 0xffff0000
206 ENDP ; |GetCop15Reg1|
207 EXPORT |SetCop15Reg1|
209 mcr p15
, 0, r0
, c1
, c0
, 0
214 ENDP ; |SetCop15Reg1|
216 ; Reg2 Translation table base (R/W)
217 EXPORT |GetCop15Reg2|
219 mrc p15
, 0, r0
, c2
, c0
, 0
221 ENDP ; |GetCop15Reg2|
222 EXPORT |SetCop15Reg2|
224 mcr p15
, 0, r0
, c2
, c0
, 0
226 ENDP ; |SetCop15Reg2|
228 ; Reg3 Domain access control (R/W)
229 EXPORT |GetCop15Reg3|
231 mrc p15
, 0, r0
, c3
, c0
, 0
233 ENDP ; |GetCop15Reg3|
234 EXPORT |SetCop15Reg3|
236 mcr p15
, 0, r0
, c3
, c0
, 0
238 ENDP ; |SetCop15Reg3|
240 ; Reg5 Fault status (R/W)
241 EXPORT |GetCop15Reg5|
243 mrc p15
, 0, r0
, c5
, c0
, 0
245 ENDP ; |GetCop15Reg5|
247 ; Reg6 Fault address (R/W)
248 EXPORT |GetCop15Reg6|
250 mrc p15
, 0, r0
, c6
, c0
, 0
252 ENDP ; |GetCop15Reg6|
254 ; Reg7 Cache operations (W)
256 ; Reg8 TLB operations (Flush) (W)
258 ; Reg9 Read buffer operations (W)
259 ; Reg13 Process ID (R/W)
260 EXPORT |GetCop15Reg13|
262 mrc p15
, 0, r0
, c13
, c0
, 0
264 ENDP ; |GetCop15Reg13|
265 EXPORT |SetCop15Reg13|
267 mcr p15
, 0, r0
, c13
, c0
, 0
269 ENDP ; |SetCop15Reg13|
271 ; Reg14 Breakpoint (R/W)
272 EXPORT |GetCop15Reg14|
274 mrc p15
, 0, r0
, c14
, c0
, 0
276 ENDP ; |GetCop15Reg14|
277 ; Reg15 Test, clock, and idle (W)
279 ; FlatJump (kaddr_t bootinfo, kaddr_t pvec, kaddr_t stack
281 ; bootinfo boot information block address.
282 ; pvec page vector of kernel.
283 ; stack physical address of stack
284 ; jump physical address of boot function
285 ; *** MMU and pipeline behavier are SA-1100 specific. ***
292 ; disable MMU, I/D-Cache, Writebuffer.
293 ; interrupt vector address is 0xffff0000
294 ; 32bit exception handler/address range.
296 ; Disable WB/Cache/MMU
297 mcr p15
, 0, r4
, c1
, c0
, 0
298 ; Invalidate I/D-cache.
299 mcr p15
, 0, r4
, c7
, c7
, 0 ; Fetch translated fetch
300 ; Invalidate TLB entries.
301 mcr p15
, 0, r4
, c8
, c7
, 0 ; Fetch translated decode
302 ; jump to kernel entry physical address.
303 mov pc
, r3
; Fetch translated execute
305 nop ; Fetch nontranslated cache access
306 nop ; Fetch nontranslated writeback
307 mov pc
, lr
; Fetch nontranslated
313 ; boot_func (uint32_t mapaddr, uint32_t bootinfo, uint32_t flags)
320 mov sp, r2
; set bootloader stack
333 stmfd
sp!, {r4-r7, lr}
342 orr r6
, r6
, r6
, LSL #
8
343 orr r6
, r6
, r6
, LSL #
16
353 ldmfd
sp!, {r4-r7, pc}
355 DCD
0xc0003000 ; use WindowsCE default.
363 ; ; print boot_info address (r0) and page_vector start address (r1).
377 mov r7
, r0
; if enabled above debug print, remove this.
378 mov r2
, r1
; if enabled above debug print, remove this.
382 beq |page_end|
; if (next == ~0) goto page_end
384 mov r1
, r2
; p = next
386 ldr r3
, [r1
, #
4] ; src
387 ldr r4
, [r1
, #
8] ; dst
388 ldr r5
, [r1
, #
12] ; sz
391 add r6
, r4
, r5
; end address
392 bne |page_memcpy4|
; if (src != ~0) goto page_memcpy4
395 |page_memset|
; memset (dst, 0, sz) uncached.
401 |page_memcpy4|
; memcpy (dst, src, sz) uncached.
461 stmfd
sp!, {r4-r5, lr}
468 ; Transmit register address
471 ; Transmit busy register address
478 addgt r3
, r3
, #
0x41 - 10
493 ldmfd
sp!, {r4-r5, pc}
501 EXPORT |boot_func_end|
[ DATA
]
502 |boot_func_end| DCD
0x0