]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/bram_v4_0/src/xbram.h
cbbe4d84a1579623c86d5971085250f057e2378a
[freertos] / FreeRTOS / Demo / MicroBlaze_Kintex7_EthernetLite / BSP / microblaze_0 / libsrc / bram_v4_0 / src / xbram.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2010 - 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
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 * @file xbram.h
35 *
36 * If ECC is not enabled, this driver exists only to allow the tools to
37 * create a memory test application and to populate xparameters.h with memory
38 * range constants. In this case there is no source code.
39 *
40 * If ECC is enabled, this file contains the software API definition of the
41 * Xilinx BRAM Interface Controller (XBram) device driver.
42 *
43 * The Xilinx BRAM controller is a soft IP core designed for Xilinx
44 * FPGAs and contains the following general features:
45 *   - LMB v2.0 bus interfaces with byte enable support
46 *   - Used in conjunction with bram_block peripheral to provide fast BRAM
47 *     memory solution for MicroBlaze ILMB and DLMB ports
48 *   - Supports byte, half-word, and word transfers
49 *   - Supports optional BRAM error correction and detection.
50 *
51 * The driver provides interrupt management functions. Implementation of
52 * interrupt handlers is left to the user. Refer to the provided interrupt
53 * example in the examples directory for details.
54 *
55 * This driver is intended to be RTOS and processor independent. Any needs for
56 * dynamic memory management, threads or thread mutual exclusion, virtual
57 * memory, or cache control must be satisfied by the layer above this driver.
58 *
59 * <b>Initialization & Configuration</b>
60 *
61 * The XBram_Config structure is used by the driver to configure
62 * itself. This configuration structure is typically created by the tool-chain
63 * based on HW build properties.
64 *
65 * To support multiple runtime loading and initialization strategies employed
66 * by various operating systems, the driver instance can be initialized as
67 * follows:
68 *
69 *   - XBram_CfgInitialize(InstancePtr, CfgPtr, EffectiveAddr) -
70 *     Uses a configuration structure provided by the caller. If running in a
71 *     system with address translation, the provided virtual memory base address
72 *     replaces the physical address present in the configuration structure.
73 *
74 * @note
75 *
76 * This API utilizes 32 bit I/O to the BRAM registers. With less
77 * than 32 bits, the unused bits from registers are read as zero and written as
78 * don't cares.
79 *
80 * <pre>
81 * MODIFICATION HISTORY:
82 *
83 * Ver   Who  Date     Changes
84 * ----- ---- -------- -----------------------------------------------
85 * 3.00a sa  05/11/10 Added ECC support
86 * 3.01a sa  01/13/12  Changed Selftest API from
87 *                     XBram_SelfTest(XBram *InstancePtr) to
88 *                     XBram_SelfTest(XBram *InstancePtr, u8 IntMask) and
89 *                     fixed a problem with interrupt generation for CR 639274
90 *                     Modified Selftest example to return XST_SUCCESS when
91 *                     ECC is not enabled and return XST_FAILURE when ECC is
92 *                     enabled and Control Base Address is zero (CR 636581)
93 *                     Modified Selftest to use correct CorrectableCounterBits
94 *                     for CR 635655
95 *                     Updated to check CorrectableFailingDataRegs in the case
96 *                     of LMB BRAM.
97 *                     Added CorrectableFailingDataRegs and
98 *                     UncorrectableFailingDataRegs to the config structure to
99 *                     distinguish between AXI BRAM and LMB BRAM.
100 *                     These registers are not present in the current version of
101 *                     the AXI BRAM Controller.
102 * 3.02a sa 04/16/12   Added test of byte and halfword read-modify-write
103 * 3.02a sa 04/16/12   Modified driver tcl to sort the address parameters
104 *                     to support both xps and vivado designs.
105 * 3.02a adk 24/4/13   Modified the tcl file to avoid warnings
106 *                     when ecc is disabled cr:705002.
107 * 3.03a bss 05/22/13  Added Xil_DCacheFlushRange in xbram_selftest.c to
108 *                     flush the Cache after writing to BRAM in InjectErrors
109 *                     API(CR #719011)
110 * 4.0   adk  19/12/13 Updated as per the New Tcl API's
111 * </pre>
112 *****************************************************************************/
113 #ifndef XBRAM_H         /* prevent circular inclusions */
114 #define XBRAM_H         /* by using protection macros */
115
116 #ifdef __cplusplus
117 extern "C" {
118 #endif
119
120 /***************************** Include Files ********************************/
121
122 #include "xil_types.h"
123 #include "xil_assert.h"
124 #include "xstatus.h"
125 #include "xbram_hw.h"
126
127 /************************** Constant Definitions ****************************/
128
129
130 /**************************** Type Definitions ******************************/
131
132 /**
133  * This typedef contains configuration information for the device.
134  */
135 typedef struct {
136         u16 DeviceId;                      /**< Unique ID  of device */
137         u32 DataWidth;                     /**< BRAM data width */
138         int EccPresent;                    /**< Is ECC supported in H/W */
139         int FaultInjectionPresent;         /**< Is Fault Injection
140                                              *  supported in H/W */
141         int CorrectableFailingRegisters;   /**< Is Correctable Failing Registers
142                                              *  supported in H/W */
143         int CorrectableFailingDataRegs;    /**< Is Correctable Failing Data
144                                             *   Registers supported in H/W */
145         int UncorrectableFailingRegisters; /**< Is Un-correctable Failing
146                                              *  Registers supported in H/W */
147         int UncorrectableFailingDataRegs;  /**< Is Un-correctable Failing Data
148                                              *  Registers supported in H/W */
149         int EccStatusInterruptPresent;     /**< Are ECC status and interrupts
150                                              *  supported in H/W */
151         int CorrectableCounterBits;        /**< Number of bits in the
152                                              *  Correctable Error Counter */
153         int EccOnOffRegister;              /**< Is ECC on/off register supported
154                                              *  in h/w */
155         int EccOnOffResetValue;            /**< Reset value of the ECC on/off
156                                              *  register in h/w */
157         int WriteAccess;                   /**< Is write access enabled in
158                                              *  h/w */
159         u32 MemBaseAddress;                /**< Device memory base address */
160         u32 MemHighAddress;                /**< Device memory high address */
161         u32 CtrlBaseAddress;               /**< Device register base address.*/
162         u32 CtrlHighAddress;               /**< Device register base address.*/
163 } XBram_Config;
164
165 /**
166  * The XBram driver instance data. The user is required to
167  * allocate a variable of this type for every BRAM device in the
168  * system. A pointer to a variable of this type is then passed to the driver
169  * API functions.
170  */
171 typedef struct {
172         XBram_Config  Config;           /* BRAM config structure */
173         u32 IsReady;                    /* Device is initialized and ready */
174 } XBram;
175
176 /***************** Macros (Inline Functions) Definitions ********************/
177
178
179 /************************** Function Prototypes *****************************/
180
181 /*
182  * Functions in xbram_sinit.c
183  */
184 XBram_Config *XBram_LookupConfig(u16 DeviceId);
185
186 /*
187  * Functions implemented in xbram.c
188  */
189 int XBram_CfgInitialize(XBram *InstancePtr, XBram_Config *Config,
190                         u32 EffectiveAddr);
191
192 /*
193  * Functions implemented in xbram_selftest.c
194  */
195 int XBram_SelfTest(XBram *InstancePtr, u8 IntMask);
196
197 /*
198  * Functions implemented in xbram_intr.c
199  */
200 void XBram_InterruptEnable(XBram *InstancePtr, u32 Mask);
201 void XBram_InterruptDisable(XBram *InstancePtr, u32 Mask);
202 void XBram_InterruptClear(XBram *InstancePtr, u32 Mask);
203 u32 XBram_InterruptGetEnabled(XBram *InstancePtr);
204 u32 XBram_InterruptGetStatus(XBram *InstancePtr);
205
206 #ifdef __cplusplus
207 }
208 #endif
209
210 #endif /* end of protection macro */