Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 
0003 /*
0004  * Early init before relocation
0005  */
0006 
0007 #include <linux/init.h>
0008 #include <linux/kernel.h>
0009 #include <asm/setup.h>
0010 #include <asm/sections.h>
0011 
0012 /*
0013  * We're called here very early in the boot.
0014  *
0015  * Note that the kernel may be running at an address which is different
0016  * from the address that it was linked at, so we must use RELOC/PTRRELOC
0017  * to access static data (including strings).  -- paulus
0018  */
0019 notrace unsigned long __init early_init(unsigned long dt_ptr)
0020 {
0021     unsigned long kva, offset = reloc_offset();
0022 
0023     kva = *PTRRELOC(&kernstart_virt_addr);
0024 
0025     /* First zero the BSS */
0026     if (kva == KERNELBASE)
0027         memset(PTRRELOC(&__bss_start), 0, __bss_stop - __bss_start);
0028 
0029     /*
0030      * Identify the CPU type and fix up code sections
0031      * that depend on which cpu we have.
0032      */
0033     identify_cpu(offset, mfspr(SPRN_PVR));
0034 
0035     apply_feature_fixups();
0036 
0037     return kva + offset;
0038 }