early_32.c 888 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. /*
  10. * We're called here very early in the boot.
  11. *
  12. * Note that the kernel may be running at an address which is different
  13. * from the address that it was linked at, so we must use RELOC/PTRRELOC
  14. * to access static data (including strings). -- paulus
  15. */
  16. notrace unsigned long __init early_init(unsigned long dt_ptr)
  17. {
  18. unsigned long kva, offset = reloc_offset();
  19. kva = *PTRRELOC(&kernstart_virt_addr);
  20. /* First zero the BSS */
  21. if (kva == KERNELBASE)
  22. memset(PTRRELOC(&__bss_start), 0, __bss_stop - __bss_start);
  23. /*
  24. * Identify the CPU type and fix up code sections
  25. * that depend on which cpu we have.
  26. */
  27. identify_cpu(offset, mfspr(SPRN_PVR));
  28. apply_feature_fixups();
  29. return kva + offset;
  30. }