xref: /rk3399_rockchip-uboot/arch/arm/include/asm/arch-rockchip/resource_img.h (revision d1e7b9e1d9259b6a26a1dc310b724936b8d5e55e)
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 #define DTB_SUFFIX			".dtb"
15 
16 struct resource_file {
17 	char		name[MAX_FILE_NAME_LEN];
18 	ulong		blk_start;
19 	ulong		blk_offset;
20 	char		hash[MAX_HASH_LEN];
21 	uint32_t	hash_size;
22 	uint32_t	size;		/* in byte */
23 	bool		in_ram;
24 	struct list_head link;
25 };
26 
27 extern struct list_head entry_head;
28 
29 /*
30  * resource_destroy() - Destroy resource file list
31  */
32 void resource_destroy(void);
33 
34 /*
35  * resource_setup_ram_list() - setup resource file list by given resource image.
36  *
37  * @dev_desc: boot device
38  * @hdr: resource file hdr
39  *
40  * return 0 on success, otherwise fail.
41  */
42 int resource_setup_ram_list(struct blk_desc *dev_desc, void *hdr);
43 
44 /*
45  * rockchip_read_resource_file() - read file from resource.
46  *
47  * @buf: destination buf to store file data
48  * @name: file name
49  * @blk_offset: blocks offset in the file, 1 block = 512 bytes
50  * @len: the size(by bytes) of file to read
51  *
52  * return the length of read data.
53  */
54 int rockchip_read_resource_file(void *buf, const char *name, int blk_offset, int len);
55 
56 /*
57  * rockchip_read_resource_dtb() - read dtb file
58  *
59  * @fdt_addr: destination buf to store dtb file
60  * @hash: hash value buffer
61  * @hash_size: hash value length
62  */
63 int rockchip_read_resource_dtb(void *fdt_addr, char **hash, int *hash_size);
64 
65 #endif
66