• 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  * Description: Provides MEM_Monitor driver api \n
16  *
17  * History: \n
18  * 2023-02-23, Create file. \n
19  */
20 #ifndef MEM_MONITOR_H
21 #define MEM_MONITOR_H
22 
23 #include <stdint.h>
24 #include "errcode.h"
25 #include "mem_monitor_porting.h"
26 
27 #ifdef __cplusplus
28 #if __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31 #endif /* __cplusplus */
32 
33 /**
34  * @defgroup drivers_driver_mem_monitor MEM_Monitor
35  * @ingroup  drivers_driver
36  * @{
37  */
38 
39 /**
40  * @if Eng
41  * @brief  Definition of the MEM_Monitor work mode.
42  * @else
43  * @brief  MEM_Monitor监控模式定义。
44  * @endif
45  */
46 typedef enum mem_monitor_mode {
47     MEM_MONITOR_MODE_READ = 1,              /*!< @if Eng MEM_Monitor mode: read mode.
48                                                  @else   MEM_Monitor模式:监控读模式。  @endif */
49     MEM_MONITOR_MODE_WRITE                  /*!< @if Eng MEM_Monitor mode: write mode.
50                                                  @else   MEM_Monitor模式:监控写模式。  @endif */
51 } mem_monitor_mode_t;
52 
53 /**
54  * @if Eng
55  * @brief  Definition of MEM_Monitor configuration.
56  * @else
57  * @brief  MEM_Monitor配置类型定义。
58  * @endif
59  */
60 typedef struct mem_monitor_config {
61     mem_monitor_section_t section;          /*!< @if Eng Address section for memory monitoring.
62                                                  @else   内存监控地址段。  @endif */
63     uint32_t addr_start;                    /*!< @if Eng Monitoring start address.
64                                                  @else   监控起始地址。  @endif */
65     uint32_t addr_end;                      /*!< @if Eng Monitoring end address.
66                                                  @else   监控结束地址。  @endif */
67     mem_monitor_mode_t mode;                /*!< @if Eng Memory monitoring mode.
68                                                  @else   内存监控模式。  @endif */
69 } mem_monitor_config_t;
70 
71 /**
72  * @if Eng
73  * @brief  MEM_Monitor callback function.
74  * @param  [in]  addr MEM_Monitor Monitoring Address.
75  * @param  [in]  mode MEM_Monitor Monitor the read/write mode.
76  * @else
77  * @brief  MEM_Monitor 回调类型定义。
78  * @param  [in]  addr MEM_Monitor监控地址。
79  * @param  [in]  mode MEM_Monitor监控读写模式。
80  * @endif
81  */
82 typedef void (*uapi_mem_monitor_callback_t)(uint32_t addr, mem_monitor_mode_t mode);
83 
84 /**
85  * @if Eng
86  * @brief  Initialize the MEM_Monitor.
87  * @retval ERRCODE_SUCC Success.
88  * @retval Other        Failure. For details, see @ref errcode_t.
89  * @else
90  * @brief  初始化MEM_Monitor。
91  * @retval ERRCODE_SUCC 成功。
92  * @retval Other        失败,参考 @ref errcode_t 。
93  * @endif
94  */
95 errcode_t uapi_mem_monitor_init(void);
96 
97 /**
98  * @if Eng
99  * @brief  Deinitialize the MEM_Monitor.
100  * @else
101  * @brief  去初始化MEM_Monitor。
102  * @endif
103  */
104 void uapi_mem_monitor_deinit(void);
105 
106 /**
107  * @if Eng
108  * @brief  Enable the specified MEM_Monitor.
109  * @param  [in]  monitor Indicates the index of MEM_Monitor want to enable.
110  * @param  [in]  callback The MEM_Monitor callback of the interrupt.
111  * @else
112  * @brief  使能指定的MEM_Monitor。
113  * @param  [in]  monitor MEM_Monitor的索引。
114  * @param  [in]  callback 中断的MEM_Monitor回调。
115  * @endif
116  */
117 void uapi_mem_monitor_enable(mem_monitor_t monitor, uapi_mem_monitor_callback_t callback);
118 
119 /**
120  * @if Eng
121  * @brief  Disable the specified MEM_Monitor.
122  * @param  [in]  monitor Indicates the index of MEM_Monitor want to disable.
123  * @else
124  * @brief  去使能MEM_Monitor。
125  * @param  [in]  monitor MEM_Monitor的索引。
126  * @endif
127  */
128 void uapi_mem_monitor_disable(mem_monitor_t monitor);
129 
130 /**
131  * @if Eng
132  * @brief  Set the Monitoring address and Monitoring mode for a MEM_Monitor section.
133  * @param  [in]  monitor Indicates the index of MEM_Monitor.
134  * @param  [in]  config Configuration of the section need to set, see @ref mem_monitor_config_t.
135  * @retval ERRCODE_SUCC   Success.
136  * @retval Other          Failure. For details, see @ref errcode_t .
137  * @else
138  * @brief  设置监控地址段以及工作模式。
139  * @param  [in]  monitor MEM_Monitor的索引
140  * @param  [in]  config 内存监控段的需要设置。 see @ref mem_monitor_config_t 。
141  * @retval ERRCODE_SUCC 成功。
142  * @retval Other        失败,参考 @ref errcode_t 。
143  * @endif
144  */
145 errcode_t uapi_mem_monitor_set_section(mem_monitor_t monitor, mem_monitor_config_t *config);
146 
147 /**
148  * @}
149  */
150 
151 #ifdef __cplusplus
152 #if __cplusplus
153 }
154 #endif /* __cplusplus */
155 #endif /* __cplusplus */
156 
157 #endif
158 
159