]> git.ipfire.org Git - people/ms/u-boot.git/blame - tools/rksd.c
dtoc: make ScanTree recurse into subnodes
[people/ms/u-boot.git] / tools / rksd.c
CommitLineData
f9a3c278
SG
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
7bf274b9 16static char dummy_hdr[RK_IMAGE_HEADER_LEN];
f9a3c278
SG
17
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
7bf274b9
JC
34 size = params->file_size - RK_SPL_HDR_START;
35 ret = rkcommon_set_header(buf, size, params);
f9a3c278
SG
36 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
7bf274b9
JC
42 memcpy(buf + RK_SPL_HDR_START, rkcommon_get_spl_hdr(params),
43 RK_SPL_HDR_SIZE);
cfbcdade
HS
44
45 if (rkcommon_need_rc4_spl(params))
46 rkcommon_rc4_encode_spl(buf, RK_SPL_START - 4,
47 params->file_size - RK_SPL_START + 4);
f9a3c278
SG
48}
49
50static int rksd_extract_subimage(void *buf, struct image_tool_params *params)
51{
52 return 0;
53}
54
55static int rksd_check_image_type(uint8_t type)
56{
57 if (type == IH_TYPE_RKSD)
58 return EXIT_SUCCESS;
59 else
60 return EXIT_FAILURE;
61}
62
63/* We pad the file out to a fixed size - this method returns that size */
64static int rksd_vrec_header(struct image_tool_params *params,
65 struct image_type_params *tparams)
66{
67 int pad_size;
68
7bf274b9 69 pad_size = RK_SPL_HDR_START + rkcommon_get_spl_size(params);
f9a3c278
SG
70 debug("pad_size %x\n", pad_size);
71
72 return pad_size - params->file_size;
73}
74
75/*
76 * rk_sd parameters
77 */
78U_BOOT_IMAGE_TYPE(
79 rksd,
80 "Rockchip SD Boot Image support",
7bf274b9 81 RK_IMAGE_HEADER_LEN,
f9a3c278 82 dummy_hdr,
7bf274b9 83 rkcommon_check_params,
f9a3c278
SG
84 rksd_verify_header,
85 rksd_print_header,
86 rksd_set_header,
87 rksd_extract_subimage,
88 rksd_check_image_type,
89 NULL,
90 rksd_vrec_header
91);