xref: /openbmc/u-boot/tools/rkimage.c (revision 8c4e4101)
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 int rkimage_verify_header(unsigned char *buf, int size,
17 				 struct image_tool_params *params)
18 {
19 	return 0;
20 }
21 
22 static void rkimage_print_header(const void *buf)
23 {
24 }
25 
26 static void rkimage_set_header(void *buf, struct stat *sbuf, int ifd,
27 			       struct image_tool_params *params)
28 {
29 	memcpy(buf + RK_SPL_HDR_START, rkcommon_get_spl_hdr(params),
30 	       RK_SPL_HDR_SIZE);
31 
32 	if (rkcommon_need_rc4_spl(params))
33 		rkcommon_rc4_encode_spl(buf, 4, params->file_size);
34 }
35 
36 static int rkimage_extract_subimage(void *buf, struct image_tool_params *params)
37 {
38 	return 0;
39 }
40 
41 static 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  */
52 U_BOOT_IMAGE_TYPE(
53 	rkimage,
54 	"Rockchip Boot Image support",
55 	4,
56 	&header,
57 	rkcommon_check_params,
58 	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 );
66