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