blob: 49305299b39a9f473b8578c4b5957cf285711703 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Ladislav Michl9c743722016-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 Michl9c743722016-07-12 20:28:14 +02008 */
9#include <common.h>
10
11#define LINUX_ARM_ZIMAGE_MAGIC 0x016f2818
Christoph Fritz54e855f2019-05-03 13:19:49 +020012#define BAREBOX_IMAGE_MAGIC 0x00786f62
Ladislav Michl9c743722016-07-12 20:28:14 +020013
14struct 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
21int bootz_setup(ulong image, ulong *start, ulong *end)
22{
23 struct arm_z_header *zi = (struct arm_z_header *)image;
24
Christoph Fritz54e855f2019-05-03 13:19:49 +020025 if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC &&
26 zi->zi_magic != BAREBOX_IMAGE_MAGIC) {
Ladislav Michl9c743722016-07-12 20:28:14 +020027#ifndef CONFIG_SPL_FRAMEWORK
Christoph Fritz54e855f2019-05-03 13:19:49 +020028 puts("zimage: Bad magic!\n");
Ladislav Michl9c743722016-07-12 20:28:14 +020029#endif
30 return 1;
31 }
32
33 *start = zi->zi_start;
34 *end = zi->zi_end;
35#ifndef CONFIG_SPL_FRAMEWORK
36 printf("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n",
37 image, *start, *end);
38#endif
39
40 return 0;
41}