• 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. \n
14  *
15  * Description: Partition information \n
16  * Author:
17  * History: \n
18  * 2022-09-01, Create file. \n
19  */
20 #ifndef PARTITION_INFO_H
21 #define PARTITION_INFO_H
22 
23 #include <stdint.h>
24 #include "partition.h"
25 #include "partition_resource_id.h"
26 #include "errcode.h"
27 
28 #ifdef CONFIG_PARTITION_SUPPORT_DEBUG
29 #include <stdio.h>
30 #define partition_printf(fmt, arg...) printf("[PARTITION] "fmt, ##arg)
31 #else
32 #define partition_printf(fmt, arg...)
33 #endif
34 
35 #define PARTITION_ITEM_ID_OFFSET 15
36 
37 #ifdef __cplusplus
38 #if __cplusplus
39 extern "C" {
40 #endif /* __cplusplus */
41 #endif /* __cplusplus */
42 
43 /**
44  * @brief  Description for each part.
45  */
46 typedef struct {
47     uint32_t addr;
48     uint32_t dir : 1;
49     uint32_t rsv : 31;
50     uint32_t id  : 8;
51     uint32_t size : 24;
52     uint32_t extra;
53 } partition_info_t;
54 
55 /**
56  * @brief  Partition struct in ram.
57  */
58 typedef struct {
59     uint32_t image_id;
60     uint32_t struct_ver;
61     uint32_t params_area_ver;
62     uint32_t partition_cnt;
63     partition_info_t partition_tbl[PARTITION_MAX_CNT];
64 } partition_t;
65 
66 /**
67  * @brief  Partition struct in flash.
68  */
69 typedef struct {
70     uint32_t addr;
71     uint32_t size;
72 } param_area_data_t;
73 
74 typedef struct {
75     uint32_t image_id;
76     uint32_t struct_ver;
77     uint32_t params_area_ver;
78     uint16_t param_item_offset;
79     uint8_t param_item_count;
80 } params_area_t;
81 
82 partition_t *partition_get_global_info(void);
83 
84 #ifdef __cplusplus
85 #if __cplusplus
86 }
87 #endif /* __cplusplus */
88 #endif /* __cplusplus */
89 
90 #endif /* PARTITION_INFO_H */
91