• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <hi_types.h>
17 
18 #define SFC_BUFFER_BASE_ADDRESS 0x400000
19 
20 /** @defgroup iot_flash_partiton Partition Table APIs
21 * @ingroup  iot_flashboot
22 */
23 /**
24  * @ingroup iot_flash_partiton
25  *
26  * partition number.
27  */
28 #define HI_FLASH_PARTITON_MAX 12
29 
30 /**
31  * @ingroup iot_flash_partiton
32  *
33  * partition ID.
34  */
35 typedef enum {
36     HI_FLASH_PARTITON_BOOT = 0,    /**< Boot partition ID.CNcomment:BOOT分区ID.CNend */
37     HI_FLASH_PARTITON_FACTORY_NV,  /**< Factory NV working partition ID.CNcomment:工厂NV分区ID.CNend */
38     HI_FLASH_PARTITON_NORMAL_NV,   /**< NORMAL NV partition ID.CNcomment:非工厂NV分区ID.CNend */
39     HI_FLASH_PARTITON_NORMAL_NV_BACKUP,   /**< NORMAL backup NV partition ID.CNcomment:非工厂NV备份分区ID,必须和非工厂区连续.CNend */
40     HI_FLASH_PARTITON_KERNEL_A,    /**< Kernel A running partition ID.CNcomment:内核A区ID.CNend */
41     HI_FLASH_PARTITON_KERNEL_B,    /**< Kernel B runing partition ID.CNcomment:内核B区ID.CNend */
42     HI_FLASH_PARTITON_HILINK,      /**< HILINK partition ID.CNcomment:HILINK分区ID(未使用HILINK可不需要).CNend */
43     HI_FLASH_PARTITON_FILE_SYSTEM, /**< File system partition ID.CNcomment:文件系统区ID.CNend */
44     HI_FLASH_PARTITON_USR_RESERVE, /**< User Reserved partition.CNcomment:用户保留区ID.CNend */
45     HI_FLASH_PARTITON_HILINK_PKI,  /**< HiLink PKI partition.CNcomment: HILINK PKI证书ID(未使用HILINK可不需要). CNend */
46     HI_FLASH_PARTITON_CRASH_INFO,  /**< Crash log partition.CNcomment:死机存储区ID.CNend */
47     HI_FLASH_PARTITON_BOOT_BACK,   /**< Boot backup partition.CNcomment:备份boot区ID. CNend */
48 } hi_flash_partition_table_id;
49 
50 /**
51  *  @ingroup iot_flash_partiton
52  *
53  *  Flash partition management. CNcomment:Flash分区表项。CNend
54  */
55 typedef struct {
56     hi_u32  addr    : 24;   /* Flash partition address. The value is 16 MB. If the address is in reverse order,
57                                 the value is the end low address. CNcomment:Flash分区地址,限制为16MB,
58                                 如果为倒序,存放为结束的低地址值 CNend */
59     hi_u32  id      : 7;    /* Flash partition ID. CNcomment:Flash区ID.CNend  */
60     hi_u32  dir     : 1;    /* Flash area storage direction. 0:regular. 1: reversed.CNcomment:Flash区存放方向。
61                                 0:分区内容正序;1:倒序末地址 CNend */
62 
63     hi_u32  size    : 24;   /* Size of the parition(Unit:byte). CNcomment:Flash分区大小(单位:byte)CNend */
64     hi_u32  reserve : 8;    /* Reserved. CNcomment:保留区CNend  */
65 
66     hi_u32  addition;       /* Supplementary information about the flash partition, such as the address of the Ram.
67                                CNcomment:Flash分区补充信息,如Ram对应地址等 CNend */
68 } hi_flash_partition_info;
69 
70 /**
71  *  @ingroup iot_flash_partiton
72  *  Flash partiton table.
73  */
74 typedef struct {
75     hi_flash_partition_info table[HI_FLASH_PARTITON_MAX]; /**< Flash分区表项描述  */
76 } hi_flash_partition_table;
77 
78 /**
79 * @ingroup  iot_flash_partiton
80 * @brief  Initialize flash partition table. CNcomment:初始化Flash分区表。CNend
81 *
82 * @par 描述:
83 *           Initialize flash partition table. CNcomment:初始化Flash分区表。CNend
84 *
85 * @attention None.
86 * @param  None.
87 *
88 * @retval #HI_ERR_FAILURE Failure.
89 * @retval #HI_ERR_SUCCESS Success.
90 * @par 依赖:
91 *            @li hi_flashboot.h:Describes FlashBoot APIs.CNcomment:文件用于描述Boot模块接口。CNend
92 * @see  hi_get_partition_table。
93 */
94 hi_u32 hi_flash_partition_init(hi_void);
95 
96 /**
97 * @ingroup  iot_flash_partiton
98 * @brief  Get flash partition table. CNcomment:获取Flash分区表。CNend
99 *
100 * @par 描述:
101 *           Get flash partition table. CNcomment:获取Flash分区表。CNend
102 *
103 * @attention None.
104 * @param  None.
105 *
106 * @retval #HI_NULL Failure.
107 * @retval #Other Success.
108 * @par 依赖:
109 *            @li hi_flashboot.h:Describes FlashBoot APIs.CNcomment:文件用于描述Boot模块接口。CNend
110 * @see  hi_flash_partition_init。
111 */
112 hi_flash_partition_table* hi_get_partition_table(hi_void);
113