blob: 8e0d0ada62dfef4fc8dd2f2c398e27956467d8e0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/boot/compressed/head.S
3 *
4 * Copyright (C) 1996-2002 Russell King
Hyok S. Choi10c2df62006-03-27 10:21:34 +01005 * Copyright (C) 2004 Hyok S. Choi (MPU support)
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/linkage.h>
Dave Martin424e5992012-02-10 18:07:07 -080012#include <asm/assembler.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
14/*
15 * Debugging stuff
16 *
17 * Note that these macros must not contain any code which is not
18 * 100% relocatable. Any attempt to do so will result in a crash.
19 * Please select one of the following when turning on debugging.
20 */
21#ifdef DEBUG
Russell King5cd0c342005-05-03 12:18:46 +010022
Russell King5cd0c342005-05-03 12:18:46 +010023#if defined(CONFIG_DEBUG_ICEDCC)
Tony Lindgren7d95ded2006-09-20 13:03:34 +010024
Stephen Boyddfad5492011-03-23 22:46:15 +010025#if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V6K) || defined(CONFIG_CPU_V7)
Tony Lindgren4e6d4882010-02-01 23:26:53 +010026 .macro loadsp, rb, tmp
Tony Lindgren7d95ded2006-09-20 13:03:34 +010027 .endm
28 .macro writeb, ch, rb
29 mcr p14, 0, \ch, c0, c5, 0
30 .endm
Jean-Christop PLAGNIOL-VILLARDc633c3c2009-02-25 04:20:40 +010031#elif defined(CONFIG_CPU_XSCALE)
Tony Lindgren4e6d4882010-02-01 23:26:53 +010032 .macro loadsp, rb, tmp
Jean-Christop PLAGNIOL-VILLARDc633c3c2009-02-25 04:20:40 +010033 .endm
34 .macro writeb, ch, rb
35 mcr p14, 0, \ch, c8, c0, 0
36 .endm
Tony Lindgren7d95ded2006-09-20 13:03:34 +010037#else
Tony Lindgren4e6d4882010-02-01 23:26:53 +010038 .macro loadsp, rb, tmp
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 .endm
Russell King224b5be2005-11-16 14:59:51 +000040 .macro writeb, ch, rb
Uwe Kleine-König41a9e682007-12-13 09:31:34 +010041 mcr p14, 0, \ch, c1, c0, 0
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 .endm
Tony Lindgren7d95ded2006-09-20 13:03:34 +010043#endif
44
Russell King5cd0c342005-05-03 12:18:46 +010045#else
Russell King224b5be2005-11-16 14:59:51 +000046
Shawn Guo4beba082012-12-11 07:06:37 +010047#include CONFIG_DEBUG_LL_INCLUDE
Russell King224b5be2005-11-16 14:59:51 +000048
Russell King5cd0c342005-05-03 12:18:46 +010049 .macro writeb, ch, rb
50 senduart \ch, \rb
51 .endm
52
Russell King224b5be2005-11-16 14:59:51 +000053#if defined(CONFIG_ARCH_SA1100)
Tony Lindgren4e6d4882010-02-01 23:26:53 +010054 .macro loadsp, rb, tmp
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 mov \rb, #0x80000000 @ physical base address
Russell King224b5be2005-11-16 14:59:51 +000056#ifdef CONFIG_DEBUG_LL_SER3
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 add \rb, \rb, #0x00050000 @ Ser3
Russell King224b5be2005-11-16 14:59:51 +000058#else
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 add \rb, \rb, #0x00010000 @ Ser1
Russell King224b5be2005-11-16 14:59:51 +000060#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 .endm
Kukjin Kimb130d5c2012-02-03 14:29:23 +090062#elif defined(CONFIG_ARCH_S3C24XX)
Tony Lindgren4e6d4882010-02-01 23:26:53 +010063 .macro loadsp, rb, tmp
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 mov \rb, #0x50000000
Ben Dooksc7657842007-07-22 16:11:20 +010065 add \rb, \rb, #0x4000 * CONFIG_S3C_LOWLEVEL_UART_PORT
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#else
Tony Lindgren4e6d4882010-02-01 23:26:53 +010068 .macro loadsp, rb, tmp
69 addruart \rb, \tmp
Russell King224b5be2005-11-16 14:59:51 +000070 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -070071#endif
72#endif
Russell King5cd0c342005-05-03 12:18:46 +010073#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
75 .macro kputc,val
76 mov r0, \val
77 bl putc
78 .endm
79
80 .macro kphex,val,len
81 mov r0, \val
82 mov r1, #\len
83 bl phex
84 .endm
85
86 .macro debug_reloc_start
87#ifdef DEBUG
88 kputc #'\n'
89 kphex r6, 8 /* processor id */
90 kputc #':'
91 kphex r7, 8 /* architecture id */
Hyok S. Choif12d0d72006-09-26 17:36:37 +090092#ifdef CONFIG_CPU_CP15
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 kputc #':'
94 mrc p15, 0, r0, c1, c0
95 kphex r0, 8 /* control reg */
Hyok S. Choif12d0d72006-09-26 17:36:37 +090096#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 kputc #'\n'
98 kphex r5, 8 /* decompressed kernel start */
99 kputc #'-'
Russell Kingf4619022006-01-12 17:17:57 +0000100 kphex r9, 8 /* decompressed kernel end */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 kputc #'>'
102 kphex r4, 8 /* kernel execution address */
103 kputc #'\n'
104#endif
105 .endm
106
107 .macro debug_reloc_end
108#ifdef DEBUG
109 kphex r5, 8 /* end of kernel */
110 kputc #'\n'
111 mov r0, r4
112 bl memdump /* dump 256 bytes at start of kernel */
113#endif
114 .endm
115
116 .section ".start", #alloc, #execinstr
117/*
118 * sort out different calling conventions
119 */
120 .align
Dave Martin26e5ca92010-11-29 19:43:27 +0100121 .arm @ Always enter in ARM state
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122start:
123 .type start,#function
Nicolas Pitreb11fe382011-02-12 22:25:27 +0100124 .rept 7
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 mov r0, r0
126 .endr
Nicolas Pitreb11fe382011-02-12 22:25:27 +0100127 ARM( mov r0, r0 )
128 ARM( b 1f )
129 THUMB( adr r12, BSYM(1f) )
130 THUMB( bx r12 )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 .word 0x016f2818 @ Magic numbers to help the loader
133 .word start @ absolute load/run zImage address
134 .word _edata @ zImage end address
Dave Martin26e5ca92010-11-29 19:43:27 +0100135 THUMB( .thumb )
Dave Martin424e5992012-02-10 18:07:07 -08001361:
137 mrs r9, cpsr
138#ifdef CONFIG_ARM_VIRT_EXT
139 bl __hyp_stub_install @ get into SVC mode, reversibly
140#endif
141 mov r7, r1 @ save architecture ID
Russell Kingf4619022006-01-12 17:17:57 +0000142 mov r8, r2 @ save atags pointer
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
144#ifndef __ARM_ARCH_2__
145 /*
146 * Booting from Angel - need to enter SVC mode and disable
147 * FIQs/IRQs (numeric definitions from angel arm.h source).
148 * We only do this if we were in user mode on entry.
149 */
150 mrs r2, cpsr @ get current mode
151 tst r2, #3 @ not user?
152 bne not_angel
153 mov r0, #0x17 @ angel_SWIreason_EnterSVC
Catalin Marinas0e056f22009-07-24 12:32:58 +0100154 ARM( swi 0x123456 ) @ angel_SWI_ARM
155 THUMB( svc 0xab ) @ angel_SWI_THUMB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156not_angel:
Dave Martin424e5992012-02-10 18:07:07 -0800157 safe_svcmode_maskall r0
158 msr spsr_cxsf, r9 @ Save the CPU boot mode in
159 @ SPSR
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160#else
161 teqp pc, #0x0c000003 @ turn off interrupts
162#endif
163
164 /*
165 * Note that some cache flushing and other stuff may
166 * be needed here - is there an Angel SWI call for this?
167 */
168
169 /*
170 * some architecture specific code can be inserted
Russell Kingf4619022006-01-12 17:17:57 +0000171 * by the linker here, but it should preserve r7, r8, and r9.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 */
173
174 .text
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100175
Eric Miaoe69edc792010-07-05 15:56:50 +0200176#ifdef CONFIG_AUTO_ZRELADDR
177 @ determine final kernel image address
Dave Martinbfa64c42010-11-29 19:43:26 +0100178 mov r4, pc
179 and r4, r4, #0xf8000000
Eric Miaoe69edc792010-07-05 15:56:50 +0200180 add r4, r4, #TEXT_OFFSET
181#else
Russell King9e84ed62010-09-09 22:39:41 +0100182 ldr r4, =zreladdr
Eric Miaoe69edc792010-07-05 15:56:50 +0200183#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184
Nicolas Pitre28748652013-06-06 05:13:48 +0100185 /*
186 * Set up a page table only if it won't overwrite ourself.
187 * That means r4 < pc && r4 - 16k page directory > &_end.
188 * Given that r4 > &_end is most unfrequent, we add a rough
189 * additional 1MB of room for a possible appended DTB.
190 */
191 mov r0, pc
192 cmp r0, r4
193 ldrcc r0, LC0+32
194 addcc r0, r0, pc
195 cmpcc r4, r0
196 orrcc r4, r4, #1 @ remember we skipped cache_on
197 blcs cache_on
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100198
199restart: adr r0, LC0
Nicolas Pitre34cc1a82011-04-19 15:42:43 -0400200 ldmia r0, {r1, r2, r3, r6, r10, r11, r12}
Nicolas Pitreadcc2592011-04-27 16:15:11 -0400201 ldr sp, [r0, #28]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
203 /*
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100204 * We might be running at a different address. We need
205 * to fix up various pointers.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 */
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100207 sub r0, r0, r1 @ calculate the delta offset
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100208 add r6, r6, r0 @ _edata
Nicolas Pitre34cc1a82011-04-19 15:42:43 -0400209 add r10, r10, r0 @ inflated kernel size location
210
211 /*
212 * The kernel build system appends the size of the
213 * decompressed kernel at the end of the compressed data
214 * in little-endian form.
215 */
216 ldrb r9, [r10, #0]
217 ldrb lr, [r10, #1]
218 orr r9, r9, lr, lsl #8
219 ldrb lr, [r10, #2]
220 ldrb r10, [r10, #3]
221 orr r9, r9, lr, lsl #16
222 orr r9, r9, r10, lsl #24
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100223
224#ifndef CONFIG_ZBOOT_ROM
225 /* malloc space is above the relocated stack (64k max) */
226 add sp, sp, r0
227 add r10, sp, #0x10000
228#else
229 /*
230 * With ZBOOT_ROM the bss/stack is non relocatable,
231 * but someone could still run this code from RAM,
232 * in which case our reference is _edata.
233 */
234 mov r10, r6
235#endif
236
John Bonesioe2a6a3a2011-05-27 18:45:50 -0400237 mov r5, #0 @ init dtb size to 0
238#ifdef CONFIG_ARM_APPENDED_DTB
239/*
240 * r0 = delta
241 * r2 = BSS start
242 * r3 = BSS end
Nicolas Pitre28748652013-06-06 05:13:48 +0100243 * r4 = final kernel address (possibly with LSB set)
John Bonesioe2a6a3a2011-05-27 18:45:50 -0400244 * r5 = appended dtb size (still unknown)
245 * r6 = _edata
246 * r7 = architecture ID
247 * r8 = atags/device tree pointer
248 * r9 = size of decompressed image
249 * r10 = end of this image, including bss/stack/malloc space if non XIP
250 * r11 = GOT start
251 * r12 = GOT end
252 * sp = stack pointer
253 *
254 * if there are device trees (dtb) appended to zImage, advance r10 so that the
255 * dtb data will get relocated along with the kernel if necessary.
256 */
257
258 ldr lr, [r6, #0]
259#ifndef __ARMEB__
260 ldr r1, =0xedfe0dd0 @ sig is 0xd00dfeed big endian
261#else
262 ldr r1, =0xd00dfeed
263#endif
264 cmp lr, r1
265 bne dtb_check_done @ not found
266
Nicolas Pitreb90b9a32011-09-13 22:37:07 -0400267#ifdef CONFIG_ARM_ATAG_DTB_COMPAT
268 /*
269 * OK... Let's do some funky business here.
270 * If we do have a DTB appended to zImage, and we do have
271 * an ATAG list around, we want the later to be translated
272 * and folded into the former here. To be on the safe side,
273 * let's temporarily move the stack away into the malloc
274 * area. No GOT fixup has occurred yet, but none of the
275 * code we're about to call uses any global variable.
276 */
277 add sp, sp, #0x10000
278 stmfd sp!, {r0-r3, ip, lr}
279 mov r0, r8
280 mov r1, r6
281 sub r2, sp, r6
282 bl atags_to_fdt
283
284 /*
285 * If returned value is 1, there is no ATAG at the location
286 * pointed by r8. Try the typical 0x100 offset from start
287 * of RAM and hope for the best.
288 */
289 cmp r0, #1
Nicolas Pitre531a6a92011-10-24 13:30:32 +0100290 sub r0, r4, #TEXT_OFFSET
Nicolas Pitre28748652013-06-06 05:13:48 +0100291 bic r0, r0, #1
Nicolas Pitre531a6a92011-10-24 13:30:32 +0100292 add r0, r0, #0x100
Nicolas Pitreb90b9a32011-09-13 22:37:07 -0400293 mov r1, r6
294 sub r2, sp, r6
Marc Zyngier9c5fd9e2012-04-11 14:52:55 +0100295 bleq atags_to_fdt
Nicolas Pitreb90b9a32011-09-13 22:37:07 -0400296
297 ldmfd sp!, {r0-r3, ip, lr}
298 sub sp, sp, #0x10000
299#endif
300
John Bonesioe2a6a3a2011-05-27 18:45:50 -0400301 mov r8, r6 @ use the appended device tree
302
Nicolas Pitre5ffb04f2011-06-12 01:07:33 -0400303 /*
304 * Make sure that the DTB doesn't end up in the final
305 * kernel's .bss area. To do so, we adjust the decompressed
306 * kernel size to compensate if that .bss size is larger
307 * than the relocated code.
308 */
309 ldr r5, =_kernel_bss_size
310 adr r1, wont_overwrite
311 sub r1, r6, r1
312 subs r1, r5, r1
313 addhi r9, r9, r1
314
John Bonesioe2a6a3a2011-05-27 18:45:50 -0400315 /* Get the dtb's size */
316 ldr r5, [r6, #4]
317#ifndef __ARMEB__
318 /* convert r5 (dtb size) to little endian */
319 eor r1, r5, r5, ror #16
320 bic r1, r1, #0x00ff0000
321 mov r5, r5, ror #8
322 eor r5, r5, r1, lsr #8
323#endif
324
325 /* preserve 64-bit alignment */
326 add r5, r5, #7
327 bic r5, r5, #7
328
329 /* relocate some pointers past the appended dtb */
330 add r6, r6, r5
331 add r10, r10, r5
332 add sp, sp, r5
333dtb_check_done:
334#endif
335
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100336/*
337 * Check to see if we will overwrite ourselves.
Nicolas Pitre28748652013-06-06 05:13:48 +0100338 * r4 = final kernel address (possibly with LSB set)
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100339 * r9 = size of decompressed image
340 * r10 = end of this image, including bss/stack/malloc space if non XIP
341 * We basically want:
Nicolas Pitreea9df3b2011-04-21 22:52:06 -0400342 * r4 - 16k page directory >= r10 -> OK
Nicolas Pitre5ffb04f2011-06-12 01:07:33 -0400343 * r4 + image length <= address of wont_overwrite -> OK
Nicolas Pitre28748652013-06-06 05:13:48 +0100344 * Note: the possible LSB in r4 is harmless here.
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100345 */
Nicolas Pitreea9df3b2011-04-21 22:52:06 -0400346 add r10, r10, #16384
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100347 cmp r4, r10
348 bhs wont_overwrite
349 add r10, r4, r9
Nicolas Pitre5ffb04f2011-06-12 01:07:33 -0400350 adr r9, wont_overwrite
351 cmp r10, r9
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100352 bls wont_overwrite
353
354/*
355 * Relocate ourselves past the end of the decompressed kernel.
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100356 * r6 = _edata
357 * r10 = end of the decompressed kernel
358 * Because we always copy ahead, we need to do it from the end and go
359 * backward in case the source and destination overlap.
360 */
Nicolas Pitreadcc2592011-04-27 16:15:11 -0400361 /*
362 * Bump to the next 256-byte boundary with the size of
363 * the relocation code added. This avoids overwriting
364 * ourself when the offset is small.
365 */
366 add r10, r10, #((reloc_code_end - restart + 256) & ~255)
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100367 bic r10, r10, #255
368
Nicolas Pitreadcc2592011-04-27 16:15:11 -0400369 /* Get start of code we want to copy and align it down. */
370 adr r5, restart
371 bic r5, r5, #31
372
Dave Martin424e5992012-02-10 18:07:07 -0800373/* Relocate the hyp vector base if necessary */
374#ifdef CONFIG_ARM_VIRT_EXT
375 mrs r0, spsr
376 and r0, r0, #MODE_MASK
377 cmp r0, #HYP_MODE
378 bne 1f
379
380 bl __hyp_get_vectors
381 sub r0, r0, r5
382 add r0, r0, r10
383 bl __hyp_set_vectors
3841:
385#endif
386
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100387 sub r9, r6, r5 @ size to copy
388 add r9, r9, #31 @ rounded up to a multiple
389 bic r9, r9, #31 @ ... of 32 bytes
390 add r6, r9, r5
391 add r9, r9, r10
392
3931: ldmdb r6!, {r0 - r3, r10 - r12, lr}
394 cmp r6, r5
395 stmdb r9!, {r0 - r3, r10 - r12, lr}
396 bhi 1b
397
398 /* Preserve offset to relocated code. */
399 sub r6, r9, r6
400
Tony Lindgren7c2527f2011-04-26 05:37:46 -0700401#ifndef CONFIG_ZBOOT_ROM
402 /* cache_clean_flush may use the stack, so relocate it */
403 add sp, sp, r6
404#endif
405
Nicolas Pitre28748652013-06-06 05:13:48 +0100406 tst r4, #1
407 bleq cache_clean_flush
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100408
409 adr r0, BSYM(restart)
410 add r0, r0, r6
411 mov pc, r0
412
413wont_overwrite:
414/*
415 * If delta is zero, we are running at the address we were linked at.
416 * r0 = delta
417 * r2 = BSS start
418 * r3 = BSS end
Nicolas Pitre28748652013-06-06 05:13:48 +0100419 * r4 = kernel execution address (possibly with LSB set)
John Bonesioe2a6a3a2011-05-27 18:45:50 -0400420 * r5 = appended dtb size (0 if not present)
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100421 * r7 = architecture ID
422 * r8 = atags pointer
423 * r11 = GOT start
424 * r12 = GOT end
425 * sp = stack pointer
426 */
John Bonesioe2a6a3a2011-05-27 18:45:50 -0400427 orrs r1, r0, r5
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100428 beq not_relocated
John Bonesioe2a6a3a2011-05-27 18:45:50 -0400429
Russell King98e12b52010-02-25 23:56:38 +0000430 add r11, r11, r0
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100431 add r12, r12, r0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432
433#ifndef CONFIG_ZBOOT_ROM
434 /*
435 * If we're running fully PIC === CONFIG_ZBOOT_ROM = n,
436 * we need to fix up pointers into the BSS region.
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100437 * Note that the stack pointer has already been fixed up.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 */
439 add r2, r2, r0
440 add r3, r3, r0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
442 /*
443 * Relocate all entries in the GOT table.
John Bonesioe2a6a3a2011-05-27 18:45:50 -0400444 * Bump bss entries to _edata + dtb size
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 */
Russell King98e12b52010-02-25 23:56:38 +00004461: ldr r1, [r11, #0] @ relocate entries in the GOT
John Bonesioe2a6a3a2011-05-27 18:45:50 -0400447 add r1, r1, r0 @ This fixes up C references
448 cmp r1, r2 @ if entry >= bss_start &&
449 cmphs r3, r1 @ bss_end > entry
450 addhi r1, r1, r5 @ entry += dtb size
451 str r1, [r11], #4 @ next entry
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100452 cmp r11, r12
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 blo 1b
John Bonesioe2a6a3a2011-05-27 18:45:50 -0400454
455 /* bump our bss pointers too */
456 add r2, r2, r5
457 add r3, r3, r5
458
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459#else
460
461 /*
462 * Relocate entries in the GOT table. We only relocate
463 * the entries that are outside the (relocated) BSS region.
464 */
Russell King98e12b52010-02-25 23:56:38 +00004651: ldr r1, [r11, #0] @ relocate entries in the GOT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 cmp r1, r2 @ entry < bss_start ||
467 cmphs r3, r1 @ _end < entry
468 addlo r1, r1, r0 @ table. This fixes up the
Russell King98e12b52010-02-25 23:56:38 +0000469 str r1, [r11], #4 @ C references.
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100470 cmp r11, r12
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 blo 1b
472#endif
473
474not_relocated: mov r0, #0
4751: str r0, [r2], #4 @ clear bss
476 str r0, [r2], #4
477 str r0, [r2], #4
478 str r0, [r2], #4
479 cmp r2, r3
480 blo 1b
481
Nicolas Pitre28748652013-06-06 05:13:48 +0100482 /*
483 * Did we skip the cache setup earlier?
484 * That is indicated by the LSB in r4.
485 * Do it now if so.
486 */
487 tst r4, #1
488 bic r4, r4, #1
489 blne cache_on
490
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100491/*
492 * The C runtime environment should now be setup sufficiently.
493 * Set up some pointers, and start decompressing.
494 * r4 = kernel execution address
495 * r7 = architecture ID
496 * r8 = atags pointer
497 */
498 mov r0, r4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 mov r1, sp @ malloc space above stack
500 add r2, sp, #0x10000 @ 64k max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 mov r3, r7
502 bl decompress_kernel
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 bl cache_clean_flush
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100504 bl cache_off
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100505 mov r1, r7 @ restore architecture number
506 mov r2, r8 @ restore atags pointer
Dave Martin424e5992012-02-10 18:07:07 -0800507
508#ifdef CONFIG_ARM_VIRT_EXT
509 mrs r0, spsr @ Get saved CPU boot mode
510 and r0, r0, #MODE_MASK
511 cmp r0, #HYP_MODE @ if not booted in HYP mode...
512 bne __enter_kernel @ boot kernel directly
513
514 adr r12, .L__hyp_reentry_vectors_offset
515 ldr r0, [r12]
516 add r0, r0, r12
517
518 bl __hyp_set_vectors
519 __HVC(0) @ otherwise bounce to hyp mode
520
521 b . @ should never be reached
522
523 .align 2
524.L__hyp_reentry_vectors_offset: .long __hyp_reentry_vectors - .
525#else
526 b __enter_kernel
527#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528
Catalin Marinas88987ef2009-07-24 12:32:52 +0100529 .align 2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 .type LC0, #object
531LC0: .word LC0 @ r1
532 .word __bss_start @ r2
533 .word _end @ r3
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100534 .word _edata @ r6
Nicolas Pitre34cc1a82011-04-19 15:42:43 -0400535 .word input_data_end - 4 @ r10 (inflated size location)
Russell King98e12b52010-02-25 23:56:38 +0000536 .word _got_start @ r11
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 .word _got_end @ ip
Nicolas Pitre8d7e4cc2011-04-27 14:54:39 -0400538 .word .L_user_stack_end @ sp
Nicolas Pitre28748652013-06-06 05:13:48 +0100539 .word _end - restart + 16384 + 1024*1024
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 .size LC0, . - LC0
541
542#ifdef CONFIG_ARCH_RPC
543 .globl params
Eric Miaodb7b2b42010-06-03 15:36:49 +0800544params: ldr r0, =0x10000100 @ params_phys for RPC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 mov pc, lr
546 .ltorg
547 .align
548#endif
549
550/*
551 * Turn on the cache. We need to setup some page tables so that we
552 * can have both the I and D caches on.
553 *
554 * We place the page tables 16k down from the kernel execution address,
555 * and we hope that nothing else is using it. If we're using it, we
556 * will go pop!
557 *
558 * On entry,
559 * r4 = kernel execution address
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 * r7 = architecture number
Russell Kingf4619022006-01-12 17:17:57 +0000561 * r8 = atags pointer
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 * On exit,
Uwe Kleine-König21b28412010-01-26 22:08:09 +0100563 * r0, r1, r2, r3, r9, r10, r12 corrupted
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 * This routine must preserve:
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100565 * r4, r7, r8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 */
567 .align 5
568cache_on: mov r3, #8 @ cache_on function
569 b call_cache_fn
570
Hyok S. Choi10c2df62006-03-27 10:21:34 +0100571/*
572 * Initialize the highest priority protection region, PR7
573 * to cover all 32bit address and cacheable and bufferable.
574 */
575__armv4_mpu_cache_on:
576 mov r0, #0x3f @ 4G, the whole
577 mcr p15, 0, r0, c6, c7, 0 @ PR7 Area Setting
578 mcr p15, 0, r0, c6, c7, 1
579
580 mov r0, #0x80 @ PR7
581 mcr p15, 0, r0, c2, c0, 0 @ D-cache on
582 mcr p15, 0, r0, c2, c0, 1 @ I-cache on
583 mcr p15, 0, r0, c3, c0, 0 @ write-buffer on
584
585 mov r0, #0xc000
586 mcr p15, 0, r0, c5, c0, 1 @ I-access permission
587 mcr p15, 0, r0, c5, c0, 0 @ D-access permission
588
589 mov r0, #0
590 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
591 mcr p15, 0, r0, c7, c5, 0 @ flush(inval) I-Cache
592 mcr p15, 0, r0, c7, c6, 0 @ flush(inval) D-Cache
593 mrc p15, 0, r0, c1, c0, 0 @ read control reg
594 @ ...I .... ..D. WC.M
595 orr r0, r0, #0x002d @ .... .... ..1. 11.1
596 orr r0, r0, #0x1000 @ ...1 .... .... ....
597
598 mcr p15, 0, r0, c1, c0, 0 @ write control reg
599
600 mov r0, #0
601 mcr p15, 0, r0, c7, c5, 0 @ flush(inval) I-Cache
602 mcr p15, 0, r0, c7, c6, 0 @ flush(inval) D-Cache
603 mov pc, lr
604
605__armv3_mpu_cache_on:
606 mov r0, #0x3f @ 4G, the whole
607 mcr p15, 0, r0, c6, c7, 0 @ PR7 Area Setting
608
609 mov r0, #0x80 @ PR7
610 mcr p15, 0, r0, c2, c0, 0 @ cache on
611 mcr p15, 0, r0, c3, c0, 0 @ write-buffer on
612
613 mov r0, #0xc000
614 mcr p15, 0, r0, c5, c0, 0 @ access permission
615
616 mov r0, #0
617 mcr p15, 0, r0, c7, c0, 0 @ invalidate whole cache v3
Uwe Kleine-König4a8d57a2010-01-26 22:14:23 +0100618 /*
619 * ?? ARMv3 MMU does not allow reading the control register,
620 * does this really work on ARMv3 MPU?
621 */
Hyok S. Choi10c2df62006-03-27 10:21:34 +0100622 mrc p15, 0, r0, c1, c0, 0 @ read control reg
623 @ .... .... .... WC.M
624 orr r0, r0, #0x000d @ .... .... .... 11.1
Uwe Kleine-König4a8d57a2010-01-26 22:14:23 +0100625 /* ?? this overwrites the value constructed above? */
Hyok S. Choi10c2df62006-03-27 10:21:34 +0100626 mov r0, #0
627 mcr p15, 0, r0, c1, c0, 0 @ write control reg
628
Uwe Kleine-König4a8d57a2010-01-26 22:14:23 +0100629 /* ?? invalidate for the second time? */
Hyok S. Choi10c2df62006-03-27 10:21:34 +0100630 mcr p15, 0, r0, c7, c0, 0 @ invalidate whole cache v3
631 mov pc, lr
632
Russell King1fdc08a2012-05-10 09:48:34 +0100633#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
634#define CB_BITS 0x08
635#else
636#define CB_BITS 0x0c
637#endif
638
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639__setup_mmu: sub r3, r4, #16384 @ Page directory size
640 bic r3, r3, #0xff @ Align the pointer
641 bic r3, r3, #0x3f00
642/*
643 * Initialise the page tables, turning on the cacheable and bufferable
644 * bits for the RAM area only.
645 */
646 mov r0, r3
Russell Kingf4619022006-01-12 17:17:57 +0000647 mov r9, r0, lsr #18
648 mov r9, r9, lsl #18 @ start of RAM
649 add r10, r9, #0x10000000 @ a reasonable RAM size
Russell King1fdc08a2012-05-10 09:48:34 +0100650 mov r1, #0x12 @ XN|U + section mapping
651 orr r1, r1, #3 << 10 @ AP=11
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 add r2, r3, #16384
Nicolas Pitre265d5e42006-01-18 22:38:51 +00006531: cmp r1, r9 @ if virt > start of RAM
Russell King1fdc08a2012-05-10 09:48:34 +0100654 cmphs r10, r1 @ && end of RAM > virt
655 bic r1, r1, #0x1c @ clear XN|U + C + B
656 orrlo r1, r1, #0x10 @ Set XN|U for non-RAM
657 orrhs r1, r1, r6 @ set RAM section settings
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 str r1, [r0], #4 @ 1:1 mapping
659 add r1, r1, #1048576
660 teq r0, r2
661 bne 1b
662/*
663 * If ever we are running from Flash, then we surely want the cache
664 * to be enabled also for our execution instance... We map 2MB of it
665 * so there is no map overlap problem for up to 1 MB compressed kernel.
666 * If the execution is in RAM then we would only be duplicating the above.
667 */
Russell King1fdc08a2012-05-10 09:48:34 +0100668 orr r1, r6, #0x04 @ ensure B is set for this
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 orr r1, r1, #3 << 10
Dave Martinbfa64c42010-11-29 19:43:26 +0100670 mov r2, pc
671 mov r2, r2, lsr #20
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 orr r1, r1, r2, lsl #20
673 add r0, r3, r2, lsl #2
674 str r1, [r0], #4
675 add r1, r1, #1048576
676 str r1, [r0]
677 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +0100678ENDPROC(__setup_mmu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679
Dave Martin50101922012-11-22 12:50:43 +0100680@ Enable unaligned access on v6, to allow better code generation
681@ for the decompressor C code:
682__armv6_mmu_cache_on:
683 mrc p15, 0, r0, c1, c0, 0 @ read SCTLR
684 bic r0, r0, #2 @ A (no unaligned access fault)
685 orr r0, r0, #1 << 22 @ U (v6 unaligned access model)
686 mcr p15, 0, r0, c1, c0, 0 @ write SCTLR
687 b __armv4_mmu_cache_on
688
Mark A. Greeraf3e4fd2011-04-01 15:41:26 +0100689__arm926ejs_mmu_cache_on:
690#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
691 mov r0, #4 @ put dcache in WT mode
692 mcr p15, 7, r0, c15, c0, 0
693#endif
694
Hyok S. Choic76b6b42006-03-24 09:53:18 +0000695__armv4_mmu_cache_on:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 mov r12, lr
Catalin Marinas8bdca0a2009-07-24 12:35:06 +0100697#ifdef CONFIG_MMU
Russell King1fdc08a2012-05-10 09:48:34 +0100698 mov r6, #CB_BITS | 0x12 @ U
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 bl __setup_mmu
700 mov r0, #0
701 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
702 mcr p15, 0, r0, c8, c7, 0 @ flush I,D TLBs
703 mrc p15, 0, r0, c1, c0, 0 @ read control reg
704 orr r0, r0, #0x5000 @ I-cache enable, RR cache replacement
705 orr r0, r0, #0x0030
Catalin Marinas26584852009-05-30 14:00:18 +0100706#ifdef CONFIG_CPU_ENDIAN_BE8
707 orr r0, r0, #1 << 25 @ big-endian page tables
708#endif
Hyok S. Choic76b6b42006-03-24 09:53:18 +0000709 bl __common_mmu_cache_on
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 mov r0, #0
711 mcr p15, 0, r0, c8, c7, 0 @ flush I,D TLBs
Catalin Marinas8bdca0a2009-07-24 12:35:06 +0100712#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 mov pc, r12
714
Catalin Marinas7d09e852007-06-01 17:14:53 +0100715__armv7_mmu_cache_on:
716 mov r12, lr
Catalin Marinas8bdca0a2009-07-24 12:35:06 +0100717#ifdef CONFIG_MMU
Catalin Marinas7d09e852007-06-01 17:14:53 +0100718 mrc p15, 0, r11, c0, c1, 4 @ read ID_MMFR0
719 tst r11, #0xf @ VMSA
Russell King1fdc08a2012-05-10 09:48:34 +0100720 movne r6, #CB_BITS | 0x02 @ !XN
Catalin Marinas7d09e852007-06-01 17:14:53 +0100721 blne __setup_mmu
722 mov r0, #0
723 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
724 tst r11, #0xf @ VMSA
725 mcrne p15, 0, r0, c8, c7, 0 @ flush I,D TLBs
Catalin Marinas8bdca0a2009-07-24 12:35:06 +0100726#endif
Catalin Marinas7d09e852007-06-01 17:14:53 +0100727 mrc p15, 0, r0, c1, c0, 0 @ read control reg
Matthew Leache1e5b7e2012-09-11 17:56:57 +0100728 bic r0, r0, #1 << 28 @ clear SCTLR.TRE
Catalin Marinas7d09e852007-06-01 17:14:53 +0100729 orr r0, r0, #0x5000 @ I-cache enable, RR cache replacement
730 orr r0, r0, #0x003c @ write buffer
Dave Martin50101922012-11-22 12:50:43 +0100731 bic r0, r0, #2 @ A (no unaligned access fault)
732 orr r0, r0, #1 << 22 @ U (v6 unaligned access model)
733 @ (needed for ARM1176)
Catalin Marinas8bdca0a2009-07-24 12:35:06 +0100734#ifdef CONFIG_MMU
Catalin Marinas26584852009-05-30 14:00:18 +0100735#ifdef CONFIG_CPU_ENDIAN_BE8
736 orr r0, r0, #1 << 25 @ big-endian page tables
737#endif
Will Deacondbece452012-08-24 15:20:59 +0100738 mrcne p15, 0, r6, c2, c0, 2 @ read ttb control reg
Catalin Marinas7d09e852007-06-01 17:14:53 +0100739 orrne r0, r0, #1 @ MMU enabled
Russell King1fdc08a2012-05-10 09:48:34 +0100740 movne r1, #0xfffffffd @ domain 0 = client
Will Deacondbece452012-08-24 15:20:59 +0100741 bic r6, r6, #1 << 31 @ 32-bit translation system
742 bic r6, r6, #3 << 0 @ use only ttbr0
Catalin Marinas7d09e852007-06-01 17:14:53 +0100743 mcrne p15, 0, r3, c2, c0, 0 @ load page table pointer
744 mcrne p15, 0, r1, c3, c0, 0 @ load domain access control
Will Deacondbece452012-08-24 15:20:59 +0100745 mcrne p15, 0, r6, c2, c0, 2 @ load ttb control
Catalin Marinas8bdca0a2009-07-24 12:35:06 +0100746#endif
Will Deacond675d0b2011-11-22 17:30:28 +0000747 mcr p15, 0, r0, c7, c5, 4 @ ISB
Catalin Marinas7d09e852007-06-01 17:14:53 +0100748 mcr p15, 0, r0, c1, c0, 0 @ load control register
749 mrc p15, 0, r0, c1, c0, 0 @ and read it back
750 mov r0, #0
751 mcr p15, 0, r0, c7, c5, 4 @ ISB
752 mov pc, r12
753
Paulius Zaleckas28853ac2009-03-25 13:10:01 +0200754__fa526_cache_on:
755 mov r12, lr
Russell King1fdc08a2012-05-10 09:48:34 +0100756 mov r6, #CB_BITS | 0x12 @ U
Paulius Zaleckas28853ac2009-03-25 13:10:01 +0200757 bl __setup_mmu
758 mov r0, #0
759 mcr p15, 0, r0, c7, c7, 0 @ Invalidate whole cache
760 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
761 mcr p15, 0, r0, c8, c7, 0 @ flush UTLB
762 mrc p15, 0, r0, c1, c0, 0 @ read control reg
763 orr r0, r0, #0x1000 @ I-cache enable
764 bl __common_mmu_cache_on
765 mov r0, #0
766 mcr p15, 0, r0, c8, c7, 0 @ flush UTLB
767 mov pc, r12
768
Hyok S. Choic76b6b42006-03-24 09:53:18 +0000769__common_mmu_cache_on:
Catalin Marinas0e056f22009-07-24 12:32:58 +0100770#ifndef CONFIG_THUMB2_KERNEL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771#ifndef DEBUG
772 orr r0, r0, #0x000d @ Write buffer, mmu
773#endif
774 mov r1, #-1
775 mcr p15, 0, r3, c2, c0, 0 @ load page table pointer
776 mcr p15, 0, r1, c3, c0, 0 @ load domain access control
Nicolas Pitre2dc76672006-07-01 21:29:32 +0100777 b 1f
778 .align 5 @ cache line aligned
7791: mcr p15, 0, r0, c1, c0, 0 @ load control register
780 mrc p15, 0, r0, c1, c0, 0 @ and read it back to
781 sub pc, lr, r0, lsr #32 @ properly flush pipeline
Catalin Marinas0e056f22009-07-24 12:32:58 +0100782#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783
Dave Martin946a1052011-06-14 14:20:44 +0100784#define PROC_ENTRY_SIZE (4*5)
785
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 * Here follow the relocatable cache support functions for the
788 * various processors. This is a generic hook for locating an
789 * entry and jumping to an instruction at the specified offset
790 * from the start of the block. Please note this is all position
791 * independent code.
792 *
793 * r1 = corrupted
794 * r2 = corrupted
795 * r3 = block offset
Russell King98e12b52010-02-25 23:56:38 +0000796 * r9 = corrupted
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 * r12 = corrupted
798 */
799
800call_cache_fn: adr r12, proc_types
Hyok S. Choif12d0d72006-09-26 17:36:37 +0900801#ifdef CONFIG_CPU_CP15
Russell King98e12b52010-02-25 23:56:38 +0000802 mrc p15, 0, r9, c0, c0 @ get processor ID
Hyok S. Choif12d0d72006-09-26 17:36:37 +0900803#else
Russell King98e12b52010-02-25 23:56:38 +0000804 ldr r9, =CONFIG_PROCESSOR_ID
Hyok S. Choif12d0d72006-09-26 17:36:37 +0900805#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07008061: ldr r1, [r12, #0] @ get value
807 ldr r2, [r12, #4] @ get mask
Russell King98e12b52010-02-25 23:56:38 +0000808 eor r1, r1, r9 @ (real ^ match)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 tst r1, r2 @ & mask
Catalin Marinas0e056f22009-07-24 12:32:58 +0100810 ARM( addeq pc, r12, r3 ) @ call cache function
811 THUMB( addeq r12, r3 )
812 THUMB( moveq pc, r12 ) @ call cache function
Dave Martin946a1052011-06-14 14:20:44 +0100813 add r12, r12, #PROC_ENTRY_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 b 1b
815
816/*
817 * Table for cache operations. This is basically:
818 * - CPU ID match
819 * - CPU ID mask
820 * - 'cache on' method instruction
821 * - 'cache off' method instruction
822 * - 'cache flush' method instruction
823 *
824 * We match an entry using: ((real_id ^ match) & mask) == 0
825 *
826 * Writethrough caches generally only need 'on' and 'off'
827 * methods. Writeback caches _must_ have the flush method
828 * defined.
829 */
Catalin Marinas88987ef2009-07-24 12:32:52 +0100830 .align 2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 .type proc_types,#object
832proc_types:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833 .word 0x00000000 @ old ARM ID
834 .word 0x0000f000
835 mov pc, lr
Catalin Marinas0e056f22009-07-24 12:32:58 +0100836 THUMB( nop )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 mov pc, lr
Catalin Marinas0e056f22009-07-24 12:32:58 +0100838 THUMB( nop )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839 mov pc, lr
Catalin Marinas0e056f22009-07-24 12:32:58 +0100840 THUMB( nop )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841
842 .word 0x41007000 @ ARM7/710
843 .word 0xfff8fe00
Russell King4cdfc2e2012-05-09 15:18:19 +0100844 mov pc, lr
845 THUMB( nop )
846 mov pc, lr
847 THUMB( nop )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848 mov pc, lr
Catalin Marinas0e056f22009-07-24 12:32:58 +0100849 THUMB( nop )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850
851 .word 0x41807200 @ ARM720T (writethrough)
852 .word 0xffffff00
Catalin Marinas0e056f22009-07-24 12:32:58 +0100853 W(b) __armv4_mmu_cache_on
854 W(b) __armv4_mmu_cache_off
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855 mov pc, lr
Catalin Marinas0e056f22009-07-24 12:32:58 +0100856 THUMB( nop )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857
Hyok S. Choi10c2df62006-03-27 10:21:34 +0100858 .word 0x41007400 @ ARM74x
859 .word 0xff00ff00
Catalin Marinas0e056f22009-07-24 12:32:58 +0100860 W(b) __armv3_mpu_cache_on
861 W(b) __armv3_mpu_cache_off
862 W(b) __armv3_mpu_cache_flush
Hyok S. Choi10c2df62006-03-27 10:21:34 +0100863
864 .word 0x41009400 @ ARM94x
865 .word 0xff00ff00
Catalin Marinas0e056f22009-07-24 12:32:58 +0100866 W(b) __armv4_mpu_cache_on
867 W(b) __armv4_mpu_cache_off
868 W(b) __armv4_mpu_cache_flush
Hyok S. Choi10c2df62006-03-27 10:21:34 +0100869
Mark A. Greeraf3e4fd2011-04-01 15:41:26 +0100870 .word 0x41069260 @ ARM926EJ-S (v5TEJ)
871 .word 0xff0ffff0
Nicolas Pitre720c60e2011-06-09 05:05:27 +0100872 W(b) __arm926ejs_mmu_cache_on
873 W(b) __armv4_mmu_cache_off
874 W(b) __armv5tej_mmu_cache_flush
Mark A. Greeraf3e4fd2011-04-01 15:41:26 +0100875
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 .word 0x00007000 @ ARM7 IDs
877 .word 0x0000f000
878 mov pc, lr
Catalin Marinas0e056f22009-07-24 12:32:58 +0100879 THUMB( nop )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 mov pc, lr
Catalin Marinas0e056f22009-07-24 12:32:58 +0100881 THUMB( nop )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 mov pc, lr
Catalin Marinas0e056f22009-07-24 12:32:58 +0100883 THUMB( nop )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884
885 @ Everything from here on will be the new ID system.
886
887 .word 0x4401a100 @ sa110 / sa1100
888 .word 0xffffffe0
Catalin Marinas0e056f22009-07-24 12:32:58 +0100889 W(b) __armv4_mmu_cache_on
890 W(b) __armv4_mmu_cache_off
891 W(b) __armv4_mmu_cache_flush
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892
893 .word 0x6901b110 @ sa1110
894 .word 0xfffffff0
Catalin Marinas0e056f22009-07-24 12:32:58 +0100895 W(b) __armv4_mmu_cache_on
896 W(b) __armv4_mmu_cache_off
897 W(b) __armv4_mmu_cache_flush
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898
Haojian Zhuang4157d312010-03-12 05:47:55 -0500899 .word 0x56056900
900 .word 0xffffff00 @ PXA9xx
Catalin Marinas0e056f22009-07-24 12:32:58 +0100901 W(b) __armv4_mmu_cache_on
902 W(b) __armv4_mmu_cache_off
903 W(b) __armv4_mmu_cache_flush
Eric Miao59c7bcd2008-11-29 21:42:39 +0800904
Eric Miao49cbe782009-01-20 14:15:18 +0800905 .word 0x56158000 @ PXA168
906 .word 0xfffff000
Catalin Marinas0e056f22009-07-24 12:32:58 +0100907 W(b) __armv4_mmu_cache_on
908 W(b) __armv4_mmu_cache_off
909 W(b) __armv5tej_mmu_cache_flush
Eric Miao49cbe782009-01-20 14:15:18 +0800910
Nicolas Pitre2e2023f2008-06-03 23:06:21 +0200911 .word 0x56050000 @ Feroceon
912 .word 0xff0f0000
Catalin Marinas0e056f22009-07-24 12:32:58 +0100913 W(b) __armv4_mmu_cache_on
914 W(b) __armv4_mmu_cache_off
915 W(b) __armv5tej_mmu_cache_flush
Nicolas Pitre3ebb5a22007-10-31 15:31:48 -0400916
Joonyoung Shim55879312009-06-16 20:05:57 +0900917#ifdef CONFIG_CPU_FEROCEON_OLD_ID
918 /* this conflicts with the standard ARMv5TE entry */
919 .long 0x41009260 @ Old Feroceon
920 .long 0xff00fff0
921 b __armv4_mmu_cache_on
922 b __armv4_mmu_cache_off
923 b __armv5tej_mmu_cache_flush
924#endif
925
Paulius Zaleckas28853ac2009-03-25 13:10:01 +0200926 .word 0x66015261 @ FA526
927 .word 0xff01fff1
Catalin Marinas0e056f22009-07-24 12:32:58 +0100928 W(b) __fa526_cache_on
929 W(b) __armv4_mmu_cache_off
930 W(b) __fa526_cache_flush
Paulius Zaleckas28853ac2009-03-25 13:10:01 +0200931
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932 @ These match on the architecture ID
933
934 .word 0x00020000 @ ARMv4T
935 .word 0x000f0000
Catalin Marinas0e056f22009-07-24 12:32:58 +0100936 W(b) __armv4_mmu_cache_on
937 W(b) __armv4_mmu_cache_off
938 W(b) __armv4_mmu_cache_flush
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939
940 .word 0x00050000 @ ARMv5TE
941 .word 0x000f0000
Catalin Marinas0e056f22009-07-24 12:32:58 +0100942 W(b) __armv4_mmu_cache_on
943 W(b) __armv4_mmu_cache_off
944 W(b) __armv4_mmu_cache_flush
Linus Torvalds1da177e2005-04-16 15:20:36 -0700945
946 .word 0x00060000 @ ARMv5TEJ
947 .word 0x000f0000
Catalin Marinas0e056f22009-07-24 12:32:58 +0100948 W(b) __armv4_mmu_cache_on
949 W(b) __armv4_mmu_cache_off
Sascha Hauer75216852010-03-15 15:14:50 +0100950 W(b) __armv5tej_mmu_cache_flush
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951
Catalin Marinas45a7b9c2006-06-18 16:21:50 +0100952 .word 0x0007b000 @ ARMv6
Catalin Marinas7d09e852007-06-01 17:14:53 +0100953 .word 0x000ff000
Dave Martin50101922012-11-22 12:50:43 +0100954 W(b) __armv6_mmu_cache_on
Catalin Marinas0e056f22009-07-24 12:32:58 +0100955 W(b) __armv4_mmu_cache_off
956 W(b) __armv6_mmu_cache_flush
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957
Catalin Marinas7d09e852007-06-01 17:14:53 +0100958 .word 0x000f0000 @ new CPU Id
959 .word 0x000f0000
Catalin Marinas0e056f22009-07-24 12:32:58 +0100960 W(b) __armv7_mmu_cache_on
961 W(b) __armv7_mmu_cache_off
962 W(b) __armv7_mmu_cache_flush
Catalin Marinas7d09e852007-06-01 17:14:53 +0100963
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964 .word 0 @ unrecognised type
965 .word 0
966 mov pc, lr
Catalin Marinas0e056f22009-07-24 12:32:58 +0100967 THUMB( nop )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968 mov pc, lr
Catalin Marinas0e056f22009-07-24 12:32:58 +0100969 THUMB( nop )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700970 mov pc, lr
Catalin Marinas0e056f22009-07-24 12:32:58 +0100971 THUMB( nop )
Linus Torvalds1da177e2005-04-16 15:20:36 -0700972
973 .size proc_types, . - proc_types
974
Dave Martin946a1052011-06-14 14:20:44 +0100975 /*
976 * If you get a "non-constant expression in ".if" statement"
977 * error from the assembler on this line, check that you have
978 * not accidentally written a "b" instruction where you should
979 * have written W(b).
980 */
981 .if (. - proc_types) % PROC_ENTRY_SIZE != 0
982 .error "The size of one or more proc_types entries is wrong."
983 .endif
984
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985/*
986 * Turn off the Cache and MMU. ARMv3 does not support
987 * reading the control register, but ARMv4 does.
988 *
Uwe Kleine-König21b28412010-01-26 22:08:09 +0100989 * On exit,
990 * r0, r1, r2, r3, r9, r12 corrupted
991 * This routine must preserve:
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +0100992 * r4, r7, r8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993 */
994 .align 5
995cache_off: mov r3, #12 @ cache_off function
996 b call_cache_fn
997
Hyok S. Choi10c2df62006-03-27 10:21:34 +0100998__armv4_mpu_cache_off:
999 mrc p15, 0, r0, c1, c0
1000 bic r0, r0, #0x000d
1001 mcr p15, 0, r0, c1, c0 @ turn MPU and cache off
1002 mov r0, #0
1003 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
1004 mcr p15, 0, r0, c7, c6, 0 @ flush D-Cache
1005 mcr p15, 0, r0, c7, c5, 0 @ flush I-Cache
1006 mov pc, lr
1007
1008__armv3_mpu_cache_off:
1009 mrc p15, 0, r0, c1, c0
1010 bic r0, r0, #0x000d
1011 mcr p15, 0, r0, c1, c0, 0 @ turn MPU and cache off
1012 mov r0, #0
1013 mcr p15, 0, r0, c7, c0, 0 @ invalidate whole cache v3
1014 mov pc, lr
1015
Hyok S. Choic76b6b42006-03-24 09:53:18 +00001016__armv4_mmu_cache_off:
Catalin Marinas8bdca0a2009-07-24 12:35:06 +01001017#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018 mrc p15, 0, r0, c1, c0
1019 bic r0, r0, #0x000d
1020 mcr p15, 0, r0, c1, c0 @ turn MMU and cache off
1021 mov r0, #0
1022 mcr p15, 0, r0, c7, c7 @ invalidate whole cache v4
1023 mcr p15, 0, r0, c8, c7 @ invalidate whole TLB v4
Catalin Marinas8bdca0a2009-07-24 12:35:06 +01001024#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001025 mov pc, lr
1026
Catalin Marinas7d09e852007-06-01 17:14:53 +01001027__armv7_mmu_cache_off:
1028 mrc p15, 0, r0, c1, c0
Catalin Marinas8bdca0a2009-07-24 12:35:06 +01001029#ifdef CONFIG_MMU
Catalin Marinas7d09e852007-06-01 17:14:53 +01001030 bic r0, r0, #0x000d
Catalin Marinas8bdca0a2009-07-24 12:35:06 +01001031#else
1032 bic r0, r0, #0x000c
1033#endif
Catalin Marinas7d09e852007-06-01 17:14:53 +01001034 mcr p15, 0, r0, c1, c0 @ turn MMU and cache off
1035 mov r12, lr
1036 bl __armv7_mmu_cache_flush
1037 mov r0, #0
Catalin Marinas8bdca0a2009-07-24 12:35:06 +01001038#ifdef CONFIG_MMU
Catalin Marinas7d09e852007-06-01 17:14:53 +01001039 mcr p15, 0, r0, c8, c7, 0 @ invalidate whole TLB
Catalin Marinas8bdca0a2009-07-24 12:35:06 +01001040#endif
Catalin Marinasc30c2f92008-11-06 13:23:07 +00001041 mcr p15, 0, r0, c7, c5, 6 @ invalidate BTC
1042 mcr p15, 0, r0, c7, c10, 4 @ DSB
1043 mcr p15, 0, r0, c7, c5, 4 @ ISB
Catalin Marinas7d09e852007-06-01 17:14:53 +01001044 mov pc, r12
1045
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046/*
1047 * Clean and flush the cache to maintain consistency.
1048 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049 * On exit,
Uwe Kleine-König21b28412010-01-26 22:08:09 +01001050 * r1, r2, r3, r9, r10, r11, r12 corrupted
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051 * This routine must preserve:
Nicolas Pitre6d7d0ae2011-02-21 07:06:45 +01001052 * r4, r6, r7, r8
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053 */
1054 .align 5
1055cache_clean_flush:
1056 mov r3, #16
1057 b call_cache_fn
1058
Hyok S. Choi10c2df62006-03-27 10:21:34 +01001059__armv4_mpu_cache_flush:
1060 mov r2, #1
1061 mov r3, #0
1062 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
1063 mov r1, #7 << 5 @ 8 segments
10641: orr r3, r1, #63 << 26 @ 64 entries
10652: mcr p15, 0, r3, c7, c14, 2 @ clean & invalidate D index
1066 subs r3, r3, #1 << 26
1067 bcs 2b @ entries 63 to 0
1068 subs r1, r1, #1 << 5
1069 bcs 1b @ segments 7 to 0
1070
1071 teq r2, #0
1072 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
1073 mcr p15, 0, ip, c7, c10, 4 @ drain WB
1074 mov pc, lr
1075
Paulius Zaleckas28853ac2009-03-25 13:10:01 +02001076__fa526_cache_flush:
1077 mov r1, #0
1078 mcr p15, 0, r1, c7, c14, 0 @ clean and invalidate D cache
1079 mcr p15, 0, r1, c7, c5, 0 @ flush I cache
1080 mcr p15, 0, r1, c7, c10, 4 @ drain WB
1081 mov pc, lr
Hyok S. Choi10c2df62006-03-27 10:21:34 +01001082
Hyok S. Choic76b6b42006-03-24 09:53:18 +00001083__armv6_mmu_cache_flush:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084 mov r1, #0
1085 mcr p15, 0, r1, c7, c14, 0 @ clean+invalidate D
1086 mcr p15, 0, r1, c7, c5, 0 @ invalidate I+BTB
1087 mcr p15, 0, r1, c7, c15, 0 @ clean+invalidate unified
1088 mcr p15, 0, r1, c7, c10, 4 @ drain WB
1089 mov pc, lr
1090
Catalin Marinas7d09e852007-06-01 17:14:53 +01001091__armv7_mmu_cache_flush:
1092 mrc p15, 0, r10, c0, c1, 5 @ read ID_MMFR1
1093 tst r10, #0xf << 16 @ hierarchical cache (ARMv7)
Catalin Marinas7d09e852007-06-01 17:14:53 +01001094 mov r10, #0
Catalin Marinasc30c2f92008-11-06 13:23:07 +00001095 beq hierarchical
Catalin Marinas7d09e852007-06-01 17:14:53 +01001096 mcr p15, 0, r10, c7, c14, 0 @ clean+invalidate D
1097 b iflush
1098hierarchical:
Catalin Marinasc30c2f92008-11-06 13:23:07 +00001099 mcr p15, 0, r10, c7, c10, 5 @ DMB
Catalin Marinas0e056f22009-07-24 12:32:58 +01001100 stmfd sp!, {r0-r7, r9-r11}
Catalin Marinas7d09e852007-06-01 17:14:53 +01001101 mrc p15, 1, r0, c0, c0, 1 @ read clidr
1102 ands r3, r0, #0x7000000 @ extract loc from clidr
1103 mov r3, r3, lsr #23 @ left align loc bit field
1104 beq finished @ if loc is 0, then no need to clean
1105 mov r10, #0 @ start clean at cache level 0
1106loop1:
1107 add r2, r10, r10, lsr #1 @ work out 3x current cache level
1108 mov r1, r0, lsr r2 @ extract cache type bits from clidr
1109 and r1, r1, #7 @ mask of the bits for current cache only
1110 cmp r1, #2 @ see what cache we have at this level
1111 blt skip @ skip if no cache, or just i-cache
1112 mcr p15, 2, r10, c0, c0, 0 @ select current cache level in cssr
1113 mcr p15, 0, r10, c7, c5, 4 @ isb to sych the new cssr&csidr
1114 mrc p15, 1, r1, c0, c0, 0 @ read the new csidr
1115 and r2, r1, #7 @ extract the length of the cache lines
1116 add r2, r2, #4 @ add 4 (line length offset)
1117 ldr r4, =0x3ff
1118 ands r4, r4, r1, lsr #3 @ find maximum number on the way size
Catalin Marinas000b5022008-10-03 11:09:10 +01001119 clz r5, r4 @ find bit position of way size increment
Catalin Marinas7d09e852007-06-01 17:14:53 +01001120 ldr r7, =0x7fff
1121 ands r7, r7, r1, lsr #13 @ extract max number of the index size
1122loop2:
1123 mov r9, r4 @ create working copy of max way size
1124loop3:
Catalin Marinas0e056f22009-07-24 12:32:58 +01001125 ARM( orr r11, r10, r9, lsl r5 ) @ factor way and cache number into r11
1126 ARM( orr r11, r11, r7, lsl r2 ) @ factor index number into r11
1127 THUMB( lsl r6, r9, r5 )
1128 THUMB( orr r11, r10, r6 ) @ factor way and cache number into r11
1129 THUMB( lsl r6, r7, r2 )
1130 THUMB( orr r11, r11, r6 ) @ factor index number into r11
Catalin Marinas7d09e852007-06-01 17:14:53 +01001131 mcr p15, 0, r11, c7, c14, 2 @ clean & invalidate by set/way
1132 subs r9, r9, #1 @ decrement the way
1133 bge loop3
1134 subs r7, r7, #1 @ decrement the index
1135 bge loop2
1136skip:
1137 add r10, r10, #2 @ increment cache number
1138 cmp r3, r10
1139 bgt loop1
1140finished:
Catalin Marinas0e056f22009-07-24 12:32:58 +01001141 ldmfd sp!, {r0-r7, r9-r11}
Catalin Marinas7d09e852007-06-01 17:14:53 +01001142 mov r10, #0 @ swith back to cache level 0
1143 mcr p15, 2, r10, c0, c0, 0 @ select current cache level in cssr
Catalin Marinas7d09e852007-06-01 17:14:53 +01001144iflush:
Catalin Marinasc30c2f92008-11-06 13:23:07 +00001145 mcr p15, 0, r10, c7, c10, 4 @ DSB
Catalin Marinas7d09e852007-06-01 17:14:53 +01001146 mcr p15, 0, r10, c7, c5, 0 @ invalidate I+BTB
Catalin Marinasc30c2f92008-11-06 13:23:07 +00001147 mcr p15, 0, r10, c7, c10, 4 @ DSB
1148 mcr p15, 0, r10, c7, c5, 4 @ ISB
Catalin Marinas7d09e852007-06-01 17:14:53 +01001149 mov pc, lr
1150
Nicolas Pitre15754bf2007-10-31 15:15:29 -04001151__armv5tej_mmu_cache_flush:
11521: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate D cache
1153 bne 1b
1154 mcr p15, 0, r0, c7, c5, 0 @ flush I cache
1155 mcr p15, 0, r0, c7, c10, 4 @ drain WB
1156 mov pc, lr
1157
Hyok S. Choic76b6b42006-03-24 09:53:18 +00001158__armv4_mmu_cache_flush:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159 mov r2, #64*1024 @ default: 32K dcache size (*2)
1160 mov r11, #32 @ default: 32 byte line size
1161 mrc p15, 0, r3, c0, c0, 1 @ read cache type
Russell King98e12b52010-02-25 23:56:38 +00001162 teq r3, r9 @ cache ID register present?
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163 beq no_cache_id
1164 mov r1, r3, lsr #18
1165 and r1, r1, #7
1166 mov r2, #1024
1167 mov r2, r2, lsl r1 @ base dcache size *2
1168 tst r3, #1 << 14 @ test M bit
1169 addne r2, r2, r2, lsr #1 @ +1/2 size if M == 1
1170 mov r3, r3, lsr #12
1171 and r3, r3, #3
1172 mov r11, #8
1173 mov r11, r11, lsl r3 @ cache line size in bytes
1174no_cache_id:
Catalin Marinas0e056f22009-07-24 12:32:58 +01001175 mov r1, pc
1176 bic r1, r1, #63 @ align to longest cache line
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177 add r2, r1, r2
Catalin Marinas0e056f22009-07-24 12:32:58 +010011781:
1179 ARM( ldr r3, [r1], r11 ) @ s/w flush D cache
1180 THUMB( ldr r3, [r1] ) @ s/w flush D cache
1181 THUMB( add r1, r1, r11 )
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 teq r1, r2
1183 bne 1b
1184
1185 mcr p15, 0, r1, c7, c5, 0 @ flush I cache
1186 mcr p15, 0, r1, c7, c6, 0 @ flush D cache
1187 mcr p15, 0, r1, c7, c10, 4 @ drain WB
1188 mov pc, lr
1189
Hyok S. Choic76b6b42006-03-24 09:53:18 +00001190__armv3_mmu_cache_flush:
Hyok S. Choi10c2df62006-03-27 10:21:34 +01001191__armv3_mpu_cache_flush:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192 mov r1, #0
Uwe Kleine-König63fa7182010-01-26 22:18:09 +01001193 mcr p15, 0, r1, c7, c0, 0 @ invalidate whole cache v3
Linus Torvalds1da177e2005-04-16 15:20:36 -07001194 mov pc, lr
1195
1196/*
1197 * Various debugging routines for printing hex characters and
1198 * memory, which again must be relocatable.
1199 */
1200#ifdef DEBUG
Catalin Marinas88987ef2009-07-24 12:32:52 +01001201 .align 2
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202 .type phexbuf,#object
1203phexbuf: .space 12
1204 .size phexbuf, . - phexbuf
1205
Uwe Kleine-Königbe6f9f02010-01-26 22:22:20 +01001206@ phex corrupts {r0, r1, r2, r3}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207phex: adr r3, phexbuf
1208 mov r2, #0
1209 strb r2, [r3, r1]
12101: subs r1, r1, #1
1211 movmi r0, r3
1212 bmi puts
1213 and r2, r0, #15
1214 mov r0, r0, lsr #4
1215 cmp r2, #10
1216 addge r2, r2, #7
1217 add r2, r2, #'0'
1218 strb r2, [r3, r1]
1219 b 1b
1220
Uwe Kleine-Königbe6f9f02010-01-26 22:22:20 +01001221@ puts corrupts {r0, r1, r2, r3}
Tony Lindgren4e6d4882010-02-01 23:26:53 +01001222puts: loadsp r3, r1
Linus Torvalds1da177e2005-04-16 15:20:36 -070012231: ldrb r2, [r0], #1
1224 teq r2, #0
1225 moveq pc, lr
Russell King5cd0c342005-05-03 12:18:46 +010012262: writeb r2, r3
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227 mov r1, #0x00020000
12283: subs r1, r1, #1
1229 bne 3b
1230 teq r2, #'\n'
1231 moveq r2, #'\r'
1232 beq 2b
1233 teq r0, #0
1234 bne 1b
1235 mov pc, lr
Uwe Kleine-Königbe6f9f02010-01-26 22:22:20 +01001236@ putc corrupts {r0, r1, r2, r3}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001237putc:
1238 mov r2, r0
1239 mov r0, #0
Tony Lindgren4e6d4882010-02-01 23:26:53 +01001240 loadsp r3, r1
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241 b 2b
1242
Uwe Kleine-Königbe6f9f02010-01-26 22:22:20 +01001243@ memdump corrupts {r0, r1, r2, r3, r10, r11, r12, lr}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001244memdump: mov r12, r0
1245 mov r10, lr
1246 mov r11, #0
12472: mov r0, r11, lsl #2
1248 add r0, r0, r12
1249 mov r1, #8
1250 bl phex
1251 mov r0, #':'
1252 bl putc
12531: mov r0, #' '
1254 bl putc
1255 ldr r0, [r12, r11, lsl #2]
1256 mov r1, #8
1257 bl phex
1258 and r0, r11, #7
1259 teq r0, #3
1260 moveq r0, #' '
1261 bleq putc
1262 and r0, r11, #7
1263 add r11, r11, #1
1264 teq r0, #7
1265 bne 1b
1266 mov r0, #'\n'
1267 bl putc
1268 cmp r11, #64
1269 blt 2b
1270 mov pc, r10
1271#endif
1272
Catalin Marinas92c83ff2007-06-22 14:27:50 +01001273 .ltorg
Dave Martin424e5992012-02-10 18:07:07 -08001274
1275#ifdef CONFIG_ARM_VIRT_EXT
1276.align 5
1277__hyp_reentry_vectors:
1278 W(b) . @ reset
1279 W(b) . @ undef
1280 W(b) . @ svc
1281 W(b) . @ pabort
1282 W(b) . @ dabort
1283 W(b) __enter_kernel @ hyp
1284 W(b) . @ irq
1285 W(b) . @ fiq
1286#endif /* CONFIG_ARM_VIRT_EXT */
1287
1288__enter_kernel:
1289 mov r0, #0 @ must be 0
1290 ARM( mov pc, r4 ) @ call kernel
1291 THUMB( bx r4 ) @ entry point is always ARM
1292
Nicolas Pitreadcc2592011-04-27 16:15:11 -04001293reloc_code_end:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294
1295 .align
Russell Kingb0c4d4e2010-11-22 12:00:59 +00001296 .section ".stack", "aw", %nobits
Nicolas Pitre8d7e4cc2011-04-27 14:54:39 -04001297.L_user_stack: .space 4096
1298.L_user_stack_end: