blob: ae50de55c93b1fe32a3072d7ef1403ea5c966bda [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glassa131c1f2015-08-30 16:55:24 -06002/*
3 * (C) Copyright 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
5 *
Simon Glassa131c1f2015-08-30 16:55:24 -06006 * See README.rockchip for details of the rkimage format
7 */
8
9#include "imagetool.h"
10#include <image.h>
Jeffy Chen7bf274b2015-11-27 12:07:17 +080011#include "rkcommon.h"
Simon Glassa131c1f2015-08-30 16:55:24 -060012
13static uint32_t header;
14
Simon Glassa131c1f2015-08-30 16:55:24 -060015static void rkimage_set_header(void *buf, struct stat *sbuf, int ifd,
16 struct image_tool_params *params)
17{
Daniel Gröberf25c1752018-10-04 15:32:42 +020018 memcpy(buf, rkcommon_get_spl_hdr(params), RK_SPL_HDR_SIZE);
Heiko Stübnercfbcdad2017-02-18 19:46:27 +010019
20 if (rkcommon_need_rc4_spl(params))
21 rkcommon_rc4_encode_spl(buf, 4, params->file_size);
Simon Glassa131c1f2015-08-30 16:55:24 -060022}
23
Simon Glassa131c1f2015-08-30 16:55:24 -060024static int rkimage_check_image_type(uint8_t type)
25{
26 if (type == IH_TYPE_RKIMAGE)
27 return EXIT_SUCCESS;
28 else
29 return EXIT_FAILURE;
30}
31
32/*
33 * rk_image parameters
34 */
35U_BOOT_IMAGE_TYPE(
36 rkimage,
37 "Rockchip Boot Image support",
Daniel Gröberf25c1752018-10-04 15:32:42 +020038 0,
Simon Glassa131c1f2015-08-30 16:55:24 -060039 &header,
Simon Glass9217d932016-05-14 14:02:59 -060040 rkcommon_check_params,
Philipp Tomsich253c60a2017-04-17 17:48:06 +020041 NULL,
42 NULL,
Simon Glassa131c1f2015-08-30 16:55:24 -060043 rkimage_set_header,
Philipp Tomsich253c60a2017-04-17 17:48:06 +020044 NULL,
Simon Glassa131c1f2015-08-30 16:55:24 -060045 rkimage_check_image_type,
46 NULL,
47 NULL
48);