[ARM] Allow r2 to be passed through the decompressor to the kernel

This is part of a patch from Marc Singer to allow r2 to be
passed to the kernel. Marc's original comments follow:

This revised R2 (atags pointer) patch incorporates comments from Nico
Pitre and Ben Dooks. It modifies the head.S files such that the R2
value set by the bootloader is conveyed to the kernel startup code.
The kernel head.S heuristically validates the pointer. It will set R2
to zero if it believes the pointer is invalid. Presently, it requires
that the ATAGS list reside in the first 16KiB of physical RAM.
Relaxing this contraint may be both desirable as well as tricky.

Signed-off-by: Marc Singer <elf@buici.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Russell King and committed by Russell King f4619025 90303b10

+25 -21
+25 -21
arch/arm/boot/compressed/head.S
··· 84 84 kputc #'\n' 85 85 kphex r5, 8 /* decompressed kernel start */ 86 86 kputc #'-' 87 - kphex r8, 8 /* decompressed kernel end */ 87 + kphex r9, 8 /* decompressed kernel end */ 88 88 kputc #'>' 89 89 kphex r4, 8 /* kernel execution address */ 90 90 kputc #'\n' ··· 116 116 .word start @ absolute load/run zImage address 117 117 .word _edata @ zImage end address 118 118 1: mov r7, r1 @ save architecture ID 119 - mov r8, #0 @ save r0 119 + mov r8, r2 @ save atags pointer 120 120 121 121 #ifndef __ARM_ARCH_2__ 122 122 /* ··· 144 144 145 145 /* 146 146 * some architecture specific code can be inserted 147 - * by the linker here, but it should preserve r7 and r8. 147 + * by the linker here, but it should preserve r7, r8, and r9. 148 148 */ 149 149 150 150 .text ··· 249 249 * r5 = decompressed kernel start 250 250 * r6 = processor ID 251 251 * r7 = architecture ID 252 - * r8-r14 = unused 252 + * r8 = atags pointer 253 + * r9-r14 = corrupted 253 254 */ 254 255 add r1, r5, r0 @ end of decompressed kernel 255 256 adr r2, reloc_start 256 257 ldr r3, LC1 257 258 add r3, r2, r3 258 - 1: ldmia r2!, {r8 - r13} @ copy relocation code 259 - stmia r1!, {r8 - r13} 260 - ldmia r2!, {r8 - r13} 261 - stmia r1!, {r8 - r13} 259 + 1: ldmia r2!, {r9 - r14} @ copy relocation code 260 + stmia r1!, {r9 - r14} 261 + ldmia r2!, {r9 - r14} 262 + stmia r1!, {r9 - r14} 262 263 cmp r2, r3 263 264 blo 1b 264 265 ··· 309 308 * r4 = kernel execution address 310 309 * r6 = processor ID 311 310 * r7 = architecture number 312 - * r8 = run-time address of "start" 311 + * r8 = atags pointer 312 + * r9 = run-time address of "start" (???) 313 313 * On exit, 314 - * r1, r2, r3, r8, r9, r12 corrupted 314 + * r1, r2, r3, r9, r10, r12 corrupted 315 315 * This routine must preserve: 316 - * r4, r5, r6, r7 316 + * r4, r5, r6, r7, r8 317 317 */ 318 318 .align 5 319 319 cache_on: mov r3, #8 @ cache_on function ··· 328 326 * bits for the RAM area only. 329 327 */ 330 328 mov r0, r3 331 - mov r8, r0, lsr #18 332 - mov r8, r8, lsl #18 @ start of RAM 333 - add r9, r8, #0x10000000 @ a reasonable RAM size 329 + mov r9, r0, lsr #18 330 + mov r9, r9, lsl #18 @ start of RAM 331 + add r10, r9, #0x10000000 @ a reasonable RAM size 334 332 mov r1, #0x12 335 333 orr r1, r1, #3 << 10 336 334 add r2, r3, #16384 337 335 1: cmp r1, r8 @ if virt > start of RAM 338 336 orrhs r1, r1, #0x0c @ set cacheable, bufferable 339 - cmp r1, r9 @ if virt > end of RAM 337 + cmp r1, r10 @ if virt > end of RAM 340 338 bichs r1, r1, #0x0c @ clear cacheable, bufferable 341 339 str r1, [r0], #4 @ 1:1 mapping 342 340 add r1, r1, #1048576 ··· 405 403 * r5 = decompressed kernel start 406 404 * r6 = processor ID 407 405 * r7 = architecture ID 408 - * r8-r14 = unused 406 + * r8 = atags pointer 407 + * r9-r14 = corrupted 409 408 */ 410 409 .align 5 411 - reloc_start: add r8, r5, r0 410 + reloc_start: add r9, r5, r0 412 411 debug_reloc_start 413 412 mov r1, r4 414 413 1: 415 414 .rept 4 416 - ldmia r5!, {r0, r2, r3, r9 - r13} @ relocate kernel 417 - stmia r1!, {r0, r2, r3, r9 - r13} 415 + ldmia r5!, {r0, r2, r3, r10 - r14} @ relocate kernel 416 + stmia r1!, {r0, r2, r3, r10 - r14} 418 417 .endr 419 418 420 - cmp r5, r8 419 + cmp r5, r9 421 420 blo 1b 422 421 debug_reloc_end 423 422 424 423 call_kernel: bl cache_clean_flush 425 424 bl cache_off 426 - mov r0, #0 425 + mov r0, #0 @ must be zero 427 426 mov r1, r7 @ restore architecture number 427 + mov r2, r8 @ restore atags pointer 428 428 mov pc, r4 @ call kernel 429 429 430 430 /*