• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * @file hi_partition_table.h
3  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /** @defgroup iot_flash_partiton FLASH Partition Management
18  *  @ingroup system
19  */
20 #ifndef __HI_PARTITION_TABLE_H__
21 #define __HI_PARTITION_TABLE_H__
22 #include <hi_types.h>
23 
24 #define HI_FLASH_PARTITON_MAX 12
25 /**
26  * @ingroup iot_flash_partiton
27  *
28  * Partition entry ID. CNcomment:分区项ID。CNend
29  */
30 typedef enum {
31     HI_FLASH_PARTITON_BOOT = 0,    /**< Boot partition ID.CNcomment:BOOT分区ID.CNend */
32     HI_FLASH_PARTITON_FACTORY_NV,  /**< Factory NV working partition ID.CNcomment:工厂NV分区ID.CNend */
33     HI_FLASH_PARTITON_NORMAL_NV,   /**< NORMAL NV partition ID.CNcomment:非工厂NV分区ID.CNend */
34     HI_FLASH_PARTITON_NORMAL_NV_BACKUP,   /**< NORMAL backup NV partition ID.CNcomment:非工厂NV备份分区ID,必须和非工厂区连续.CNend */
35     HI_FLASH_PARTITON_KERNEL_A,    /**< Kernel A running partition ID.CNcomment:内核A区ID.CNend */
36     HI_FLASH_PARTITON_KERNEL_B,    /**< Kernel B runing partition ID.CNcomment:内核B区ID.CNend */
37     HI_FLASH_PARTITON_HILINK,      /**< HILINK partition ID.CNcomment:HILINK分区ID(未使用HILINK可不需要).CNend */
38     HI_FLASH_PARTITON_FILE_SYSTEM, /**< File system partition ID.CNcomment:文件系统区ID.CNend */
39     HI_FLASH_PARTITON_USR_RESERVE, /**< User Reserved partition.CNcomment:用户保留区ID.CNend */
40     HI_FLASH_PARTITON_HILINK_PKI,  /**< HiLink PKI partition.CNcomment: HILINK PKI证书ID(未使用HILINK可不需要). CNend */
41     HI_FLASH_PARTITON_CRASH_INFO,  /**< Crash log partition.CNcomment:死机存储区ID.CNend */
42     HI_FLASH_PARTITON_BOOT_BACK,   /**< Boot backup partition.CNcomment:备份boot区ID. CNend */
43 } hi_flash_partition_table_id;
44 
45 /**
46  *  @ingroup iot_flash_partiton
47  *
48  *  Flash partition management. CNcomment:Flash分区表项。CNend
49  */
50 typedef struct {
51     hi_u32  addr    : 24;   /**< Flash partition address.The value is 16 MB.If the address is in reverse order,
52                                the value is the end low address.CNcomment:Flash分区地址,限制为16MB,
53                                如果为倒序,存放为结束的低地址值 CNend */
54     hi_u32  id      : 7;    /**< Flash partition ID.CNcomment:Flash区ID.CNend  */
55     hi_u32  dir     : 1;    /**< Flash area storage direction.0:regular.1: reversed.CNcomment:Flash区存放方向。
56                                0:分区内容正序;1:倒序末地址 CNend */
57 
58     hi_u32  size    : 24;   /**< Size of the parition(Unit:byte).CNcomment:Flash分区大小(单位:byte)CNend */
59     hi_u32  reserve : 8;    /**< Reserved. CNcomment:保留区CNend  */
60 
61     hi_u32  addition;      /**< Supplementary information about the flash partition, such as the address of the
62                                Ram.CNcomment:Flash分区补充信息,如Ram对应地址等 CNend */
63 } hi_flash_partition_info;
64 
65 
66 /**
67  *  @ingroup iot_flash_partiton
68  *
69  *  Flash partition table. CNcomment:Flash分区表。CNend
70  */
71 typedef struct {
72     hi_flash_partition_info table[HI_FLASH_PARTITON_MAX];  /**< Flash partition entry information.CNcomment:
73                                                                Flash分区表项描述 CNend */
74 } hi_flash_partition_table;
75 
76 /**
77 * @ingroup  iot_flash_partiton
78 * @brief  Obtains the flash partition table. CNcomment:获取Flash分区表。CNend
79 *
80 * @par 描述:
81 *           Obtains the flash partition table. CNcomment:获取Flash分区表。CNend
82 *
83 * @attention None
84 * @param None
85 *
86 * @retval #hi_flash_partition_table  Pointer to partition table information. CNcomment:分区表指针。CNend
87 * @par 依赖:
88 *            @li hi_partition_table.h:Describes flash partition APIs.
89 CNcomment:文件用于描述Flash分区相关接口。CNend
90 * @see  None
91 */
92 hi_flash_partition_table *hi_get_partition_table(hi_void);
93 
94 /**
95 * @ingroup  iot_flash_partiton
96 * @brief  Initializes the flash partition table. CNcomment:Flash分区表初始化。CNend
97 *
98 * @par 描述:
99 *           Initializes the flash partition table. CNcomment:Flash分区表初始化。CNend
100 *
101 * @attention None
102 * @param   None
103 *
104 * @retval #0      Success
105 * @retval #Other  Failure. For details, see hi_errno.h.
106 * @par 依赖:
107 *            @li hi_partition_table.h:Describes flash partition APIs.
108 CNcomment:文件用于描述Flash分区相关接口。CNend
109 * @see  None
110 */
111 hi_u32 hi_flash_partition_init(hi_void);
112 
113 /**
114 * @ingroup  iot_flash_partiton
115 * @brief  Get HiLink partition table'addr and size. CNcomment:获取HiLink分区地址和大小。CNend
116 *
117 * @par 描述:
118 *           Get HiLink partition table'addr and size. CNcomment:获取HiLink分区地址和大小。CNend
119 *
120 * @attention Call after hi_flash_partition_init. CNcomment:在hi_flash_partition_init之后调用。CNend
121 * @param  addr    [OUT] type #hi_u32*, Address of HiLink partition.CNcomment:HiLink分区地址。CNend
122 * @param  size     [OUT] type #hi_u32*, Size of HiLink partitioin, in bytes.CNcomment:HiLink分区大小,单位byte。CNend
123 *
124 * @retval #0      Success
125 * @retval #Other  Failure. For details, see hi_errno.h.
126 * @par 依赖:
127 *            @li hi_partition_table.h:Describes flash partition APIs.
128 CNcomment:文件用于描述Flash分区相关接口。CNend
129 * @see  None
130 */
131 hi_u32 hi_get_hilink_partition_table(hi_u32 *addr, hi_u32 *size);
132 
133 /**
134 * @ingroup  iot_flash_partiton
135 * @brief  Get HiLink PKI partition table'addr and size. CNcomment:获取HiLink PKI 分区地址和大小。CNend
136 *
137 * @par 描述:
138 *           Get HiLink PKI partition table'addr and size. CNcomment:获取HiLink PKI 分区地址和大小。CNend
139 *
140 * @attention Call after hi_flash_partition_init. CNcomment:在hi_flash_partition_init之后调用。CNend
141 * @param  addr    [OUT] type #hi_u32*, Address of HiLink PKI partition.CNcomment:HiLink PKI分区地址。CNend
142 * @param  size     [OUT] type #hi_u32*, Size of HiLink PKI partitioin, in bytes.CNcomment:HiLink PKI分区大小,单位byte。CNend
143 *
144 * @retval #0      Success
145 * @retval #Other  Failure. For details, see hi_errno.h.
146 * @par 依赖:
147 *            @li hi_partition_table.h:Describes flash partition APIs.
148 CNcomment:文件用于描述Flash分区相关接口。CNend
149 * @see  None
150 */
151 hi_u32 hi_get_hilink_pki_partition_table(hi_u32 *addr, hi_u32 *size);
152 
153 
154 /**
155 * @ingroup  iot_flash_partiton
156 * @brief  Get Crash info partition table'addr and size. CNcomment:获取死机信息分区地址和大小。CNend
157 *
158 * @par 描述:
159 *           Get Crash info partition table'addr and size. CNcomment:获取死机信息分区地址和大小。CNend
160 *
161 * @attention Call after hi_flash_partition_init. CNcomment:在hi_flash_partition_init之后调用。CNend
162 * @param  addr    [OUT] type #hi_u32*, Address of Crash info partition.CNcomment:死机信息分区地址。CNend
163 * @param  size     [OUT] type #hi_u32*, Size of Crash info partitioin, in bytes.CNcomment:死机信息分区大小,单位byte。CNend
164 *
165 * @retval #0      Success
166 * @retval #Other  Failure. For details, see hi_errno.h.
167 * @par 依赖:
168 *            @li hi_partition_table.h:Describes flash partition APIs.
169 CNcomment:文件用于描述Flash分区相关接口。CNend
170 * @see  None
171 */
172 hi_u32 hi_get_crash_partition_table(hi_u32 *addr, hi_u32 *size);
173 
174 /**
175 * @ingroup  iot_flash_partiton
176 * @brief  Get File system partition table'addr and size. CNcomment:获取文件系统分区地址和大小。CNend
177 *
178 * @par 描述:
179 *           Get File system partition table'addr and size. CNcomment:获取文件系统分区地址和大小。CNend
180 *
181 * @attention Call after hi_flash_partition_init. CNcomment:在hi_flash_partition_init之后调用。CNend
182 * @param  addr    [OUT] type #hi_u32*, Address of File system partition.CNcomment:文件系统分区地址。CNend
183 * @param  size     [OUT] type #hi_u32*, Size of HiLink partitioin, in bytes.CNcomment:文件系统分区大小,单位byte。CNend
184 *
185 * @retval #0      Success
186 * @retval #Other  Failure. For details, see hi_errno.h.
187 * @par 依赖:
188 *            @li hi_partition_table.h:Describes flash partition APIs.
189 CNcomment:文件用于描述Flash分区相关接口。CNend
190 * @see  None
191 */
192 hi_u32 hi_get_fs_partition_table(hi_u32 *addr, hi_u32 *size);
193 
194 /**
195 * @ingroup  iot_flash_partiton
196 * @brief  Get Normal NV partition table'addr and size. CNcomment:获取非工厂区分区地址和大小。CNend
197 *
198 * @par 描述:
199 *           Get Normal NV partition table'addr and size. CNcomment:获取非工厂区分区地址和大小。CNend
200 *
201 * @attention Call after hi_flash_partition_init. CNcomment:在hi_flash_partition_init之后调用。CNend
202 * @param  addr    [OUT] type #hi_u32*, Address of Normal NV partition.CNcomment:非工厂区分区地址。CNend
203 * @param  size     [OUT] type #hi_u32*, Size of Normal NV partitioin, in bytes.CNcomment:非工厂区分区大小,单位byte。CNend
204 *
205 * @retval #0      Success
206 * @retval #Other  Failure. For details, see hi_errno.h.
207 * @par 依赖:
208 *            @li hi_partition_table.h:Describes flash partition APIs.
209 CNcomment:文件用于描述Flash分区相关接口。CNend
210 * @see  None
211 */
212 hi_u32 hi_get_normal_nv_partition_table(hi_u32 *addr, hi_u32 *size);
213 
214 /**
215 * @ingroup  iot_flash_partiton
216 * @brief  Get Normal NV backup partition table'addr and size. CNcomment:获取非工厂备份区分区地址和大小。CNend
217 *
218 * @par 描述:
219 *           Get Normal NV backup partition table'addr and size. CNcomment:获取非工厂备份区分区地址和大小。CNend
220 *
221 * @attention Call after hi_flash_partition_init. CNcomment:在hi_flash_partition_init之后调用。CNend
222 * @param  addr    [OUT] type #hi_u32*, Address of Normal NV backup partition.CNcomment:非工厂备份区分区地址。CNend
223 * @param  size     [OUT] type #hi_u32*, Size of Normal NV backup partitioin, in bytes.CNcomment:非工厂备份区分区大小,单位byte。CNend
224 *
225 * @retval #0      Success
226 * @retval #Other  Failure. For details, see hi_errno.h.
227 * @par 依赖:
228 *            @li hi_partition_table.h:Describes flash partition APIs.
229 CNcomment:文件用于描述Flash分区相关接口。CNend
230 * @see  None
231 */
232 hi_u32 hi_get_normal_nv_backup_partition_table(hi_u32 *addr, hi_u32 *size);
233 
234 /**
235 * @ingroup  iot_flash_partiton
236 * @brief  Get User's reserved NV partition table'addr and size. CNcomment:获取用户保留区分区地址和大小。CNend
237 *
238 * @par 描述:
239 *           Get User's reserved NV partition table'addr and size. CNcomment:获取用户保留区分区地址和大小。CNend
240 *
241 * @attention Call after hi_flash_partition_init. CNcomment:在hi_flash_partition_init之后调用。CNend
242 * @param  addr    [OUT] type #hi_u32*, Address of user partition.CNcomment:用户保留区分区地址。CNend
243 * @param  size     [OUT] type #hi_u32*, Size of user partitioin, in bytes.CNcomment:用户保留区分区大小,单位byte。CNend
244 *
245 * @retval #0      Success
246 * @retval #Other  Failure. For details, see hi_errno.h.
247 * @par 依赖:
248 *            @li hi_partition_table.h:Describes flash partition APIs.
249 CNcomment:文件用于描述Flash分区相关接口。CNend
250 * @see  None
251 */
252 hi_u32 hi_get_usr_partition_table(hi_u32 *addr, hi_u32 *size);
253 
254 /**
255 * @ingroup  iot_flash_partiton
256 * @brief  Get Factory bin'addr and size. CNcomment:获取产测BIN 地址和大小。CNend
257 *
258 * @par 描述:
259 *           Get Factory bin'addr and size.. CNcomment:获取产测BIN 地址和大小。CNend
260 *
261 * @attention Call after hi_flash_partition_init. CNcomment:在hi_flash_partition_init之后调用。CNend
262 * @param  addr    [OUT] type #hi_u32*, Address of factory bin.CNcomment:产测BIN 地址。CNend
263 * @param  size     [OUT] type #hi_u32*, Size of factory bin, in bytes.CNcomment:产测bin 大小,单位byte。CNend
264 *
265 * @retval #0      Success
266 * @retval #Other  Failure. For details, see hi_errno.h.
267 * @par 依赖:
268 *            @li hi_partition_table.h:Describes flash partition APIs.
269 CNcomment:文件用于描述Flash分区相关接口。CNend
270 * @see  None
271 */
272 hi_u32 hi_get_factory_bin_partition_table(hi_u32 *addr, hi_u32 *size);
273 
274 #endif
275 
276