1 /******************************************************************************
3 * (c) Copyright 2011-13 Xilinx, Inc. All rights reserved.
5 * This file contains confidential and proprietary information of Xilinx, Inc.
6 * and is protected under U.S. and international copyright and other
7 * intellectual property laws.
10 * This disclaimer is not a license and does not grant any rights to the
11 * materials distributed herewith. Except as otherwise provided in a valid
12 * license issued to you by Xilinx, and to the maximum extent permitted by
13 * applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL
14 * FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS,
15 * IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
16 * MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE;
17 * and (2) Xilinx shall not be liable (whether in contract or tort, including
18 * negligence, or under any other theory of liability) for any loss or damage
19 * of any kind or nature related to, arising under or in connection with these
20 * materials, including for any direct, or any indirect, special, incidental,
21 * or consequential loss or damage (including loss of data, profits, goodwill,
22 * or any type of loss or damage suffered as a result of any action brought by
23 * a third party) even if such damage or loss was reasonably foreseeable or
24 * Xilinx had been advised of the possibility of the same.
26 * CRITICAL APPLICATIONS
27 * Xilinx products are not designed or intended to be fail-safe, or for use in
28 * any application requiring fail-safe performance, such as life-support or
29 * safety devices or systems, Class III medical devices, nuclear facilities,
30 * applications related to the deployment of airbags, or any other applications
31 * that could lead to death, personal injury, or severe property or
32 * environmental damage (individually and collectively, "Critical
33 * Applications"). Customer assumes the sole risk and liability of any use of
34 * Xilinx products in Critical Applications, subject only to applicable laws
35 * and regulations governing limitations on product liability.
37 * THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE
40 ******************************************************************************/
41 /*****************************************************************************/
46 * This header file contains APIs for configuring and controlling the Cortex-A9
47 * Performance Monitor Events.
48 * Cortex-A9 Performance Monitor has 6 event counters which can be used to
49 * count a variety of events described in Coretx-A9 TRM. This file defines
50 * configurations, where value configures the event counters to count a
53 * Xpm_SetEvents can be used to set the event counters to count a set of events
54 * and Xpm_GetEventCounters can be used to read the counter values.
58 * This file doesn't handle the Cortex-A9 cycle counter, as the cycle counter is
59 * being used for time keeping.
62 * MODIFICATION HISTORY:
64 * Ver Who Date Changes
65 * ----- ---- -------- -----------------------------------------------
66 * 1.00a sdm 07/11/11 First release
69 ******************************************************************************/
71 #ifndef XPMCOUNTER_H /* prevent circular inclusions */
72 #define XPMCOUNTER_H /* by using protection macros */
74 /***************************** Include Files ********************************/
77 #include "xpseudo_asm.h"
78 #include "xil_types.h"
82 #endif /* __cplusplus */
84 /************************** Constant Definitions ****************************/
86 /* Number of performance counters */
87 #define XPM_CTRCOUNT 6
89 /* The following constants define the Cortex-A9 Performance Monitor Events */
92 * Software increment. The register is incremented only on writes to the
93 * Software Increment Register
95 #define XPM_EVENT_SOFTINCR 0x00
98 * Instruction fetch that causes a refill at (at least) the lowest level(s) of
99 * instruction or unified cache. Includes the speculative linefills in the
102 #define XPM_EVENT_INSRFETCH_CACHEREFILL 0x01
105 * Instruction fetch that causes a TLB refill at (at least) the lowest level of
106 * TLB. Includes the speculative requests in the count
108 #define XPM_EVENT_INSTRFECT_TLBREFILL 0x02
111 * Data read or write operation that causes a refill at (at least) the lowest
112 * level(s)of data or unified cache. Counts the number of allocations performed
113 * in the Data Cache due to a read or a write
115 #define XPM_EVENT_DATA_CACHEREFILL 0x03
118 * Data read or write operation that causes a cache access at (at least) the
119 * lowest level(s) of data or unified cache. This includes speculative reads
121 #define XPM_EVENT_DATA_CACHEACCESS 0x04
124 * Data read or write operation that causes a TLB refill at (at least) the
125 * lowest level of TLB. This does not include micro TLB misses due to PLD, PLI,
126 * CP15 Cache operation by MVA and CP15 VA to PA operations
128 #define XPM_EVENT_DATA_TLBREFILL 0x05
131 * Data read architecturally executed. Counts the number of data read
132 * instructions accepted by the Load Store Unit. This includes counting the
133 * speculative and aborted LDR/LDM, as well as the reads due to the SWP
136 #define XPM_EVENT_DATA_READS 0x06
139 * Data write architecturally executed. Counts the number of data write
140 * instructions accepted by the Load Store Unit. This includes counting the
141 * speculative and aborted STR/STM, as well as the writes due to the SWP
144 #define XPM_EVENT_DATA_WRITE 0x07
146 /* Exception taken. Counts the number of exceptions architecturally taken.*/
147 #define XPM_EVENT_EXCEPTION 0x09
149 /* Exception return architecturally executed.*/
150 #define XPM_EVENT_EXCEPRETURN 0x0A
153 * Change to ContextID retired. Counts the number of instructions
154 * architecturally executed writing into the ContextID Register
156 #define XPM_EVENT_CHANGECONTEXT 0x0B
159 * Software change of PC, except by an exception, architecturally executed.
160 * Count the number of PC changes architecturally executed, excluding the PC
161 * changes due to taken exceptions
163 #define XPM_EVENT_SW_CHANGEPC 0x0C
166 * Immediate branch architecturally executed (taken or not taken). This includes
167 * the branches which are flushed due to a previous load/store which aborts
170 #define XPM_EVENT_IMMEDBRANCH 0x0D
173 * Unaligned access architecturally executed. Counts the number of aborted
174 * unaligned accessed architecturally executed, and the number of not-aborted
175 * unaligned accesses, including the speculative ones
177 #define XPM_EVENT_UNALIGNEDACCESS 0x0F
180 * Branch mispredicted/not predicted. Counts the number of mispredicted or
181 * not-predicted branches executed. This includes the branches which are flushed
182 * due to a previous load/store which aborts late
184 #define XPM_EVENT_BRANCHMISS 0x10
187 * Counts clock cycles when the Cortex-A9 processor is not in WFE/WFI. This
188 * event is not exported on the PMUEVENT bus
190 #define XPM_EVENT_CLOCKCYCLES 0x11
193 * Branches or other change in program flow that could have been predicted by
194 * the branch prediction resources of the processor. This includes the branches
195 * which are flushed due to a previous load/store which aborts late
197 #define XPM_EVENT_BRANCHPREDICT 0x12
200 * Java bytecode execute. Counts the number of Java bytecodes being decoded,
201 * including speculative ones
203 #define XPM_EVENT_JAVABYTECODE 0x40
206 * Software Java bytecode executed. Counts the number of software java bytecodes
207 * being decoded, including speculative ones
209 #define XPM_EVENT_SWJAVABYTECODE 0x41
212 * Jazelle backward branches executed. Counts the number of Jazelle taken
213 * branches being executed. This includes the branches which are flushed due
214 * to a previous load/store which aborts late
216 #define XPM_EVENT_JAVABACKBRANCH 0x42
219 * Coherent linefill miss Counts the number of coherent linefill requests
220 * performed by the Cortex-A9 processor which also miss in all the other
221 * Cortex-A9 processors, meaning that the request is sent to the external
224 #define XPM_EVENT_COHERLINEMISS 0x50
227 * Coherent linefill hit. Counts the number of coherent linefill requests
228 * performed by the Cortex-A9 processor which hit in another Cortex-A9
229 * processor, meaning that the linefill data is fetched directly from the
230 * relevant Cortex-A9 cache
232 #define XPM_EVENT_COHERLINEHIT 0x51
235 * Instruction cache dependent stall cycles. Counts the number of cycles where
236 * the processor is ready to accept new instructions, but does not receive any
237 * due to the instruction side not being able to provide any and the
238 * instruction cache is currently performing at least one linefill
240 #define XPM_EVENT_INSTRSTALL 0x60
243 * Data cache dependent stall cycles. Counts the number of cycles where the core
244 * has some instructions that it cannot issue to any pipeline, and the Load
245 * Store unit has at least one pending linefill request, and no pending
247 #define XPM_EVENT_DATASTALL 0x61
250 * Main TLB miss stall cycles. Counts the number of cycles where the processor
251 * is stalled waiting for the completion of translation table walks from the
252 * main TLB. The processor stalls can be due to the instruction side not being
253 * able to provide the instructions, or to the data side not being able to
254 * provide the necessary data, due to them waiting for the main TLB translation
255 * table walk to complete
257 #define XPM_EVENT_MAINTLBSTALL 0x62
260 * Counts the number of STREX instructions architecturally executed and
263 #define XPM_EVENT_STREXPASS 0x63
266 * Counts the number of STREX instructions architecturally executed and
269 #define XPM_EVENT_STREXFAIL 0x64
272 * Data eviction. Counts the number of eviction requests due to a linefill in
275 #define XPM_EVENT_DATAEVICT 0x65
278 * Counts the number of cycles where the issue stage does not dispatch any
279 * instruction because it is empty or cannot dispatch any instructions
281 #define XPM_EVENT_NODISPATCH 0x66
284 * Counts the number of cycles where the issue stage is empty
286 #define XPM_EVENT_ISSUEEMPTY 0x67
289 * Counts the number of instructions going through the Register Renaming stage.
290 * This number is an approximate number of the total number of instructions
291 * speculatively executed, and even more approximate of the total number of
292 * instructions architecturally executed. The approximation depends mainly on
293 * the branch misprediction rate.
294 * The renaming stage can handle two instructions in the same cycle so the event
296 * - b00 no instructions renamed
297 * - b01 one instruction renamed
298 * - b10 two instructions renamed
300 #define XPM_EVENT_INSTRRENAME 0x68
303 * Counts the number of procedure returns whose condition codes do not fail,
304 * excluding all returns from exception. This count includes procedure returns
305 * which are flushed due to a previous load/store which aborts late.
306 * Only the following instructions are reported:
310 * - LDR pc,[sp],#offset
311 * The following instructions are not reported:
312 * - LDMIA R9!,{..,PC} (ThumbEE state only)
313 * - LDR PC,[R9],#offset (ThumbEE state only)
314 * - BX R0 (Rm != R14)
315 * - MOV PC,R0 (Rm != R14)
316 * - LDM SP,{...,PC} (writeback not specified)
317 * - LDR PC,[SP,#offset] (wrong addressing mode)
319 #define XPM_EVENT_PREDICTFUNCRET 0x6E
322 * Counts the number of instructions being executed in the main execution
323 * pipeline of the processor, the multiply pipeline and arithmetic logic unit
324 * pipeline. The counted instructions are still speculative
326 #define XPM_EVENT_MAINEXEC 0x70
329 * Counts the number of instructions being executed in the processor second
330 * execution pipeline (ALU). The counted instructions are still speculative
332 #define XPM_EVENT_SECEXEC 0x71
335 * Counts the number of instructions being executed in the Load/Store unit. The
336 * counted instructions are still speculative
338 #define XPM_EVENT_LDRSTR 0x72
341 * Counts the number of Floating-point instructions going through the Register
342 * Rename stage. Instructions are still speculative in this stage.
343 *Two floating-point instructions can be renamed in the same cycle so the event
345 *0b00 no floating-point instruction renamed
346 *0b01 one floating-point instruction renamed
347 *0b10 two floating-point instructions renamed
349 #define XPM_EVENT_FLOATRENAME 0x73
352 * Counts the number of Neon instructions going through the Register Rename
353 * stage.Instructions are still speculative in this stage.
354 * Two NEON instructions can be renamed in the same cycle so the event is two
356 *0b00 no NEON instruction renamed
357 *0b01 one NEON instruction renamed
358 *0b10 two NEON instructions renamed
360 #define XPM_EVENT_NEONRENAME 0x74
363 * Counts the number of cycles where the processor is stalled because PLD slots
366 #define XPM_EVENT_PLDSTALL 0x80
369 * Counts the number of cycles when the processor is stalled and the data side
370 * is stalled too because it is full and executing writes to the external
373 #define XPM_EVENT_WRITESTALL 0x81
376 * Counts the number of stall cycles due to main TLB misses on requests issued
377 * by the instruction side
379 #define XPM_EVENT_INSTRTLBSTALL 0x82
382 * Counts the number of stall cycles due to main TLB misses on requests issued
385 #define XPM_EVENT_DATATLBSTALL 0x83
388 * Counts the number of stall cycles due to micro TLB misses on the instruction
389 * side. This event does not include main TLB miss stall cycles that are already
390 * counted in the corresponding main TLB event
392 #define XPM_EVENT_INSTR_uTLBSTALL 0x84
395 * Counts the number of stall cycles due to micro TLB misses on the data side.
396 * This event does not include main TLB miss stall cycles that are already
397 * counted in the corresponding main TLB event
399 #define XPM_EVENT_DATA_uTLBSTALL 0x85
402 * Counts the number of stall cycles because of the execution of a DMB memory
403 * barrier. This includes all DMB instructions being executed, even
406 #define XPM_EVENT_DMB_STALL 0x86
409 * Counts the number of cycles during which the integer core clock is enabled
411 #define XPM_EVENT_INT_CLKEN 0x8A
414 * Counts the number of cycles during which the Data Engine clock is enabled
416 #define XPM_EVENT_DE_CLKEN 0x8B
419 * Counts the number of ISB instructions architecturally executed
421 #define XPM_EVENT_INSTRISB 0x90
424 * Counts the number of DSB instructions architecturally executed
426 #define XPM_EVENT_INSTRDSB 0x91
429 * Counts the number of DMB instructions speculatively executed
431 #define XPM_EVENT_INSTRDMB 0x92
434 * Counts the number of external interrupts executed by the processor
436 #define XPM_EVENT_EXTINT 0x93
439 * PLE cache line request completed
441 #define XPM_EVENT_PLE_LRC 0xA0
444 * PLE cache line request skipped
446 #define XPM_EVENT_PLE_LRS 0xA1
451 #define XPM_EVENT_PLE_FLUSH 0xA2
454 * PLE request complete
456 #define XPM_EVENT_PLE_CMPL 0xA3
461 #define XPM_EVENT_PLE_OVFL 0xA4
464 * PLE request programmed
466 #define XPM_EVENT_PLE_PROG 0xA5
469 * The following constants define the configurations for Cortex-A9 Performance
470 * Monitor Events. Each configuration configures the event counters for a set
472 * -----------------------------------------------
473 * Config PmCtr0... PmCtr5
474 * -----------------------------------------------
475 * XPM_CNTRCFG1 { XPM_EVENT_SOFTINCR,
476 * XPM_EVENT_INSRFETCH_CACHEREFILL,
477 * XPM_EVENT_INSTRFECT_TLBREFILL,
478 * XPM_EVENT_DATA_CACHEREFILL,
479 * XPM_EVENT_DATA_CACHEACCESS,
480 * XPM_EVENT_DATA_TLBREFILL }
482 * XPM_CNTRCFG2 { XPM_EVENT_DATA_READS,
483 * XPM_EVENT_DATA_WRITE,
484 * XPM_EVENT_EXCEPTION,
485 * XPM_EVENT_EXCEPRETURN,
486 * XPM_EVENT_CHANGECONTEXT,
487 * XPM_EVENT_SW_CHANGEPC }
489 * XPM_CNTRCFG3 { XPM_EVENT_IMMEDBRANCH,
490 * XPM_EVENT_UNALIGNEDACCESS,
491 * XPM_EVENT_BRANCHMISS,
492 * XPM_EVENT_CLOCKCYCLES,
493 * XPM_EVENT_BRANCHPREDICT,
494 * XPM_EVENT_JAVABYTECODE }
496 * XPM_CNTRCFG4 { XPM_EVENT_SWJAVABYTECODE,
497 * XPM_EVENT_JAVABACKBRANCH,
498 * XPM_EVENT_COHERLINEMISS,
499 * XPM_EVENT_COHERLINEHIT,
500 * XPM_EVENT_INSTRSTALL,
501 * XPM_EVENT_DATASTALL }
503 * XPM_CNTRCFG5 { XPM_EVENT_MAINTLBSTALL,
504 * XPM_EVENT_STREXPASS,
505 * XPM_EVENT_STREXFAIL,
506 * XPM_EVENT_DATAEVICT,
507 * XPM_EVENT_NODISPATCH,
508 * XPM_EVENT_ISSUEEMPTY }
510 * XPM_CNTRCFG6 { XPM_EVENT_INSTRRENAME,
511 * XPM_EVENT_PREDICTFUNCRET,
512 * XPM_EVENT_MAINEXEC,
515 * XPM_EVENT_FLOATRENAME }
517 * XPM_CNTRCFG7 { XPM_EVENT_NEONRENAME,
518 * XPM_EVENT_PLDSTALL,
519 * XPM_EVENT_WRITESTALL,
520 * XPM_EVENT_INSTRTLBSTALL,
521 * XPM_EVENT_DATATLBSTALL,
522 * XPM_EVENT_INSTR_uTLBSTALL }
524 * XPM_CNTRCFG8 { XPM_EVENT_DATA_uTLBSTALL,
525 * XPM_EVENT_DMB_STALL,
526 * XPM_EVENT_INT_CLKEN,
527 * XPM_EVENT_DE_CLKEN,
528 * XPM_EVENT_INSTRISB,
529 * XPM_EVENT_INSTRDSB }
531 * XPM_CNTRCFG9 { XPM_EVENT_INSTRDMB,
535 * XPM_EVENT_PLE_FLUSH,
536 * XPM_EVENT_PLE_CMPL }
538 * XPM_CNTRCFG10 { XPM_EVENT_PLE_OVFL,
539 * XPM_EVENT_PLE_PROG,
542 * XPM_EVENT_PLE_FLUSH,
543 * XPM_EVENT_PLE_CMPL }
545 * XPM_CNTRCFG11 { XPM_EVENT_DATASTALL,
546 * XPM_EVENT_INSRFETCH_CACHEREFILL,
547 * XPM_EVENT_INSTRFECT_TLBREFILL,
548 * XPM_EVENT_DATA_CACHEREFILL,
549 * XPM_EVENT_DATA_CACHEACCESS,
550 * XPM_EVENT_DATA_TLBREFILL }
552 #define XPM_CNTRCFG1 0
553 #define XPM_CNTRCFG2 1
554 #define XPM_CNTRCFG3 2
555 #define XPM_CNTRCFG4 3
556 #define XPM_CNTRCFG5 4
557 #define XPM_CNTRCFG6 5
558 #define XPM_CNTRCFG7 6
559 #define XPM_CNTRCFG8 7
560 #define XPM_CNTRCFG9 8
561 #define XPM_CNTRCFG10 9
562 #define XPM_CNTRCFG11 10
564 /**************************** Type Definitions ******************************/
566 /***************** Macros (Inline Functions) Definitions ********************/
568 /************************** Variable Definitions ****************************/
570 /************************** Function Prototypes *****************************/
572 /* Interface fuctions to access perfromance counters from abstraction layer */
573 void Xpm_SetEvents(int PmcrCfg);
574 void Xpm_GetEventCounters(u32 *PmCtrValue);