Simon Glass | f9a3c27 | 2015-08-30 16:55:25 -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 rksd format |
| 8 | */ |
| 9 | |
| 10 | #include "imagetool.h" |
| 11 | #include <image.h> |
| 12 | #include <rc4.h> |
| 13 | #include "mkimage.h" |
| 14 | #include "rkcommon.h" |
| 15 | |
Simon Glass | f9a3c27 | 2015-08-30 16:55:25 -0600 | [diff] [blame] | 16 | static int rksd_verify_header(unsigned char *buf, int size, |
| 17 | struct image_tool_params *params) |
| 18 | { |
| 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | static void rksd_print_header(const void *buf) |
| 23 | { |
| 24 | } |
| 25 | |
| 26 | static void rksd_set_header(void *buf, struct stat *sbuf, int ifd, |
| 27 | struct image_tool_params *params) |
| 28 | { |
| 29 | unsigned int size; |
| 30 | int ret; |
| 31 | |
Jeffy Chen | 7bf274b | 2015-11-27 12:07:17 +0800 | [diff] [blame] | 32 | size = params->file_size - RK_SPL_HDR_START; |
| 33 | ret = rkcommon_set_header(buf, size, params); |
Simon Glass | f9a3c27 | 2015-08-30 16:55:25 -0600 | [diff] [blame] | 34 | if (ret) { |
| 35 | /* TODO(sjg@chromium.org): This method should return an error */ |
| 36 | printf("Warning: SPL image is too large (size %#x) and will not boot\n", |
| 37 | size); |
| 38 | } |
Simon Glass | f9a3c27 | 2015-08-30 16:55:25 -0600 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | static int rksd_extract_subimage(void *buf, struct image_tool_params *params) |
| 42 | { |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | static int rksd_check_image_type(uint8_t type) |
| 47 | { |
| 48 | if (type == IH_TYPE_RKSD) |
| 49 | return EXIT_SUCCESS; |
| 50 | else |
| 51 | return EXIT_FAILURE; |
| 52 | } |
| 53 | |
| 54 | /* We pad the file out to a fixed size - this method returns that size */ |
| 55 | static int rksd_vrec_header(struct image_tool_params *params, |
| 56 | struct image_type_params *tparams) |
| 57 | { |
| 58 | int pad_size; |
| 59 | |
Philipp Tomsich | 111bcc4 | 2017-03-15 12:08:43 +0100 | [diff] [blame] | 60 | rkcommon_vrec_header(params, tparams); |
| 61 | |
Jeffy Chen | 7bf274b | 2015-11-27 12:07:17 +0800 | [diff] [blame] | 62 | pad_size = RK_SPL_HDR_START + rkcommon_get_spl_size(params); |
Simon Glass | f9a3c27 | 2015-08-30 16:55:25 -0600 | [diff] [blame] | 63 | debug("pad_size %x\n", pad_size); |
| 64 | |
Philipp Tomsich | 111bcc4 | 2017-03-15 12:08:43 +0100 | [diff] [blame] | 65 | return pad_size - params->file_size - tparams->header_size; |
Simon Glass | f9a3c27 | 2015-08-30 16:55:25 -0600 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | /* |
| 69 | * rk_sd parameters |
| 70 | */ |
| 71 | U_BOOT_IMAGE_TYPE( |
| 72 | rksd, |
| 73 | "Rockchip SD Boot Image support", |
Philipp Tomsich | 111bcc4 | 2017-03-15 12:08:43 +0100 | [diff] [blame] | 74 | 0, |
| 75 | NULL, |
Jeffy Chen | 7bf274b | 2015-11-27 12:07:17 +0800 | [diff] [blame] | 76 | rkcommon_check_params, |
Simon Glass | f9a3c27 | 2015-08-30 16:55:25 -0600 | [diff] [blame] | 77 | rksd_verify_header, |
| 78 | rksd_print_header, |
| 79 | rksd_set_header, |
| 80 | rksd_extract_subimage, |
| 81 | rksd_check_image_type, |
| 82 | NULL, |
| 83 | rksd_vrec_header |
| 84 | ); |