blob: a2baa74d3121168503f65ea56ee3b3a9a0b16f68 [file] [log] [blame]
Simon Glassf9a3c272015-08-30 16:55:25 -06001/*
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
Jeffy Chen7bf274b2015-11-27 12:07:17 +080016static char dummy_hdr[RK_IMAGE_HEADER_LEN];
Simon Glassf9a3c272015-08-30 16:55:25 -060017
18static int rksd_verify_header(unsigned char *buf, int size,
19 struct image_tool_params *params)
20{
21 return 0;
22}
23
24static void rksd_print_header(const void *buf)
25{
26}
27
28static void rksd_set_header(void *buf, struct stat *sbuf, int ifd,
29 struct image_tool_params *params)
30{
31 unsigned int size;
32 int ret;
33
Jeffy Chen7bf274b2015-11-27 12:07:17 +080034 size = params->file_size - RK_SPL_HDR_START;
35 ret = rkcommon_set_header(buf, size, params);
Simon Glassf9a3c272015-08-30 16:55:25 -060036 if (ret) {
37 /* TODO(sjg@chromium.org): This method should return an error */
38 printf("Warning: SPL image is too large (size %#x) and will not boot\n",
39 size);
40 }
41
Jeffy Chen7bf274b2015-11-27 12:07:17 +080042 memcpy(buf + RK_SPL_HDR_START, rkcommon_get_spl_hdr(params),
43 RK_SPL_HDR_SIZE);
Simon Glassf9a3c272015-08-30 16:55:25 -060044}
45
46static int rksd_extract_subimage(void *buf, struct image_tool_params *params)
47{
48 return 0;
49}
50
51static int rksd_check_image_type(uint8_t type)
52{
53 if (type == IH_TYPE_RKSD)
54 return EXIT_SUCCESS;
55 else
56 return EXIT_FAILURE;
57}
58
59/* We pad the file out to a fixed size - this method returns that size */
60static int rksd_vrec_header(struct image_tool_params *params,
61 struct image_type_params *tparams)
62{
63 int pad_size;
64
Jeffy Chen7bf274b2015-11-27 12:07:17 +080065 pad_size = RK_SPL_HDR_START + rkcommon_get_spl_size(params);
Simon Glassf9a3c272015-08-30 16:55:25 -060066 debug("pad_size %x\n", pad_size);
67
68 return pad_size - params->file_size;
69}
70
71/*
72 * rk_sd parameters
73 */
74U_BOOT_IMAGE_TYPE(
75 rksd,
76 "Rockchip SD Boot Image support",
Jeffy Chen7bf274b2015-11-27 12:07:17 +080077 RK_IMAGE_HEADER_LEN,
Simon Glassf9a3c272015-08-30 16:55:25 -060078 dummy_hdr,
Jeffy Chen7bf274b2015-11-27 12:07:17 +080079 rkcommon_check_params,
Simon Glassf9a3c272015-08-30 16:55:25 -060080 rksd_verify_header,
81 rksd_print_header,
82 rksd_set_header,
83 rksd_extract_subimage,
84 rksd_check_image_type,
85 NULL,
86 rksd_vrec_header
87);