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