]> git.sur5r.net Git - u-boot/blob - tools/rkimage.c
Merge branch 'master' of git://git.denx.de/u-boot-imx
[u-boot] / tools / rkimage.c
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>
12 #include "rkcommon.h"
13
14 static uint32_t header;
15
16 static void rkimage_set_header(void *buf, struct stat *sbuf, int ifd,
17                                struct image_tool_params *params)
18 {
19         memcpy(buf + RK_SPL_HDR_START, rkcommon_get_spl_hdr(params),
20                RK_SPL_HDR_SIZE);
21
22         if (rkcommon_need_rc4_spl(params))
23                 rkcommon_rc4_encode_spl(buf, 4, params->file_size);
24 }
25
26 static int rkimage_check_image_type(uint8_t type)
27 {
28         if (type == IH_TYPE_RKIMAGE)
29                 return EXIT_SUCCESS;
30         else
31                 return EXIT_FAILURE;
32 }
33
34 /*
35  * rk_image parameters
36  */
37 U_BOOT_IMAGE_TYPE(
38         rkimage,
39         "Rockchip Boot Image support",
40         4,
41         &header,
42         rkcommon_check_params,
43         NULL,
44         NULL,
45         rkimage_set_header,
46         NULL,
47         rkimage_check_image_type,
48         NULL,
49         NULL
50 );