Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Ladislav Michl | 9c74372 | 2016-07-12 20:28:14 +0200 | [diff] [blame] | 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> |
Ladislav Michl | 9c74372 | 2016-07-12 20:28:14 +0200 | [diff] [blame] | 8 | */ |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 9 | #include <image.h> |
Ladislav Michl | 9c74372 | 2016-07-12 20:28:14 +0200 | [diff] [blame] | 10 | |
| 11 | #define LINUX_ARM_ZIMAGE_MAGIC 0x016f2818 |
Christoph Fritz | 54e855f | 2019-05-03 13:19:49 +0200 | [diff] [blame] | 12 | #define BAREBOX_IMAGE_MAGIC 0x00786f62 |
Ladislav Michl | 9c74372 | 2016-07-12 20:28:14 +0200 | [diff] [blame] | 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 | |
Christoph Fritz | 54e855f | 2019-05-03 13:19:49 +0200 | [diff] [blame] | 25 | if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC && |
| 26 | zi->zi_magic != BAREBOX_IMAGE_MAGIC) { |
Simon Glass | 85ed77d | 2024-09-29 19:49:46 -0600 | [diff] [blame] | 27 | if (!IS_ENABLED(CONFIG_XPL_BUILD)) |
Samuel Holland | 3b2ae6a | 2021-04-17 09:34:37 -0500 | [diff] [blame] | 28 | puts("zimage: Bad magic!\n"); |
Ladislav Michl | 9c74372 | 2016-07-12 20:28:14 +0200 | [diff] [blame] | 29 | return 1; |
| 30 | } |
| 31 | |
| 32 | *start = zi->zi_start; |
| 33 | *end = zi->zi_end; |
Simon Glass | 85ed77d | 2024-09-29 19:49:46 -0600 | [diff] [blame] | 34 | if (!IS_ENABLED(CONFIG_XPL_BUILD)) |
Samuel Holland | 3b2ae6a | 2021-04-17 09:34:37 -0500 | [diff] [blame] | 35 | printf("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n", |
| 36 | image, *start, *end); |
Ladislav Michl | 9c74372 | 2016-07-12 20:28:14 +0200 | [diff] [blame] | 37 | |
| 38 | return 0; |
| 39 | } |