2 * (C) Copyright 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
5 * SPDX-License-Identifier: GPL-2.0+
14 RK_MAX_BOOT_SIZE = 512 << 10,
15 RK_SPL_HDR_START = RK_INIT_OFFSET * RK_BLK_SIZE,
17 RK_SPL_START = RK_SPL_HDR_START + RK_SPL_HDR_SIZE,
18 RK_IMAGE_HEADER_LEN = RK_SPL_START,
22 * rkcommon_check_params() - check params
24 * @return 0 if OK, -1 if ERROR.
26 int rkcommon_check_params(struct image_tool_params *params);
29 * rkcommon_get_spl_hdr() - get 4-bytes spl hdr for a Rockchip boot image
31 * Rockchip's bootrom requires the spl loader to start with a 4-bytes
32 * header. The content of this header depends on the chip type.
34 const char *rkcommon_get_spl_hdr(struct image_tool_params *params);
37 * rkcommon_get_spl_hdr_padto8() - check if we need to pad to 8 bytes
39 * Rockchip's bootrom starts execution right after the SPL header (i.e.
40 * at offset 4), but we can not reasonably align the test section of
41 * an AArch64 SPL at 4 bytes (as this would break natural alignment
42 * and any embedded constants might cause an alignment exception, which
43 * is illegal in privileged modes).
45 * Padding is (for now) assumed to occur with a single AArch64 'nop'.
47 const bool rkcommon_get_spl_hdr_padto8(struct image_tool_params *params);
50 * rkcommon_get_spl_size() - get spl size for a Rockchip boot image
52 * Different chip may have different sram size. And if we want to jump
53 * back to the bootrom after spl, we may need to reserve some sram space
55 * The spl loader size should be sram size minus reserved size(if needed)
57 int rkcommon_get_spl_size(struct image_tool_params *params);
60 * rkcommon_set_header() - set up the header for a Rockchip boot image
62 * This sets up a 2KB header which can be interpreted by the Rockchip boot ROM.
64 * @buf: Pointer to header place (must be at least 2KB in size)
65 * @file_size: Size of the file we want the boot ROM to load, in bytes
66 * @return 0 if OK, -ENOSPC if too large
68 int rkcommon_set_header(void *buf, uint file_size,
69 struct image_tool_params *params);
72 * rkcommon_need_rc4_spl() - check if rc4 encoded spl is required
74 * Some socs cannot disable the rc4-encryption of the spl binary.
75 * rc4 encryption is disabled normally except on socs that cannot
76 * handle unencrypted binaries.
77 * @return true or false depending on rc4 being required.
79 bool rkcommon_need_rc4_spl(struct image_tool_params *params);
82 * rkcommon_rc4_encode_spl() - encode the spl binary
84 * Encrypts the SPL binary using the generic rc4 key as required
87 * @buf: Pointer to the SPL data (header and SPL binary)
88 * @offset: offset inside buf to start at
89 * @size: number of bytes to encode
91 void rkcommon_rc4_encode_spl(void *buf, unsigned int offset, unsigned int size);
94 * rkcommon_vrec_header() - allocate memory for the header
96 * @params: Pointer to the tool params structure
97 * @tparams: Pointer tot the image type structure (for setting
98 * the header and header_size)
100 void rkcommon_vrec_header(struct image_tool_params *params,
101 struct image_type_params *tparams);