| Richard Purdie | c587e4a | 2007-02-06 21:29:00 +0100 | [diff] [blame] | 1 | /* | 
|  | 2 | * relocate_kernel.S - put the kernel image in place to boot | 
|  | 3 | */ | 
|  | 4 |  | 
|  | 5 | #include <asm/kexec.h> | 
|  | 6 |  | 
|  | 7 | .globl relocate_new_kernel | 
|  | 8 | relocate_new_kernel: | 
|  | 9 |  | 
|  | 10 | ldr	r0,kexec_indirection_page | 
|  | 11 | ldr	r1,kexec_start_address | 
|  | 12 |  | 
| Mika Westerberg | 8594a0c | 2010-05-10 09:24:53 +0100 | [diff] [blame] | 13 | /* | 
|  | 14 | * If there is no indirection page (we are doing crashdumps) | 
|  | 15 | * skip any relocation. | 
|  | 16 | */ | 
|  | 17 | cmp	r0, #0 | 
|  | 18 | beq	2f | 
| Richard Purdie | c587e4a | 2007-02-06 21:29:00 +0100 | [diff] [blame] | 19 |  | 
|  | 20 | 0:	/* top, read another word for the indirection page */ | 
|  | 21 | ldr	r3, [r0],#4 | 
|  | 22 |  | 
|  | 23 | /* Is it a destination page. Put destination address to r4 */ | 
|  | 24 | tst	r3,#1,0 | 
|  | 25 | beq	1f | 
|  | 26 | bic	r4,r3,#1 | 
|  | 27 | b	0b | 
|  | 28 | 1: | 
|  | 29 | /* Is it an indirection page */ | 
|  | 30 | tst	r3,#2,0 | 
|  | 31 | beq	1f | 
|  | 32 | bic	r0,r3,#2 | 
|  | 33 | b	0b | 
|  | 34 | 1: | 
|  | 35 |  | 
|  | 36 | /* are we done ? */ | 
|  | 37 | tst	r3,#4,0 | 
|  | 38 | beq	1f | 
|  | 39 | b	2f | 
|  | 40 |  | 
|  | 41 | 1: | 
|  | 42 | /* is it source ? */ | 
|  | 43 | tst	r3,#8,0 | 
|  | 44 | beq	0b | 
|  | 45 | bic r3,r3,#8 | 
|  | 46 | mov r6,#1024 | 
|  | 47 | 9: | 
|  | 48 | ldr r5,[r3],#4 | 
|  | 49 | str r5,[r4],#4 | 
|  | 50 | subs r6,r6,#1 | 
|  | 51 | bne 9b | 
|  | 52 | b 0b | 
|  | 53 |  | 
|  | 54 | 2: | 
|  | 55 | /* Jump to relocated kernel */ | 
|  | 56 | mov lr,r1 | 
|  | 57 | mov r0,#0 | 
|  | 58 | ldr r1,kexec_mach_type | 
| Richard Purdie | 4cd9d6f | 2008-01-02 00:56:46 +0100 | [diff] [blame] | 59 | ldr r2,kexec_boot_atags | 
| Richard Purdie | c587e4a | 2007-02-06 21:29:00 +0100 | [diff] [blame] | 60 | mov pc,lr | 
|  | 61 |  | 
|  | 62 | .globl kexec_start_address | 
|  | 63 | kexec_start_address: | 
|  | 64 | .long	0x0 | 
|  | 65 |  | 
|  | 66 | .globl kexec_indirection_page | 
|  | 67 | kexec_indirection_page: | 
|  | 68 | .long	0x0 | 
|  | 69 |  | 
|  | 70 | .globl kexec_mach_type | 
|  | 71 | kexec_mach_type: | 
|  | 72 | .long	0x0 | 
|  | 73 |  | 
| Richard Purdie | 4cd9d6f | 2008-01-02 00:56:46 +0100 | [diff] [blame] | 74 | /* phy addr of the atags for the new kernel */ | 
|  | 75 | .globl kexec_boot_atags | 
|  | 76 | kexec_boot_atags: | 
| Mike Westerhof | 033b8ff | 2007-10-11 03:18:14 +0100 | [diff] [blame] | 77 | .long	0x0 | 
|  | 78 |  | 
| Richard Purdie | c587e4a | 2007-02-06 21:29:00 +0100 | [diff] [blame] | 79 | relocate_new_kernel_end: | 
|  | 80 |  | 
|  | 81 | .globl relocate_new_kernel_size | 
|  | 82 | relocate_new_kernel_size: | 
|  | 83 | .long relocate_new_kernel_end - relocate_new_kernel | 
|  | 84 |  | 
|  | 85 |  |