blob: a0a3185370b89590bcb3b67c2011e868f132c070 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glassc9c74032015-08-30 16:55:24 -06002/*
3 * (C) Copyright 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
5 *
Simon Glassc9c74032015-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 Chen06cdc342015-11-27 12:07:17 +080011#include "rkcommon.h"
Simon Glassc9c74032015-08-30 16:55:24 -060012
13static uint32_t header;
14
Simon Glassc9c74032015-08-30 16:55:24 -060015static void rkimage_set_header(void *buf, struct stat *sbuf, int ifd,
16 struct image_tool_params *params)
17{
Jeffy Chen06cdc342015-11-27 12:07:17 +080018 memcpy(buf + RK_SPL_HDR_START, rkcommon_get_spl_hdr(params),
19 RK_SPL_HDR_SIZE);
Heiko Stübner3b404d42017-02-18 19:46:27 +010020
21 if (rkcommon_need_rc4_spl(params))
22 rkcommon_rc4_encode_spl(buf, 4, params->file_size);
Simon Glassc9c74032015-08-30 16:55:24 -060023}
24
Simon Glassc9c74032015-08-30 16:55:24 -060025static int rkimage_check_image_type(uint8_t type)
26{
27 if (type == IH_TYPE_RKIMAGE)
28 return EXIT_SUCCESS;
29 else
30 return EXIT_FAILURE;
31}
32
33/*
34 * rk_image parameters
35 */
36U_BOOT_IMAGE_TYPE(
37 rkimage,
38 "Rockchip Boot Image support",
39 4,
40 &header,
Simon Glassaba696d2016-05-14 14:02:59 -060041 rkcommon_check_params,
Philipp Tomsichf8fcbba2017-04-17 17:48:06 +020042 NULL,
43 NULL,
Simon Glassc9c74032015-08-30 16:55:24 -060044 rkimage_set_header,
Philipp Tomsichf8fcbba2017-04-17 17:48:06 +020045 NULL,
Simon Glassc9c74032015-08-30 16:55:24 -060046 rkimage_check_image_type,
47 NULL,
48 NULL
49);