1 /******************************************************************************
3 * Copyright (C) 2007 - 2015 Xilinx, Inc. All rights reserved.
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
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
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.
31 ******************************************************************************/
32 /****************************************************************************/
36 * @addtogroup axipmon_v6_3
40 * The XAxiPmon driver supports the Xilinx AXI Performance Monitor device.
42 * The AXI Performance Monitor device provides following features:
44 * Configurable number of Metric Counters and Incrementers
45 * Computes performance metrics for Agents connected to
46 * monitor slots (Up to 8 slots)
48 * The following Metrics can be computed:
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
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
69 * Master Write Idle Cycle Count: Number of idle cycles caused by the
70 * masters during write transactions to
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
77 * Slave Read Idle Cycle Count: Number of idle cycles caused by this slave
78 * during read transactions to the slave.
80 * Metrics computed for an AXI4-Stream agent:
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
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.
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.
98 * This header file contains the prototypes of driver functions that can
99 * be used to access the AXI Performance Monitor device.
102 * <b> Initialization and Configuration </b>
104 * The device driver enables higher layer software (e.g., an application) to
105 * communicate to the AXI Performance Monitor device.
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.
115 * The AXI Performance Monitor does not support Interrupts
118 * <b> Virtual Memory </b>
120 * This driver supports Virtual Memory. The RTOS is responsible for calculating
121 * the correct device base address in Virtual Memory space.
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.
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.
137 * <b> Building the driver </b>
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.
142 * <b> Limitations of the driver </b>
149 * MODIFICATION HISTORY:
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
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
178 * Added XAxiPmon_StartEventLog and XAxiPmon_StopEventLog
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
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
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.
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.
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
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
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
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.
258 *****************************************************************************/
259 #ifndef XAXIPMON_H /* Prevent circular inclusions */
260 #define XAXIPMON_H /* by using protection macros */
266 /***************************** Include Files ********************************/
268 #include "xil_types.h"
269 #include "xil_assert.h"
271 #include "xaxipmon_hw.h"
273 /************************** Constant Definitions ****************************/
277 * @name Macro for Maximum number of Counters
281 #define XAPM_MAX_COUNTERS 10U /**< Maximum number of Counters */
282 #define XAPM_MAX_COUNTERS_PROFILE 48U /**< Maximum number of Counters */
288 * @name Indices for Metric Counters and Sampled Metric Coounters used with
289 * XAxiPmon_GetMetricCounter and XAxiPmon_GetSampledMetricCounter APIs
293 #define XAPM_METRIC_COUNTER_0 0U /**< Metric Counter 0 Register Index */
294 #define XAPM_METRIC_COUNTER_1 1U /**< Metric Counter 1 Register Index */
295 #define XAPM_METRIC_COUNTER_2 2U /**< Metric Counter 2 Register Index */
296 #define XAPM_METRIC_COUNTER_3 3U /**< Metric Counter 3 Register Index */
297 #define XAPM_METRIC_COUNTER_4 4U /**< Metric Counter 4 Register Index */
298 #define XAPM_METRIC_COUNTER_5 5U /**< Metric Counter 5 Register Index */
299 #define XAPM_METRIC_COUNTER_6 6U /**< Metric Counter 6 Register Index */
300 #define XAPM_METRIC_COUNTER_7 7U /**< Metric Counter 7 Register Index */
301 #define XAPM_METRIC_COUNTER_8 8U /**< Metric Counter 8 Register Index */
302 #define XAPM_METRIC_COUNTER_9 9U /**< Metric Counter 9 Register Index */
307 * @name Indices for Incrementers and Sampled Incrementers used with
308 * XAxiPmon_GetIncrementer and XAxiPmon_GetSampledIncrementer APIs
312 #define XAPM_INCREMENTER_0 0U /**< Metric Counter 0 Register Index */
313 #define XAPM_INCREMENTER_1 1U /**< Metric Counter 0 Register Index */
314 #define XAPM_INCREMENTER_2 2U /**< Metric Counter 0 Register Index */
315 #define XAPM_INCREMENTER_3 3U /**< Metric Counter 0 Register Index */
316 #define XAPM_INCREMENTER_4 4U /**< Metric Counter 0 Register Index */
317 #define XAPM_INCREMENTER_5 5U /**< Metric Counter 0 Register Index */
318 #define XAPM_INCREMENTER_6 6U /**< Metric Counter 0 Register Index */
319 #define XAPM_INCREMENTER_7 7U /**< Metric Counter 0 Register Index */
320 #define XAPM_INCREMENTER_8 8U /**< Metric Counter 0 Register Index */
321 #define XAPM_INCREMENTER_9 9U /**< Metric Counter 0 Register Index */
326 * @name Macros for Metric Selector Settings
330 #define XAPM_METRIC_SET_0 0U /**< Write Transaction Count */
331 #define XAPM_METRIC_SET_1 1U /**< Read Transaction Count */
332 #define XAPM_METRIC_SET_2 2U /**< Write Byte Count */
333 #define XAPM_METRIC_SET_3 3U /**< Read Byte Count */
334 #define XAPM_METRIC_SET_4 4U /**< Write Beat Count */
335 #define XAPM_METRIC_SET_5 5U /**< Total Read Latency */
336 #define XAPM_METRIC_SET_6 6U /**< Total Write Latency */
337 #define XAPM_METRIC_SET_7 7U /**< Slv_Wr_Idle_Cnt */
338 #define XAPM_METRIC_SET_8 8U /**< Mst_Rd_Idle_Cnt */
339 #define XAPM_METRIC_SET_9 9U /**< Num_BValids */
340 #define XAPM_METRIC_SET_10 10U /**< Num_WLasts */
341 #define XAPM_METRIC_SET_11 11U /**< Num_RLasts */
342 #define XAPM_METRIC_SET_12 12U /**< Minimum Write Latency */
343 #define XAPM_METRIC_SET_13 13U /**< Maximum Write Latency */
344 #define XAPM_METRIC_SET_14 14U /**< Minimum Read Latency */
345 #define XAPM_METRIC_SET_15 15U /**< Maximum Read Latency */
346 #define XAPM_METRIC_SET_16 16U /**< Transfer Cycle Count */
347 #define XAPM_METRIC_SET_17 17U /**< Packet Count */
348 #define XAPM_METRIC_SET_18 18U /**< Data Byte Count */
349 #define XAPM_METRIC_SET_19 19U /**< Position Byte Count */
350 #define XAPM_METRIC_SET_20 20U /**< Null Byte Count */
351 #define XAPM_METRIC_SET_21 21U /**< Slv_Idle_Cnt */
352 #define XAPM_METRIC_SET_22 22U /**< Mst_Idle_Cnt */
353 #define XAPM_METRIC_SET_30 30U /**< External event count */
360 * @name Macros for Maximum number of Agents
364 #define XAPM_MAX_AGENTS 8U /**< Maximum number of Agents */
369 * @name Macros for Flags in Flag Enable Control Register
373 #define XAPM_FLAG_WRADDR 0x00000001 /**< Write Address Flag */
374 #define XAPM_FLAG_FIRSTWR 0x00000002 /**< First Write Flag */
375 #define XAPM_FLAG_LASTWR 0x00000004 /**< Last Write Flag */
376 #define XAPM_FLAG_RESPONSE 0x00000008 /**< Response Flag */
377 #define XAPM_FLAG_RDADDR 0x00000010 /**< Read Address Flag */
378 #define XAPM_FLAG_FIRSTRD 0x00000020 /**< First Read Flag */
379 #define XAPM_FLAG_LASTRD 0x00000040 /**< Last Read Flag */
380 #define XAPM_FLAG_SWDATA 0x00010000 /**< Software-written Data Flag */
381 #define XAPM_FLAG_EVENT 0x00020000 /**< Last Read Flag */
382 #define XAPM_FLAG_EVNTSTOP 0x00040000 /**< Last Read Flag */
383 #define XAPM_FLAG_EVNTSTART 0x00080000 /**< Last Read Flag */
384 #define XAPM_FLAG_GCCOVF 0x00100000 /**< Global Clock Counter Overflow
386 #define XAPM_FLAG_SCLAPSE 0x00200000 /**< Sample Counter Lapse Flag */
387 #define XAPM_FLAG_MC0 0x00400000U /**< Metric Counter 0 Flag */
388 #define XAPM_FLAG_MC1 0x00800000U /**< Metric Counter 1 Flag */
389 #define XAPM_FLAG_MC2 0x01000000U /**< Metric Counter 2 Flag */
390 #define XAPM_FLAG_MC3 0x02000000U /**< Metric Counter 3 Flag */
391 #define XAPM_FLAG_MC4 0x04000000U /**< Metric Counter 4 Flag */
392 #define XAPM_FLAG_MC5 0x08000000U /**< Metric Counter 5 Flag */
393 #define XAPM_FLAG_MC6 0x10000000U /**< Metric Counter 6 Flag */
394 #define XAPM_FLAG_MC7 0x20000000U /**< Metric Counter 7 Flag */
395 #define XAPM_FLAG_MC8 0x40000000U /**< Metric Counter 8 Flag */
396 #define XAPM_FLAG_MC9 0x80000000U /**< Metric Counter 9 Flag */
401 * @name Macros for Read/Write Latency Start and End points
404 #define XAPM_LATENCY_ADDR_ISSUE 0U /**< Address Issue as start
405 point for Latency calculation*/
406 #define XAPM_LATENCY_ADDR_ACCEPT 1U /**< Address Acceptance as start
407 point for Latency calculation*/
408 #define XAPM_LATENCY_LASTRD 0U /**< Last Read as end point for
409 Latency calculation */
410 #define XAPM_LATENCY_LASTWR 0U /**< Last Write as end point for
411 Latency calculation */
412 #define XAPM_LATENCY_FIRSTRD 1U /**< First Read as end point for
413 Latency calculation */
414 #define XAPM_LATENCY_FIRSTWR 1U /**< First Write as end point for
415 Latency calculation */
420 * @name Macros for Modes of APM
424 #define XAPM_MODE_TRACE 2U /**< APM in Trace mode */
426 #define XAPM_MODE_PROFILE 1U /**< APM in Profile mode */
428 #define XAPM_MODE_ADVANCED 0U /**< APM in Advanced mode */
432 /**************************** Type Definitions *******************************/
435 * This typedef contains configuration information for the AXI Performance
439 u16 DeviceId; /**< Unique ID of device */
440 UINTPTR BaseAddress; /**< Device base address */
441 s32 GlobalClkCounterWidth; /**< Global Clock Counter Width */
442 s32 MetricSampleCounterWidth ; /**< Metric Sample Counters Width */
443 u8 IsEventCount; /**< Event Count Enabled 1 - enabled
445 u8 NumberofSlots; /**< Number of Monitor Slots */
446 u8 NumberofCounters; /**< Number of Counters */
447 u8 HaveSampledCounters; /**< Have Sampled Counters 1 - present
449 u8 IsEventLog; /**< Event Logging Enabled 1 - enabled
451 u32 FifoDepth; /**< Event Log FIFO Depth */
452 u32 FifoWidth; /**< Event Log FIFO Width */
453 u32 TidWidth; /**< Streaming Interface TID Width */
454 u8 ScaleFactor; /**< Event Count Scaling factor */
455 u8 ModeAdvanced; /**< Advanced Mode */
456 u8 ModeProfile; /**< Profile Mode */
457 u8 ModeTrace; /**< Trace Mode */
458 u8 Is32BitFiltering; /**< 32 bit filtering enabled */
463 * The driver's instance data. The user is required to allocate a variable
464 * of this type for every AXI Performance Monitor device in system. A pointer
465 * to a variable of this type is then passed to the driver API functions.
468 XAxiPmon_Config Config; /**< XAxiPmon_Config of current device */
469 u32 IsReady; /**< Device is initialized and ready */
470 u8 Mode; /**< APM Mode */
473 /***************** Macros (Inline Functions) Definitions ********************/
476 /****************************************************************************/
479 * This routine enables the Global Interrupt.
481 * @param InstancePtr is a pointer to the XAxiPmon instance.
485 * @note C-Style signature:
486 * void XAxiPmon_IntrGlobalEnable(XAxiPmon *InstancePtr)
488 *****************************************************************************/
489 #define XAxiPmon_IntrGlobalEnable(InstancePtr) \
490 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, \
494 /****************************************************************************/
497 * This routine disables the Global Interrupt.
499 * @param InstancePtr is a pointer to the XAxiPmon instance.
503 * @note C-Style signature:
504 * void XAxiPmon_IntrGlobalDisable(XAxiPmon *InstancePtr)
506 *****************************************************************************/
507 #define XAxiPmon_IntrGlobalDisable(InstancePtr) \
508 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, \
512 /****************************************************************************/
515 * This routine enables interrupt(s). Use the XAPM_IXR_* constants defined in
516 * xaxipmon_hw.h to create the bit-mask to enable interrupts.
518 * @param InstancePtr is a pointer to the XAxiPmon instance.
519 * @param Mask is the mask to enable. Bit positions of 1 will be enabled.
520 * Bit positions of 0 will keep the previous setting. This mask is
521 * formed by OR'ing XAPM_IXR__* bits defined in xaxipmon_hw.h.
525 * @note C-Style signature:
526 * void XAxiPmon_IntrEnable(XAxiPmon *InstancePtr, u32 Mask)
528 *****************************************************************************/
529 #define XAxiPmon_IntrEnable(InstancePtr, Mask) \
530 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_IE_OFFSET, \
531 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
532 XAPM_IE_OFFSET) | (Mask));
535 /****************************************************************************/
538 * This routine disable interrupt(s). Use the XAPM_IXR_* constants defined in
539 * xaxipmon_hw.h to create the bit-mask to disable interrupts.
541 * @param InstancePtr is a pointer to the XAxiPmon instance.
542 * @param Mask is the mask to disable. Bit positions of 1 will be
543 * disabled. Bit positions of 0 will keep the previous setting.
544 * This mask is formed by OR'ing XAPM_IXR_* bits defined in
549 * @note C-Style signature:
550 * void XAxiPmon_IntrEnable(XAxiPmon *InstancePtr, u32 Mask)
552 *****************************************************************************/
553 #define XAxiPmon_IntrDisable(InstancePtr, Mask) \
554 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_IE_OFFSET, \
555 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
556 XAPM_IE_OFFSET) | (Mask));
558 /****************************************************************************/
561 * This routine clears the specified interrupt(s).
563 * @param InstancePtr is a pointer to the XAxiPmon instance.
564 * @param Mask is the mask to clear. Bit positions of 1 will be cleared.
565 * This mask is formed by OR'ing XAPM_IXR_* bits defined in
570 * @note C-Style signature:
571 * void XAxiPmon_IntrClear(XAxiPmon *InstancePtr, u32 Mask)
573 *****************************************************************************/
574 #define XAxiPmon_IntrClear(InstancePtr, Mask) \
575 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_IS_OFFSET, \
576 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
577 XAPM_IS_OFFSET) | (Mask));
579 /****************************************************************************/
582 * This routine returns the Interrupt Status Register.
584 * @param InstancePtr is a pointer to the XAxiPmon instance.
586 * @return Interrupt Status Register contents
588 * @note C-Style signature:
589 * void XAxiPmon_IntrClear(XAxiPmon *InstancePtr)
591 *****************************************************************************/
592 #define XAxiPmon_IntrGetStatus(InstancePtr) \
593 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
596 /****************************************************************************/
599 * This function enables the Global Clock Counter.
601 * @param InstancePtr is a pointer to the XAxiPmon instance.
605 * @note C-Style signature:
606 * void XAxiPmon_EnableGlobalClkCounter(XAxiPmon *InstancePtr)
608 *****************************************************************************/
609 #define XAxiPmon_EnableGlobalClkCounter(InstancePtr) \
610 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
611 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
612 XAPM_CTL_OFFSET) | XAPM_CR_GCC_ENABLE_MASK);
614 /****************************************************************************/
617 * This function disbles the Global Clock Counter.
619 * @param InstancePtr is a pointer to the XAxiPmon instance.
623 * @note C-Style signature:
624 * void XAxiPmon_DisableGlobalClkCounter(XAxiPmon *InstancePtr)
626 *****************************************************************************/
627 #define XAxiPmon_DisableGlobalClkCounter(InstancePtr) \
628 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
629 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
630 XAPM_CTL_OFFSET) & ~(XAPM_CR_GCC_ENABLE_MASK));
632 /****************************************************************************/
635 * This function enables the specified flag in Flag Control Register.
637 * @param InstancePtr is a pointer to the XAxiPmon instance.
638 * @param Flag is one of the XAPM_FLAG_* masks defined in xaxipmon.h
642 * @note C-Style signature:
643 * void XAxiPmon_EnableFlag(XAxiPmon *InstancePtr)
645 *****************************************************************************/
646 #define XAxiPmon_EnableFlag(InstancePtr, Flag) \
647 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_FEC_OFFSET, \
648 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
649 XAPM_FEC_OFFSET) | (Flag));
651 /****************************************************************************/
654 * This function disables the specified flag in Flag Control Register.
656 * @param InstancePtr is a pointer to the XAxiPmon instance.
657 * @param Flag is one of the XAPM_FLAG_* masks defined in xaxipmon.h*
660 * @note C-Style signature:
661 * void XAxiPmon_DisableFlag(XAxiPmon *InstancePtr)
663 *****************************************************************************/
664 #define XAxiPmon_DisableFlag(InstancePtr, Flag) \
665 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_FEC_OFFSET, \
666 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
667 XAPM_FEC_OFFSET) & ~(Flag));
669 /****************************************************************************/
672 * This function loads the sample interval register value into the sample
675 * @param InstancePtr is a pointer to the XAxiPmon instance.
679 * @note C-Style signature:
680 * void XAxiPmon_LoadSampleIntervalCounter(XAxiPmon *InstancePtr)
682 *****************************************************************************/
683 #define XAxiPmon_LoadSampleIntervalCounter(InstancePtr) \
684 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET, \
685 XAPM_SICR_LOAD_MASK);
689 /****************************************************************************/
692 * This enables the down count of the sample interval counter.
694 * @param InstancePtr is a pointer to the XAxiPmon instance.
698 * @note C-Style signature:
699 * void XAxiPmon_EnableSampleIntervalCounter(XAxiPmon *InstancePtr)
701 *****************************************************************************/
702 #define XAxiPmon_EnableSampleIntervalCounter(InstancePtr) \
703 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET,\
704 XAPM_SICR_ENABLE_MASK);
707 /****************************************************************************/
710 * This disables the down count of the sample interval counter.
712 * @param InstancePtr is a pointer to the XAxiPmon instance.
716 * @note C-Style signature:
717 * void XAxiPmon_DisableSampleIntervalCounter(XAxiPmon *InstancePtr)
719 *****************************************************************************/
720 #define XAxiPmon_DisableSampleIntervalCounter(InstancePtr) \
721 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET, \
722 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
723 XAPM_SICR_OFFSET) & ~(XAPM_SICR_ENABLE_MASK));
725 /****************************************************************************/
728 * This enables Reset of Metric Counters when Sample Interval Counter lapses.
730 * @param InstancePtr is a pointer to the XAxiPmon instance.
734 * @note C-Style signature:
735 * void XAxiPmon_EnableMetricCounterReset(XAxiPmon *InstancePtr)
737 *****************************************************************************/
738 #define XAxiPmon_EnableMetricCounterReset(InstancePtr) \
739 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET,\
740 XAPM_SICR_MCNTR_RST_MASK);
742 /****************************************************************************/
745 * This disables the down count of the sample interval counter.
747 * @param InstancePtr is a pointer to the XAxiPmon instance.
751 * @note C-Style signature:
752 * void XAxiPmon_DisableMetricCounterReset(XAxiPmon *InstancePtr)
754 *****************************************************************************/
755 #define XAxiPmon_DisableMetricCounterReset(InstancePtr) \
756 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET, \
757 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
758 XAPM_SICR_OFFSET) & ~(XAPM_SICR_MCNTR_RST_MASK));
760 /****************************************************************************/
763 * This function enables the ID Filter Masking.
765 * @param InstancePtr is a pointer to the XAxiPmon instance.
769 * @note C-Style signature:
770 * void XAxiPmon_EnableIDFilter(XAxiPmon *InstancePtr)
772 *****************************************************************************/
773 #define XAxiPmon_EnableIDFilter(InstancePtr) \
774 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
775 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
776 XAPM_CTL_OFFSET) | XAPM_CR_IDFILTER_ENABLE_MASK);
778 /****************************************************************************/
781 * This function disbles the ID Filter masking.
783 * @param InstancePtr is a pointer to the XAxiPmon instance.
787 * @note C-Style signature:
788 * void XAxiPmon_DisableIDFilter(XAxiPmon *InstancePtr)
790 *****************************************************************************/
791 #define XAxiPmon_DisableIDFilter(InstancePtr) \
792 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
793 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
794 XAPM_CTL_OFFSET) & ~(XAPM_CR_IDFILTER_ENABLE_MASK));
796 /****************************************************************************/
799 * This function samples Metric Counters to Sampled Metric Counters by
800 * reading Sample Register and also returns interval. i.e. the number of
801 * clocks in between previous read to the current read of sample register.
803 * @param InstancePtr is a pointer to the XAxiPmon instance.
805 * @return Interval. i.e. the number of clocks in between previous
806 * read to the current read of sample register.
808 * @note C-Style signature:
809 * u32 XAxiPmon_SampleMetrics(XAxiPmon *InstancePtr)
811 *****************************************************************************/
812 #define XAxiPmon_SampleMetrics(InstancePtr) \
813 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, XAPM_SR_OFFSET);
816 /************************** Function Prototypes *****************************/
819 * Functions in xaxipmon_sinit.c
821 XAxiPmon_Config *XAxiPmon_LookupConfig(u16 DeviceId);
824 * Functions in xaxipmon.c
826 s32 XAxiPmon_CfgInitialize(XAxiPmon *InstancePtr,
827 XAxiPmon_Config *ConfigPtr, UINTPTR EffectiveAddr);
829 s32 XAxiPmon_ResetMetricCounter(XAxiPmon *InstancePtr);
831 void XAxiPmon_ResetGlobalClkCounter(XAxiPmon *InstancePtr);
833 s32 XAxiPmon_ResetFifo(XAxiPmon *InstancePtr);
835 void XAxiPmon_SetIncrementerRange(XAxiPmon *InstancePtr, u8 IncrementerNum,
836 u16 RangeUpper, u16 RangeLower);
838 void XAxiPmon_GetIncrementerRange(XAxiPmon *InstancePtr, u8 IncrementerNum,
839 u16 *RangeUpper, u16 *RangeLower);
841 void XAxiPmon_SetSampleInterval(XAxiPmon *InstancePtr, u32 SampleInterval);
843 void XAxiPmon_GetSampleInterval(XAxiPmon *InstancePtr, u32 *SampleInterval);
845 s32 XAxiPmon_SetMetrics(XAxiPmon *InstancePtr, u8 Slot, u8 Metrics,
848 s32 XAxiPmon_GetMetrics(XAxiPmon *InstancePtr, u8 CounterNum, u8 *Metrics,
850 void XAxiPmon_GetGlobalClkCounter(XAxiPmon *InstancePtr,u32 *CntHighValue,
853 u32 XAxiPmon_GetMetricCounter(XAxiPmon *InstancePtr, u32 CounterNum);
855 u32 XAxiPmon_GetSampledMetricCounter(XAxiPmon *InstancePtr, u32 CounterNum);
857 u32 XAxiPmon_GetIncrementer(XAxiPmon *InstancePtr, u32 IncrementerNum);
859 u32 XAxiPmon_GetSampledIncrementer(XAxiPmon *InstancePtr, u32 IncrementerNum);
861 void XAxiPmon_SetSwDataReg(XAxiPmon *InstancePtr, u32 SwData);
863 u32 XAxiPmon_GetSwDataReg(XAxiPmon *InstancePtr);
865 s32 XAxiPmon_StartEventLog(XAxiPmon *InstancePtr, u32 FlagEnables);
867 s32 XAxiPmon_StopEventLog(XAxiPmon *InstancePtr);
869 s32 XAxiPmon_StartCounters(XAxiPmon *InstancePtr, u32 SampleInterval);
871 s32 XAxiPmon_StopCounters(XAxiPmon *InstancePtr);
873 void XAxiPmon_EnableMetricsCounter(XAxiPmon *InstancePtr);
875 void XAxiPmon_DisableMetricsCounter(XAxiPmon *InstancePtr);
877 void XAxiPmon_SetLogEnableRanges(XAxiPmon *InstancePtr, u32 CounterNum,
878 u16 RangeUpper, u16 RangeLower);
880 void XAxiPmon_GetLogEnableRanges(XAxiPmon *InstancePtr, u32 CounterNum,
881 u16 *RangeUpper, u16 *RangeLower);
883 void XAxiPmon_EnableEventLog(XAxiPmon *InstancePtr);
885 void XAxiPmon_EnableMetricCounterTrigger(XAxiPmon *InstancePtr);
887 void XAxiPmon_DisableMetricCounterTrigger(XAxiPmon *InstancePtr);
889 void XAxiPmon_EnableEventLogTrigger(XAxiPmon *InstancePtr);
891 void XAxiPmon_DisableEventLogTrigger(XAxiPmon *InstancePtr);
893 const char * XAxiPmon_GetMetricName(u8 Metrics);
895 void XAxiPmon_SetWriteId(XAxiPmon *InstancePtr, u32 WriteId);
897 void XAxiPmon_SetReadId(XAxiPmon *InstancePtr, u32 ReadId);
899 u32 XAxiPmon_GetWriteId(XAxiPmon *InstancePtr);
901 u32 XAxiPmon_GetReadId(XAxiPmon *InstancePtr);
903 void XAxiPmon_SetWrLatencyStart(XAxiPmon *InstancePtr, u8 Param);
905 void XAxiPmon_SetWrLatencyEnd(XAxiPmon *InstancePtr, u8 Param);
907 void XAxiPmon_SetRdLatencyStart(XAxiPmon *InstancePtr, u8 Param);
909 void XAxiPmon_SetRdLatencyEnd(XAxiPmon *InstancePtr, u8 Param);
911 u8 XAxiPmon_GetWrLatencyStart(XAxiPmon *InstancePtr);
913 u8 XAxiPmon_GetWrLatencyEnd(XAxiPmon *InstancePtr);
915 u8 XAxiPmon_GetRdLatencyStart(XAxiPmon *InstancePtr);
917 u8 XAxiPmon_GetRdLatencyEnd(XAxiPmon *InstancePtr);
919 void XAxiPmon_SetWriteIdMask(XAxiPmon *InstancePtr, u32 WrMask);
921 void XAxiPmon_SetReadIdMask(XAxiPmon *InstancePtr, u32 RdMask);
923 u32 XAxiPmon_GetWriteIdMask(XAxiPmon *InstancePtr);
925 u32 XAxiPmon_GetReadIdMask(XAxiPmon *InstancePtr);
929 * Functions in xaxipmon_selftest.c
931 s32 XAxiPmon_SelfTest(XAxiPmon *InstancePtr);
937 #endif /* End of protection macro. */