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