zimage.c 906 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2016
  4. * Ladislav Michl <ladis@linux-mips.org>
  5. *
  6. * bootz code:
  7. * Copyright (C) 2012 Marek Vasut <marek.vasut@gmail.com>
  8. */
  9. #include <common.h>
  10. #include <image.h>
  11. #define LINUX_ARM_ZIMAGE_MAGIC 0x016f2818
  12. #define BAREBOX_IMAGE_MAGIC 0x00786f62
  13. struct arm_z_header {
  14. uint32_t code[9];
  15. uint32_t zi_magic;
  16. uint32_t zi_start;
  17. uint32_t zi_end;
  18. } __attribute__ ((__packed__));
  19. int bootz_setup(ulong image, ulong *start, ulong *end)
  20. {
  21. struct arm_z_header *zi = (struct arm_z_header *)image;
  22. if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC &&
  23. zi->zi_magic != BAREBOX_IMAGE_MAGIC) {
  24. #ifndef CONFIG_SPL_FRAMEWORK
  25. puts("zimage: Bad magic!\n");
  26. #endif
  27. return 1;
  28. }
  29. *start = zi->zi_start;
  30. *end = zi->zi_end;
  31. #ifndef CONFIG_SPL_FRAMEWORK
  32. printf("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n",
  33. image, *start, *end);
  34. #endif
  35. return 0;
  36. }