]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/include/xaxipmon.h
Completely re-generate the Zynq 7000 demo using the 2016.1 SDK tools.
[freertos] / FreeRTOS / Demo / CORTEX_A53_64-bit_UltraScale_MPSoC / RTOSDemo_A53_bsp / psu_cortexa53_0 / include / xaxipmon.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2007 - 2015 Xilinx, Inc.  All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32 /****************************************************************************/
33 /**
34 *
35 * @file xaxipmon.h
36 *
37 * The XAxiPmon driver supports the Xilinx AXI Performance Monitor device.
38 *
39 * The AXI Performance Monitor device provides following features:
40 *
41 *       Configurable number of Metric Counters and Incrementers
42 *       Computes performance metrics for Agents connected to
43 *       monitor slots (Up to 8 slots)
44 *
45 * The following Metrics can be computed:
46 *
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
50 *                           agent.
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
65 *                             request count.
66 *       Master Write Idle Cycle Count: Number of idle cycles caused by the
67 *                                      masters during write transactions to
68 *                                      the slave.
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
73 *                                     slave.
74 *       Slave Read Idle Cycle Count: Number of idle cycles caused by this slave
75 *                                    during read transactions to the slave.
76 *
77 * Metrics computed for an AXI4-Stream agent:
78 *
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
82 *                        of the system.
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.
86 *
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.
94 *
95 * This header file contains the prototypes of driver functions that can
96 * be used to access the AXI Performance Monitor device.
97 *
98 *
99 * <b> Initialization and Configuration </b>
100 *
101 * The device driver enables higher layer software (e.g., an application) to
102 * communicate to the AXI Performance Monitor device.
103 *
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.
108 *
109 *
110 * <b>Interrupts</b>
111 *
112 * The AXI Performance Monitor does not support Interrupts
113 *
114 *
115 * <b> Virtual Memory </b>
116 *
117 * This driver supports Virtual Memory. The RTOS is responsible for calculating
118 * the correct device base address in Virtual Memory space.
119 *
120 *
121 * <b> Threads </b>
122 *
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.
125 *
126 * <b> Asserts </b>
127 *
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.
132 *
133 *
134 * <b> Building the driver </b>
135 *
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.
138 *
139 * <b> Limitations of the driver </b>
140 *
141 *
142 * <br><br>
143 *
144 * <pre>
145 *
146 * MODIFICATION HISTORY:
147 *
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
158 *                       in xaxipmon.c
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
174 *                       APIs (CR #683799).
175 *                       Added XAxiPmon_StartEventLog and XAxiPmon_StopEventLog
176 *                       APIs (CR #683801).
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
199 *                       xaxipmon_hw.h
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
211 *                       Renamed :
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.
225 *                       Renamed:
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.
229 *                       in xaxipmon_hw.h.
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
235 *                     The Axi pmon IP.
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
239 *                       Advanced.
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
248 *                                               xaxipmon_hw.h
249 *
250 * </pre>
251 *
252 *****************************************************************************/
253 #ifndef XAXIPMON_H /* Prevent circular inclusions */
254 #define XAXIPMON_H /* by using protection macros  */
255
256 #ifdef __cplusplus
257 extern "C" {
258 #endif
259
260 /***************************** Include Files ********************************/
261
262 #include "xil_types.h"
263 #include "xil_assert.h"
264 #include "xstatus.h"
265 #include "xaxipmon_hw.h"
266
267 /************************** Constant Definitions ****************************/
268
269
270 /**
271  * @name Macro for Maximum number of Counters
272  *
273  * @{
274  */
275 #define XAPM_MAX_COUNTERS               10 /**< Maximum number of Counters */
276 #define XAPM_MAX_COUNTERS_PROFILE       48 /**< Maximum number of Counters */
277
278 /*@}*/
279
280
281 /**
282  * @name Indices for Metric Counters and Sampled Metric Coounters used with
283  *       XAxiPmon_GetMetricCounter and XAxiPmon_GetSampledMetricCounter APIs
284  * @{
285  */
286
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 */
297
298 /*@}*/
299
300 /**
301  * @name Indices for Incrementers and Sampled Incrementers used with
302  *       XAxiPmon_GetIncrementer and XAxiPmon_GetSampledIncrementer APIs
303  * @{
304  */
305
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 */
316
317 /*@}*/
318
319 /**
320  * @name Macros for Metric Selector Settings
321  * @{
322  */
323
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 */
348
349
350 /*@}*/
351
352
353 /**
354  * @name Macros for Maximum number of Agents
355  * @{
356  */
357
358 #define XAPM_MAX_AGENTS         8 /**< Maximum number of Agents */
359
360 /*@}*/
361
362 /**
363  * @name Macros for Flags in Flag Enable Control Register
364  * @{
365  */
366
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
379                                              *  Flag */
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 */
391
392 /*@}*/
393
394 /**
395  * @name Macros for Read/Write Latency Start and End points
396  * @{
397  */
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 */
410
411 /*@}*/
412
413 /**
414  * @name Macros for Modes of APM
415  * @{
416  */
417
418 #define XAPM_MODE_TRACE                 2 /**< APM in Trace mode */
419
420 #define XAPM_MODE_PROFILE               1 /**< APM in Profile mode */
421
422 #define XAPM_MODE_ADVANCED              0 /**< APM in Advanced mode */
423
424 /*@}*/
425
426 /**************************** Type Definitions *******************************/
427
428 /**
429  * This typedef contains configuration information for the AXI Performance
430  * Monitor device.
431  */
432 typedef struct {
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
438                                                            0 - not enabled */
439         u8  NumberofSlots;              /**< Number of Monitor Slots */
440         u8  NumberofCounters;           /**< Number of Counters */
441         u8  HaveSampledCounters;        /**< Have Sampled Counters 1 - present
442                                                             0 - Not present */
443         u8 IsEventLog;                  /**< Event Logging Enabled 1 - enabled
444                                                             0 - Not 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 */
453 } XAxiPmon_Config;
454
455
456 /**
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.
460  */
461 typedef struct {
462         XAxiPmon_Config Config; /**< XAxiPmon_Config of current device */
463         u32  IsReady;           /**< Device is initialized and ready  */
464         u8   Mode;              /**< APM Mode */
465 } XAxiPmon;
466
467 /***************** Macros (Inline Functions) Definitions ********************/
468
469
470 /****************************************************************************/
471 /**
472 *
473 * This routine enables the Global Interrupt.
474 *
475 * @param        InstancePtr is a pointer to the XAxiPmon instance.
476 *
477 * @return       None.
478 *
479 * @note         C-Style signature:
480 *               void XAxiPmon_IntrGlobalEnable(XAxiPmon *InstancePtr)
481 *
482 *****************************************************************************/
483 #define XAxiPmon_IntrGlobalEnable(InstancePtr)                  \
484         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress,    \
485                         XAPM_GIE_OFFSET, 1)
486
487
488 /****************************************************************************/
489 /**
490 *
491 * This routine disables the Global Interrupt.
492 *
493 * @param        InstancePtr is a pointer to the XAxiPmon instance.
494 *
495 * @return       None.
496 *
497 * @note         C-Style signature:
498 *               void XAxiPmon_IntrGlobalDisable(XAxiPmon *InstancePtr)
499 *
500 *****************************************************************************/
501 #define XAxiPmon_IntrGlobalDisable(InstancePtr)                         \
502         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress,            \
503                                 XAPM_GIE_OFFSET, 0)
504
505
506 /****************************************************************************/
507 /**
508 *
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.
511 *
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.
516 *
517 * @return       None.
518 *
519 * @note         C-Style signature:
520 *               void XAxiPmon_IntrEnable(XAxiPmon *InstancePtr, u32 Mask)
521 *
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);
527
528
529 /****************************************************************************/
530 /**
531 *
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.
534 *
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
539 *               xaxipmon_hw.h.
540 *
541 * @return       None.
542 *
543 * @note         C-Style signature:
544 *               void XAxiPmon_IntrEnable(XAxiPmon *InstancePtr, u32 Mask)
545 *
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);
551
552 /****************************************************************************/
553 /**
554 *
555 * This routine clears the specified interrupt(s).
556 *
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
560 *               xaxipmon_hw.h.
561 *
562 * @return       None.
563 *
564 * @note         C-Style signature:
565 *               void XAxiPmon_IntrClear(XAxiPmon *InstancePtr, u32 Mask)
566 *
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);
572
573 /****************************************************************************/
574 /**
575 *
576 * This routine returns the Interrupt Status Register.
577 *
578 * @param        InstancePtr is a pointer to the XAxiPmon instance.
579 *
580 * @return       Interrupt Status Register contents
581 *
582 * @note         C-Style signature:
583 *               void XAxiPmon_IntrClear(XAxiPmon *InstancePtr)
584 *
585 *****************************************************************************/
586 #define XAxiPmon_IntrGetStatus(InstancePtr)                                  \
587                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
588                         XAPM_IS_OFFSET);
589
590 /****************************************************************************/
591 /**
592 *
593 * This function enables the Global Clock Counter.
594 *
595 * @param        InstancePtr is a pointer to the XAxiPmon instance.
596 *
597 * @return       None
598 *
599 * @note         C-Style signature:
600 *               void XAxiPmon_EnableGlobalClkCounter(XAxiPmon *InstancePtr);
601 *
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);
607
608 /****************************************************************************/
609 /**
610 *
611 * This function disbles the Global Clock Counter.
612 *
613 * @param        InstancePtr is a pointer to the XAxiPmon instance.
614 *
615 * @return       None
616 *
617 * @note         C-Style signature:
618 *               void XAxiPmon_DisableGlobalClkCounter(XAxiPmon *InstancePtr);
619 *
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));
625
626 /****************************************************************************/
627 /**
628 *
629 * This function enables the specified flag in Flag Control Register.
630 *
631 * @param        InstancePtr is a pointer to the XAxiPmon instance.
632 * @param        Flag is one of the XAPM_FLAG_* masks defined in xaxipmon.h
633 *
634 * @return       None
635 *
636 * @note         C-Style signature:
637 *               void XAxiPmon_EnableFlag(XAxiPmon *InstancePtr);
638 *
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);
644
645 /****************************************************************************/
646 /**
647 *
648 * This function disables the specified flag in Flag Control Register.
649 *
650 * @param        InstancePtr is a pointer to the XAxiPmon instance.
651 * @param        Flag is one of the XAPM_FLAG_* masks defined in xaxipmon.h*
652 * @return       None
653 *
654 * @note         C-Style signature:
655 *               void XAxiPmon_DisableFlag(XAxiPmon *InstancePtr);
656 *
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));
662
663 /****************************************************************************/
664 /**
665 *
666 * This function loads the sample interval register value into the sample
667 * interval counter.
668 *
669 * @param        InstancePtr is a pointer to the XAxiPmon instance.
670 *
671 * @return       None
672 *
673 * @note         C-Style signature:
674 *               void XAxiPmon_LoadSampleIntervalCounter(XAxiPmon *InstancePtr);
675 *
676 *****************************************************************************/
677 #define XAxiPmon_LoadSampleIntervalCounter(InstancePtr) \
678        XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET, \
679                                                         XAPM_SICR_LOAD_MASK);
680
681
682
683 /****************************************************************************/
684 /**
685 *
686 * This enables the down count of the sample interval counter.
687 *
688 * @param        InstancePtr is a pointer to the XAxiPmon instance.
689 *
690 * @return       None
691 *
692 * @note         C-Style signature:
693 *          void XAxiPmon_EnableSampleIntervalCounter(XAxiPmon *InstancePtr);
694 *
695 *****************************************************************************/
696 #define XAxiPmon_EnableSampleIntervalCounter(InstancePtr) \
697         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET,\
698                                                         XAPM_SICR_ENABLE_MASK);
699
700
701 /****************************************************************************/
702 /**
703 *
704 * This disables the down count of the sample interval counter.
705 *
706 * @param        InstancePtr is a pointer to the XAxiPmon instance.
707 *
708 * @return       None
709 *
710 * @note         C-Style signature:
711 *           void XAxiPmon_DisableSampleIntervalCounter(XAxiPmon *InstancePtr);
712 *
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));
718
719 /****************************************************************************/
720 /**
721 *
722 * This enables Reset of Metric Counters when Sample Interval Counter lapses.
723 *
724 * @param        InstancePtr is a pointer to the XAxiPmon instance.
725 *
726 * @return       None
727 *
728 * @note         C-Style signature:
729 *               void XAxiPmon_EnableMetricCounterReset(XAxiPmon *InstancePtr);
730 *
731 *****************************************************************************/
732 #define XAxiPmon_EnableMetricCounterReset(InstancePtr) \
733         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET,\
734                                                 XAPM_SICR_MCNTR_RST_MASK);
735
736 /****************************************************************************/
737 /**
738 *
739 * This disables the down count of the sample interval counter.
740 *
741 * @param        InstancePtr is a pointer to the XAxiPmon instance.
742 *
743 * @return       None
744 *
745 * @note         C-Style signature:
746 *               void XAxiPmon_DisableMetricCounterReset(XAxiPmon *InstancePtr);
747 *
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));
753
754 /****************************************************************************/
755 /**
756 *
757 * This function enables the ID Filter Masking.
758 *
759 * @param        InstancePtr is a pointer to the XAxiPmon instance.
760 *
761 * @return       None
762 *
763 * @note         C-Style signature:
764 *               void XAxiPmon_EnableIDFilter(XAxiPmon *InstancePtr);
765 *
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);
771
772 /****************************************************************************/
773 /**
774 *
775 * This function disbles the ID Filter masking.
776 *
777 * @param        InstancePtr is a pointer to the XAxiPmon instance.
778 *
779 * @return       None
780 *
781 * @note         C-Style signature:
782 *               void XAxiPmon_DisableIDFilter(XAxiPmon *InstancePtr);
783 *
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));
789
790 /****************************************************************************/
791 /**
792 *
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.
796 *
797 * @param        InstancePtr is a pointer to the XAxiPmon instance.
798 *
799 * @return       Interval. i.e. the number of clocks in between previous
800 *               read to the current read of sample register.
801 *
802 * @note         C-Style signature:
803 *               u32 XAxiPmon_SampleMetrics(XAxiPmon *InstancePtr);
804 *
805 *****************************************************************************/
806 #define XAxiPmon_SampleMetrics(InstancePtr) \
807        XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, XAPM_SR_OFFSET);
808
809
810 /************************** Function Prototypes *****************************/
811
812 /**
813  * Functions in xaxipmon_sinit.c
814  */
815 XAxiPmon_Config *XAxiPmon_LookupConfig(u16 DeviceId);
816
817 /**
818  * Functions in xaxipmon.c
819  */
820 int XAxiPmon_CfgInitialize(XAxiPmon *InstancePtr,
821                 XAxiPmon_Config *ConfigPtr, u32 EffectiveAddr);
822
823 int XAxiPmon_ResetMetricCounter(XAxiPmon *InstancePtr);
824
825 void XAxiPmon_ResetGlobalClkCounter(XAxiPmon *InstancePtr);
826
827 int XAxiPmon_ResetFifo(XAxiPmon *InstancePtr);
828
829 void XAxiPmon_SetIncrementerRange(XAxiPmon *InstancePtr, u8 IncrementerNum,
830                                         u16 RangeUpper, u16 RangeLower);
831
832 void XAxiPmon_GetIncrementerRange(XAxiPmon *InstancePtr, u8 IncrementerNum,
833                                 u16 *RangeUpper, u16 *RangeLower);
834
835 void XAxiPmon_SetSampleInterval(XAxiPmon *InstancePtr, u32 SampleInterval);
836
837 void XAxiPmon_GetSampleInterval(XAxiPmon *InstancePtr, u32 *SampleInterval);
838
839 int XAxiPmon_SetMetrics(XAxiPmon *InstancePtr, u8 Slot, u8 Metrics,
840                                                         u8 CounterNum);
841
842 int XAxiPmon_GetMetrics(XAxiPmon *InstancePtr, u8 CounterNum, u8 *Metrics,
843                                                                 u8 *Slot);
844 void XAxiPmon_GetGlobalClkCounter(XAxiPmon *InstancePtr,u32 *CntHighValue,
845                                                         u32 *CntLowValue);
846
847 u32 XAxiPmon_GetMetricCounter(XAxiPmon *InstancePtr, u32 CounterNum);
848
849 u32 XAxiPmon_GetSampledMetricCounter(XAxiPmon *InstancePtr, u32 CounterNum);
850
851 u32 XAxiPmon_GetIncrementer(XAxiPmon *InstancePtr, u32 IncrementerNum);
852
853 u32 XAxiPmon_GetSampledIncrementer(XAxiPmon *InstancePtr, u32 IncrementerNum);
854
855 void XAxiPmon_SetSwDataReg(XAxiPmon *InstancePtr, u32 SwData);
856
857 u32 XAxiPmon_GetSwDataReg(XAxiPmon *InstancePtr);
858
859 int XAxiPmon_StartEventLog(XAxiPmon *InstancePtr, u32 FlagEnables);
860
861 int XAxiPmon_StopEventLog(XAxiPmon *InstancePtr);
862
863 int XAxiPmon_StartCounters(XAxiPmon *InstancePtr, u32 SampleInterval);
864
865 int XAxiPmon_StopCounters(XAxiPmon *InstancePtr);
866
867 void XAxiPmon_EnableMetricsCounter(XAxiPmon *InstancePtr);
868
869 void XAxiPmon_DisableMetricsCounter(XAxiPmon *InstancePtr);
870
871 void XAxiPmon_SetLogEnableRanges(XAxiPmon *InstancePtr, u32 CounterNum,
872                                         u16 RangeUpper, u16 RangeLower);
873
874 void XAxiPmon_GetLogEnableRanges(XAxiPmon *InstancePtr, u32 CounterNum,
875                                         u16 *RangeUpper, u16 *RangeLower);
876
877 void XAxiPmon_EnableEventLog(XAxiPmon *InstancePtr);
878
879 void XAxiPmon_EnableMetricCounterTrigger(XAxiPmon *InstancePtr);
880
881 void XAxiPmon_DisableMetricCounterTrigger(XAxiPmon *InstancePtr);
882
883 void XAxiPmon_EnableEventLogTrigger(XAxiPmon *InstancePtr);
884
885 void XAxiPmon_DisableEventLogTrigger(XAxiPmon *InstancePtr);
886
887 const char * XAxiPmon_GetMetricName(u8 Metrics);
888
889 void XAxiPmon_SetWriteId(XAxiPmon *InstancePtr, u32 WriteId);
890
891 void XAxiPmon_SetReadId(XAxiPmon *InstancePtr, u32 ReadId);
892
893 u32 XAxiPmon_GetWriteId(XAxiPmon *InstancePtr);
894
895 u32 XAxiPmon_GetReadId(XAxiPmon *InstancePtr);
896
897 void XAxiPmon_SetWrLatencyStart(XAxiPmon *InstancePtr, u8 Param);
898
899 void XAxiPmon_SetWrLatencyEnd(XAxiPmon *InstancePtr, u8 Param);
900
901 void XAxiPmon_SetRdLatencyStart(XAxiPmon *InstancePtr, u8 Param);
902
903 void XAxiPmon_SetRdLatencyEnd(XAxiPmon *InstancePtr, u8 Param);
904
905 u8 XAxiPmon_GetWrLatencyStart(XAxiPmon *InstancePtr);
906
907 u8 XAxiPmon_GetWrLatencyEnd(XAxiPmon *InstancePtr);
908
909 u8 XAxiPmon_GetRdLatencyStart(XAxiPmon *InstancePtr);
910
911 u8 XAxiPmon_GetRdLatencyEnd(XAxiPmon *InstancePtr);
912
913 void XAxiPmon_SetWriteIdMask(XAxiPmon *InstancePtr, u32 WrMask);
914
915 void XAxiPmon_SetReadIdMask(XAxiPmon *InstancePtr, u32 RdMask);
916
917 u32 XAxiPmon_GetWriteIdMask(XAxiPmon *InstancePtr);
918
919 u32 XAxiPmon_GetReadIdMask(XAxiPmon *InstancePtr);
920
921
922 /**
923  * Functions in xaxipmon_selftest.c
924  */
925 int XAxiPmon_SelfTest(XAxiPmon *InstancePtr);
926
927 #ifdef __cplusplus
928 }
929 #endif
930
931 #endif  /* End of protection macro. */