epapr.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Bootwrapper for ePAPR compliant firmwares
  4. *
  5. * Copyright 2010 David Gibson <[email protected]>, IBM Corporation.
  6. *
  7. * Based on earlier bootwrappers by:
  8. * (c) Benjamin Herrenschmidt <[email protected]>, IBM Corp,\
  9. * and
  10. * Scott Wood <[email protected]>
  11. * Copyright (c) 2007 Freescale Semiconductor, Inc.
  12. */
  13. #include "ops.h"
  14. #include "stdio.h"
  15. #include "io.h"
  16. #include <libfdt.h>
  17. BSS_STACK(4096);
  18. #define EPAPR_SMAGIC 0x65504150
  19. #define EPAPR_EMAGIC 0x45504150
  20. static unsigned epapr_magic;
  21. static unsigned long ima_size;
  22. static unsigned long fdt_addr;
  23. static void platform_fixups(void)
  24. {
  25. if ((epapr_magic != EPAPR_EMAGIC)
  26. && (epapr_magic != EPAPR_SMAGIC))
  27. fatal("r6 contained 0x%08x instead of ePAPR magic number\n",
  28. epapr_magic);
  29. if (ima_size < (unsigned long)_end)
  30. printf("WARNING: Image loaded outside IMA!"
  31. " (_end=%p, ima_size=0x%lx)\n", _end, ima_size);
  32. if (ima_size < fdt_addr)
  33. printf("WARNING: Device tree address is outside IMA!"
  34. "(fdt_addr=0x%lx, ima_size=0x%lx)\n", fdt_addr,
  35. ima_size);
  36. if (ima_size < fdt_addr + fdt_totalsize((void *)fdt_addr))
  37. printf("WARNING: Device tree extends outside IMA!"
  38. " (fdt_addr=0x%lx, size=0x%x, ima_size=0x%lx\n",
  39. fdt_addr, fdt_totalsize((void *)fdt_addr), ima_size);
  40. }
  41. void epapr_platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  42. unsigned long r6, unsigned long r7)
  43. {
  44. epapr_magic = r6;
  45. ima_size = r7;
  46. fdt_addr = r3;
  47. /* FIXME: we should process reserve entries */
  48. simple_alloc_init(_end, ima_size - (unsigned long)_end, 32, 64);
  49. fdt_init((void *)fdt_addr);
  50. serial_console_init();
  51. platform_ops.fixups = platform_fixups;
  52. }