]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/libsrc/axipmon_v6_6/src/xaxipmon.h
Update Zynq, MPSoc Cortex-A53 and MPSoc Cortex-R5 demo projects to build with the...
[freertos] / FreeRTOS / Demo / CORTEX_A53_64-bit_UltraScale_MPSoC / RTOSDemo_A53_bsp / psu_cortexa53_0 / libsrc / axipmon_v6_6 / src / xaxipmon.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2007 - 2015 Xilinx, Inc.  All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32 /****************************************************************************/
33 /**
34 *
35 * @file xaxipmon.h
36 * @addtogroup axipmon_v6_6
37 * @{
38 * @details
39 *
40 * The XAxiPmon driver supports the Xilinx AXI Performance Monitor device.
41 *
42 * The AXI Performance Monitor device provides following features:
43 *
44 *       Configurable number of Metric Counters and Incrementers
45 *       Computes performance metrics for Agents connected to
46 *       monitor slots (Up to 8 slots)
47 *
48 * The following Metrics can be computed:
49 *
50 * Metrics computed for an AXI4 MM agent:
51 *       Write Request Count: Total number of write requests by/to the agent.
52 *       Read Request Count: Total number of read requests given by/to the
53 *                           agent.
54 *       Read Latency: It is defined as the time from the start of read address
55 *                     transaction to the beginning of the read data service.
56 *       Write Latency: It is defined as the period needed a master completes
57 *                      write data transaction, i.e. from write address
58 *                      transaction to write response from slave.
59 *       Write Byte Count: Total number of bytes written by/to the agent.
60 *                         This metric is helpful when calculating the
61 *                         throughput of the system.
62 *       Read Byte Count: Total number of bytes read from/by the agent.
63 *       Average Write Latency: Average write latency seen by the agent.
64 *                              It can be derived from total write latency
65 *                              and the write request count.
66 *       Average Read Latency: Average read latency seen by the agent. It can be
67 *                             derived from total read latency and the read
68 *                             request count.
69 *       Master Write Idle Cycle Count: Number of idle cycles caused by the
70 *                                      masters during write transactions to
71 *                                      the slave.
72 *       Slave Write Idle Cycle Count: Number of idle cycles caused by this slave
73 *                                     during write transactions to the slave.
74 *       Master Read Idle Cycle Count: Number of idle cycles caused by the
75 *                                     master during read transactions to the
76 *                                     slave.
77 *       Slave Read Idle Cycle Count: Number of idle cycles caused by this slave
78 *                                    during read transactions to the slave.
79 *
80 * Metrics computed for an AXI4-Stream agent:
81 *
82 *       Transfer Cycle Count: Total number of writes by/to the agent.
83 *       Data Byte Count: Total number of data bytes written by/to the agent.
84 *                        This metric helps in calculating the throughput
85 *                        of the system.
86 *       Position Byte Count: Total number of position bytes transferred.
87 *       Null Byte Count: Total number of null bytes transferred.
88 *       Packet Count: Total number of packets transferred.
89 *
90 * There are three modes : Advanced, Profile and Trace.
91 * - Advanced mode has 10 Mertic Counters, Sampled Metric Counters, Incrementors
92 *   and Sampled Incrementors.
93 * - Profile mode has only 47 Metric Counters and Sampled Metric Counters.
94 * - Trace mode has no Counters.
95 * User should refer to the hardware device specification for detailed
96 * information about the device.
97 *
98 * This header file contains the prototypes of driver functions that can
99 * be used to access the AXI Performance Monitor device.
100 *
101 *
102 * <b> Initialization and Configuration </b>
103 *
104 * The device driver enables higher layer software (e.g., an application) to
105 * communicate to the AXI Performance Monitor device.
106 *
107 * XAxiPmon_CfgInitialize() API is used to initialize the AXI Performance Monitor
108 * device. The user needs to first call the XAxiPmon_LookupConfig() API which
109 * returns the Configuration structure pointer which is passed as a parameter to
110 * the XAxiPmon_CfgInitialize() API.
111 *
112 *
113 * <b>Interrupts</b>
114 *
115 * The AXI Performance Monitor does not support Interrupts
116 *
117 *
118 * <b> Virtual Memory </b>
119 *
120 * This driver supports Virtual Memory. The RTOS is responsible for calculating
121 * the correct device base address in Virtual Memory space.
122 *
123 *
124 * <b> Threads </b>
125 *
126 * This driver is not thread safe. Any needs for threads or thread mutual
127 * exclusion must be satisfied by the layer above this driver.
128 *
129 * <b> Asserts </b>
130 *
131 * Asserts are used within all Xilinx drivers to enforce constraints on argument
132 * values. Asserts can be turned off on a system-wide basis by defining, at
133 * compile time, the NDEBUG identifier. By default, asserts are turned on and it
134 * is recommended that users leave asserts on during development.
135 *
136 *
137 * <b> Building the driver </b>
138 *
139 * The XAxiPmon driver is composed of several source files. This allows the user
140 * to build and link only those parts of the driver that are necessary.
141 *
142 * <b> Limitations of the driver </b>
143 *
144 *
145 * <br><br>
146 *
147 * <pre>
148 *
149 * MODIFICATION HISTORY:
150 *
151 * Ver   Who    Date     Changes
152 * ----- -----  -------- -----------------------------------------------------
153 * 1.00a bss    02/27/12 First release
154 * 2.00a bss    06/23/12 Updated to support v2_00a version of IP.
155 * 3.00a bss    09/03/12 To support v2_01_a version of IP:
156 *                       Deleted XAxiPmon_SetAgent, XAxiPmon_GetAgent APIs and
157 *                       added XAPM_FLAG_EVENT, XAPM_FLAG_EVNTSTAR,
158 *                       XAPM_FLAG_EVNTSTOP.
159 *                       Deleted XAxiPmon_SetAgent, XAxiPmon_GetAgent APIs and
160 *                       modified XAxiPmon_SetMetrics, XAxiPmon_GetMetrics APIs
161 *                       in xaxipmon.c
162 *                       Deleted XAPM_AGENT_OFFSET Macro in xaxipmon_hw.h
163 * 3.01a bss    10/25/12 To support new version of IP:
164 *                       Added XAPM_MCXLOGEN_OFFSET macros in xaxipmon_hw.h.
165 *                       Added XAxiPmon_SetMetricCounterCutOff,
166 *                       XAxiPmon_GetMetricCounterCutOff,
167 *                       XAxiPmon_EnableExternalTrigger and
168 *                       XAxiPmon_DisableExternalTrigger APIs in xaxipmon.c
169 *                       Modified XAxiPmon_SetMetrics and XAxiPmon_GetMetrics
170 *                       (CR #683746) in xaxipmon.c
171 *                       Added XAxiPmon_EnableEventLog,
172 *                       XAxiPmon_DisableMetricsCounter,
173 *                       XAxiPmon_EnableMetricsCounter APIs in xaxipmon.c to
174 *                       replace macros in this file.
175 *                       Added XAPM_FLAG_XXX macros.
176 *                       Added XAxiPmon_StartCounters and XAxiPmon_StopCounters
177 *                       APIs (CR #683799).
178 *                       Added XAxiPmon_StartEventLog and XAxiPmon_StopEventLog
179 *                       APIs (CR #683801).
180 *                       Added XAxiPmon_GetMetricName API (CR #683803).
181 *                       Deleted XAxiPmon_SetAgent, XAxiPmon_GetAgent
182 *                       declarations (CR #677337)
183 * 4.00a bss    01/17/13 To support new version of IP:
184 *                       Added XAPM_METRIC_SET_12 to XAPM_METRIC_SET_15 macros.
185 *                       Added XAxiPmon_SetLogEnableRanges,
186 *                       XAxiPmon_GetLogEnableRanges,
187 *                       XAxiPmon_EnableMetricCounterTrigger,
188 *                       XAxiPmon_DisableMetricCounterTrigger,
189 *                       XAxiPmon_EnableEventLogTrigger,
190 *                       XAxiPmon_DisableEventLogTrigger,
191 *                       XAxiPmon_SetWriteLatencyId,
192 *                       XAxiPmon_SetReadLatencyId,
193 *                       XAxiPmon_GetWriteLatencyId,
194 *                       XAxiPmon_GetReadLatencyId APIs and removed
195 *                       XAxiPmon_SetMetricCounterCutOff,
196 *                       XAxiPmon_GetMetricCounterCutOff,
197 *                       XAxiPmon_EnableExternalTrigger and
198 *                       XAxiPmon_DisableExternalTrigger APIs in xaxipmon.c
199 *                       Added XAPM_LATENCYID_OFFSET,
200 *                       XAPM_CR_EVTLOG_EXTTRIGGER_MASK,
201 *                       XAPM_LATENCYID_RID_MASK and XAPM_LATENCYID_WID_MASK in
202 *                       xaxipmon_hw.h
203 * 5.00a bss   08/26/13  To support new version of IP:
204 *                       XAxiPmon_SampleMetrics Macro.
205 *                       Modified XAxiPmon_CfgInitialize, Assert functions
206 *                       Added XAxiPmon_GetMetricCounter,
207 *                       XAxiPmon_SetSampleInterval, XAxiPmon_GetSampleInterval,
208 *                       XAxiPmon_SetWrLatencyStart, XAxiPmon_SetWrLatencyEnd,
209 *                       XAxiPmon_SetRdLatencyStart, XAxiPmon_SetRdLatencyEnd,
210 *                       XAxiPmon_GetWrLatencyStart, XAxiPmon_GetWrLatencyEnd,
211 *                       XAxiPmon_GetRdLatencyStart, XAxiPmon_GetRdLatencyEnd,
212 *                       XAxiPmon_SetWriteIdMask, XAxiPmon_SetReadIdMask,
213 *                       XAxiPmon_GetWriteIdMask and XAxiPmon_GetReadIdMask APIs
214 *                       Renamed :
215 *                       XAxiPmon_SetWriteLatencyId to
216 *                       XAxiPmon_SetWriteId, XAxiPmon_SetReadLatencyId to
217 *                       XAxiPmon_SetReadId, XAxiPmon_GetWriteLatencyId to
218 *                       XAxiPmon_GetWriteId and XAxiPmon_SetReadLatencyId to
219 *                       XAxiPmon_GetReadId. in xaxipmon.c
220 *                       Added Macros XAPM_MC10_OFFSET to XAPM_MC47_OFFSET,
221 *                       XAPM_SMC10_OFFSET to XAPM_SMC47_OFFSET,
222 *                       XAPM_IDMASK_OFFSET, XAPM_CR_IDFILTER_ENABLE_MASK,
223 *                       XAPM_CR_WRLATENCY_START_MASK,
224 *                       XAPM_CR_WRLATENCY_END_MASK,
225 *                       XAPM_CR_RDLATENCY_START_MASK,
226 *                       XAPM_CR_RDLATENCY_END_MASK and
227 *                       XAPM_MAX_COUNTERS_PROFILE.
228 *                       Renamed:
229 *                       XAPM_LATENCYID_OFFSET to XAPM_ID_OFFSET,
230 *                       XAPM_LATENCYID_RID_MASK to XAPM_ID_RID_MASK,
231 *                       XAPM_LATENCYID_WID_MASK to XAPM_ID_WID_MASK.
232 *                       in xaxipmon_hw.h.
233 *                       Modified driver tcl to generate new parameters
234 *                       ScaleFactor, ModeProfile, ModeTrace and ModeAdvanced
235 *                       in Config structure.
236 * 6.0   adk  19/12/13 Updated as per the New Tcl API's
237 * 6.1   adk  16/04/14 Updated the driver tcl for the newly added parameters in
238 *                     The Axi pmon IP.
239 * 6.2   bss  04/21/14   Updated XAxiPmon_CfgInitialize in xaxipmon.c to Reset
240 *                       counters and FIFOs based on Modes(CR#782671). And if
241 *                       both profile and trace modes are present set mode as
242 *                       Advanced.
243 * 6.2   bss  03/02/15   To support Zynq MP APM:
244 *                                               Added Is32BitFiltering in XAxiPmon_Config structure.
245 *                                               Updated XAxiPmon_SetWriteId, XAxiPmon_SetReadId,
246 *                                               XAxiPmon_GetWriteId, XAxiPmon_GetReadId
247 *                                               XAxiPmon_SetWriteIdMask, XAxiPmon_SetReadIdMask
248 *                                               XAxiPmon_GetWriteIdMask, XAxiPmon_GetReadIdMask
249 *                                               functions in xaxipmon.c.
250 *                                               Added XAPM_RID_OFFSET and XAPM_RIDMASK_OFFSET in
251 *                                               xaxipmon_hw.h
252 *
253 * 6.3   kvn  07/02/15   Modified code according to MISRA-C:2012 guidelines.
254 * 6.4   sk   11/10/15 Used UINTPTR instead of u32 for Baseaddress CR# 867425.
255 *                     Changed the prototype of XAxiPmon_CfgInitialize API.
256 * 6.5   ms   01/23/17 Modified xil_printf statement in main function for all
257 *                     examples to ensure that "Successfully ran" and "Failed"
258 *                     strings are available in all examples. This is a fix
259 *                     for CR-965028.
260 *       ms   03/17/17 Added readme.txt file in examples folder for doxygen
261 *                     generation.
262 * 6.6   ms   04/18/17 Modified tcl file to add suffix U for all macro
263 *                     definitions of axipmon in xparameters.h
264 * </pre>
265 *
266 *****************************************************************************/
267 #ifndef XAXIPMON_H /* Prevent circular inclusions */
268 #define XAXIPMON_H /* by using protection macros  */
269
270 #ifdef __cplusplus
271 extern "C" {
272 #endif
273
274 /***************************** Include Files ********************************/
275
276 #include "xil_types.h"
277 #include "xil_assert.h"
278 #include "xstatus.h"
279 #include "xaxipmon_hw.h"
280
281 /************************** Constant Definitions ****************************/
282
283
284 /**
285  * @name Macro for Maximum number of Counters
286  *
287  * @{
288  */
289 #define XAPM_MAX_COUNTERS               10U /**< Maximum number of Counters */
290 #define XAPM_MAX_COUNTERS_PROFILE       48U /**< Maximum number of Counters */
291
292 /*@}*/
293
294
295 /**
296  * @name Indices for Metric Counters and Sampled Metric Coounters used with
297  *       XAxiPmon_GetMetricCounter and XAxiPmon_GetSampledMetricCounter APIs
298  * @{
299  */
300
301 #define XAPM_METRIC_COUNTER_0   0U /**< Metric Counter 0 Register Index */
302 #define XAPM_METRIC_COUNTER_1   1U /**< Metric Counter 1 Register Index */
303 #define XAPM_METRIC_COUNTER_2   2U /**< Metric Counter 2 Register Index */
304 #define XAPM_METRIC_COUNTER_3   3U /**< Metric Counter 3 Register Index */
305 #define XAPM_METRIC_COUNTER_4   4U /**< Metric Counter 4 Register Index */
306 #define XAPM_METRIC_COUNTER_5   5U /**< Metric Counter 5 Register Index */
307 #define XAPM_METRIC_COUNTER_6   6U /**< Metric Counter 6 Register Index */
308 #define XAPM_METRIC_COUNTER_7   7U /**< Metric Counter 7 Register Index */
309 #define XAPM_METRIC_COUNTER_8   8U /**< Metric Counter 8 Register Index */
310 #define XAPM_METRIC_COUNTER_9   9U /**< Metric Counter 9 Register Index */
311
312 /*@}*/
313
314 /**
315  * @name Indices for Incrementers and Sampled Incrementers used with
316  *       XAxiPmon_GetIncrementer and XAxiPmon_GetSampledIncrementer APIs
317  * @{
318  */
319
320 #define XAPM_INCREMENTER_0      0U /**< Metric Counter 0 Register Index */
321 #define XAPM_INCREMENTER_1      1U /**< Metric Counter 0 Register Index */
322 #define XAPM_INCREMENTER_2      2U /**< Metric Counter 0 Register Index */
323 #define XAPM_INCREMENTER_3      3U /**< Metric Counter 0 Register Index */
324 #define XAPM_INCREMENTER_4      4U /**< Metric Counter 0 Register Index */
325 #define XAPM_INCREMENTER_5      5U /**< Metric Counter 0 Register Index */
326 #define XAPM_INCREMENTER_6      6U /**< Metric Counter 0 Register Index */
327 #define XAPM_INCREMENTER_7      7U /**< Metric Counter 0 Register Index */
328 #define XAPM_INCREMENTER_8      8U /**< Metric Counter 0 Register Index */
329 #define XAPM_INCREMENTER_9      9U /**< Metric Counter 0 Register Index */
330
331 /*@}*/
332
333 /**
334  * @name Macros for Metric Selector Settings
335  * @{
336  */
337
338 #define XAPM_METRIC_SET_0               0U /**< Write Transaction Count */
339 #define XAPM_METRIC_SET_1               1U /**< Read Transaction Count */
340 #define XAPM_METRIC_SET_2               2U /**< Write Byte Count */
341 #define XAPM_METRIC_SET_3               3U /**< Read Byte Count */
342 #define XAPM_METRIC_SET_4               4U /**< Write Beat Count */
343 #define XAPM_METRIC_SET_5               5U /**< Total Read Latency */
344 #define XAPM_METRIC_SET_6               6U /**< Total Write Latency */
345 #define XAPM_METRIC_SET_7               7U /**< Slv_Wr_Idle_Cnt */
346 #define XAPM_METRIC_SET_8               8U /**< Mst_Rd_Idle_Cnt */
347 #define XAPM_METRIC_SET_9               9U /**< Num_BValids */
348 #define XAPM_METRIC_SET_10              10U /**< Num_WLasts */
349 #define XAPM_METRIC_SET_11              11U /**< Num_RLasts */
350 #define XAPM_METRIC_SET_12              12U /**< Minimum Write Latency */
351 #define XAPM_METRIC_SET_13              13U /**< Maximum Write Latency */
352 #define XAPM_METRIC_SET_14              14U /**< Minimum Read Latency */
353 #define XAPM_METRIC_SET_15              15U /**< Maximum Read Latency */
354 #define XAPM_METRIC_SET_16              16U /**< Transfer Cycle Count */
355 #define XAPM_METRIC_SET_17              17U /**< Packet Count */
356 #define XAPM_METRIC_SET_18              18U /**< Data Byte Count */
357 #define XAPM_METRIC_SET_19              19U /**< Position Byte Count */
358 #define XAPM_METRIC_SET_20              20U /**< Null Byte Count */
359 #define XAPM_METRIC_SET_21              21U /**< Slv_Idle_Cnt */
360 #define XAPM_METRIC_SET_22              22U /**< Mst_Idle_Cnt */
361 #define XAPM_METRIC_SET_30              30U /**< External event count */
362
363
364 /*@}*/
365
366
367 /**
368  * @name Macros for Maximum number of Agents
369  * @{
370  */
371
372 #define XAPM_MAX_AGENTS         8U /**< Maximum number of Agents */
373
374 /*@}*/
375
376 /**
377  * @name Macros for Flags in Flag Enable Control Register
378  * @{
379  */
380
381 #define XAPM_FLAG_WRADDR        0x00000001 /**< Write Address Flag */
382 #define XAPM_FLAG_FIRSTWR       0x00000002 /**< First Write Flag */
383 #define XAPM_FLAG_LASTWR        0x00000004 /**< Last Write Flag */
384 #define XAPM_FLAG_RESPONSE      0x00000008 /**< Response Flag */
385 #define XAPM_FLAG_RDADDR        0x00000010 /**< Read Address Flag */
386 #define XAPM_FLAG_FIRSTRD       0x00000020 /**< First Read Flag */
387 #define XAPM_FLAG_LASTRD        0x00000040 /**< Last Read Flag */
388 #define XAPM_FLAG_SWDATA        0x00010000 /**< Software-written Data Flag */
389 #define XAPM_FLAG_EVENT         0x00020000 /**< Last Read Flag */
390 #define XAPM_FLAG_EVNTSTOP      0x00040000 /**< Last Read Flag */
391 #define XAPM_FLAG_EVNTSTART     0x00080000 /**< Last Read Flag */
392 #define XAPM_FLAG_GCCOVF        0x00100000 /**< Global Clock Counter Overflow
393                                              *  Flag */
394 #define XAPM_FLAG_SCLAPSE       0x00200000 /**< Sample Counter Lapse Flag */
395 #define XAPM_FLAG_MC0           0x00400000U /**< Metric Counter 0 Flag */
396 #define XAPM_FLAG_MC1           0x00800000U /**< Metric Counter 1 Flag */
397 #define XAPM_FLAG_MC2           0x01000000U /**< Metric Counter 2 Flag */
398 #define XAPM_FLAG_MC3           0x02000000U /**< Metric Counter 3 Flag */
399 #define XAPM_FLAG_MC4           0x04000000U /**< Metric Counter 4 Flag */
400 #define XAPM_FLAG_MC5           0x08000000U /**< Metric Counter 5 Flag */
401 #define XAPM_FLAG_MC6           0x10000000U /**< Metric Counter 6 Flag */
402 #define XAPM_FLAG_MC7           0x20000000U /**< Metric Counter 7 Flag */
403 #define XAPM_FLAG_MC8           0x40000000U /**< Metric Counter 8 Flag */
404 #define XAPM_FLAG_MC9           0x80000000U /**< Metric Counter 9 Flag */
405
406 /*@}*/
407
408 /**
409  * @name Macros for Read/Write Latency Start and End points
410  * @{
411  */
412 #define XAPM_LATENCY_ADDR_ISSUE         0U /**< Address Issue as start
413                                         point for Latency calculation*/
414 #define XAPM_LATENCY_ADDR_ACCEPT        1U /**< Address Acceptance as start
415                                         point for Latency calculation*/
416 #define XAPM_LATENCY_LASTRD             0U /**< Last Read as end point for
417                                         Latency calculation */
418 #define XAPM_LATENCY_LASTWR             0U /**< Last Write as end point for
419                                         Latency calculation */
420 #define XAPM_LATENCY_FIRSTRD            1U /**< First Read as end point for
421                                         Latency calculation */
422 #define XAPM_LATENCY_FIRSTWR            1U /**< First Write as end point for
423                                         Latency calculation */
424
425 /*@}*/
426
427 /**
428  * @name Macros for Modes of APM
429  * @{
430  */
431
432 #define XAPM_MODE_TRACE                 2U /**< APM in Trace mode */
433
434 #define XAPM_MODE_PROFILE               1U /**< APM in Profile mode */
435
436 #define XAPM_MODE_ADVANCED              0U /**< APM in Advanced mode */
437
438 /*@}*/
439
440 /**************************** Type Definitions *******************************/
441
442 /**
443  * This typedef contains configuration information for the AXI Performance
444  * Monitor device.
445  */
446 typedef struct {
447         u16 DeviceId;                   /**< Unique ID of device */
448         UINTPTR BaseAddress;            /**< Device base address */
449         s32 GlobalClkCounterWidth;      /**< Global Clock Counter Width */
450         s32 MetricSampleCounterWidth ;  /**< Metric Sample Counters Width */
451         u8  IsEventCount;               /**< Event Count Enabled 1 - enabled
452                                                            0 - not enabled */
453         u8  NumberofSlots;              /**< Number of Monitor Slots */
454         u8  NumberofCounters;           /**< Number of Counters */
455         u8  HaveSampledCounters;        /**< Have Sampled Counters 1 - present
456                                                             0 - Not present */
457         u8 IsEventLog;                  /**< Event Logging Enabled 1 - enabled
458                                                             0 - Not enabled */
459         u32 FifoDepth;                  /**< Event Log FIFO Depth */
460         u32 FifoWidth;                  /**< Event Log FIFO Width */
461         u32 TidWidth;                   /**< Streaming Interface TID Width */
462         u8  ScaleFactor;                /**< Event Count Scaling factor */
463         u8  ModeAdvanced;               /**< Advanced Mode */
464         u8  ModeProfile;                /**< Profile Mode */
465         u8  ModeTrace;                  /**< Trace Mode */
466         u8  Is32BitFiltering;   /**< 32 bit filtering enabled */
467 } XAxiPmon_Config;
468
469
470 /**
471  * The driver's instance data. The user is required to allocate a variable
472  * of this type for every AXI Performance Monitor device in system. A pointer
473  * to a variable of this type is then passed to the driver API functions.
474  */
475 typedef struct {
476         XAxiPmon_Config Config; /**< XAxiPmon_Config of current device */
477         u32  IsReady;           /**< Device is initialized and ready  */
478         u8   Mode;              /**< APM Mode */
479 } XAxiPmon;
480
481 /***************** Macros (Inline Functions) Definitions ********************/
482
483
484 /****************************************************************************/
485 /**
486 *
487 * This routine enables the Global Interrupt.
488 *
489 * @param        InstancePtr is a pointer to the XAxiPmon instance.
490 *
491 * @return       None.
492 *
493 * @note         C-Style signature:
494 *               void XAxiPmon_IntrGlobalEnable(XAxiPmon *InstancePtr)
495 *
496 *****************************************************************************/
497 #define XAxiPmon_IntrGlobalEnable(InstancePtr)                  \
498         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress,    \
499                         XAPM_GIE_OFFSET, 1)
500
501
502 /****************************************************************************/
503 /**
504 *
505 * This routine disables the Global Interrupt.
506 *
507 * @param        InstancePtr is a pointer to the XAxiPmon instance.
508 *
509 * @return       None.
510 *
511 * @note         C-Style signature:
512 *               void XAxiPmon_IntrGlobalDisable(XAxiPmon *InstancePtr)
513 *
514 *****************************************************************************/
515 #define XAxiPmon_IntrGlobalDisable(InstancePtr)                         \
516         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress,            \
517                                 XAPM_GIE_OFFSET, 0)
518
519
520 /****************************************************************************/
521 /**
522 *
523 * This routine enables interrupt(s). Use the XAPM_IXR_* constants defined in
524 * xaxipmon_hw.h to create the bit-mask to enable interrupts.
525 *
526 * @param        InstancePtr is a pointer to the XAxiPmon instance.
527 * @param        Mask is the mask to enable. Bit positions of 1 will be enabled.
528 *               Bit positions of 0 will keep the previous setting. This mask is
529 *               formed by OR'ing XAPM_IXR__* bits defined in xaxipmon_hw.h.
530 *
531 * @return       None.
532 *
533 * @note         C-Style signature:
534 *               void XAxiPmon_IntrEnable(XAxiPmon *InstancePtr, u32 Mask)
535 *
536 *****************************************************************************/
537 #define XAxiPmon_IntrEnable(InstancePtr, Mask)                               \
538         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_IE_OFFSET, \
539                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
540                         XAPM_IE_OFFSET) | (Mask));
541
542
543 /****************************************************************************/
544 /**
545 *
546 * This routine disable interrupt(s). Use the XAPM_IXR_* constants defined in
547 * xaxipmon_hw.h to create the bit-mask to disable interrupts.
548 *
549 * @param        InstancePtr is a pointer to the XAxiPmon instance.
550 * @param        Mask is the mask to disable. Bit positions of 1 will be
551 *               disabled. Bit positions of 0 will keep the previous setting.
552 *               This mask is formed by OR'ing XAPM_IXR_* bits defined in
553 *               xaxipmon_hw.h.
554 *
555 * @return       None.
556 *
557 * @note         C-Style signature:
558 *               void XAxiPmon_IntrEnable(XAxiPmon *InstancePtr, u32 Mask)
559 *
560 *****************************************************************************/
561 #define XAxiPmon_IntrDisable(InstancePtr, Mask)                              \
562         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_IE_OFFSET, \
563                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
564                         XAPM_IE_OFFSET) | (Mask));
565
566 /****************************************************************************/
567 /**
568 *
569 * This routine clears the specified interrupt(s).
570 *
571 * @param        InstancePtr is a pointer to the XAxiPmon instance.
572 * @param        Mask is the mask to clear. Bit positions of 1 will be cleared.
573 *               This mask is formed by OR'ing XAPM_IXR_* bits defined in
574 *               xaxipmon_hw.h.
575 *
576 * @return       None.
577 *
578 * @note         C-Style signature:
579 *               void XAxiPmon_IntrClear(XAxiPmon *InstancePtr, u32 Mask)
580 *
581 *****************************************************************************/
582 #define XAxiPmon_IntrClear(InstancePtr, Mask)                                \
583         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_IS_OFFSET, \
584                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
585                         XAPM_IS_OFFSET) | (Mask));
586
587 /****************************************************************************/
588 /**
589 *
590 * This routine returns the Interrupt Status Register.
591 *
592 * @param        InstancePtr is a pointer to the XAxiPmon instance.
593 *
594 * @return       Interrupt Status Register contents
595 *
596 * @note         C-Style signature:
597 *               void XAxiPmon_IntrClear(XAxiPmon *InstancePtr)
598 *
599 *****************************************************************************/
600 #define XAxiPmon_IntrGetStatus(InstancePtr)                                  \
601                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
602                         XAPM_IS_OFFSET);
603
604 /****************************************************************************/
605 /**
606 *
607 * This function enables the Global Clock Counter.
608 *
609 * @param        InstancePtr is a pointer to the XAxiPmon instance.
610 *
611 * @return       None
612 *
613 * @note         C-Style signature:
614 *               void XAxiPmon_EnableGlobalClkCounter(XAxiPmon *InstancePtr)
615 *
616 *****************************************************************************/
617 #define XAxiPmon_EnableGlobalClkCounter(InstancePtr) \
618         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
619                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
620                         XAPM_CTL_OFFSET) | XAPM_CR_GCC_ENABLE_MASK);
621
622 /****************************************************************************/
623 /**
624 *
625 * This function disbles the Global Clock Counter.
626 *
627 * @param        InstancePtr is a pointer to the XAxiPmon instance.
628 *
629 * @return       None
630 *
631 * @note         C-Style signature:
632 *               void XAxiPmon_DisableGlobalClkCounter(XAxiPmon *InstancePtr)
633 *
634 *****************************************************************************/
635 #define XAxiPmon_DisableGlobalClkCounter(InstancePtr) \
636         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
637                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
638                         XAPM_CTL_OFFSET) & ~(XAPM_CR_GCC_ENABLE_MASK));
639
640 /****************************************************************************/
641 /**
642 *
643 * This function enables the specified flag in Flag Control Register.
644 *
645 * @param        InstancePtr is a pointer to the XAxiPmon instance.
646 * @param        Flag is one of the XAPM_FLAG_* masks defined in xaxipmon.h
647 *
648 * @return       None
649 *
650 * @note         C-Style signature:
651 *               void XAxiPmon_EnableFlag(XAxiPmon *InstancePtr)
652 *
653 *****************************************************************************/
654 #define XAxiPmon_EnableFlag(InstancePtr, Flag) \
655         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_FEC_OFFSET, \
656                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
657                         XAPM_FEC_OFFSET) | (Flag));
658
659 /****************************************************************************/
660 /**
661 *
662 * This function disables the specified flag in Flag Control Register.
663 *
664 * @param        InstancePtr is a pointer to the XAxiPmon instance.
665 * @param        Flag is one of the XAPM_FLAG_* masks defined in xaxipmon.h*
666 * @return       None
667 *
668 * @note         C-Style signature:
669 *               void XAxiPmon_DisableFlag(XAxiPmon *InstancePtr)
670 *
671 *****************************************************************************/
672 #define XAxiPmon_DisableFlag(InstancePtr, Flag) \
673         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_FEC_OFFSET, \
674                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
675                         XAPM_FEC_OFFSET) & ~(Flag));
676
677 /****************************************************************************/
678 /**
679 *
680 * This function loads the sample interval register value into the sample
681 * interval counter.
682 *
683 * @param        InstancePtr is a pointer to the XAxiPmon instance.
684 *
685 * @return       None
686 *
687 * @note         C-Style signature:
688 *               void XAxiPmon_LoadSampleIntervalCounter(XAxiPmon *InstancePtr)
689 *
690 *****************************************************************************/
691 #define XAxiPmon_LoadSampleIntervalCounter(InstancePtr) \
692        XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET, \
693                                                         XAPM_SICR_LOAD_MASK);
694
695
696
697 /****************************************************************************/
698 /**
699 *
700 * This enables the down count of the sample interval counter.
701 *
702 * @param        InstancePtr is a pointer to the XAxiPmon instance.
703 *
704 * @return       None
705 *
706 * @note         C-Style signature:
707 *          void XAxiPmon_EnableSampleIntervalCounter(XAxiPmon *InstancePtr)
708 *
709 *****************************************************************************/
710 #define XAxiPmon_EnableSampleIntervalCounter(InstancePtr) \
711         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET,\
712                                                         XAPM_SICR_ENABLE_MASK);
713
714
715 /****************************************************************************/
716 /**
717 *
718 * This disables the down count of the sample interval counter.
719 *
720 * @param        InstancePtr is a pointer to the XAxiPmon instance.
721 *
722 * @return       None
723 *
724 * @note         C-Style signature:
725 *           void XAxiPmon_DisableSampleIntervalCounter(XAxiPmon *InstancePtr)
726 *
727 *****************************************************************************/
728 #define XAxiPmon_DisableSampleIntervalCounter(InstancePtr) \
729         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET, \
730                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
731                         XAPM_SICR_OFFSET) & ~(XAPM_SICR_ENABLE_MASK));
732
733 /****************************************************************************/
734 /**
735 *
736 * This enables Reset of Metric Counters when Sample Interval Counter lapses.
737 *
738 * @param        InstancePtr is a pointer to the XAxiPmon instance.
739 *
740 * @return       None
741 *
742 * @note         C-Style signature:
743 *               void XAxiPmon_EnableMetricCounterReset(XAxiPmon *InstancePtr)
744 *
745 *****************************************************************************/
746 #define XAxiPmon_EnableMetricCounterReset(InstancePtr) \
747         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET,\
748                                                 XAPM_SICR_MCNTR_RST_MASK);
749
750 /****************************************************************************/
751 /**
752 *
753 * This disables the down count of the sample interval counter.
754 *
755 * @param        InstancePtr is a pointer to the XAxiPmon instance.
756 *
757 * @return       None
758 *
759 * @note         C-Style signature:
760 *               void XAxiPmon_DisableMetricCounterReset(XAxiPmon *InstancePtr)
761 *
762 *****************************************************************************/
763 #define XAxiPmon_DisableMetricCounterReset(InstancePtr) \
764        XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET, \
765                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
766                         XAPM_SICR_OFFSET) & ~(XAPM_SICR_MCNTR_RST_MASK));
767
768 /****************************************************************************/
769 /**
770 *
771 * This function enables the ID Filter Masking.
772 *
773 * @param        InstancePtr is a pointer to the XAxiPmon instance.
774 *
775 * @return       None
776 *
777 * @note         C-Style signature:
778 *               void XAxiPmon_EnableIDFilter(XAxiPmon *InstancePtr)
779 *
780 *****************************************************************************/
781 #define XAxiPmon_EnableIDFilter(InstancePtr) \
782         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
783                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
784                         XAPM_CTL_OFFSET) | XAPM_CR_IDFILTER_ENABLE_MASK);
785
786 /****************************************************************************/
787 /**
788 *
789 * This function disbles the ID Filter masking.
790 *
791 * @param        InstancePtr is a pointer to the XAxiPmon instance.
792 *
793 * @return       None
794 *
795 * @note         C-Style signature:
796 *               void XAxiPmon_DisableIDFilter(XAxiPmon *InstancePtr)
797 *
798 *****************************************************************************/
799 #define XAxiPmon_DisableIDFilter(InstancePtr) \
800         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
801                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
802                         XAPM_CTL_OFFSET) & ~(XAPM_CR_IDFILTER_ENABLE_MASK));
803
804 /****************************************************************************/
805 /**
806 *
807 * This function samples Metric Counters to Sampled Metric Counters by
808 * reading Sample Register and also returns interval. i.e. the number of
809 * clocks in between previous read to the current read of sample register.
810 *
811 * @param        InstancePtr is a pointer to the XAxiPmon instance.
812 *
813 * @return       Interval. i.e. the number of clocks in between previous
814 *               read to the current read of sample register.
815 *
816 * @note         C-Style signature:
817 *               u32 XAxiPmon_SampleMetrics(XAxiPmon *InstancePtr)
818 *
819 *****************************************************************************/
820 #define XAxiPmon_SampleMetrics(InstancePtr) \
821        XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, XAPM_SR_OFFSET);
822
823
824 /************************** Function Prototypes *****************************/
825
826 /**
827  * Functions in xaxipmon_sinit.c
828  */
829 XAxiPmon_Config *XAxiPmon_LookupConfig(u16 DeviceId);
830
831 /**
832  * Functions in xaxipmon.c
833  */
834 s32 XAxiPmon_CfgInitialize(XAxiPmon *InstancePtr,
835                 XAxiPmon_Config *ConfigPtr, UINTPTR EffectiveAddr);
836
837 s32 XAxiPmon_ResetMetricCounter(XAxiPmon *InstancePtr);
838
839 void XAxiPmon_ResetGlobalClkCounter(XAxiPmon *InstancePtr);
840
841 s32 XAxiPmon_ResetFifo(XAxiPmon *InstancePtr);
842
843 void XAxiPmon_SetIncrementerRange(XAxiPmon *InstancePtr, u8 IncrementerNum,
844                                         u16 RangeUpper, u16 RangeLower);
845
846 void XAxiPmon_GetIncrementerRange(XAxiPmon *InstancePtr, u8 IncrementerNum,
847                                 u16 *RangeUpper, u16 *RangeLower);
848
849 void XAxiPmon_SetSampleInterval(XAxiPmon *InstancePtr, u32 SampleInterval);
850
851 void XAxiPmon_GetSampleInterval(XAxiPmon *InstancePtr, u32 *SampleInterval);
852
853 s32 XAxiPmon_SetMetrics(XAxiPmon *InstancePtr, u8 Slot, u8 Metrics,
854                                                         u8 CounterNum);
855
856 s32 XAxiPmon_GetMetrics(XAxiPmon *InstancePtr, u8 CounterNum, u8 *Metrics,
857                                                                 u8 *Slot);
858 void XAxiPmon_GetGlobalClkCounter(XAxiPmon *InstancePtr,u32 *CntHighValue,
859                                                         u32 *CntLowValue);
860
861 u32 XAxiPmon_GetMetricCounter(XAxiPmon *InstancePtr, u32 CounterNum);
862
863 u32 XAxiPmon_GetSampledMetricCounter(XAxiPmon *InstancePtr, u32 CounterNum);
864
865 u32 XAxiPmon_GetIncrementer(XAxiPmon *InstancePtr, u32 IncrementerNum);
866
867 u32 XAxiPmon_GetSampledIncrementer(XAxiPmon *InstancePtr, u32 IncrementerNum);
868
869 void XAxiPmon_SetSwDataReg(XAxiPmon *InstancePtr, u32 SwData);
870
871 u32 XAxiPmon_GetSwDataReg(XAxiPmon *InstancePtr);
872
873 s32 XAxiPmon_StartEventLog(XAxiPmon *InstancePtr, u32 FlagEnables);
874
875 s32 XAxiPmon_StopEventLog(XAxiPmon *InstancePtr);
876
877 s32 XAxiPmon_StartCounters(XAxiPmon *InstancePtr, u32 SampleInterval);
878
879 s32 XAxiPmon_StopCounters(XAxiPmon *InstancePtr);
880
881 void XAxiPmon_EnableMetricsCounter(XAxiPmon *InstancePtr);
882
883 void XAxiPmon_DisableMetricsCounter(XAxiPmon *InstancePtr);
884
885 void XAxiPmon_SetLogEnableRanges(XAxiPmon *InstancePtr, u32 CounterNum,
886                                         u16 RangeUpper, u16 RangeLower);
887
888 void XAxiPmon_GetLogEnableRanges(XAxiPmon *InstancePtr, u32 CounterNum,
889                                         u16 *RangeUpper, u16 *RangeLower);
890
891 void XAxiPmon_EnableEventLog(XAxiPmon *InstancePtr);
892
893 void XAxiPmon_EnableMetricCounterTrigger(XAxiPmon *InstancePtr);
894
895 void XAxiPmon_DisableMetricCounterTrigger(XAxiPmon *InstancePtr);
896
897 void XAxiPmon_EnableEventLogTrigger(XAxiPmon *InstancePtr);
898
899 void XAxiPmon_DisableEventLogTrigger(XAxiPmon *InstancePtr);
900
901 const char * XAxiPmon_GetMetricName(u8 Metrics);
902
903 void XAxiPmon_SetWriteId(XAxiPmon *InstancePtr, u32 WriteId);
904
905 void XAxiPmon_SetReadId(XAxiPmon *InstancePtr, u32 ReadId);
906
907 u32 XAxiPmon_GetWriteId(XAxiPmon *InstancePtr);
908
909 u32 XAxiPmon_GetReadId(XAxiPmon *InstancePtr);
910
911 void XAxiPmon_SetWrLatencyStart(XAxiPmon *InstancePtr, u8 Param);
912
913 void XAxiPmon_SetWrLatencyEnd(XAxiPmon *InstancePtr, u8 Param);
914
915 void XAxiPmon_SetRdLatencyStart(XAxiPmon *InstancePtr, u8 Param);
916
917 void XAxiPmon_SetRdLatencyEnd(XAxiPmon *InstancePtr, u8 Param);
918
919 u8 XAxiPmon_GetWrLatencyStart(XAxiPmon *InstancePtr);
920
921 u8 XAxiPmon_GetWrLatencyEnd(XAxiPmon *InstancePtr);
922
923 u8 XAxiPmon_GetRdLatencyStart(XAxiPmon *InstancePtr);
924
925 u8 XAxiPmon_GetRdLatencyEnd(XAxiPmon *InstancePtr);
926
927 void XAxiPmon_SetWriteIdMask(XAxiPmon *InstancePtr, u32 WrMask);
928
929 void XAxiPmon_SetReadIdMask(XAxiPmon *InstancePtr, u32 RdMask);
930
931 u32 XAxiPmon_GetWriteIdMask(XAxiPmon *InstancePtr);
932
933 u32 XAxiPmon_GetReadIdMask(XAxiPmon *InstancePtr);
934
935
936 /**
937  * Functions in xaxipmon_selftest.c
938  */
939 s32 XAxiPmon_SelfTest(XAxiPmon *InstancePtr);
940
941 #ifdef __cplusplus
942 }
943 #endif
944
945 #endif  /* End of protection macro. */
946 /** @} */