blob: 0fb5c382c1fddd8f78bbe34b9a73c81950f60c13 [file] [log] [blame]
xf.libfc6e712025-02-07 01:54:34 -08001/**
2* @file upi_delta.h
3* @brief ²î·ÖÎļþÏà¹ØÍ·Îļþ
4*
5* Copyright (C) 2017 Sanechips Technology Co., Ltd.
6* @author
7*
8*/
9
10#ifndef _UPI_UPGRADE_PACKAGE_H
11#define _UPI_UPGRADE_PACKAGE_H
12
13/*******************************************************************************
14 * Include header files *
15 ******************************************************************************/
16
17#include "upi_public.h"
18
19/*******************************************************************************
20 * Macro definitions *
21 ******************************************************************************/
22
23#define UPGRADE_PACKAGE_HEAD_MAGIC ("FOTA")
24#define UPGRADE_PACKAGE_HEAD_MAGIC_LEN (4)
25
26#define VERSION_LEN (64)
27
28
29/*******************************************************************************
30 * Type definitions *
31 ******************************************************************************/
32
33/**
34* @brief ²î·ÖÎļþÎļþÍ·ÐÅÏ¢£¬¿ÉÒÔÓÃÓÚУÑé²î·ÖÎļþµÈ£»¼°»ñÈ¡µ±Ç°ÎļþÖзÖÇø¼°extraÊýµÈ£»
35* @param magic_word: ÎļþͷħÊõ×Ö
36* @param plat: ƽ̨
37* @param upgrade_package_type: Éý¼¶°üÎļþÀàÐÍ AL£ºÈ«°æ±¾£¬ DE£º²î·Ö
38* @param upgrade_type Éý¼¶ÀàÐÍ
39* @param upgrade_package_version: Éý¼¶°üÎļþ°æ±¾
40* @param partition_num: ·ÖÇøÊý
41* @param extra_num: hashËã·¨ÀàÐÍ£¬0£ºÄ¬ÈÏ SHA512
42* @param block_size: ¿é´óС£¬128ÕûÊý±¶
43* @param extra_num: extraÎļþÊý
44* @param version_src: ²î·ÖÎļþÉý¼¶Ô´°æ±¾£¬¶ÔÓ¦ÄÚ²¿°æ±¾ºÅ
45* @param version_dst: ²î·ÖÎļþÉý¼¶Ä¿±ê°æ±¾ºÅ£¬¶ÔÓ¦ÄÚ²¿°æ±¾ºÅ
46* @param hash: hashËã·¨Öµ
47**/
48
49
50
51typedef struct
52{
53 char magic_word[UPGRADE_PACKAGE_HEAD_MAGIC_LEN];
54 int upgrade_package_version;
55 int plat;
56 int upgrade_package_type;
57 int upgrade_type;
58 int partition_num;
59 int extra_num;
60 int hash_type;
61 int block_size;
62 char version_src[VERSION_LEN];
63 char version_dst[VERSION_LEN];
64 unsigned char hash[HASH_MAX_LEN];
65 char reserve[28];
66} upgrade_package_head_info_t;
67
68/**
69* @brief ·ÖÇøÎļþÍ·ÐÅÏ¢£¬°üº¬´ýÉý¼¶µÄ²î·Ö·ÖÇøÎļþÐÅÏ¢
70* @param name: ²î·Ö·ÖÇøÃû
71* @param len: ²î·Ö·ÖÇøÎļþ³¤¶È
72* @param offset: ²î·Ö·ÖÇøÎļþÏà¶ÔÓÚdeltaÎļþ0µØÖ·µÄÆ«ÒÆ
73* @param partition_type: ·ÖÇøÀàÐÍ
74* @param zipped: ÊÇ·ñ¾­¹ýѹËõ
75* @param reserve: ±£Áô
76* @param hash: ÖÆ×÷²î·Ö·ÖÇøµÄÔ´·ÖÇøÎļþmd5
77*/
78typedef struct
79{
80 char name[PARTITION_NAME_LEN];
81 int len;
82 int offset;
83 int partition_type;
84 int zipped;
85 char reserve[16];
86 unsigned char hash[HASH_MAX_LEN];
87} partition_head_info_t;
88
89
90/**
91* @brief extraÐÅÏ¢
92* @param name: extraÎļþÃû
93* @param len: Îļþ³¤¶È
94* @param offset: »ùÓÚÕû¸ö²î·ÖÎļþµÄÆ«ÒÆ
95* @param hash: ÎļþhashÖµ
96* @param reserve: Ô¤ÁôÐÅÏ¢
97*/
98typedef struct
99{
100 char name[EXTRA_NAME_LEN];
101 int len;
102 int offset;
103 char reserve_1[8];
104 unsigned char hash[HASH_MAX_LEN];
105 char reserve_2[8];
106} extra_head_info_t;
107
108
109/**
110* @brief ²î·ÖÎļþÐÅÏ¢
111* @param head: ÎļþÍ·ÐÅÏ¢
112* @param partition_num: ÎļþÖзÖÇøÊý
113* @param partition_info: ·ÖÇøÐÅÏ¢Ö¸ÕëÍ·
114* @param extra_num: extraÎļþÊý
115* @param extra_info: extraÎļþÐÅÏ¢Ö¸Õë
116* @param upgrade_package_file_desc: Îļþ¾ä±ú
117* @param upgrade_package_file_size: Îļþ³¤¶È
118*/
119typedef struct
120{
121 upgrade_package_head_info_t *head;
122 // int partition_num;
123 partition_head_info_t *partition_info;
124 // int extra_num;
125 extra_head_info_t *extra_info;
126 int upgrade_package_file_desc;
127 unsigned int upgrade_package_file_size;
128} upgrade_package_info_t;
129
130
131
132
133
134
135/*******************************************************************************
136 * Global variable declarations *
137 ******************************************************************************/
138
139
140/*******************************************************************************
141 * Global function declarations *
142 ******************************************************************************/
143
144
145int init_upgrade_package_info(const char * upagrade_package_file_path);
146void deinit_upgrade_package_info();
147
148upgrade_package_info_t *get_upgrade_package_info();
149
150partition_head_info_t *get_partition_head_info();
151int get_partition_num();
152
153extra_head_info_t *get_extra_head_info();
154int get_extra_num();
155
156int get_upgrade_package_file_fd();
157
158partition_head_info_t *get_partition_head_info_by_name(const char *partition_name);
159int get_total_partition_length();
160
161int get_upgrade_type();
162
163/*******************************************************************************
164 * Inline function implementations *
165 ******************************************************************************/
166
167
168
169
170#endif // _UPI_UPGRADE_PACKAGE_H
171