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 char hash[MAX_HASH_LEN]; 19 uint32_t hash_size; 20 uint32_t f_offset; /* Sector offset */ 21 uint32_t f_size; /* Bytes */ 22 struct list_head link; 23 /* Sector base of resource when ram=false, byte base when ram=true */ 24 uint32_t rsce_base; 25 bool ram; 26 }; 27 28 extern struct list_head entrys_head; 29 30 /* 31 * resource_image_check_header - check resource image header 32 * 33 * @rsce_hdr: resource file hdr 34 * 35 * return 0 on header okay, otherwise failed 36 */ 37 int resource_image_check_header(void *rsce_hdr); 38 39 /* 40 * resource_create_ram_list - create resource file list by data from memory 41 * 42 * @dev_desc: blk dev descritpion 43 * @rsce_hdr: resource file hdr 44 * 45 * return 0 on header okay, otherwise failed 46 */ 47 int resource_create_ram_list(struct blk_desc *dev_desc, void *rsce_hdr); 48 49 /* 50 * rockchip_read_resource_file - read file from resource partition 51 * 52 * @buf: destination buf to store file data 53 * @name: file name 54 * @offset: blocks offset in the file, 1 block = 512 bytes 55 * @len: the size(by bytes) of file to read. 56 * 57 * return negative num on failed, otherwise the file size 58 */ 59 int rockchip_read_resource_file(void *buf, const char *name, int offset, int len); 60 61 /* 62 * rockchip_read_resource_dtb() - read dtb file 63 * 64 * @fdt_addr: destination buf to store dtb file 65 * @hash: hash value buffer 66 * @hash_size: hash value length 67 */ 68 int rockchip_read_resource_dtb(void *fdt_addr, char **hash, int *hash_size); 69 70 /* 71 * resource_init_list - init resource list of android image from storage 72 */ 73 int resource_init_list(void); 74 75 /* 76 * resource_replace_entry - replace resource entry, override if find exist one 77 */ 78 int resource_replace_entry(const char *f_name, uint32_t base, 79 uint32_t f_offset, uint32_t f_size); 80 81 /* 82 * resource_read_logo_bmps() - read logo bmp from "logo" partition 83 */ 84 int resource_read_logo_bmps(void); 85 86 /* 87 * resource_read_hwid_dtb() - read hwid dtb 88 */ 89 struct resource_file *resource_read_hwid_dtb(void); 90 91 /* 92 * resource_is_empty() - return if resource is empty 93 */ 94 int resource_is_empty(void); 95 96 /* 97 * resource_traverse_init_list() - traverse all image(android/fit/uimage) 98 */ 99 int resource_traverse_init_list(void); 100 101 #endif 102