blob: 477ea94997de090e952bb08679d18de7df03da8e [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Ladislav Michl431889d2016-07-12 20:28:14 +02002/*
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>
Ladislav Michl431889d2016-07-12 20:28:14 +02008 */
9#include <common.h>
Simon Glass4d72caa2020-05-10 11:40:01 -060010#include <image.h>
Ladislav Michl431889d2016-07-12 20:28:14 +020011
12#define LINUX_ARM_ZIMAGE_MAGIC 0x016f2818
Christoph Fritz02c038d2019-05-03 13:19:49 +020013#define BAREBOX_IMAGE_MAGIC 0x00786f62
Ladislav Michl431889d2016-07-12 20:28:14 +020014
15struct 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
22int bootz_setup(ulong image, ulong *start, ulong *end)
23{
24 struct arm_z_header *zi = (struct arm_z_header *)image;
25
Christoph Fritz02c038d2019-05-03 13:19:49 +020026 if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC &&
27 zi->zi_magic != BAREBOX_IMAGE_MAGIC) {
Ladislav Michl431889d2016-07-12 20:28:14 +020028#ifndef CONFIG_SPL_FRAMEWORK
Christoph Fritz02c038d2019-05-03 13:19:49 +020029 puts("zimage: Bad magic!\n");
Ladislav Michl431889d2016-07-12 20:28:14 +020030#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}