1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * (C) Copyright 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
14 RK_MAX_BOOT_SIZE = 512 << 10,
15 RK_SPL_HDR_START = RK_INIT_OFFSET * RK_BLK_SIZE,
20 * rkcommon_check_params() - check params
22 * @return 0 if OK, -1 if ERROR.
24 int rkcommon_check_params(struct image_tool_params *params);
27 * rkcommon_get_spl_hdr() - get 4-bytes spl hdr for a Rockchip boot image
29 * Rockchip's bootrom requires the spl loader to start with a 4-bytes
30 * header. The content of this header depends on the chip type.
32 const char *rkcommon_get_spl_hdr(struct image_tool_params *params);
35 * rkcommon_get_spl_size() - get spl size for a Rockchip boot image
37 * Different chip may have different sram size. And if we want to jump
38 * back to the bootrom after spl, we may need to reserve some sram space
40 * The spl loader size should be sram size minus reserved size(if needed)
42 int rkcommon_get_spl_size(struct image_tool_params *params);
45 * rkcommon_set_header() - set up the header for a Rockchip boot image
47 * This sets up a 2KB header which can be interpreted by the Rockchip boot ROM.
49 * @buf: Pointer to header place (must be at least 2KB in size)
51 void rkcommon_set_header(void *buf, struct stat *sbuf, int ifd,
52 struct image_tool_params *params);
55 * rkcommon_verify_header() - verify the header for a Rockchip boot image
57 * @buf: Pointer to the image file
58 * @file_size: Size of entire bootable image file (incl. all padding)
61 int rkcommon_verify_header(unsigned char *buf, int size,
62 struct image_tool_params *params);
65 * rkcommon_print_header() - print the header for a Rockchip boot image
67 * This prints the header, spl_name and whether this is a SD/MMC or SPI image.
69 * @buf: Pointer to the image (can be a read-only file-mapping)
71 void rkcommon_print_header(const void *buf);
74 * rkcommon_need_rc4_spl() - check if rc4 encoded spl is required
76 * Some socs cannot disable the rc4-encryption of the spl binary.
77 * rc4 encryption is disabled normally except on socs that cannot
78 * handle unencrypted binaries.
79 * @return true or false depending on rc4 being required.
81 bool rkcommon_need_rc4_spl(struct image_tool_params *params);
84 * rkcommon_rc4_encode_spl() - encode the spl binary
86 * Encrypts the SPL binary using the generic rc4 key as required
89 * @buf: Pointer to the SPL data (header and SPL binary)
90 * @offset: offset inside buf to start at
91 * @size: number of bytes to encode
93 void rkcommon_rc4_encode_spl(void *buf, unsigned int offset, unsigned int size);
96 * rkcommon_vrec_header() - allocate memory for the header
98 * @params: Pointer to the tool params structure
99 * @tparams: Pointer tot the image type structure (for setting
100 * the header and header_size)
104 int rkcommon_vrec_header(struct image_tool_params *params,
105 struct image_type_params *tparams);