blob: 9880b1569f165a3709c7de9fd48d1dd5dcb1b93e [file] [log] [blame]
Simon Glassc9c74032015-08-30 16:55:24 -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 rkimage format
8 */
9
10#include "imagetool.h"
11#include <image.h>
Jeffy Chen06cdc342015-11-27 12:07:17 +080012#include "rkcommon.h"
Simon Glassc9c74032015-08-30 16:55:24 -060013
14static uint32_t header;
15
Simon Glassc9c74032015-08-30 16:55:24 -060016static void rkimage_set_header(void *buf, struct stat *sbuf, int ifd,
17 struct image_tool_params *params)
18{
Jeffy Chen06cdc342015-11-27 12:07:17 +080019 memcpy(buf + RK_SPL_HDR_START, rkcommon_get_spl_hdr(params),
20 RK_SPL_HDR_SIZE);
Heiko Stübner3b404d42017-02-18 19:46:27 +010021
22 if (rkcommon_need_rc4_spl(params))
23 rkcommon_rc4_encode_spl(buf, 4, params->file_size);
Simon Glassc9c74032015-08-30 16:55:24 -060024}
25
Simon Glassc9c74032015-08-30 16:55:24 -060026static 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 */
37U_BOOT_IMAGE_TYPE(
38 rkimage,
39 "Rockchip Boot Image support",
40 4,
41 &header,
Simon Glassaba696d2016-05-14 14:02:59 -060042 rkcommon_check_params,
Philipp Tomsichf8fcbba2017-04-17 17:48:06 +020043 NULL,
44 NULL,
Simon Glassc9c74032015-08-30 16:55:24 -060045 rkimage_set_header,
Philipp Tomsichf8fcbba2017-04-17 17:48:06 +020046 NULL,
Simon Glassc9c74032015-08-30 16:55:24 -060047 rkimage_check_image_type,
48 NULL,
49 NULL
50);