early_32.c 920 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Early init before relocation
  4. */
  5. #include <linux/init.h>
  6. #include <linux/kernel.h>
  7. #include <asm/setup.h>
  8. #include <asm/sections.h>
  9. #include <asm/asm-prototypes.h>
  10. /*
  11. * We're called here very early in the boot.
  12. *
  13. * Note that the kernel may be running at an address which is different
  14. * from the address that it was linked at, so we must use RELOC/PTRRELOC
  15. * to access static data (including strings). -- paulus
  16. */
  17. notrace unsigned long __init early_init(unsigned long dt_ptr)
  18. {
  19. unsigned long kva, offset = reloc_offset();
  20. kva = *PTRRELOC(&kernstart_virt_addr);
  21. /* First zero the BSS */
  22. if (kva == KERNELBASE)
  23. memset(PTRRELOC(&__bss_start), 0, __bss_stop - __bss_start);
  24. /*
  25. * Identify the CPU type and fix up code sections
  26. * that depend on which cpu we have.
  27. */
  28. identify_cpu(offset, mfspr(SPRN_PVR));
  29. apply_feature_fixups();
  30. return kva + offset;
  31. }