]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo_bsp/ps7_cortexa9_0/libsrc/standalone_v5_4/src/xl2cc_counter.c
xTaskGenericNotify() now sets xYieldPending to pdTRUE even when the 'higher priority...
[freertos] / FreeRTOS / Demo / CORTEX_A9_Zynq_ZC702 / RTOSDemo_bsp / ps7_cortexa9_0 / libsrc / standalone_v5_4 / src / xl2cc_counter.c
1 /******************************************************************************
2 *
3 * Copyright (C) 2011 - 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 xl2cc_counter.c
36 *
37 * This file contains APIs for configuring and controlling the event counters
38 * in PL310 L2 cache controller. For more information about the event counters,
39 * see xl2cc_counter.h.
40 *
41 * <pre>
42 * MODIFICATION HISTORY:
43 *
44 * Ver   Who  Date     Changes
45 * ----- ---- -------- -----------------------------------------------
46 * 1.00a sdm  07/11/11 First release
47 * 3.07a asa  08/30/12 Updated for CR 675636 to provide the L2 Base Address
48 *                     inside the APIs
49 * </pre>
50 *
51 ******************************************************************************/
52
53 /***************************** Include Files *********************************/
54
55 #include <stdint.h>
56 #include "xparameters_ps.h"
57 #include "xl2cc_counter.h"
58 #include "xl2cc.h"
59
60 /************************** Constant Definitions ****************************/
61
62 /**************************** Type Definitions ******************************/
63
64 /***************** Macros (Inline Functions) Definitions ********************/
65
66 /************************** Variable Definitions *****************************/
67
68 /************************** Function Prototypes ******************************/
69
70 void XL2cc_EventCtrReset(void);
71
72 /******************************************************************************/
73
74 /****************************************************************************/
75 /**
76 *
77 * This function initializes the event counters in L2 Cache controller with a
78 * set of event codes specified by the user.
79 *
80 * @param        Event0 is the event code for counter 0.
81 * @param        Event1 is the event code for counter 1.
82 *               Use the event codes defined by XL2CC_* in xl2cc_counter.h.
83 *
84 * @return       None.
85 *
86 * @note         None.
87 *
88 *****************************************************************************/
89 void XL2cc_EventCtrInit(s32 Event0, s32 Event1)
90 {
91
92         /* Write event code into cnt1 cfg reg */
93         *((volatile u32*)(XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNT1_CTRL_OFFSET)) = (((u32)Event1) << 2);
94
95         /* Write event code into cnt0 cfg reg */
96         *((volatile u32*)(XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNT0_CTRL_OFFSET)) = (((u32)Event0) << 2);
97
98         /* Reset counters */
99         XL2cc_EventCtrReset();
100 }
101
102 /****************************************************************************/
103 /**
104 *
105 * This function starts the event counters in L2 Cache controller.
106 *
107 * @param        None.
108 *
109 * @return       None.
110 *
111 * @note         None.
112 *
113 *****************************************************************************/
114 void XL2cc_EventCtrStart(void)
115 {
116         u32 *LocalPtr;
117         LocalPtr = (u32 *)(XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNTRL_OFFSET);
118         XL2cc_EventCtrReset();
119
120         /* Enable counter */
121         /* *((volatile u32*)((void *)(XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNTRL_OFFSET))) = 1 */
122         *LocalPtr = (u32)1;
123 }
124
125 /****************************************************************************/
126 /**
127 *
128 * This function disables the event counters in L2 Cache controller, saves the
129 * counter values and resets the counters.
130 *
131 * @param        EveCtr0 is an output parameter which is used to return the value
132 *               in event counter 0.
133 *               EveCtr1 is an output parameter which is used to return the value
134 *               in event counter 1.
135 *
136 * @return       None.
137 *
138 * @note         None.
139 *
140 *****************************************************************************/
141 void XL2cc_EventCtrStop(u32 *EveCtr0, u32 *EveCtr1)
142 {
143         /* Disable counter */
144         *((volatile u32*) (XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNTRL_OFFSET)) = 0U;
145
146         /* Save counter values */
147         *EveCtr1 = *((volatile u32*)(XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNT1_VAL_OFFSET));
148         *EveCtr0 = *((volatile u32*)(XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNT0_VAL_OFFSET));
149
150         XL2cc_EventCtrReset();
151 }
152
153 /****************************************************************************/
154 /**
155 *
156 * This function resets the event counters in L2 Cache controller.
157 *
158 * @param        None.
159 *
160 * @return       None.
161 *
162 * @note         None.
163 *
164 *****************************************************************************/
165 void XL2cc_EventCtrReset(void)
166 {
167         *((volatile u32*)(XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNTRL_OFFSET)) = 0x6U;
168 }