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_6
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.
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
260 * ms 03/17/17 Added readme.txt file in examples folder for doxygen
262 * 6.6 ms 04/18/17 Modified tcl file to add suffix U for all macro
263 * definitions of axipmon in xparameters.h
266 *****************************************************************************/
267 #ifndef XAXIPMON_H /* Prevent circular inclusions */
268 #define XAXIPMON_H /* by using protection macros */
274 /***************************** Include Files ********************************/
276 #include "xil_types.h"
277 #include "xil_assert.h"
279 #include "xaxipmon_hw.h"
281 /************************** Constant Definitions ****************************/
285 * @name Macro for Maximum number of Counters
289 #define XAPM_MAX_COUNTERS 10U /**< Maximum number of Counters */
290 #define XAPM_MAX_COUNTERS_PROFILE 48U /**< Maximum number of Counters */
296 * @name Indices for Metric Counters and Sampled Metric Coounters used with
297 * XAxiPmon_GetMetricCounter and XAxiPmon_GetSampledMetricCounter APIs
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 */
315 * @name Indices for Incrementers and Sampled Incrementers used with
316 * XAxiPmon_GetIncrementer and XAxiPmon_GetSampledIncrementer APIs
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 */
334 * @name Macros for Metric Selector Settings
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 */
368 * @name Macros for Maximum number of Agents
372 #define XAPM_MAX_AGENTS 8U /**< Maximum number of Agents */
377 * @name Macros for Flags in Flag Enable Control Register
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
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 */
409 * @name Macros for Read/Write Latency Start and End points
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 */
428 * @name Macros for Modes of APM
432 #define XAPM_MODE_TRACE 2U /**< APM in Trace mode */
434 #define XAPM_MODE_PROFILE 1U /**< APM in Profile mode */
436 #define XAPM_MODE_ADVANCED 0U /**< APM in Advanced mode */
440 /**************************** Type Definitions *******************************/
443 * This typedef contains configuration information for the AXI Performance
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
453 u8 NumberofSlots; /**< Number of Monitor Slots */
454 u8 NumberofCounters; /**< Number of Counters */
455 u8 HaveSampledCounters; /**< Have Sampled Counters 1 - present
457 u8 IsEventLog; /**< Event Logging Enabled 1 - 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 */
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.
476 XAxiPmon_Config Config; /**< XAxiPmon_Config of current device */
477 u32 IsReady; /**< Device is initialized and ready */
478 u8 Mode; /**< APM Mode */
481 /***************** Macros (Inline Functions) Definitions ********************/
484 /****************************************************************************/
487 * This routine enables the Global Interrupt.
489 * @param InstancePtr is a pointer to the XAxiPmon instance.
493 * @note C-Style signature:
494 * void XAxiPmon_IntrGlobalEnable(XAxiPmon *InstancePtr)
496 *****************************************************************************/
497 #define XAxiPmon_IntrGlobalEnable(InstancePtr) \
498 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, \
502 /****************************************************************************/
505 * This routine disables the Global Interrupt.
507 * @param InstancePtr is a pointer to the XAxiPmon instance.
511 * @note C-Style signature:
512 * void XAxiPmon_IntrGlobalDisable(XAxiPmon *InstancePtr)
514 *****************************************************************************/
515 #define XAxiPmon_IntrGlobalDisable(InstancePtr) \
516 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, \
520 /****************************************************************************/
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.
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.
533 * @note C-Style signature:
534 * void XAxiPmon_IntrEnable(XAxiPmon *InstancePtr, u32 Mask)
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));
543 /****************************************************************************/
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.
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
557 * @note C-Style signature:
558 * void XAxiPmon_IntrEnable(XAxiPmon *InstancePtr, u32 Mask)
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));
566 /****************************************************************************/
569 * This routine clears the specified interrupt(s).
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
578 * @note C-Style signature:
579 * void XAxiPmon_IntrClear(XAxiPmon *InstancePtr, u32 Mask)
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));
587 /****************************************************************************/
590 * This routine returns the Interrupt Status Register.
592 * @param InstancePtr is a pointer to the XAxiPmon instance.
594 * @return Interrupt Status Register contents
596 * @note C-Style signature:
597 * void XAxiPmon_IntrClear(XAxiPmon *InstancePtr)
599 *****************************************************************************/
600 #define XAxiPmon_IntrGetStatus(InstancePtr) \
601 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
604 /****************************************************************************/
607 * This function enables the Global Clock Counter.
609 * @param InstancePtr is a pointer to the XAxiPmon instance.
613 * @note C-Style signature:
614 * void XAxiPmon_EnableGlobalClkCounter(XAxiPmon *InstancePtr)
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);
622 /****************************************************************************/
625 * This function disbles the Global Clock Counter.
627 * @param InstancePtr is a pointer to the XAxiPmon instance.
631 * @note C-Style signature:
632 * void XAxiPmon_DisableGlobalClkCounter(XAxiPmon *InstancePtr)
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));
640 /****************************************************************************/
643 * This function enables the specified flag in Flag Control Register.
645 * @param InstancePtr is a pointer to the XAxiPmon instance.
646 * @param Flag is one of the XAPM_FLAG_* masks defined in xaxipmon.h
650 * @note C-Style signature:
651 * void XAxiPmon_EnableFlag(XAxiPmon *InstancePtr)
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));
659 /****************************************************************************/
662 * This function disables the specified flag in Flag Control Register.
664 * @param InstancePtr is a pointer to the XAxiPmon instance.
665 * @param Flag is one of the XAPM_FLAG_* masks defined in xaxipmon.h*
668 * @note C-Style signature:
669 * void XAxiPmon_DisableFlag(XAxiPmon *InstancePtr)
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));
677 /****************************************************************************/
680 * This function loads the sample interval register value into the sample
683 * @param InstancePtr is a pointer to the XAxiPmon instance.
687 * @note C-Style signature:
688 * void XAxiPmon_LoadSampleIntervalCounter(XAxiPmon *InstancePtr)
690 *****************************************************************************/
691 #define XAxiPmon_LoadSampleIntervalCounter(InstancePtr) \
692 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET, \
693 XAPM_SICR_LOAD_MASK);
697 /****************************************************************************/
700 * This enables the down count of the sample interval counter.
702 * @param InstancePtr is a pointer to the XAxiPmon instance.
706 * @note C-Style signature:
707 * void XAxiPmon_EnableSampleIntervalCounter(XAxiPmon *InstancePtr)
709 *****************************************************************************/
710 #define XAxiPmon_EnableSampleIntervalCounter(InstancePtr) \
711 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET,\
712 XAPM_SICR_ENABLE_MASK);
715 /****************************************************************************/
718 * This disables the down count of the sample interval counter.
720 * @param InstancePtr is a pointer to the XAxiPmon instance.
724 * @note C-Style signature:
725 * void XAxiPmon_DisableSampleIntervalCounter(XAxiPmon *InstancePtr)
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));
733 /****************************************************************************/
736 * This enables Reset of Metric Counters when Sample Interval Counter lapses.
738 * @param InstancePtr is a pointer to the XAxiPmon instance.
742 * @note C-Style signature:
743 * void XAxiPmon_EnableMetricCounterReset(XAxiPmon *InstancePtr)
745 *****************************************************************************/
746 #define XAxiPmon_EnableMetricCounterReset(InstancePtr) \
747 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET,\
748 XAPM_SICR_MCNTR_RST_MASK);
750 /****************************************************************************/
753 * This disables the down count of the sample interval counter.
755 * @param InstancePtr is a pointer to the XAxiPmon instance.
759 * @note C-Style signature:
760 * void XAxiPmon_DisableMetricCounterReset(XAxiPmon *InstancePtr)
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));
768 /****************************************************************************/
771 * This function enables the ID Filter Masking.
773 * @param InstancePtr is a pointer to the XAxiPmon instance.
777 * @note C-Style signature:
778 * void XAxiPmon_EnableIDFilter(XAxiPmon *InstancePtr)
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);
786 /****************************************************************************/
789 * This function disbles the ID Filter masking.
791 * @param InstancePtr is a pointer to the XAxiPmon instance.
795 * @note C-Style signature:
796 * void XAxiPmon_DisableIDFilter(XAxiPmon *InstancePtr)
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));
804 /****************************************************************************/
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.
811 * @param InstancePtr is a pointer to the XAxiPmon instance.
813 * @return Interval. i.e. the number of clocks in between previous
814 * read to the current read of sample register.
816 * @note C-Style signature:
817 * u32 XAxiPmon_SampleMetrics(XAxiPmon *InstancePtr)
819 *****************************************************************************/
820 #define XAxiPmon_SampleMetrics(InstancePtr) \
821 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, XAPM_SR_OFFSET);
824 /************************** Function Prototypes *****************************/
827 * Functions in xaxipmon_sinit.c
829 XAxiPmon_Config *XAxiPmon_LookupConfig(u16 DeviceId);
832 * Functions in xaxipmon.c
834 s32 XAxiPmon_CfgInitialize(XAxiPmon *InstancePtr,
835 XAxiPmon_Config *ConfigPtr, UINTPTR EffectiveAddr);
837 s32 XAxiPmon_ResetMetricCounter(XAxiPmon *InstancePtr);
839 void XAxiPmon_ResetGlobalClkCounter(XAxiPmon *InstancePtr);
841 s32 XAxiPmon_ResetFifo(XAxiPmon *InstancePtr);
843 void XAxiPmon_SetIncrementerRange(XAxiPmon *InstancePtr, u8 IncrementerNum,
844 u16 RangeUpper, u16 RangeLower);
846 void XAxiPmon_GetIncrementerRange(XAxiPmon *InstancePtr, u8 IncrementerNum,
847 u16 *RangeUpper, u16 *RangeLower);
849 void XAxiPmon_SetSampleInterval(XAxiPmon *InstancePtr, u32 SampleInterval);
851 void XAxiPmon_GetSampleInterval(XAxiPmon *InstancePtr, u32 *SampleInterval);
853 s32 XAxiPmon_SetMetrics(XAxiPmon *InstancePtr, u8 Slot, u8 Metrics,
856 s32 XAxiPmon_GetMetrics(XAxiPmon *InstancePtr, u8 CounterNum, u8 *Metrics,
858 void XAxiPmon_GetGlobalClkCounter(XAxiPmon *InstancePtr,u32 *CntHighValue,
861 u32 XAxiPmon_GetMetricCounter(XAxiPmon *InstancePtr, u32 CounterNum);
863 u32 XAxiPmon_GetSampledMetricCounter(XAxiPmon *InstancePtr, u32 CounterNum);
865 u32 XAxiPmon_GetIncrementer(XAxiPmon *InstancePtr, u32 IncrementerNum);
867 u32 XAxiPmon_GetSampledIncrementer(XAxiPmon *InstancePtr, u32 IncrementerNum);
869 void XAxiPmon_SetSwDataReg(XAxiPmon *InstancePtr, u32 SwData);
871 u32 XAxiPmon_GetSwDataReg(XAxiPmon *InstancePtr);
873 s32 XAxiPmon_StartEventLog(XAxiPmon *InstancePtr, u32 FlagEnables);
875 s32 XAxiPmon_StopEventLog(XAxiPmon *InstancePtr);
877 s32 XAxiPmon_StartCounters(XAxiPmon *InstancePtr, u32 SampleInterval);
879 s32 XAxiPmon_StopCounters(XAxiPmon *InstancePtr);
881 void XAxiPmon_EnableMetricsCounter(XAxiPmon *InstancePtr);
883 void XAxiPmon_DisableMetricsCounter(XAxiPmon *InstancePtr);
885 void XAxiPmon_SetLogEnableRanges(XAxiPmon *InstancePtr, u32 CounterNum,
886 u16 RangeUpper, u16 RangeLower);
888 void XAxiPmon_GetLogEnableRanges(XAxiPmon *InstancePtr, u32 CounterNum,
889 u16 *RangeUpper, u16 *RangeLower);
891 void XAxiPmon_EnableEventLog(XAxiPmon *InstancePtr);
893 void XAxiPmon_EnableMetricCounterTrigger(XAxiPmon *InstancePtr);
895 void XAxiPmon_DisableMetricCounterTrigger(XAxiPmon *InstancePtr);
897 void XAxiPmon_EnableEventLogTrigger(XAxiPmon *InstancePtr);
899 void XAxiPmon_DisableEventLogTrigger(XAxiPmon *InstancePtr);
901 const char * XAxiPmon_GetMetricName(u8 Metrics);
903 void XAxiPmon_SetWriteId(XAxiPmon *InstancePtr, u32 WriteId);
905 void XAxiPmon_SetReadId(XAxiPmon *InstancePtr, u32 ReadId);
907 u32 XAxiPmon_GetWriteId(XAxiPmon *InstancePtr);
909 u32 XAxiPmon_GetReadId(XAxiPmon *InstancePtr);
911 void XAxiPmon_SetWrLatencyStart(XAxiPmon *InstancePtr, u8 Param);
913 void XAxiPmon_SetWrLatencyEnd(XAxiPmon *InstancePtr, u8 Param);
915 void XAxiPmon_SetRdLatencyStart(XAxiPmon *InstancePtr, u8 Param);
917 void XAxiPmon_SetRdLatencyEnd(XAxiPmon *InstancePtr, u8 Param);
919 u8 XAxiPmon_GetWrLatencyStart(XAxiPmon *InstancePtr);
921 u8 XAxiPmon_GetWrLatencyEnd(XAxiPmon *InstancePtr);
923 u8 XAxiPmon_GetRdLatencyStart(XAxiPmon *InstancePtr);
925 u8 XAxiPmon_GetRdLatencyEnd(XAxiPmon *InstancePtr);
927 void XAxiPmon_SetWriteIdMask(XAxiPmon *InstancePtr, u32 WrMask);
929 void XAxiPmon_SetReadIdMask(XAxiPmon *InstancePtr, u32 RdMask);
931 u32 XAxiPmon_GetWriteIdMask(XAxiPmon *InstancePtr);
933 u32 XAxiPmon_GetReadIdMask(XAxiPmon *InstancePtr);
937 * Functions in xaxipmon_selftest.c
939 s32 XAxiPmon_SelfTest(XAxiPmon *InstancePtr);
945 #endif /* End of protection macro. */