Simon Glass | c9c7403 | 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 | 06cdc34 | 2015-11-27 12:07:17 +0800 | [diff] [blame] | 12 | #include "rkcommon.h" |
Simon Glass | c9c7403 | 2015-08-30 16:55:24 -0600 | [diff] [blame] | 13 | |
| 14 | static uint32_t header; |
| 15 | |
Simon Glass | c9c7403 | 2015-08-30 16:55:24 -0600 | [diff] [blame] | 16 | static int rkimage_verify_header(unsigned char *buf, int size, |
| 17 | struct image_tool_params *params) |
| 18 | { |
| 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | static void rkimage_print_header(const void *buf) |
| 23 | { |
| 24 | } |
| 25 | |
| 26 | static void rkimage_set_header(void *buf, struct stat *sbuf, int ifd, |
| 27 | struct image_tool_params *params) |
| 28 | { |
Jeffy Chen | 06cdc34 | 2015-11-27 12:07:17 +0800 | [diff] [blame] | 29 | memcpy(buf + RK_SPL_HDR_START, rkcommon_get_spl_hdr(params), |
| 30 | RK_SPL_HDR_SIZE); |
Heiko Stübner | 3b404d4 | 2017-02-18 19:46:27 +0100 | [diff] [blame^] | 31 | |
| 32 | if (rkcommon_need_rc4_spl(params)) |
| 33 | rkcommon_rc4_encode_spl(buf, 4, params->file_size); |
Simon Glass | c9c7403 | 2015-08-30 16:55:24 -0600 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | static int rkimage_extract_subimage(void *buf, struct image_tool_params *params) |
| 37 | { |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | static int rkimage_check_image_type(uint8_t type) |
| 42 | { |
| 43 | if (type == IH_TYPE_RKIMAGE) |
| 44 | return EXIT_SUCCESS; |
| 45 | else |
| 46 | return EXIT_FAILURE; |
| 47 | } |
| 48 | |
| 49 | /* |
| 50 | * rk_image parameters |
| 51 | */ |
| 52 | U_BOOT_IMAGE_TYPE( |
| 53 | rkimage, |
| 54 | "Rockchip Boot Image support", |
| 55 | 4, |
| 56 | &header, |
Simon Glass | aba696d | 2016-05-14 14:02:59 -0600 | [diff] [blame] | 57 | rkcommon_check_params, |
Simon Glass | c9c7403 | 2015-08-30 16:55:24 -0600 | [diff] [blame] | 58 | rkimage_verify_header, |
| 59 | rkimage_print_header, |
| 60 | rkimage_set_header, |
| 61 | rkimage_extract_subimage, |
| 62 | rkimage_check_image_type, |
| 63 | NULL, |
| 64 | NULL |
| 65 | ); |