blob: f4fcf0514697bb48060322e8a1625f2c7e015f24 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001#ifndef __DRV_PCMON_H__
2#define __DRV_PCMON_H__
3
4/*****************************************************************************
5 * Includes
6 *****************************************************************************/
7
8#include "drv_pcmon_common.h"
9#include "drv_pcmon_v2.h"
10
11/*****************************************************************************
12 * Type Definition
13 *****************************************************************************/
14
15typedef PDAMON_CFG_V2_T PDAMON_CFG_T;
16typedef PDAMON_PC_PAIR_RAW_V2_T PDAMON_PC_PAIR_RAW_T;
17typedef PDAMON_RAW_PER_CORE_V2_T PDAMON_RAW_PER_CORE_T;
18typedef PDAMON_STOP_SOURCE_V2 PDAMON_STOP_SOURCE;
19typedef PDAMON_EVENT_MASK_V2 PDAMON_EVENT_MASK;
20typedef PDAMON_EX_RAW_V2_T PDAMON_EX_RAW_T;
21typedef PDAMON_NEX_RAW_V2_T PDAMON_NEX_RAW_T;
22
23#define PDAMON_IA_PIPED_CNT PDAMON_IA_PIPED_CNT_V2
24#define PDAMON_DA_PIPED_CNT PDAMON_DA_PIPED_CNT_V2
25
26/**
27 * For exception flow
28 */
29#define PDAMON_EX_PIPED_PC_CNT (PDAMON_EX_PIPED_PC_CNT_V2)
30#define PDAMON_EX_PC_PAIR_CNT (PDAMON_EX_PC_PAIR_CNT_V2)
31#define PDAMON_EX_PIPED_DA_CNT (PDAMON_EX_PIPED_DA_CNT_V2)
32#define PDAMON_EX_DA_PAIR_CNT (PDAMON_EX_DA_PAIR_CNT_V2)
33
34/**
35 * A structure for backup raw data of RMPU violation case
36 */
37typedef struct {
38 PDAMON_RAW_PER_CORE_T raw[PDAMON_CORE_NUM];
39} PDAMON_RMPU_VIO_BACKUP, *PPDAMON_RMPU_VIO_BACKUP;
40
41
42///@}
43
44///////////////////////////////////////////////////////////////////////////////
45/// \brief This function is used to initialize PDAMON driver
46///
47/// \return PDAMON_OK if initialization is successful
48/// \return PDAMON_FAIL if initialization is failed.
49///////////////////////////////////////////////////////////////////////////////
50PDAMON_RET drv_pdamon_init(void);
51
52///////////////////////////////////////////////////////////////////////////////
53//// \brief This function is to configure PCMON module when leave dormant.
54///
55/// \return PDAMON_OK if configuration is successful
56/// \return PDAMON_FAIL if configuration is failed.
57///////////////////////////////////////////////////////////////////////////////
58PDAMON_RET drv_pdamon_configure_dormant_leave(void);
59
60///////////////////////////////////////////////////////////////////////////////
61/// \brief This function is used to configure PDAMON of cores.
62///
63/// \param [in] cfg A configuration structure.
64/// \param [in] core Core ID.
65/// \return PDAMON_OK if configuration is successful;
66/// Not PDAMON_OK if failure.
67///////////////////////////////////////////////////////////////////////////////
68PDAMON_RET drv_pdamon_set_config(PDAMON_CFG_T *cfg, PDAMON_CORE_SEL core);
69
70///////////////////////////////////////////////////////////////////////////////
71/// \brief This function is used to setup PC match address.
72///
73/// \param [in] index Match index from 0 to 5.
74/// \param [in] addr Program counter to match.
75/// \param [in] enabled Set this match as enabled or not.
76/// \return PDAMON_OK if configuration is successful;
77/// Not PDAMON_OK if failure.
78///////////////////////////////////////////////////////////////////////////////
79PDAMON_RET drv_pdamon_set_pc_match(kal_uint32 index, kal_uint32 addr, kal_bool enabled);
80
81///////////////////////////////////////////////////////////////////////////////
82/// \brief This function is used to setup PC match address.
83///
84/// \param [in] index Match index from 0 to 5.
85/// \param [in] addr Program counter to match.
86/// \param [in] mask Mask of Program counter to match.
87/// \param [in] enabled Set this match as enabled or not.
88/// \return PDAMON_OK if configuration is successful;
89/// Not PDAMON_OK if failure.
90///////////////////////////////////////////////////////////////////////////////
91PDAMON_RET drv_pdamon_set_pc_match_and_mask(kal_uint32 index, kal_uint32 addr, kal_uint32 mask, kal_bool enabled);
92
93///////////////////////////////////////////////////////////////////////////////
94/// \brief This function is used to start PDAMON of cores.
95///
96/// \param [in] core Core definition. One of PDAMON_CORE_SEL.
97/// \return PDAMON_OK if starting capture is successful;
98/// Not PDAMON_OK if failure.
99///////////////////////////////////////////////////////////////////////////////
100PDAMON_RET drv_pdamon_start_capture(PDAMON_CORE_SEL core);
101
102///////////////////////////////////////////////////////////////////////////////
103/// \brief This function is used to stop PDAMON of cores.
104///
105/// \param [in] core Core definition. One of PDAMON_CORE_SEL.
106/// \return PDAMON_OK if stopping capture is successful;
107/// Not PDAMON_OK if failure.
108///////////////////////////////////////////////////////////////////////////////
109PDAMON_RET drv_pdamon_stop_capture(PDAMON_CORE_SEL core);
110
111///////////////////////////////////////////////////////////////////////////////
112/// \brief This function is to stop capturing of PDAMON via GCR control
113/// \param [in] core The core of PDAMON to be stopped
114///
115/// \return PDAMON_RET_OK if stop capturing of PDAMON via GCR is successful
116///////////////////////////////////////////////////////////////////////////////
117PDAMON_RET drv_pdamon_gcr_stop_capture(PDAMON_CORE_SEL core);
118
119///////////////////////////////////////////////////////////////////////////////
120/// \brief This function is used to select PDAMON of specific
121/// core.
122///
123/// \param [in] core Core definition. One of PDAMON_CORE_SEL.
124/// \return PDAMON_OK if core selection is successful;
125/// Not PDAMON_OK if failure.
126/// \note V2 : Not support.
127///////////////////////////////////////////////////////////////////////////////
128PDAMON_RET drv_pdamon_core_select(PDAMON_CORE_SEL core);
129
130///////////////////////////////////////////////////////////////////////////////
131/// \brief This function is used to check if PDAMON is stopped.
132///
133/// \return KAL_TRUE if PDAMON is stopped. KAL_FALSE otherwise.
134/// \note V1 : Must called after drv_pdamon_core_select
135///////////////////////////////////////////////////////////////////////////////
136kal_bool drv_pdamon_is_stopped(PDAMON_CORE_SEL core);
137
138///////////////////////////////////////////////////////////////////////////////
139/// \brief This function is used to check if PDAMON is stopped
140/// by specific sources.
141///
142/// \return KAL_TRUE if PDAMON is stopped. KAL_FALSE otherwise.
143///////////////////////////////////////////////////////////////////////////////
144kal_bool drv_pdamon_is_stopped_by_sources(PDAMON_CORE_SEL core, PDAMON_STOP_SOURCE source);
145
146///////////////////////////////////////////////////////////////////////////////
147/// \brief This function is used to get PC record count of
148/// specific core.
149///
150/// \return PC record count.
151/// \note V1 : Must called after drv_pdamon_core_select
152///////////////////////////////////////////////////////////////////////////////
153kal_uint32 drv_pdamon_get_pc_count(PDAMON_CORE_SEL core);
154
155///////////////////////////////////////////////////////////////////////////////
156/// \brief This function is used to get PC record count of
157/// a specific TC of a core.
158///
159/// \return PC record count.
160/// \note V2 support only.
161///////////////////////////////////////////////////////////////////////////////
162kal_uint32 drv_pdamon_get_pc_count_by_tc(PDAMON_CORE_SEL core, PDAMON_TC_SEL tc);
163
164///////////////////////////////////////////////////////////////////////////////
165/// \brief This function is used to get DA record count of
166/// specific core.
167///
168/// \return DA record count.
169/// \note V1 : Must called after drv_pdamon_core_select
170///////////////////////////////////////////////////////////////////////////////
171kal_uint32 drv_pdamon_get_da_count(PDAMON_CORE_SEL core);
172
173///////////////////////////////////////////////////////////////////////////////
174/// \brief This function is used to get DA record count of
175/// a specific TC of a core.
176///
177/// \return DA record count.
178/// \note V2 support only.
179///////////////////////////////////////////////////////////////////////////////
180kal_uint32 drv_pdamon_get_da_count_by_tc(PDAMON_CORE_SEL core, PDAMON_TC_SEL tc);
181
182///////////////////////////////////////////////////////////////////////////////
183/// \brief This function is used to get PDAMON status value
184///
185/// \param [in/out] status Buffer to store status value
186/// \return PDAMON_OK if status value is returned from PDAMON.
187/// Not PDAMON_OK if failure.
188/// \note V1 : Must called after drv_pdamon_core_select
189///////////////////////////////////////////////////////////////////////////////
190PDAMON_RET drv_pdamon_get_status(PDAMON_CORE_SEL core, kal_uint32 *status);
191
192///////////////////////////////////////////////////////////////////////////////
193/// \brief This function is used to get PDAMON status value
194///
195/// \param [in/out] status Pointer to a buffer to store PC/DA record.
196/// \return PDAMON_OK if record is available from PDAMON.
197/// Not PDAMON_OK if failure.
198/// \note V1 : Must called after drv_pdamon_core_select
199///////////////////////////////////////////////////////////////////////////////
200PDAMON_RET drv_pdamon_get_raw(PDAMON_CORE_SEL core, PDAMON_RAW_PER_CORE_T *raw);
201
202///////////////////////////////////////////////////////////////////////////////
203/// \brief This function is used to get PC/DA record of specific
204/// core in excpetion flow
205///
206/// \param [in] core Core definition. One of PDAMON_CORE_SEL.
207/// \param [in] raw Pointer to a buffer to store PC/DA record.
208/// \return PDAMON_OK if record is available.
209/// Not PDAMON_OK if failure.
210///////////////////////////////////////////////////////////////////////////////
211PDAMON_RET drv_pdamon_ex_get_raw(PDAMON_CORE_SEL core, PDAMON_EX_RAW_T *raw);
212
213///////////////////////////////////////////////////////////////////////////////
214/// \brief This function is used to get PC/DA record of specific
215/// core in nested excpetion flow
216///
217/// \param [in] core Core definition. One of PDAMON_CORE_SEL.
218/// \param [in] raw Pointer to a buffer to store PC/DA record.
219/// \return PDAMON_OK if record is available.
220/// Not PDAMON_OK if failure.
221///////////////////////////////////////////////////////////////////////////////
222PDAMON_RET drv_pdamon_nex_get_raw(PDAMON_CORE_SEL core, PDAMON_NEX_RAW_T *raw);
223
224///////////////////////////////////////////////////////////////////////////////
225/// \brief This function is used to get PC/DA record of all
226/// cores in excpetion flow
227///
228/// \return PDAMON_OK if all record are available.
229/// Not PDAMON_OK if failure.
230///////////////////////////////////////////////////////////////////////////////
231PDAMON_RET drv_pdamon_ex_get_all_raw();
232
233///////////////////////////////////////////////////////////////////////////////
234/// \brief This function is used to mask/un-mask stop sources.
235///
236/// \param [in] source Stop source enumeration.
237/// Please refer to PCMON_STOP_SOURCE.
238/// \param [in] mask KAL_TRUE means mask stop source.
239/// KAL_FALSE means unmask stop source.
240///
241/// \return PCMON_OK if mask/un-mask operation is done.
242///////////////////////////////////////////////////////////////////////////////
243PDAMON_RET drv_pdamon_mask_stop_sources(PDAMON_CORE_SEL core, PDAMON_STOP_SOURCE sources, kal_bool mask);
244
245///////////////////////////////////////////////////////////////////////////////
246/// \brief This function is used to backup PC/DA record and
247/// re-start PCMon.
248///
249/// \param [in] mcu KAL_TRUE means backup PC/DA record by MCU.
250/// KAL_FALSE means backup PC/DA record by GDMA.
251/// \param [in/out] data_ptr A pointer of buffer to store PC/DA record.
252/// \param [in] size Size of data_ptr in byes. This value must be 256.
253/// \param [in] mask KAL_TRUE means mask RMPU stop source after backup.
254/// KAL_FALSE means unmask RMPU stop source after backup.
255///
256/// \return PCMON_INVALID_ARGUMENT means \size if not the
257/// proper value.
258/// \return PCMON_OK if backup and restart are done.
259/// \return PCMON_FAIL if PCMon is not stopped. Backup can not
260/// be done.
261///////////////////////////////////////////////////////////////////////////////
262PDAMON_RET drv_pdamon_backup_and_restart(kal_bool mcu, PPDAMON_RMPU_VIO_BACKUP data_ptr, kal_bool mask);
263
264#endif // end of __DRV_PCMON_H__