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 /****************************************************************************/
37 * The XAxiPmon driver supports the Xilinx AXI Performance Monitor device.
39 * The AXI Performance Monitor device provides following features:
41 * Configurable number of Metric Counters and Incrementers
42 * Computes performance metrics for Agents connected to
43 * monitor slots (Up to 8 slots)
45 * The following Metrics can be computed:
47 * Metrics computed for an AXI4 MM agent:
48 * Write Request Count: Total number of write requests by/to the agent.
49 * Read Request Count: Total number of read requests given by/to the
51 * Read Latency: It is defined as the time from the start of read address
52 * transaction to the beginning of the read data service.
53 * Write Latency: It is defined as the period needed a master completes
54 * write data transaction, i.e. from write address
55 * transaction to write response from slave.
56 * Write Byte Count: Total number of bytes written by/to the agent.
57 * This metric is helpful when calculating the
58 * throughput of the system.
59 * Read Byte Count: Total number of bytes read from/by the agent.
60 * Average Write Latency: Average write latency seen by the agent.
61 * It can be derived from total write latency
62 * and the write request count.
63 * Average Read Latency: Average read latency seen by the agent. It can be
64 * derived from total read latency and the read
66 * Master Write Idle Cycle Count: Number of idle cycles caused by the
67 * masters during write transactions to
69 * Slave Write Idle Cycle Count: Number of idle cycles caused by this slave
70 * during write transactions to the slave.
71 * Master Read Idle Cycle Count: Number of idle cycles caused by the
72 * master during read transactions to the
74 * Slave Read Idle Cycle Count: Number of idle cycles caused by this slave
75 * during read transactions to the slave.
77 * Metrics computed for an AXI4-Stream agent:
79 * Transfer Cycle Count: Total number of writes by/to the agent.
80 * Data Byte Count: Total number of data bytes written by/to the agent.
81 * This metric helps in calculating the throughput
83 * Position Byte Count: Total number of position bytes transferred.
84 * Null Byte Count: Total number of null bytes transferred.
85 * Packet Count: Total number of packets transferred.
87 * There are three modes : Advanced, Profile and Trace.
88 * - Advanced mode has 10 Mertic Counters, Sampled Metric Counters, Incrementors
89 * and Sampled Incrementors.
90 * - Profile mode has only 47 Metric Counters and Sampled Metric Counters.
91 * - Trace mode has no Counters.
92 * User should refer to the hardware device specification for detailed
93 * information about the device.
95 * This header file contains the prototypes of driver functions that can
96 * be used to access the AXI Performance Monitor device.
99 * <b> Initialization and Configuration </b>
101 * The device driver enables higher layer software (e.g., an application) to
102 * communicate to the AXI Performance Monitor device.
104 * XAxiPmon_CfgInitialize() API is used to initialize the AXI Performance Monitor
105 * device. The user needs to first call the XAxiPmon_LookupConfig() API which
106 * returns the Configuration structure pointer which is passed as a parameter to
107 * the XAxiPmon_CfgInitialize() API.
112 * The AXI Performance Monitor does not support Interrupts
115 * <b> Virtual Memory </b>
117 * This driver supports Virtual Memory. The RTOS is responsible for calculating
118 * the correct device base address in Virtual Memory space.
123 * This driver is not thread safe. Any needs for threads or thread mutual
124 * exclusion must be satisfied by the layer above this driver.
128 * Asserts are used within all Xilinx drivers to enforce constraints on argument
129 * values. Asserts can be turned off on a system-wide basis by defining, at
130 * compile time, the NDEBUG identifier. By default, asserts are turned on and it
131 * is recommended that users leave asserts on during development.
134 * <b> Building the driver </b>
136 * The XAxiPmon driver is composed of several source files. This allows the user
137 * to build and link only those parts of the driver that are necessary.
139 * <b> Limitations of the driver </b>
146 * MODIFICATION HISTORY:
148 * Ver Who Date Changes
149 * ----- ----- -------- -----------------------------------------------------
150 * 1.00a bss 02/27/12 First release
151 * 2.00a bss 06/23/12 Updated to support v2_00a version of IP.
152 * 3.00a bss 09/03/12 To support v2_01_a version of IP:
153 * Deleted XAxiPmon_SetAgent, XAxiPmon_GetAgent APIs and
154 * added XAPM_FLAG_EVENT, XAPM_FLAG_EVNTSTAR,
155 * XAPM_FLAG_EVNTSTOP.
156 * Deleted XAxiPmon_SetAgent, XAxiPmon_GetAgent APIs and
157 * modified XAxiPmon_SetMetrics, XAxiPmon_GetMetrics APIs
159 * Deleted XAPM_AGENT_OFFSET Macro in xaxipmon_hw.h
160 * 3.01a bss 10/25/12 To support new version of IP:
161 * Added XAPM_MCXLOGEN_OFFSET macros in xaxipmon_hw.h.
162 * Added XAxiPmon_SetMetricCounterCutOff,
163 * XAxiPmon_GetMetricCounterCutOff,
164 * XAxiPmon_EnableExternalTrigger and
165 * XAxiPmon_DisableExternalTrigger APIs in xaxipmon.c
166 * Modified XAxiPmon_SetMetrics and XAxiPmon_GetMetrics
167 * (CR #683746) in xaxipmon.c
168 * Added XAxiPmon_EnableEventLog,
169 * XAxiPmon_DisableMetricsCounter,
170 * XAxiPmon_EnableMetricsCounter APIs in xaxipmon.c to
171 * replace macros in this file.
172 * Added XAPM_FLAG_XXX macros.
173 * Added XAxiPmon_StartCounters and XAxiPmon_StopCounters
175 * Added XAxiPmon_StartEventLog and XAxiPmon_StopEventLog
177 * Added XAxiPmon_GetMetricName API (CR #683803).
178 * Deleted XAxiPmon_SetAgent, XAxiPmon_GetAgent
179 * declarations (CR #677337)
180 * 4.00a bss 01/17/13 To support new version of IP:
181 * Added XAPM_METRIC_SET_12 to XAPM_METRIC_SET_15 macros.
182 * Added XAxiPmon_SetLogEnableRanges,
183 * XAxiPmon_GetLogEnableRanges,
184 * XAxiPmon_EnableMetricCounterTrigger,
185 * XAxiPmon_DisableMetricCounterTrigger,
186 * XAxiPmon_EnableEventLogTrigger,
187 * XAxiPmon_DisableEventLogTrigger,
188 * XAxiPmon_SetWriteLatencyId,
189 * XAxiPmon_SetReadLatencyId,
190 * XAxiPmon_GetWriteLatencyId,
191 * XAxiPmon_GetReadLatencyId APIs and removed
192 * XAxiPmon_SetMetricCounterCutOff,
193 * XAxiPmon_GetMetricCounterCutOff,
194 * XAxiPmon_EnableExternalTrigger and
195 * XAxiPmon_DisableExternalTrigger APIs in xaxipmon.c
196 * Added XAPM_LATENCYID_OFFSET,
197 * XAPM_CR_EVTLOG_EXTTRIGGER_MASK,
198 * XAPM_LATENCYID_RID_MASK and XAPM_LATENCYID_WID_MASK in
200 * 5.00a bss 08/26/13 To support new version of IP:
201 * XAxiPmon_SampleMetrics Macro.
202 * Modified XAxiPmon_CfgInitialize, Assert functions
203 * Added XAxiPmon_GetMetricCounter,
204 * XAxiPmon_SetSampleInterval, XAxiPmon_GetSampleInterval,
205 * XAxiPmon_SetWrLatencyStart, XAxiPmon_SetWrLatencyEnd,
206 * XAxiPmon_SetRdLatencyStart, XAxiPmon_SetRdLatencyEnd,
207 * XAxiPmon_GetWrLatencyStart, XAxiPmon_GetWrLatencyEnd,
208 * XAxiPmon_GetRdLatencyStart, XAxiPmon_GetRdLatencyEnd,
209 * XAxiPmon_SetWriteIdMask, XAxiPmon_SetReadIdMask,
210 * XAxiPmon_GetWriteIdMask and XAxiPmon_GetReadIdMask APIs
212 * XAxiPmon_SetWriteLatencyId to
213 * XAxiPmon_SetWriteId, XAxiPmon_SetReadLatencyId to
214 * XAxiPmon_SetReadId, XAxiPmon_GetWriteLatencyId to
215 * XAxiPmon_GetWriteId and XAxiPmon_SetReadLatencyId to
216 * XAxiPmon_GetReadId. in xaxipmon.c
217 * Added Macros XAPM_MC10_OFFSET to XAPM_MC47_OFFSET,
218 * XAPM_SMC10_OFFSET to XAPM_SMC47_OFFSET,
219 * XAPM_IDMASK_OFFSET, XAPM_CR_IDFILTER_ENABLE_MASK,
220 * XAPM_CR_WRLATENCY_START_MASK,
221 * XAPM_CR_WRLATENCY_END_MASK,
222 * XAPM_CR_RDLATENCY_START_MASK,
223 * XAPM_CR_RDLATENCY_END_MASK and
224 * XAPM_MAX_COUNTERS_PROFILE.
226 * XAPM_LATENCYID_OFFSET to XAPM_ID_OFFSET,
227 * XAPM_LATENCYID_RID_MASK to XAPM_ID_RID_MASK,
228 * XAPM_LATENCYID_WID_MASK to XAPM_ID_WID_MASK.
230 * Modified driver tcl to generate new parameters
231 * ScaleFactor, ModeProfile, ModeTrace and ModeAdvanced
232 * in Config structure.
233 * 6.0 adk 19/12/13 Updated as per the New Tcl API's
234 * 6.1 adk 16/04/14 Updated the driver tcl for the newly added parameters in
236 * 6.2 bss 04/21/14 Updated XAxiPmon_CfgInitialize in xaxipmon.c to Reset
237 * counters and FIFOs based on Modes(CR#782671). And if
238 * both profile and trace modes are present set mode as
240 * 6.2 bss 03/02/15 To support Zynq MP APM:
241 * Added Is32BitFiltering in XAxiPmon_Config structure.
242 * Updated XAxiPmon_SetWriteId, XAxiPmon_SetReadId,
243 * XAxiPmon_GetWriteId, XAxiPmon_GetReadId
244 * XAxiPmon_SetWriteIdMask, XAxiPmon_SetReadIdMask
245 * XAxiPmon_GetWriteIdMask, XAxiPmon_GetReadIdMask
246 * functions in xaxipmon.c.
247 * Added XAPM_RID_OFFSET and XAPM_RIDMASK_OFFSET in
252 *****************************************************************************/
253 #ifndef XAXIPMON_H /* Prevent circular inclusions */
254 #define XAXIPMON_H /* by using protection macros */
260 /***************************** Include Files ********************************/
262 #include "xil_types.h"
263 #include "xil_assert.h"
265 #include "xaxipmon_hw.h"
267 /************************** Constant Definitions ****************************/
271 * @name Macro for Maximum number of Counters
275 #define XAPM_MAX_COUNTERS 10 /**< Maximum number of Counters */
276 #define XAPM_MAX_COUNTERS_PROFILE 48 /**< Maximum number of Counters */
282 * @name Indices for Metric Counters and Sampled Metric Coounters used with
283 * XAxiPmon_GetMetricCounter and XAxiPmon_GetSampledMetricCounter APIs
287 #define XAPM_METRIC_COUNTER_0 0 /**< Metric Counter 0 Register Index */
288 #define XAPM_METRIC_COUNTER_1 1 /**< Metric Counter 1 Register Index */
289 #define XAPM_METRIC_COUNTER_2 2 /**< Metric Counter 2 Register Index */
290 #define XAPM_METRIC_COUNTER_3 3 /**< Metric Counter 3 Register Index */
291 #define XAPM_METRIC_COUNTER_4 4 /**< Metric Counter 4 Register Index */
292 #define XAPM_METRIC_COUNTER_5 5 /**< Metric Counter 5 Register Index */
293 #define XAPM_METRIC_COUNTER_6 6 /**< Metric Counter 6 Register Index */
294 #define XAPM_METRIC_COUNTER_7 7 /**< Metric Counter 7 Register Index */
295 #define XAPM_METRIC_COUNTER_8 8 /**< Metric Counter 8 Register Index */
296 #define XAPM_METRIC_COUNTER_9 9 /**< Metric Counter 9 Register Index */
301 * @name Indices for Incrementers and Sampled Incrementers used with
302 * XAxiPmon_GetIncrementer and XAxiPmon_GetSampledIncrementer APIs
306 #define XAPM_INCREMENTER_0 0 /**< Metric Counter 0 Register Index */
307 #define XAPM_INCREMENTER_1 1 /**< Metric Counter 0 Register Index */
308 #define XAPM_INCREMENTER_2 2 /**< Metric Counter 0 Register Index */
309 #define XAPM_INCREMENTER_3 3 /**< Metric Counter 0 Register Index */
310 #define XAPM_INCREMENTER_4 4 /**< Metric Counter 0 Register Index */
311 #define XAPM_INCREMENTER_5 5 /**< Metric Counter 0 Register Index */
312 #define XAPM_INCREMENTER_6 6 /**< Metric Counter 0 Register Index */
313 #define XAPM_INCREMENTER_7 7 /**< Metric Counter 0 Register Index */
314 #define XAPM_INCREMENTER_8 8 /**< Metric Counter 0 Register Index */
315 #define XAPM_INCREMENTER_9 9 /**< Metric Counter 0 Register Index */
320 * @name Macros for Metric Selector Settings
324 #define XAPM_METRIC_SET_0 0 /**< Write Transaction Count */
325 #define XAPM_METRIC_SET_1 1 /**< Read Transaction Count */
326 #define XAPM_METRIC_SET_2 2 /**< Write Byte Count */
327 #define XAPM_METRIC_SET_3 3 /**< Read Byte Count */
328 #define XAPM_METRIC_SET_4 4 /**< Write Beat Count */
329 #define XAPM_METRIC_SET_5 5 /**< Total Read Latency */
330 #define XAPM_METRIC_SET_6 6 /**< Total Write Latency */
331 #define XAPM_METRIC_SET_7 7 /**< Slv_Wr_Idle_Cnt */
332 #define XAPM_METRIC_SET_8 8 /**< Mst_Rd_Idle_Cnt */
333 #define XAPM_METRIC_SET_9 9 /**< Num_BValids */
334 #define XAPM_METRIC_SET_10 10 /**< Num_WLasts */
335 #define XAPM_METRIC_SET_11 11 /**< Num_RLasts */
336 #define XAPM_METRIC_SET_12 12 /**< Minimum Write Latency */
337 #define XAPM_METRIC_SET_13 13 /**< Maximum Write Latency */
338 #define XAPM_METRIC_SET_14 14 /**< Minimum Read Latency */
339 #define XAPM_METRIC_SET_15 15 /**< Maximum Read Latency */
340 #define XAPM_METRIC_SET_16 16 /**< Transfer Cycle Count */
341 #define XAPM_METRIC_SET_17 17 /**< Packet Count */
342 #define XAPM_METRIC_SET_18 18 /**< Data Byte Count */
343 #define XAPM_METRIC_SET_19 19 /**< Position Byte Count */
344 #define XAPM_METRIC_SET_20 20 /**< Null Byte Count */
345 #define XAPM_METRIC_SET_21 21 /**< Slv_Idle_Cnt */
346 #define XAPM_METRIC_SET_22 22 /**< Mst_Idle_Cnt */
347 #define XAPM_METRIC_SET_30 30 /**< External event count */
354 * @name Macros for Maximum number of Agents
358 #define XAPM_MAX_AGENTS 8 /**< Maximum number of Agents */
363 * @name Macros for Flags in Flag Enable Control Register
367 #define XAPM_FLAG_WRADDR 0x00000001 /**< Write Address Flag */
368 #define XAPM_FLAG_FIRSTWR 0x00000002 /**< First Write Flag */
369 #define XAPM_FLAG_LASTWR 0x00000004 /**< Last Write Flag */
370 #define XAPM_FLAG_RESPONSE 0x00000008 /**< Response Flag */
371 #define XAPM_FLAG_RDADDR 0x00000010 /**< Read Address Flag */
372 #define XAPM_FLAG_FIRSTRD 0x00000020 /**< First Read Flag */
373 #define XAPM_FLAG_LASTRD 0x00000040 /**< Last Read Flag */
374 #define XAPM_FLAG_SWDATA 0x00010000 /**< Software-written Data Flag */
375 #define XAPM_FLAG_EVENT 0x00020000 /**< Last Read Flag */
376 #define XAPM_FLAG_EVNTSTOP 0x00040000 /**< Last Read Flag */
377 #define XAPM_FLAG_EVNTSTART 0x00080000 /**< Last Read Flag */
378 #define XAPM_FLAG_GCCOVF 0x00100000 /**< Global Clock Counter Overflow
380 #define XAPM_FLAG_SCLAPSE 0x00200000 /**< Sample Counter Lapse Flag */
381 #define XAPM_FLAG_MC0 0x00400000 /**< Metric Counter 0 Flag */
382 #define XAPM_FLAG_MC1 0x00800000 /**< Metric Counter 1 Flag */
383 #define XAPM_FLAG_MC2 0x01000000 /**< Metric Counter 2 Flag */
384 #define XAPM_FLAG_MC3 0x02000000 /**< Metric Counter 3 Flag */
385 #define XAPM_FLAG_MC4 0x04000000 /**< Metric Counter 4 Flag */
386 #define XAPM_FLAG_MC5 0x08000000 /**< Metric Counter 5 Flag */
387 #define XAPM_FLAG_MC6 0x10000000 /**< Metric Counter 6 Flag */
388 #define XAPM_FLAG_MC7 0x20000000 /**< Metric Counter 7 Flag */
389 #define XAPM_FLAG_MC8 0x40000000 /**< Metric Counter 8 Flag */
390 #define XAPM_FLAG_MC9 0x80000000 /**< Metric Counter 9 Flag */
395 * @name Macros for Read/Write Latency Start and End points
398 #define XAPM_LATENCY_ADDR_ISSUE 0 /**< Address Issue as start
399 point for Latency calculation*/
400 #define XAPM_LATENCY_ADDR_ACCEPT 1 /**< Address Acceptance as start
401 point for Latency calculation*/
402 #define XAPM_LATENCY_LASTRD 0 /**< Last Read as end point for
403 Latency calculation */
404 #define XAPM_LATENCY_LASTWR 0 /**< Last Write as end point for
405 Latency calculation */
406 #define XAPM_LATENCY_FIRSTRD 1 /**< First Read as end point for
407 Latency calculation */
408 #define XAPM_LATENCY_FIRSTWR 1 /**< First Write as end point for
409 Latency calculation */
414 * @name Macros for Modes of APM
418 #define XAPM_MODE_TRACE 2 /**< APM in Trace mode */
420 #define XAPM_MODE_PROFILE 1 /**< APM in Profile mode */
422 #define XAPM_MODE_ADVANCED 0 /**< APM in Advanced mode */
426 /**************************** Type Definitions *******************************/
429 * This typedef contains configuration information for the AXI Performance
433 u16 DeviceId; /**< Unique ID of device */
434 u32 BaseAddress; /**< Device base address */
435 int GlobalClkCounterWidth; /**< Global Clock Counter Width */
436 int MetricSampleCounterWidth ; /**< Metric Sample Counters Width */
437 u8 IsEventCount; /**< Event Count Enabled 1 - enabled
439 u8 NumberofSlots; /**< Number of Monitor Slots */
440 u8 NumberofCounters; /**< Number of Counters */
441 u8 HaveSampledCounters; /**< Have Sampled Counters 1 - present
443 u8 IsEventLog; /**< Event Logging Enabled 1 - enabled
445 u32 FifoDepth; /**< Event Log FIFO Depth */
446 u32 FifoWidth; /**< Event Log FIFO Width */
447 u32 TidWidth; /**< Streaming Interface TID Width */
448 u8 ScaleFactor; /**< Event Count Scaling factor */
449 u8 ModeAdvanced; /**< Advanced Mode */
450 u8 ModeProfile; /**< Profile Mode */
451 u8 ModeTrace; /**< Trace Mode */
452 u8 Is32BitFiltering; /**< 32 bit filtering enabled */
457 * The driver's instance data. The user is required to allocate a variable
458 * of this type for every AXI Performance Monitor device in system. A pointer
459 * to a variable of this type is then passed to the driver API functions.
462 XAxiPmon_Config Config; /**< XAxiPmon_Config of current device */
463 u32 IsReady; /**< Device is initialized and ready */
464 u8 Mode; /**< APM Mode */
467 /***************** Macros (Inline Functions) Definitions ********************/
470 /****************************************************************************/
473 * This routine enables the Global Interrupt.
475 * @param InstancePtr is a pointer to the XAxiPmon instance.
479 * @note C-Style signature:
480 * void XAxiPmon_IntrGlobalEnable(XAxiPmon *InstancePtr)
482 *****************************************************************************/
483 #define XAxiPmon_IntrGlobalEnable(InstancePtr) \
484 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, \
488 /****************************************************************************/
491 * This routine disables the Global Interrupt.
493 * @param InstancePtr is a pointer to the XAxiPmon instance.
497 * @note C-Style signature:
498 * void XAxiPmon_IntrGlobalDisable(XAxiPmon *InstancePtr)
500 *****************************************************************************/
501 #define XAxiPmon_IntrGlobalDisable(InstancePtr) \
502 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, \
506 /****************************************************************************/
509 * This routine enables interrupt(s). Use the XAPM_IXR_* constants defined in
510 * xaxipmon_hw.h to create the bit-mask to enable interrupts.
512 * @param InstancePtr is a pointer to the XAxiPmon instance.
513 * @param Mask is the mask to enable. Bit positions of 1 will be enabled.
514 * Bit positions of 0 will keep the previous setting. This mask is
515 * formed by OR'ing XAPM_IXR__* bits defined in xaxipmon_hw.h.
519 * @note C-Style signature:
520 * void XAxiPmon_IntrEnable(XAxiPmon *InstancePtr, u32 Mask)
522 *****************************************************************************/
523 #define XAxiPmon_IntrEnable(InstancePtr, Mask) \
524 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_IE_OFFSET, \
525 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
526 XAPM_IE_OFFSET) | Mask);
529 /****************************************************************************/
532 * This routine disable interrupt(s). Use the XAPM_IXR_* constants defined in
533 * xaxipmon_hw.h to create the bit-mask to disable interrupts.
535 * @param InstancePtr is a pointer to the XAxiPmon instance.
536 * @param Mask is the mask to disable. Bit positions of 1 will be
537 * disabled. Bit positions of 0 will keep the previous setting.
538 * This mask is formed by OR'ing XAPM_IXR_* bits defined in
543 * @note C-Style signature:
544 * void XAxiPmon_IntrEnable(XAxiPmon *InstancePtr, u32 Mask)
546 *****************************************************************************/
547 #define XAxiPmon_IntrDisable(InstancePtr, Mask) \
548 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_IE_OFFSET, \
549 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
550 XAPM_IE_OFFSET) | Mask);
552 /****************************************************************************/
555 * This routine clears the specified interrupt(s).
557 * @param InstancePtr is a pointer to the XAxiPmon instance.
558 * @param Mask is the mask to clear. Bit positions of 1 will be cleared.
559 * This mask is formed by OR'ing XAPM_IXR_* bits defined in
564 * @note C-Style signature:
565 * void XAxiPmon_IntrClear(XAxiPmon *InstancePtr, u32 Mask)
567 *****************************************************************************/
568 #define XAxiPmon_IntrClear(InstancePtr, Mask) \
569 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_IS_OFFSET, \
570 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
571 XAPM_IS_OFFSET) | Mask);
573 /****************************************************************************/
576 * This routine returns the Interrupt Status Register.
578 * @param InstancePtr is a pointer to the XAxiPmon instance.
580 * @return Interrupt Status Register contents
582 * @note C-Style signature:
583 * void XAxiPmon_IntrClear(XAxiPmon *InstancePtr)
585 *****************************************************************************/
586 #define XAxiPmon_IntrGetStatus(InstancePtr) \
587 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
590 /****************************************************************************/
593 * This function enables the Global Clock Counter.
595 * @param InstancePtr is a pointer to the XAxiPmon instance.
599 * @note C-Style signature:
600 * void XAxiPmon_EnableGlobalClkCounter(XAxiPmon *InstancePtr);
602 *****************************************************************************/
603 #define XAxiPmon_EnableGlobalClkCounter(InstancePtr) \
604 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
605 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
606 XAPM_CTL_OFFSET) | XAPM_CR_GCC_ENABLE_MASK);
608 /****************************************************************************/
611 * This function disbles the Global Clock Counter.
613 * @param InstancePtr is a pointer to the XAxiPmon instance.
617 * @note C-Style signature:
618 * void XAxiPmon_DisableGlobalClkCounter(XAxiPmon *InstancePtr);
620 *****************************************************************************/
621 #define XAxiPmon_DisableGlobalClkCounter(InstancePtr) \
622 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
623 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
624 XAPM_CTL_OFFSET) & ~(XAPM_CR_GCC_ENABLE_MASK));
626 /****************************************************************************/
629 * This function enables the specified flag in Flag Control Register.
631 * @param InstancePtr is a pointer to the XAxiPmon instance.
632 * @param Flag is one of the XAPM_FLAG_* masks defined in xaxipmon.h
636 * @note C-Style signature:
637 * void XAxiPmon_EnableFlag(XAxiPmon *InstancePtr);
639 *****************************************************************************/
640 #define XAxiPmon_EnableFlag(InstancePtr, Flag) \
641 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_FEC_OFFSET, \
642 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
643 XAPM_FEC_OFFSET) | Flag);
645 /****************************************************************************/
648 * This function disables the specified flag in Flag Control Register.
650 * @param InstancePtr is a pointer to the XAxiPmon instance.
651 * @param Flag is one of the XAPM_FLAG_* masks defined in xaxipmon.h*
654 * @note C-Style signature:
655 * void XAxiPmon_DisableFlag(XAxiPmon *InstancePtr);
657 *****************************************************************************/
658 #define XAxiPmon_DisableFlag(InstancePtr, Flag) \
659 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_FEC_OFFSET, \
660 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
661 XAPM_FEC_OFFSET) & ~(Flag));
663 /****************************************************************************/
666 * This function loads the sample interval register value into the sample
669 * @param InstancePtr is a pointer to the XAxiPmon instance.
673 * @note C-Style signature:
674 * void XAxiPmon_LoadSampleIntervalCounter(XAxiPmon *InstancePtr);
676 *****************************************************************************/
677 #define XAxiPmon_LoadSampleIntervalCounter(InstancePtr) \
678 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET, \
679 XAPM_SICR_LOAD_MASK);
683 /****************************************************************************/
686 * This enables the down count of the sample interval counter.
688 * @param InstancePtr is a pointer to the XAxiPmon instance.
692 * @note C-Style signature:
693 * void XAxiPmon_EnableSampleIntervalCounter(XAxiPmon *InstancePtr);
695 *****************************************************************************/
696 #define XAxiPmon_EnableSampleIntervalCounter(InstancePtr) \
697 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET,\
698 XAPM_SICR_ENABLE_MASK);
701 /****************************************************************************/
704 * This disables the down count of the sample interval counter.
706 * @param InstancePtr is a pointer to the XAxiPmon instance.
710 * @note C-Style signature:
711 * void XAxiPmon_DisableSampleIntervalCounter(XAxiPmon *InstancePtr);
713 *****************************************************************************/
714 #define XAxiPmon_DisableSampleIntervalCounter(InstancePtr) \
715 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET, \
716 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
717 XAPM_SICR_OFFSET) & ~(XAPM_SICR_ENABLE_MASK));
719 /****************************************************************************/
722 * This enables Reset of Metric Counters when Sample Interval Counter lapses.
724 * @param InstancePtr is a pointer to the XAxiPmon instance.
728 * @note C-Style signature:
729 * void XAxiPmon_EnableMetricCounterReset(XAxiPmon *InstancePtr);
731 *****************************************************************************/
732 #define XAxiPmon_EnableMetricCounterReset(InstancePtr) \
733 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET,\
734 XAPM_SICR_MCNTR_RST_MASK);
736 /****************************************************************************/
739 * This disables the down count of the sample interval counter.
741 * @param InstancePtr is a pointer to the XAxiPmon instance.
745 * @note C-Style signature:
746 * void XAxiPmon_DisableMetricCounterReset(XAxiPmon *InstancePtr);
748 *****************************************************************************/
749 #define XAxiPmon_DisableMetricCounterReset(InstancePtr) \
750 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET, \
751 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
752 XAPM_SICR_OFFSET) & ~(XAPM_SICR_MCNTR_RST_MASK));
754 /****************************************************************************/
757 * This function enables the ID Filter Masking.
759 * @param InstancePtr is a pointer to the XAxiPmon instance.
763 * @note C-Style signature:
764 * void XAxiPmon_EnableIDFilter(XAxiPmon *InstancePtr);
766 *****************************************************************************/
767 #define XAxiPmon_EnableIDFilter(InstancePtr) \
768 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
769 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
770 XAPM_CTL_OFFSET) | XAPM_CR_IDFILTER_ENABLE_MASK);
772 /****************************************************************************/
775 * This function disbles the ID Filter masking.
777 * @param InstancePtr is a pointer to the XAxiPmon instance.
781 * @note C-Style signature:
782 * void XAxiPmon_DisableIDFilter(XAxiPmon *InstancePtr);
784 *****************************************************************************/
785 #define XAxiPmon_DisableIDFilter(InstancePtr) \
786 XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
787 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
788 XAPM_CTL_OFFSET) & ~(XAPM_CR_IDFILTER_ENABLE_MASK));
790 /****************************************************************************/
793 * This function samples Metric Counters to Sampled Metric Counters by
794 * reading Sample Register and also returns interval. i.e. the number of
795 * clocks in between previous read to the current read of sample register.
797 * @param InstancePtr is a pointer to the XAxiPmon instance.
799 * @return Interval. i.e. the number of clocks in between previous
800 * read to the current read of sample register.
802 * @note C-Style signature:
803 * u32 XAxiPmon_SampleMetrics(XAxiPmon *InstancePtr);
805 *****************************************************************************/
806 #define XAxiPmon_SampleMetrics(InstancePtr) \
807 XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, XAPM_SR_OFFSET);
810 /************************** Function Prototypes *****************************/
813 * Functions in xaxipmon_sinit.c
815 XAxiPmon_Config *XAxiPmon_LookupConfig(u16 DeviceId);
818 * Functions in xaxipmon.c
820 int XAxiPmon_CfgInitialize(XAxiPmon *InstancePtr,
821 XAxiPmon_Config *ConfigPtr, u32 EffectiveAddr);
823 int XAxiPmon_ResetMetricCounter(XAxiPmon *InstancePtr);
825 void XAxiPmon_ResetGlobalClkCounter(XAxiPmon *InstancePtr);
827 int XAxiPmon_ResetFifo(XAxiPmon *InstancePtr);
829 void XAxiPmon_SetIncrementerRange(XAxiPmon *InstancePtr, u8 IncrementerNum,
830 u16 RangeUpper, u16 RangeLower);
832 void XAxiPmon_GetIncrementerRange(XAxiPmon *InstancePtr, u8 IncrementerNum,
833 u16 *RangeUpper, u16 *RangeLower);
835 void XAxiPmon_SetSampleInterval(XAxiPmon *InstancePtr, u32 SampleInterval);
837 void XAxiPmon_GetSampleInterval(XAxiPmon *InstancePtr, u32 *SampleInterval);
839 int XAxiPmon_SetMetrics(XAxiPmon *InstancePtr, u8 Slot, u8 Metrics,
842 int XAxiPmon_GetMetrics(XAxiPmon *InstancePtr, u8 CounterNum, u8 *Metrics,
844 void XAxiPmon_GetGlobalClkCounter(XAxiPmon *InstancePtr,u32 *CntHighValue,
847 u32 XAxiPmon_GetMetricCounter(XAxiPmon *InstancePtr, u32 CounterNum);
849 u32 XAxiPmon_GetSampledMetricCounter(XAxiPmon *InstancePtr, u32 CounterNum);
851 u32 XAxiPmon_GetIncrementer(XAxiPmon *InstancePtr, u32 IncrementerNum);
853 u32 XAxiPmon_GetSampledIncrementer(XAxiPmon *InstancePtr, u32 IncrementerNum);
855 void XAxiPmon_SetSwDataReg(XAxiPmon *InstancePtr, u32 SwData);
857 u32 XAxiPmon_GetSwDataReg(XAxiPmon *InstancePtr);
859 int XAxiPmon_StartEventLog(XAxiPmon *InstancePtr, u32 FlagEnables);
861 int XAxiPmon_StopEventLog(XAxiPmon *InstancePtr);
863 int XAxiPmon_StartCounters(XAxiPmon *InstancePtr, u32 SampleInterval);
865 int XAxiPmon_StopCounters(XAxiPmon *InstancePtr);
867 void XAxiPmon_EnableMetricsCounter(XAxiPmon *InstancePtr);
869 void XAxiPmon_DisableMetricsCounter(XAxiPmon *InstancePtr);
871 void XAxiPmon_SetLogEnableRanges(XAxiPmon *InstancePtr, u32 CounterNum,
872 u16 RangeUpper, u16 RangeLower);
874 void XAxiPmon_GetLogEnableRanges(XAxiPmon *InstancePtr, u32 CounterNum,
875 u16 *RangeUpper, u16 *RangeLower);
877 void XAxiPmon_EnableEventLog(XAxiPmon *InstancePtr);
879 void XAxiPmon_EnableMetricCounterTrigger(XAxiPmon *InstancePtr);
881 void XAxiPmon_DisableMetricCounterTrigger(XAxiPmon *InstancePtr);
883 void XAxiPmon_EnableEventLogTrigger(XAxiPmon *InstancePtr);
885 void XAxiPmon_DisableEventLogTrigger(XAxiPmon *InstancePtr);
887 const char * XAxiPmon_GetMetricName(u8 Metrics);
889 void XAxiPmon_SetWriteId(XAxiPmon *InstancePtr, u32 WriteId);
891 void XAxiPmon_SetReadId(XAxiPmon *InstancePtr, u32 ReadId);
893 u32 XAxiPmon_GetWriteId(XAxiPmon *InstancePtr);
895 u32 XAxiPmon_GetReadId(XAxiPmon *InstancePtr);
897 void XAxiPmon_SetWrLatencyStart(XAxiPmon *InstancePtr, u8 Param);
899 void XAxiPmon_SetWrLatencyEnd(XAxiPmon *InstancePtr, u8 Param);
901 void XAxiPmon_SetRdLatencyStart(XAxiPmon *InstancePtr, u8 Param);
903 void XAxiPmon_SetRdLatencyEnd(XAxiPmon *InstancePtr, u8 Param);
905 u8 XAxiPmon_GetWrLatencyStart(XAxiPmon *InstancePtr);
907 u8 XAxiPmon_GetWrLatencyEnd(XAxiPmon *InstancePtr);
909 u8 XAxiPmon_GetRdLatencyStart(XAxiPmon *InstancePtr);
911 u8 XAxiPmon_GetRdLatencyEnd(XAxiPmon *InstancePtr);
913 void XAxiPmon_SetWriteIdMask(XAxiPmon *InstancePtr, u32 WrMask);
915 void XAxiPmon_SetReadIdMask(XAxiPmon *InstancePtr, u32 RdMask);
917 u32 XAxiPmon_GetWriteIdMask(XAxiPmon *InstancePtr);
919 u32 XAxiPmon_GetReadIdMask(XAxiPmon *InstancePtr);
923 * Functions in xaxipmon_selftest.c
925 int XAxiPmon_SelfTest(XAxiPmon *InstancePtr);
931 #endif /* End of protection macro. */