Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / arm / lib / zimage.c
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
12 #define LINUX_ARM_ZIMAGE_MAGIC  0x016f2818
13 #define BAREBOX_IMAGE_MAGIC     0x00786f62
14
15 struct arm_z_header {
16         uint32_t        code[9];
17         uint32_t        zi_magic;
18         uint32_t        zi_start;
19         uint32_t        zi_end;
20 } __attribute__ ((__packed__));
21
22 int bootz_setup(ulong image, ulong *start, ulong *end)
23 {
24         struct arm_z_header *zi = (struct arm_z_header *)image;
25
26         if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC &&
27             zi->zi_magic != BAREBOX_IMAGE_MAGIC) {
28 #ifndef CONFIG_SPL_FRAMEWORK
29                 puts("zimage: Bad magic!\n");
30 #endif
31                 return 1;
32         }
33
34         *start = zi->zi_start;
35         *end = zi->zi_end;
36 #ifndef CONFIG_SPL_FRAMEWORK
37         printf("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n",
38                image, *start, *end);
39 #endif
40
41         return 0;
42 }