xref: /rk3399_rockchip-uboot/arch/arm/include/asm/arch-rockchip/resource_img.h (revision f36ea2f6e17621c4d9dd97c4dbfab62d03d061df)
1 /*
2  * (C) Copyright 2017 Rockchip Electronics Co., Ltd
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6 
7 #ifndef __RESC_IMG_H_
8 #define __RESC_IMG_H_
9 
10 #include <linux/list.h>
11 
12 #define MAX_FILE_NAME_LEN		220
13 #define MAX_HASH_LEN			32
14 
15 struct resource_file {
16 	char		name[MAX_FILE_NAME_LEN];
17 	char		hash[MAX_HASH_LEN];
18 	uint32_t	hash_size;
19 	uint32_t	f_offset;	/* Sector offset */
20 	uint32_t	f_size;		/* Bytes */
21 	struct list_head link;
22 	/* Sector base of resource when ram=false, byte base when ram=true */
23 	uint32_t	rsce_base;
24 	bool		ram;
25 };
26 
27 extern struct list_head entrys_head;
28 
29 /*
30  * resource_image_check_header - check resource image header
31  *
32  * @rsce_hdr: resource file hdr
33  *
34  * return 0 on header okay, otherwise failed
35  */
36 int resource_image_check_header(void *rsce_hdr);
37 
38 /*
39  * resource_create_ram_list - create resource file list by data from memory
40  *
41  * @dev_desc: blk dev descritpion
42  * @rsce_hdr: resource file hdr
43  *
44  * return 0 on header okay, otherwise failed
45  */
46 int resource_create_ram_list(struct blk_desc *dev_desc, void *rsce_hdr);
47 
48 /*
49  * rockchip_read_resource_file - read file from resource partition
50  *
51  * @buf: destination buf to store file data
52  * @name: file name
53  * @offset: blocks offset in the file, 1 block = 512 bytes
54  * @len: the size(by bytes) of file to read.
55  *
56  * return negative num on failed, otherwise the file size
57  */
58 int rockchip_read_resource_file(void *buf, const char *name, int offset, int len);
59 
60 /*
61  * rockchip_read_resource_dtb() - read dtb file
62  *
63  * @fdt_addr: destination buf to store dtb file
64  * @hash: hash value buffer
65  * @hash_size: hash value length
66  */
67 int rockchip_read_resource_dtb(void *fdt_addr, char **hash, int *hash_size);
68 
69 /*
70  * resource_init_list - init resource list of android image from storage
71  */
72 int resource_init_list(void);
73 
74 /*
75  * resource_replace_entry - replace resource entry, override if find exist one
76  */
77 int resource_replace_entry(const char *f_name, uint32_t base,
78 			   uint32_t f_offset, uint32_t f_size);
79 
80 /*
81  * resource_read_logo_bmps() - read logo bmp from "logo" partition
82  */
83 int resource_read_logo_bmps(void);
84 
85 /*
86  * resource_read_hwid_dtb() - read hwid dtb
87  */
88 struct resource_file *resource_read_hwid_dtb(void);
89 
90 /*
91  * resource_is_empty() - return if resource is empty
92  */
93 int resource_is_empty(void);
94 
95 /*
96  * resource_populate_dtb() - read fdt from this image: android/fit.
97  */
98 int resource_populate_dtb(void *img, void *fdt);
99 
100 /*
101  * resource_traverse_init_list() - traverse all image(android/fit/uimage)
102  */
103 int resource_traverse_init_list(void);
104 
105 #endif
106