]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/open-amp.git/blob - obsolete/system/zynqmp_r5/generic/xil_standalone_lib/xpm_counter.h
Move libs/ to obsolete/
[processor-sdk/open-amp.git] / obsolete / system / zynqmp_r5 / generic / xil_standalone_lib / xpm_counter.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2014 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 THE
22 * XILINX CONSORTIUM 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 xpm_counter.h
36 *
37 * This header file contains APIs for configuring and controlling the Cortex-R5
38 * Performance Monitor Events.
39 * Cortex-R5 Performance Monitor has 6 event counters which can be used to
40 * count a variety of events described in Coretx-R5 TRM. This file defines
41 * configurations, where value configures the event counters to count a
42 * set of events.
43 *
44 * Xpm_SetEvents can be used to set the event counters to count a set of events
45 * and Xpm_GetEventCounters can be used to read the counter values.
46 *
47 * @note
48 *
49 * This file doesn't handle the Cortex-R5 cycle counter, as the cycle counter is
50 * being used for time keeping.
51 *
52 * <pre>
53 * MODIFICATION HISTORY:
54 *
55 * Ver   Who  Date     Changes
56 * ----- ---- -------- -----------------------------------------------
57 * 5.00  pkp  02/10/14 Initial version
58 * </pre>
59 *
60 ******************************************************************************/
62 #ifndef XPMCOUNTER_H /* prevent circular inclusions */
63 #define XPMCOUNTER_H /* by using protection macros */
65 /***************************** Include Files ********************************/
67 #include <stdint.h>
68 #include "xpseudo_asm.h"
69 #include "xil_types.h"
71 #ifdef __cplusplus
72 extern "C" {
73 #endif /* __cplusplus */
75 /************************** Constant Definitions ****************************/
77 /* Number of performance counters */
78 #define XPM_CTRCOUNT 6U
80 /* The following constants define the Cortex-R5 Performance Monitor Events */
82 /*
83  * Software increment. The register is incremented only on writes to the
84  * Software Increment Register
85  */
86 #define XPM_EVENT_SOFTINCR 0x00U
88 /*
89  * Instruction fetch that causes a refill at (at least) the lowest level(s) of
90  * instruction or unified cache. Includes the speculative linefills in the
91  * count
92  */
93 #define XPM_EVENT_INSRFETCH_CACHEREFILL 0x01U
95 /*
96  * Instruction fetch that causes a TLB refill at (at least) the lowest level of
97  * TLB. Includes the speculative requests in the count
98  */
99 #define XPM_EVENT_INSTRFECT_TLBREFILL 0x02U
101 /*
102  * Data read or write operation that causes a refill at (at least) the lowest
103  * level(s)of data or unified cache. Counts the number of allocations performed
104  * in the Data Cache due to a read or a write
105  */
106 #define XPM_EVENT_DATA_CACHEREFILL 0x03U
108 /*
109  * Data read or write operation that causes a cache access at (at least) the
110  * lowest level(s) of data or unified cache. This includes speculative reads
111  */
112 #define XPM_EVENT_DATA_CACHEACCESS 0x04U
114 /*
115  * Data read or write operation that causes a TLB refill at (at least) the
116  * lowest level of TLB. This does not include micro TLB misses due to PLD, PLI,
117  * CP15 Cache operation by MVA and CP15 VA to PA operations
118  */
119 #define XPM_EVENT_DATA_TLBREFILL 0x05U
121 /*
122  * Data read architecturally executed. Counts the number of data read
123  * instructions accepted by the Load Store Unit. This includes counting the
124  * speculative and aborted LDR/LDM, as well as the reads due to the SWP
125  * instructions
126  */
127 #define XPM_EVENT_DATA_READS 0x06U
129 /*
130  * Data write architecturally executed. Counts the number of data write
131  * instructions accepted by the Load Store Unit. This includes counting the
132  * speculative and aborted STR/STM, as well as the writes due to the SWP
133  * instructions
134  */
135 #define XPM_EVENT_DATA_WRITE 0x07U
137 /* Exception taken. Counts the number of exceptions architecturally taken.*/
138 #define XPM_EVENT_EXCEPTION 0x09U
140 /* Exception return architecturally executed.*/
141 #define XPM_EVENT_EXCEPRETURN 0x0AU
143 /*
144  * Change to ContextID retired. Counts the number of instructions
145  * architecturally executed writing into the ContextID Register
146  */
147 #define XPM_EVENT_CHANGECONTEXT 0x0BU
149 /*
150  * Software change of PC, except by an exception, architecturally executed.
151  * Count the number of PC changes architecturally executed, excluding the PC
152  * changes due to taken exceptions
153  */
154 #define XPM_EVENT_SW_CHANGEPC 0x0CU
156 /*
157  * Immediate branch architecturally executed (taken or not taken). This includes
158  * the branches which are flushed due to a previous load/store which aborts
159  * late
160  */
161 #define XPM_EVENT_IMMEDBRANCH 0x0DU
163 /*
164  * Unaligned access architecturally executed. Counts the number of aborted
165  * unaligned accessed architecturally executed, and the number of not-aborted
166  * unaligned accesses, including the speculative ones
167  */
168 #define XPM_EVENT_UNALIGNEDACCESS 0x0FU
170 /*
171  * Branch mispredicted/not predicted. Counts the number of mispredicted or
172  * not-predicted branches executed. This includes the branches which are flushed
173  * due to a previous load/store which aborts late
174  */
175 #define XPM_EVENT_BRANCHMISS 0x10U
177 /*
178  * Counts clock cycles when the Cortex-R5 processor is not in WFE/WFI. This
179  * event is not exported on the PMUEVENT bus
180  */
181 #define XPM_EVENT_CLOCKCYCLES 0x11U
183 /*
184  * Branches or other change in program flow that could have been predicted by
185  * the branch prediction resources of the processor. This includes the branches
186  * which are flushed due to a previous load/store which aborts late
187  */
188 #define XPM_EVENT_BRANCHPREDICT 0x12U
190 /*
191  * Java bytecode execute. Counts the number of Java bytecodes being decoded,
192  * including speculative ones
193  */
194 #define XPM_EVENT_JAVABYTECODE 0x40U
196 /*
197  * Software Java bytecode executed. Counts the number of software java bytecodes
198  * being decoded, including speculative ones
199  */
200 #define XPM_EVENT_SWJAVABYTECODE 0x41U
202 /*
203  * Jazelle backward branches executed. Counts the number of Jazelle taken
204  * branches being executed. This includes the branches which are flushed due
205  * to a previous load/store which aborts late
206  */
207 #define XPM_EVENT_JAVABACKBRANCH 0x42U
209 /*
210  * Coherent linefill miss Counts the number of coherent linefill requests
211  * performed by the Cortex-R5 processor which also miss in all the other
212  * Cortex-R5 processors, meaning that the request is sent to the external
213  * memory
214  */
215 #define XPM_EVENT_COHERLINEMISS 0x50U
217 /*
218  * Coherent linefill hit. Counts the number of coherent linefill requests
219  * performed by the Cortex-R5 processor which hit in another Cortex-R5
220  * processor, meaning that the linefill data is fetched directly from the
221  * relevant Cortex-R5 cache
222  */
223 #define XPM_EVENT_COHERLINEHIT 0x51U
225 /*
226  * Instruction cache dependent stall cycles. Counts the number of cycles where
227  * the processor is ready to accept new instructions, but does not receive any
228  * due to the instruction side not being able to provide any and the
229  * instruction cache is currently performing at least one linefill
230  */
231 #define XPM_EVENT_INSTRSTALL 0x60U
233 /*
234  * Data cache dependent stall cycles. Counts the number of cycles where the core
235  * has some instructions that it cannot issue to any pipeline, and the Load
236  * Store unit has at least one pending linefill request, and no pending
237  */
238 #define XPM_EVENT_DATASTALL 0x61U
240 /*
241  * Main TLB miss stall cycles. Counts the number of cycles where the processor
242  * is stalled waiting for the completion of translation table walks from the
243  * main TLB. The processor stalls can be due to the instruction side not being
244  * able to provide the instructions, or to the data side not being able to
245  * provide the necessary data, due to them waiting for the main TLB translation
246  * table walk to complete
247  */
248 #define XPM_EVENT_MAINTLBSTALL 0x62U
250 /*
251  * Counts the number of STREX instructions architecturally executed and
252  * passed
253  */
254 #define XPM_EVENT_STREXPASS 0x63U
256 /*
257  * Counts the number of STREX instructions architecturally executed and
258  * failed
259  */
260 #define XPM_EVENT_STREXFAIL 0x64U
262 /*
263  * Data eviction. Counts the number of eviction requests due to a linefill in
264  * the data cache
265  */
266 #define XPM_EVENT_DATAEVICT 0x65U
268 /*
269  * Counts the number of cycles where the issue stage does not dispatch any
270  * instruction because it is empty or cannot dispatch any instructions
271  */
272 #define XPM_EVENT_NODISPATCH 0x66U
274 /*
275  * Counts the number of cycles where the issue stage is empty
276  */
277 #define XPM_EVENT_ISSUEEMPTY 0x67U
279 /*
280  * Counts the number of instructions going through the Register Renaming stage.
281  * This number is an approximate number of the total number of instructions
282  * speculatively executed, and even more approximate of the total number of
283  * instructions architecturally executed. The approximation depends mainly on
284  * the branch misprediction rate.
285  * The renaming stage can handle two instructions in the same cycle so the event
286  * is two bits long:
287  *    - b00 no instructions renamed
288  *    - b01 one instruction renamed
289  *    - b10 two instructions renamed
290  */
291 #define XPM_EVENT_INSTRRENAME 0x68U
293 /*
294  * Counts the number of procedure returns whose condition codes do not fail,
295  * excluding all returns from exception. This count includes procedure returns
296  * which are flushed due to a previous load/store which aborts late.
297  * Only the following instructions are reported:
298  * - BX R14
299  * - MOV PC LR
300  * - POP {..,pc}
301  * - LDR pc,[sp],#offset
302  * The following instructions are not reported:
303  * - LDMIA R9!,{..,PC} (ThumbEE state only)
304  * - LDR PC,[R9],#offset (ThumbEE state only)
305  * - BX R0 (Rm != R14)
306  * - MOV PC,R0 (Rm != R14)
307  * - LDM SP,{...,PC} (writeback not specified)
308  * - LDR PC,[SP,#offset] (wrong addressing mode)
309  */
310 #define XPM_EVENT_PREDICTFUNCRET 0x6EU
312 /*
313  * Counts the number of instructions being executed in the main execution
314  * pipeline of the processor, the multiply pipeline and arithmetic logic unit
315  * pipeline. The counted instructions are still speculative
316  */
317 #define XPM_EVENT_MAINEXEC 0x70U
319 /*
320  * Counts the number of instructions being executed in the processor second
321  * execution pipeline (ALU). The counted instructions are still speculative
322  */
323 #define XPM_EVENT_SECEXEC 0x71U
325 /*
326  * Counts the number of instructions being executed in the Load/Store unit. The
327  * counted instructions are still speculative
328  */
329 #define XPM_EVENT_LDRSTR 0x72U
331 /*
332  * Counts the number of Floating-point instructions going through the Register
333  * Rename stage. Instructions are still speculative in this stage.
334  *Two floating-point instructions can be renamed in the same cycle so the event
335  * is two bitslong:
336  *0b00 no floating-point instruction renamed
337  *0b01 one floating-point instruction renamed
338  *0b10 two floating-point instructions renamed
339  */
340 #define XPM_EVENT_FLOATRENAME 0x73U
342 /*
343  * Counts the number of Neon instructions going through the Register Rename
344  * stage.Instructions are still speculative in this stage.
345  * Two NEON instructions can be renamed in the same cycle so the event is two
346  * bits long:
347  *0b00 no NEON instruction renamed
348  *0b01 one NEON instruction renamed
349  *0b10 two NEON instructions renamed
350  */
351 #define XPM_EVENT_NEONRENAME 0x74U
353 /*
354  * Counts the number of cycles where the processor is stalled because PLD slots
355  * are all full
356  */
357 #define XPM_EVENT_PLDSTALL 0x80U
359 /*
360  * Counts the number of cycles when the processor is stalled and the data side
361  * is stalled too because it is full and executing writes to the external
362  * memory
363  */
364 #define XPM_EVENT_WRITESTALL 0x81U
366 /*
367  * Counts the number of stall cycles due to main TLB misses on requests issued
368  * by the instruction side
369  */
370 #define XPM_EVENT_INSTRTLBSTALL 0x82U
372 /*
373  * Counts the number of stall cycles due to main TLB misses on requests issued
374  * by the data side
375  */
376 #define XPM_EVENT_DATATLBSTALL 0x83U
378 /*
379  * Counts the number of stall cycles due to micro TLB misses on the instruction
380  * side. This event does not include main TLB miss stall cycles that are already
381  * counted in the corresponding main TLB event
382  */
383 #define XPM_EVENT_INSTR_uTLBSTALL 0x84U
385 /*
386  * Counts the number of stall cycles due to micro TLB misses on the data side.
387  * This event does not include main TLB miss stall cycles that are already
388  * counted in the corresponding main TLB event
389  */
390 #define XPM_EVENT_DATA_uTLBSTALL 0x85U
392 /*
393  * Counts the number of stall cycles because of the execution of a DMB memory
394  * barrier. This includes all DMB instructions being executed, even
395  * speculatively
396  */
397 #define XPM_EVENT_DMB_STALL 0x86U
399 /*
400  * Counts the number of cycles during which the integer core clock is enabled
401  */
402 #define XPM_EVENT_INT_CLKEN 0x8AU
404 /*
405  * Counts the number of cycles during which the Data Engine clock is enabled
406  */
407 #define XPM_EVENT_DE_CLKEN 0x8BU
409 /*
410  * Counts the number of ISB instructions architecturally executed
411  */
412 #define XPM_EVENT_INSTRISB 0x90U
414 /*
415  * Counts the number of DSB instructions architecturally executed
416  */
417 #define XPM_EVENT_INSTRDSB 0x91U
419 /*
420  * Counts the number of DMB instructions speculatively executed
421  */
422 #define XPM_EVENT_INSTRDMB 0x92U
424 /*
425  * Counts the number of external interrupts executed by the processor
426  */
427 #define XPM_EVENT_EXTINT 0x93U
429 /*
430  * PLE cache line request completed
431  */
432 #define XPM_EVENT_PLE_LRC 0xA0U
434 /*
435  * PLE cache line request skipped
436  */
437 #define XPM_EVENT_PLE_LRS 0xA1U
439 /*
440  * PLE FIFO flush
441  */
442 #define XPM_EVENT_PLE_FLUSH 0xA2U
444 /*
445  * PLE request complete
446  */
447 #define XPM_EVENT_PLE_CMPL 0xA3U
449 /*
450  * PLE FIFO overflow
451  */
452 #define XPM_EVENT_PLE_OVFL 0xA4U
454 /*
455  * PLE request programmed
456  */
457 #define XPM_EVENT_PLE_PROG 0xA5U
459 /*
460  * The following constants define the configurations for Cortex-R5 Performance
461  * Monitor Events. Each configuration configures the event counters for a set
462  * of events.
463  * -----------------------------------------------
464  * Config               PmCtr0... PmCtr5
465  * -----------------------------------------------
466  * XPM_CNTRCFG1         { XPM_EVENT_SOFTINCR,
467  *                        XPM_EVENT_INSRFETCH_CACHEREFILL,
468  *                        XPM_EVENT_INSTRFECT_TLBREFILL,
469  *                        XPM_EVENT_DATA_CACHEREFILL,
470  *                        XPM_EVENT_DATA_CACHEACCESS,
471  *                        XPM_EVENT_DATA_TLBREFILL }
472  *
473  * XPM_CNTRCFG2         { XPM_EVENT_DATA_READS,
474  *                        XPM_EVENT_DATA_WRITE,
475  *                        XPM_EVENT_EXCEPTION,
476  *                        XPM_EVENT_EXCEPRETURN,
477  *                        XPM_EVENT_CHANGECONTEXT,
478  *                        XPM_EVENT_SW_CHANGEPC }
479  *
480  * XPM_CNTRCFG3         { XPM_EVENT_IMMEDBRANCH,
481  *                        XPM_EVENT_UNALIGNEDACCESS,
482  *                        XPM_EVENT_BRANCHMISS,
483  *                        XPM_EVENT_CLOCKCYCLES,
484  *                        XPM_EVENT_BRANCHPREDICT,
485  *                        XPM_EVENT_JAVABYTECODE }
486  *
487  * XPM_CNTRCFG4         { XPM_EVENT_SWJAVABYTECODE,
488  *                        XPM_EVENT_JAVABACKBRANCH,
489  *                        XPM_EVENT_COHERLINEMISS,
490  *                        XPM_EVENT_COHERLINEHIT,
491  *                        XPM_EVENT_INSTRSTALL,
492  *                        XPM_EVENT_DATASTALL }
493  *
494  * XPM_CNTRCFG5         { XPM_EVENT_MAINTLBSTALL,
495  *                        XPM_EVENT_STREXPASS,
496  *                        XPM_EVENT_STREXFAIL,
497  *                        XPM_EVENT_DATAEVICT,
498  *                        XPM_EVENT_NODISPATCH,
499  *                        XPM_EVENT_ISSUEEMPTY }
500  *
501  * XPM_CNTRCFG6         { XPM_EVENT_INSTRRENAME,
502  *                        XPM_EVENT_PREDICTFUNCRET,
503  *                        XPM_EVENT_MAINEXEC,
504  *                        XPM_EVENT_SECEXEC,
505  *                        XPM_EVENT_LDRSTR,
506  *                        XPM_EVENT_FLOATRENAME }
507  *
508  * XPM_CNTRCFG7         { XPM_EVENT_NEONRENAME,
509  *                        XPM_EVENT_PLDSTALL,
510  *                        XPM_EVENT_WRITESTALL,
511  *                        XPM_EVENT_INSTRTLBSTALL,
512  *                        XPM_EVENT_DATATLBSTALL,
513  *                        XPM_EVENT_INSTR_uTLBSTALL }
514  *
515  * XPM_CNTRCFG8         { XPM_EVENT_DATA_uTLBSTALL,
516  *                        XPM_EVENT_DMB_STALL,
517  *                        XPM_EVENT_INT_CLKEN,
518  *                        XPM_EVENT_DE_CLKEN,
519  *                        XPM_EVENT_INSTRISB,
520  *                        XPM_EVENT_INSTRDSB }
521  *
522  * XPM_CNTRCFG9         { XPM_EVENT_INSTRDMB,
523  *                        XPM_EVENT_EXTINT,
524  *                        XPM_EVENT_PLE_LRC,
525  *                        XPM_EVENT_PLE_LRS,
526  *                        XPM_EVENT_PLE_FLUSH,
527  *                        XPM_EVENT_PLE_CMPL }
528  *
529  * XPM_CNTRCFG10        { XPM_EVENT_PLE_OVFL,
530  *                        XPM_EVENT_PLE_PROG,
531  *                        XPM_EVENT_PLE_LRC,
532  *                        XPM_EVENT_PLE_LRS,
533  *                        XPM_EVENT_PLE_FLUSH,
534  *                        XPM_EVENT_PLE_CMPL }
535  *
536  * XPM_CNTRCFG11        { XPM_EVENT_DATASTALL,
537  *                        XPM_EVENT_INSRFETCH_CACHEREFILL,
538  *                        XPM_EVENT_INSTRFECT_TLBREFILL,
539  *                        XPM_EVENT_DATA_CACHEREFILL,
540  *                        XPM_EVENT_DATA_CACHEACCESS,
541  *                        XPM_EVENT_DATA_TLBREFILL }
542  */
543 #define XPM_CNTRCFG1    0
544 #define XPM_CNTRCFG2    1
545 #define XPM_CNTRCFG3    2
546 #define XPM_CNTRCFG4    3
547 #define XPM_CNTRCFG5    4
548 #define XPM_CNTRCFG6    5
549 #define XPM_CNTRCFG7    6
550 #define XPM_CNTRCFG8    7
551 #define XPM_CNTRCFG9    8
552 #define XPM_CNTRCFG10   9
553 #define XPM_CNTRCFG11   10
555 /**************************** Type Definitions ******************************/
557 /***************** Macros (Inline Functions) Definitions ********************/
559 /************************** Variable Definitions ****************************/
561 /************************** Function Prototypes *****************************/
563 /* Interface fuctions to access perfromance counters from abstraction layer */
564 void Xpm_SetEvents(s32 PmcrCfg);
565 void Xpm_GetEventCounters(u32 *PmCtrValue);
567 #ifdef __cplusplus
569 #endif
571 #endif