]> Git Repo - J-u-boot.git/blame - tools/rkcommon.h
tools: kwbimage: Set BOOT_FROM by default to SPI
[J-u-boot.git] / tools / rkcommon.h
CommitLineData
83d290c5 1/* SPDX-License-Identifier: GPL-2.0+ */
a131c1f4
SG
2/*
3 * (C) Copyright 2015 Google, Inc
4 * Written by Simon Glass <[email protected]>
a131c1f4
SG
5 */
6
7#ifndef _RKCOMMON_H
8#define _RKCOMMON_H
9
10enum {
11 RK_BLK_SIZE = 512,
eea6cd8d 12 RK_SIZE_ALIGN = 2048,
3641339e
JC
13 RK_INIT_OFFSET = 4,
14 RK_MAX_BOOT_SIZE = 512 << 10,
7bf274b9
JC
15 RK_SPL_HDR_START = RK_INIT_OFFSET * RK_BLK_SIZE,
16 RK_SPL_HDR_SIZE = 4,
a131c1f4
SG
17};
18
7bf274b9
JC
19/**
20 * rkcommon_check_params() - check params
21 *
22 * @return 0 if OK, -1 if ERROR.
23 */
24int rkcommon_check_params(struct image_tool_params *params);
25
26/**
27 * rkcommon_get_spl_hdr() - get 4-bytes spl hdr for a Rockchip boot image
28 *
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.
31 */
32const char *rkcommon_get_spl_hdr(struct image_tool_params *params);
33
34/**
35 * rkcommon_get_spl_size() - get spl size for a Rockchip boot image
36 *
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
39 * for the bootrom.
40 * The spl loader size should be sram size minus reserved size(if needed)
41 */
42int rkcommon_get_spl_size(struct image_tool_params *params);
43
a131c1f4
SG
44/**
45 * rkcommon_set_header() - set up the header for a Rockchip boot image
46 *
47 * This sets up a 2KB header which can be interpreted by the Rockchip boot ROM.
48 *
49 * @buf: Pointer to header place (must be at least 2KB in size)
a131c1f4 50 */
eea6cd8d
JC
51void rkcommon_set_header(void *buf, struct stat *sbuf, int ifd,
52 struct image_tool_params *params);
a131c1f4 53
2fb371ff
PT
54/**
55 * rkcommon_verify_header() - verify the header for a Rockchip boot image
56 *
57 * @buf: Pointer to the image file
58 * @file_size: Size of entire bootable image file (incl. all padding)
59 * @return 0 if OK
60 */
61int rkcommon_verify_header(unsigned char *buf, int size,
62 struct image_tool_params *params);
63
64/**
65 * rkcommon_print_header() - print the header for a Rockchip boot image
66 *
67 * This prints the header, spl_name and whether this is a SD/MMC or SPI image.
68 *
69 * @buf: Pointer to the image (can be a read-only file-mapping)
70 */
71void rkcommon_print_header(const void *buf);
72
cfbcdade
HS
73/**
74 * rkcommon_need_rc4_spl() - check if rc4 encoded spl is required
75 *
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.
80 */
81bool rkcommon_need_rc4_spl(struct image_tool_params *params);
82
83/**
84 * rkcommon_rc4_encode_spl() - encode the spl binary
85 *
86 * Encrypts the SPL binary using the generic rc4 key as required
87 * by some socs.
88 *
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
92 */
93void rkcommon_rc4_encode_spl(void *buf, unsigned int offset, unsigned int size);
94
111bcc4f
PT
95/**
96 * rkcommon_vrec_header() - allocate memory for the header
97 *
98 * @params: Pointer to the tool params structure
99 * @tparams: Pointer tot the image type structure (for setting
100 * the header and header_size)
366aad4d 101 *
eea6cd8d 102 * @return 0 (always)
111bcc4f 103 */
366aad4d 104int rkcommon_vrec_header(struct image_tool_params *params,
eea6cd8d 105 struct image_type_params *tparams);
111bcc4f 106
a131c1f4 107#endif
This page took 0.275805 seconds and 4 git commands to generate.