]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/bram_v4_1/src/xbram_intr.c
Update the Microblaze hardware design and BSP to the latest IP and tool versions.
[freertos] / FreeRTOS / Demo / MicroBlaze_Kintex7_EthernetLite / BSP / microblaze_0 / libsrc / bram_v4_1 / src / xbram_intr.c
1 /******************************************************************************
2 *
3 * Copyright (C) 2010 - 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 xbram_intr.c
36 * @addtogroup bram_v4_0
37 * @{
38 *
39 * Implements BRAM interrupt processing functions for the
40 * XBram driver. See xbram.h for more information
41 * about the driver.
42 *
43 * The functions in this file require the hardware device to be built with
44 * interrupt capabilities. The functions will assert if called using hardware
45 * that does not have interrupt capabilities.
46 *
47 * <pre>
48 * MODIFICATION HISTORY:
49 *
50 * Ver   Who  Date     Changes
51 * ----- ---- -------- -----------------------------------------------
52 * 1.00a sa   05/11/10 Initial release
53 * </pre>
54 *
55 *****************************************************************************/
56
57 /***************************** Include Files ********************************/
58 #include "xbram.h"
59
60
61 /************************** Constant Definitions ****************************/
62
63 /**************************** Type Definitions ******************************/
64
65 /***************** Macros (Inline Functions) Definitions ********************/
66
67 /************************** Variable Definitions ****************************/
68
69 /************************** Function Prototypes *****************************/
70
71
72 /****************************************************************************/
73 /**
74 * Enable interrupts. This function will assert if the hardware device has not
75 * been built with interrupt capabilities.
76 *
77 * @param        InstancePtr is the BRAM instance to operate on.
78 * @param        Mask is the mask to enable. Bit positions of 1 are enabled.
79 *               This mask is formed by OR'ing bits from XBRAM_IR*
80 *               bits which are contained in xbram_hw.h.
81 *
82 * @return       None.
83 *
84 * @note         None.
85 *
86 *****************************************************************************/
87 void XBram_InterruptEnable(XBram *InstancePtr, u32 Mask)
88 {
89         u32 Register;
90
91         Xil_AssertVoid(InstancePtr != NULL);
92         Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
93         Xil_AssertVoid(InstancePtr->Config.CtrlBaseAddress != 0);
94
95         /*
96          * Read the interrupt enable register and only enable the specified
97          * interrupts without disabling or enabling any others.
98          */
99         Register = XBram_ReadReg(InstancePtr->Config.CtrlBaseAddress,
100                                         XBRAM_ECC_EN_IRQ_OFFSET);
101         XBram_WriteReg(InstancePtr->Config.CtrlBaseAddress,
102                                         XBRAM_ECC_EN_IRQ_OFFSET,
103                                         Register | Mask);
104 }
105
106
107 /****************************************************************************/
108 /**
109 * Disable interrupts. This function allows each specific interrupt to be
110 * disabled. This function will assert if the hardware device has not been
111 * built with interrupt capabilities.
112 *
113 * @param        InstancePtr is the BRAM instance to operate on.
114 * @param        Mask is the mask to disable. Bits set to 1 are disabled. This
115 *               mask is formed by OR'ing bits from XBRAM_IR* bits
116 *               which are contained in xbram_hw.h.
117 *
118 * @return       None.
119 *
120 * @note         None.
121 *
122 *****************************************************************************/
123 void XBram_InterruptDisable(XBram *InstancePtr, u32 Mask)
124 {
125         u32 Register;
126
127         Xil_AssertVoid(InstancePtr != NULL);
128         Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
129         Xil_AssertVoid(InstancePtr->Config.CtrlBaseAddress != 0);
130
131         /*
132          * Read the interrupt enable register and only disable the specified
133          * interrupts without enabling or disabling any others.
134          */
135         Register = XBram_ReadReg(InstancePtr->Config.CtrlBaseAddress,
136                                         XBRAM_ECC_EN_IRQ_OFFSET);
137         XBram_WriteReg(InstancePtr->Config.CtrlBaseAddress,
138                                 XBRAM_ECC_EN_IRQ_OFFSET,
139                                 Register & (~Mask));
140 }
141
142 /****************************************************************************/
143 /**
144 * Clear pending interrupts with the provided mask. This function should be
145 * called after the software has serviced the interrupts that are pending.
146 * This function will assert if the hardware device has not been built with
147 * interrupt capabilities.
148 *
149 * @param        InstancePtr is the BRAM instance to operate on.
150 * @param        Mask is the mask to clear pending interrupts for. Bit positions
151 *               of 1 are cleared. This mask is formed by OR'ing bits from
152 *               XBRAM_IR* bits which are contained in
153 *               xbram_hw.h.
154 *
155 * @return       None.
156 *
157 * @note         None.
158 *
159 *****************************************************************************/
160 void XBram_InterruptClear(XBram *InstancePtr, u32 Mask)
161 {
162         u32 Register;
163
164         Xil_AssertVoid(InstancePtr != NULL);
165         Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
166         Xil_AssertVoid(InstancePtr->Config.CtrlBaseAddress != 0);
167
168         /*
169          * Read the interrupt status register and only clear the interrupts
170          * that are specified without affecting any others.  Since the register
171          * is a toggle on write, make sure any bits to be written are already
172          * set.
173          */
174         Register = XBram_ReadReg(InstancePtr->Config.CtrlBaseAddress,
175                                         XBRAM_ECC_STATUS_OFFSET);
176         XBram_WriteReg(InstancePtr->Config.CtrlBaseAddress,
177                                 XBRAM_ECC_STATUS_OFFSET,
178                                 Register & Mask);
179
180
181 }
182
183
184 /****************************************************************************/
185 /**
186 * Returns the interrupt enable mask. This function will assert if the
187 * hardware device has not been built with interrupt capabilities.
188 *
189 * @param        InstancePtr is the BRAM instance to operate on.
190 *
191 * @return       A mask of bits made from XBRAM_IR* bits which
192 *               are contained in xbram_hw.h.
193 *
194 * @return       None.
195 *
196 * @note         None.
197 *
198 *****************************************************************************/
199 u32 XBram_InterruptGetEnabled(XBram * InstancePtr)
200 {
201         Xil_AssertNonvoid(InstancePtr != NULL);
202         Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
203         Xil_AssertNonvoid(InstancePtr->Config.CtrlBaseAddress != 0);
204
205         return XBram_ReadReg(InstancePtr->Config.CtrlBaseAddress,
206                                 XBRAM_ECC_EN_IRQ_OFFSET);
207 }
208
209
210 /****************************************************************************/
211 /**
212 * Returns the status of interrupt signals. Any bit in the mask set to 1
213 * indicates that the channel associated with the bit has asserted an interrupt
214 * condition. This function will assert if the hardware device has not been
215 * built with interrupt capabilities.
216 *
217 * @param        InstancePtr is the BRAM instance to operate on.
218 *
219 * @return       A pointer to a mask of bits made from XBRAM_IR*
220 *               bits which are contained in xbram_hw.h.
221 *
222 * @note
223 *
224 * The interrupt status indicates the status of the device irregardless if
225 * the interrupts from the devices have been enabled or not through
226 * XBram_InterruptEnable().
227 *
228 *****************************************************************************/
229 u32 XBram_InterruptGetStatus(XBram * InstancePtr)
230 {
231         Xil_AssertNonvoid(InstancePtr != NULL);
232         Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
233         Xil_AssertNonvoid(InstancePtr->Config.CtrlBaseAddress != 0);
234
235         return XBram_ReadReg(InstancePtr->Config.CtrlBaseAddress,
236                                 XBRAM_ECC_EN_IRQ_OFFSET);
237 }
238 /** @} */