]> git.ipfire.org Git - people/ms/u-boot.git/blame - tools/rksd.c
usb: add support for generic EHCI devices
[people/ms/u-boot.git] / tools / rksd.c
CommitLineData
f9a3c278
SG
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 rksd format
8 */
9
10#include "imagetool.h"
11#include <image.h>
12#include <rc4.h>
13#include "mkimage.h"
14#include "rkcommon.h"
15
16enum {
3641339e 17 RKSD_SPL_HDR_START = RK_INIT_OFFSET * RK_BLK_SIZE,
f9a3c278
SG
18 RKSD_SPL_START = RKSD_SPL_HDR_START + 4,
19 RKSD_HEADER_LEN = RKSD_SPL_START,
20};
21
22static char dummy_hdr[RKSD_HEADER_LEN];
23
24static int rksd_check_params(struct image_tool_params *params)
25{
26 return 0;
27}
28
29static int rksd_verify_header(unsigned char *buf, int size,
30 struct image_tool_params *params)
31{
32 return 0;
33}
34
35static void rksd_print_header(const void *buf)
36{
37}
38
39static void rksd_set_header(void *buf, struct stat *sbuf, int ifd,
40 struct image_tool_params *params)
41{
42 unsigned int size;
43 int ret;
44
f9a3c278 45 size = params->file_size - RKSD_SPL_HDR_START;
dd39bcaf 46 ret = rkcommon_set_header(buf, size);
f9a3c278
SG
47 if (ret) {
48 /* TODO(sjg@chromium.org): This method should return an error */
49 printf("Warning: SPL image is too large (size %#x) and will not boot\n",
50 size);
51 }
52
6ae58609 53 memcpy(buf + RKSD_SPL_HDR_START, CONFIG_ROCKCHIP_SPL_HDR, 4);
f9a3c278
SG
54}
55
56static int rksd_extract_subimage(void *buf, struct image_tool_params *params)
57{
58 return 0;
59}
60
61static int rksd_check_image_type(uint8_t type)
62{
63 if (type == IH_TYPE_RKSD)
64 return EXIT_SUCCESS;
65 else
66 return EXIT_FAILURE;
67}
68
69/* We pad the file out to a fixed size - this method returns that size */
70static int rksd_vrec_header(struct image_tool_params *params,
71 struct image_type_params *tparams)
72{
73 int pad_size;
74
6ae58609 75 pad_size = RKSD_SPL_HDR_START + CONFIG_ROCKCHIP_MAX_SPL_SIZE;
f9a3c278
SG
76 debug("pad_size %x\n", pad_size);
77
78 return pad_size - params->file_size;
79}
80
81/*
82 * rk_sd parameters
83 */
84U_BOOT_IMAGE_TYPE(
85 rksd,
86 "Rockchip SD Boot Image support",
87 RKSD_HEADER_LEN,
88 dummy_hdr,
89 rksd_check_params,
90 rksd_verify_header,
91 rksd_print_header,
92 rksd_set_header,
93 rksd_extract_subimage,
94 rksd_check_image_type,
95 NULL,
96 rksd_vrec_header
97);