xref: /OK3568_Linux_fs/u-boot/arch/arm/include/asm/arch-rockchip/spl_resource_img.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier:     GPL-2.0+ */
2 /*
3  * (C) Copyright 2020 Rockchip Electronics Co., Ltd
4  */
5 
6 #ifndef _SPL_RESOURCE_IMG_H_
7 #define _SPL_RESOURCE_IMG_H_
8 
9 #define RESOURCE_MAGIC			"RSCE"
10 #define RESOURCE_MAGIC_SIZE		4
11 #define RESOURCE_VERSION		0
12 #define CONTENT_VERSION			0
13 #define ENTRY_TAG			"ENTR"
14 #define ENTRY_TAG_SIZE			4
15 #define MAX_FILE_NAME_LEN		220
16 #define MAX_HASH_LEN			32
17 
18 #define DEFAULT_DTB_FILE		"rk-kernel.dtb"
19 
20 /*
21  *         resource image structure
22  * ----------------------------------------------
23  * |                                            |
24  * |    header  (1 block)                       |
25  * |                                            |
26  * ---------------------------------------------|
27  * |                      |                     |
28  * |    entry0  (1 block) |                     |
29  * |                      |                     |
30  * ------------------------                     |
31  * |                      |                     |
32  * |    entry1  (1 block) | contents (n blocks) |
33  * |                      |                     |
34  * ------------------------                     |
35  * |    ......            |                     |
36  * ------------------------                     |
37  * |                      |                     |
38  * |    entryn  (1 block) |                     |
39  * |                      |                     |
40  * ----------------------------------------------
41  * |                                            |
42  * |    file0  (x blocks)                       |
43  * |                                            |
44  * ----------------------------------------------
45  * |                                            |
46  * |    file1  (y blocks)                       |
47  * |                                            |
48  * ----------------------------------------------
49  * |                   ......                   |
50  * |---------------------------------------------
51  * |                                            |
52  * |    filen  (z blocks)                       |
53  * |                                            |
54  * ----------------------------------------------
55  */
56 
57 /**
58  * struct resource_image_header
59  *
60  * @magic: should be "RSCE"
61  * @version: resource image version, current is 0
62  * @c_version: content version, current is 0
63  * @blks: the size of the header ( 1 block = 512 bytes)
64  * @c_offset: contents offset(by block) in the image
65  * @e_blks: the size(by block) of the entry in the contents
66  * @e_num: numbers of the entries.
67  */
68 
69 struct resource_img_hdr {
70 	char		magic[4];
71 	uint16_t	version;
72 	uint16_t	c_version;
73 	uint8_t		blks;
74 	uint8_t		c_offset;
75 	uint8_t		e_blks;
76 	uint32_t	e_nums;
77 };
78 
79 struct resource_entry {
80 	char		tag[4];
81 	char		name[MAX_FILE_NAME_LEN];
82 	char		hash[MAX_HASH_LEN];
83 	uint32_t	hash_size;
84 	uint32_t	f_offset;
85 	uint32_t	f_size;
86 };
87 
88 int spl_resource_image_check_header(const struct resource_img_hdr *hdr);
89 
90 struct resource_entry *
91 	spl_resource_image_get_dtb_entry(const struct resource_img_hdr *hdr);
92 
93 #endif
94