Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * relocate_kernel.S - put the kernel image in place to boot
0004  */
0005 
0006 #include <linux/linkage.h>
0007 #include <asm/assembler.h>
0008 #include <asm/asm-offsets.h>
0009 #include <asm/kexec.h>
0010 
0011     .align  3   /* not needed for this code, but keeps fncpy() happy */
0012 
0013 ENTRY(relocate_new_kernel)
0014 
0015     adr r7, relocate_new_kernel_end
0016     ldr r0, [r7, #KEXEC_INDIR_PAGE]
0017     ldr r1, [r7, #KEXEC_START_ADDR]
0018 
0019     /*
0020      * If there is no indirection page (we are doing crashdumps)
0021      * skip any relocation.
0022      */
0023     cmp r0, #0
0024     beq 2f
0025 
0026 0:  /* top, read another word for the indirection page */
0027     ldr r3, [r0],#4
0028 
0029     /* Is it a destination page. Put destination address to r4 */
0030     tst r3,#1
0031     beq 1f
0032     bic r4,r3,#1
0033     b   0b
0034 1:
0035     /* Is it an indirection page */
0036     tst r3,#2
0037     beq 1f
0038     bic r0,r3,#2
0039     b   0b
0040 1:
0041 
0042     /* are we done ? */
0043     tst r3,#4
0044     beq 1f
0045     b   2f
0046 
0047 1:
0048     /* is it source ? */
0049     tst r3,#8
0050     beq 0b
0051     bic r3,r3,#8
0052     mov r6,#1024
0053 9:
0054     ldr r5,[r3],#4
0055     str r5,[r4],#4
0056     subs r6,r6,#1
0057     bne 9b
0058     b 0b
0059 
0060 2:
0061     /* Jump to relocated kernel */
0062     mov lr, r1
0063     mov r0, #0
0064     ldr r1, [r7, #KEXEC_MACH_TYPE]
0065     ldr r2, [r7, #KEXEC_R2]
0066  ARM(   ret lr  )
0067  THUMB( bx  lr  )
0068 
0069 ENDPROC(relocate_new_kernel)
0070 
0071     .align  3
0072 relocate_new_kernel_end:
0073 
0074     .globl relocate_new_kernel_size
0075 relocate_new_kernel_size:
0076     .long relocate_new_kernel_end - relocate_new_kernel
0077 
0078