blob: 44d098c77578f9241595254d9e6669b89ee66aa5 [file] [log] [blame]
Simon Glassa131c1f2015-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 Chen7bf274b2015-11-27 12:07:17 +080012#include "rkcommon.h"
Simon Glassa131c1f2015-08-30 16:55:24 -060013
14static uint32_t header;
15
Simon Glassa131c1f2015-08-30 16:55:24 -060016static int rkimage_verify_header(unsigned char *buf, int size,
17 struct image_tool_params *params)
18{
19 return 0;
20}
21
22static void rkimage_print_header(const void *buf)
23{
24}
25
26static void rkimage_set_header(void *buf, struct stat *sbuf, int ifd,
27 struct image_tool_params *params)
28{
Jeffy Chen7bf274b2015-11-27 12:07:17 +080029 memcpy(buf + RK_SPL_HDR_START, rkcommon_get_spl_hdr(params),
30 RK_SPL_HDR_SIZE);
Heiko Stübnercfbcdad2017-02-18 19:46:27 +010031
32 if (rkcommon_need_rc4_spl(params))
33 rkcommon_rc4_encode_spl(buf, 4, params->file_size);
Simon Glassa131c1f2015-08-30 16:55:24 -060034}
35
36static int rkimage_extract_subimage(void *buf, struct image_tool_params *params)
37{
38 return 0;
39}
40
41static int rkimage_check_image_type(uint8_t type)
42{
43 if (type == IH_TYPE_RKIMAGE)
44 return EXIT_SUCCESS;
45 else
46 return EXIT_FAILURE;
47}
48
49/*
50 * rk_image parameters
51 */
52U_BOOT_IMAGE_TYPE(
53 rkimage,
54 "Rockchip Boot Image support",
55 4,
56 &header,
Simon Glass9217d932016-05-14 14:02:59 -060057 rkcommon_check_params,
Simon Glassa131c1f2015-08-30 16:55:24 -060058 rkimage_verify_header,
59 rkimage_print_header,
60 rkimage_set_header,
61 rkimage_extract_subimage,
62 rkimage_check_image_type,
63 NULL,
64 NULL
65);