Simon Glass | a131c1f | 2015-08-30 16:55:24 -0600 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2015 Google, Inc |
| 3 | * Written by Simon Glass <sjg@chromium.org> |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | * |
| 7 | * See README.rockchip for details of the rkimage format |
| 8 | */ |
| 9 | |
| 10 | #include "imagetool.h" |
| 11 | #include <image.h> |
Jeffy Chen | 7bf274b | 2015-11-27 12:07:17 +0800 | [diff] [blame] | 12 | #include "rkcommon.h" |
Simon Glass | a131c1f | 2015-08-30 16:55:24 -0600 | [diff] [blame] | 13 | |
| 14 | static uint32_t header; |
| 15 | |
Simon Glass | a131c1f | 2015-08-30 16:55:24 -0600 | [diff] [blame] | 16 | static void rkimage_set_header(void *buf, struct stat *sbuf, int ifd, |
| 17 | struct image_tool_params *params) |
| 18 | { |
Jeffy Chen | 7bf274b | 2015-11-27 12:07:17 +0800 | [diff] [blame] | 19 | memcpy(buf + RK_SPL_HDR_START, rkcommon_get_spl_hdr(params), |
| 20 | RK_SPL_HDR_SIZE); |
Heiko Stübner | cfbcdad | 2017-02-18 19:46:27 +0100 | [diff] [blame] | 21 | |
| 22 | if (rkcommon_need_rc4_spl(params)) |
| 23 | rkcommon_rc4_encode_spl(buf, 4, params->file_size); |
Simon Glass | a131c1f | 2015-08-30 16:55:24 -0600 | [diff] [blame] | 24 | } |
| 25 | |
Simon Glass | a131c1f | 2015-08-30 16:55:24 -0600 | [diff] [blame] | 26 | static int rkimage_check_image_type(uint8_t type) |
| 27 | { |
| 28 | if (type == IH_TYPE_RKIMAGE) |
| 29 | return EXIT_SUCCESS; |
| 30 | else |
| 31 | return EXIT_FAILURE; |
| 32 | } |
| 33 | |
| 34 | /* |
| 35 | * rk_image parameters |
| 36 | */ |
| 37 | U_BOOT_IMAGE_TYPE( |
| 38 | rkimage, |
| 39 | "Rockchip Boot Image support", |
| 40 | 4, |
| 41 | &header, |
Simon Glass | 9217d93 | 2016-05-14 14:02:59 -0600 | [diff] [blame] | 42 | rkcommon_check_params, |
Philipp Tomsich | 253c60a | 2017-04-17 17:48:06 +0200 | [diff] [blame] | 43 | NULL, |
| 44 | NULL, |
Simon Glass | a131c1f | 2015-08-30 16:55:24 -0600 | [diff] [blame] | 45 | rkimage_set_header, |
Philipp Tomsich | 253c60a | 2017-04-17 17:48:06 +0200 | [diff] [blame] | 46 | NULL, |
Simon Glass | a131c1f | 2015-08-30 16:55:24 -0600 | [diff] [blame] | 47 | rkimage_check_image_type, |
| 48 | NULL, |
| 49 | NULL |
| 50 | ); |