• 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  * Description: Provides partition manage api. \n
15  *
16  * History: \n
17  * 2022-09-01, Create file. \n
18  */
19 #ifndef PARTITION_H
20 #define PARTITION_H
21 
22 #include <stdint.h>
23 #include "errcode.h"
24 #include "partition_resource_id.h"
25 
26 #ifdef __cplusplus
27 #if __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30 #endif /* __cplusplus */
31 
32 /**
33  * @defgroup middleware_utils_partition_api Partition
34  * @ingroup  middleware_utils
35  * @{
36  */
37 
38 /**
39  * @if Eng
40  * @brief  Partition storage location type.
41  * @else
42  * @brief  分区位置类型
43  * @endif
44  */
45 typedef enum partition_type {
46     PARTITION_BY_ADDRESS,  /*!< @if Eng Partition stored on an memory address.
47                                   @else   分区存储在内存地址上 @endif */
48     PARTITION_BY_PATH,     /*!< @if Eng Partition stored on filesystem.
49                                   @else   分区存储在文件系统上 @endif */
50     PARTITION_TYPE_COUNT   /*!< @if Eng type count, not a valid type.
51                                   @else   类型数量,不作为类型使用 @endif */
52 } partition_type_t;
53 
54 /**
55  * @if Eng
56  * @brief  Partition information.
57  * @else
58  * @brief  分区信息结构
59  * @endif
60  */
61 typedef struct partition_information {
62     partition_type_t type; /*!< @if Eng Partition storage location type.
63                                   @else   分区存储位置类型 @endif */
64     union {
65         struct {
66             uint32_t addr; /*!< @if Eng Address of partition if partition stored on an memory address.
67                                 @else   如果分区存储在内存地址上,addr存储分区的起始地址 @endif */
68             uint32_t size; /*!< @if Eng Byte length of partition if partition stored on flash or ram.
69                                 @else   如果分区存储在内存地址上,size存储分区的字节长度 @endif */
70         } addr_info;       /*!< @if Eng The address info of the partition.
71                                 @else   分区的地址信息 @endif */
72         char *file_path;   /*!< @if Eng File path if image partition on filesystem.
73                                 @else   如果分区存在文件系统上,file_path标识存储分区所在路径 @endif */
74     } part_info;           /*!< @if Eng the union of partition information(address or file path).
75                                 @else   保存分区信息(地址或文件路径)的共同体 @endif */
76 } partition_information_t;
77 
78 /**
79  * @if Eng
80  * @brief  Initialize the partition management module.
81  * @retval ERRCODE_SUCC            Success.
82  * @retval Others                  ERRCODE_FAIL or other error num.
83  * @else
84  * @brief  分区模块初始化
85  * @retval ERRCODE_SUCC           成功返回#ERRCODE_SUCC
86  * @retval Others                 失败返回#ERRCODE_FAIL或其他返回值
87  * @endif
88  */
89 errcode_t uapi_partition_init(void);
90 
91 /**
92  * @if Eng
93  * @brief  Obtaining Partition Information.
94  * @par Description: Obtains information about a partition specified by partition_id.
95  * The partition information includes the start address and byte length of the partition.
96  * @param  [in] partition_id Id of specified partition. see @ref partition_ids_t
97  * @param  [out] info Used to save the information when obtained successfully. see @ref partition_information_t
98  * @retval ERRCODE_SUCC            Success
99  * @retval Others                  ERRCODE_FAIL or other error num.
100  * @par Depends:
101  * @li partition_resource_id.h
102  * @else
103  * @brief  获取分区信息
104  * @par 说明: 获取partition_id指定的分区信息
105  * @param  [in] partition_id 指定的分区的ID。 参考 @ref partition_ids_t
106  * @param  [out] info 用来保存获取到的分区信息。 参考 @ref partition_information_t
107  * @retval ERRCODE_SUCC         成功返回#ERRCODE_SUCC
108  * @retval Others               失败返回#ERRCODE_FAIL或其他值
109  * @par 依赖:
110  * @li partition_resource_id.h
111  * @endif
112  */
113 errcode_t uapi_partition_get_info(partition_ids_t partition_id, partition_information_t *info);
114 
115 /**
116  * @}
117  */
118 
119 #ifdef __cplusplus
120 #if __cplusplus
121 }
122 #endif /* __cplusplus */
123 #endif /* __cplusplus */
124 
125 #endif
126