]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/libsrc/standalone_v5_4/src/xenv_standalone.h
Update the Xilinx UltraScale+ 64-bit demo to use the hardware definition and BSP...
[freertos] / FreeRTOS / Demo / CORTEX_A53_64-bit_UltraScale_MPSoC / RTOSDemo_A53_bsp / psu_cortexa53_0 / libsrc / standalone_v5_4 / src / xenv_standalone.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2002 - 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 xenv_standalone.h
36 *
37 * Defines common services specified by xenv.h.
38 *
39 * @note
40 *       This file is not intended to be included directly by driver code.
41 *       Instead, the generic xenv.h file is intended to be included by driver
42 *       code.
43 *
44 * <pre>
45 * MODIFICATION HISTORY:
46 *
47 * Ver   Who  Date     Changes
48 * ----- ---- -------- -----------------------------------------------
49 * 1.00a wgr  02/28/07 Added cache handling macros.
50 * 1.00a wgr  02/27/07 Simplified code. Deprecated old-style macro names.
51 * 1.00a rmm  01/24/06 Implemented XENV_USLEEP. Assume implementation is being
52 *                     used under Xilinx standalone BSP.
53 * 1.00a xd   11/03/04 Improved support for doxygen.
54 * 1.00a rmm  03/21/02 First release
55 * 1.00a wgr  03/22/07 Converted to new coding style.
56 * 1.00a rpm  06/29/07 Added udelay macro for standalone
57 * 1.00a xd   07/19/07 Included xparameters.h as XPAR_ constants are referred
58 *                     to in MICROBLAZE section
59 * 1.00a ecm  09/19/08 updated for v7.20 of Microblaze, new functionality
60 *
61 * </pre>
62 *
63 *
64 ******************************************************************************/
65
66 #ifndef XENV_STANDALONE_H
67 #define XENV_STANDALONE_H
68
69 #include "xil_types.h"
70
71 #ifdef __cplusplus
72 extern "C" {
73 #endif
74
75 /***************************** Include Files *********************************/
76 /******************************************************************************
77  *
78  * Get the processor dependent includes
79  *
80  ******************************************************************************/
81
82 #include <string.h>
83
84 #if defined __MICROBLAZE__
85 #  include "mb_interface.h"
86 #  include "xparameters.h"   /* XPAR constants used below in MB section */
87
88 #elif defined __PPC__
89 #  include "sleep.h"
90 #  include "xcache_l.h"      /* also include xcache_l.h for caching macros */
91 #endif
92
93 /******************************************************************************
94  *
95  * MEMCPY / MEMSET related macros.
96  *
97  * The following are straight forward implementations of memset and memcpy.
98  *
99  * NOTE: memcpy may not work if source and target memory area are overlapping.
100  *
101  ******************************************************************************/
102 /*****************************************************************************/
103 /**
104  *
105  * Copies a non-overlapping block of memory.
106  *
107  * @param       DestPtr
108  *              Destination address to copy data to.
109  *
110  * @param       SrcPtr
111  *              Source address to copy data from.
112  *
113  * @param       Bytes
114  *              Number of bytes to copy.
115  *
116  * @return      None.
117  *
118  * @note
119  *              The use of XENV_MEM_COPY is deprecated. Use memcpy() instead.
120  *
121  * @note
122  *              This implemention MAY BREAK work if source and target memory
123  *              area are overlapping.
124  *
125  *****************************************************************************/
126
127 #define XENV_MEM_COPY(DestPtr, SrcPtr, Bytes) \
128         memcpy((void *) DestPtr, (const void *) SrcPtr, (size_t) Bytes)
129
130
131
132 /*****************************************************************************/
133 /**
134  *
135  * Fills an area of memory with constant data.
136  *
137  * @param       DestPtr
138  *              Destination address to copy data to.
139  *
140  * @param       Data
141  *              Value to set.
142  *
143  * @param       Bytes
144  *              Number of bytes to copy.
145  *
146  * @return      None.
147  *
148  * @note
149  *              The use of XENV_MEM_FILL is deprecated. Use memset() instead.
150  *
151  *****************************************************************************/
152
153 #define XENV_MEM_FILL(DestPtr, Data, Bytes) \
154         memset((void *) DestPtr, (s32) Data, (size_t) Bytes)
155
156
157
158 /******************************************************************************
159  *
160  * TIME related macros
161  *
162  ******************************************************************************/
163
164 /**
165  * A structure that contains a time stamp used by other time stamp macros
166  * defined below. This structure is processor dependent.
167  */
168 typedef s32 XENV_TIME_STAMP;
169
170 /*****************************************************************************/
171 /**
172  *
173  * Time is derived from the 64 bit PPC timebase register
174  *
175  * @param   StampPtr is the storage for the retrieved time stamp.
176  *
177  * @return  None.
178  *
179  * @note
180  *
181  * Signature: void XENV_TIME_STAMP_GET(XTIME_STAMP *StampPtr)
182  * <br><br>
183  * This macro must be implemented by the user.
184  *
185  *****************************************************************************/
186 #define XENV_TIME_STAMP_GET(StampPtr)
187
188 /*****************************************************************************/
189 /**
190  *
191  * This macro is not yet implemented and always returns 0.
192  *
193  * @param   Stamp1Ptr is the first sampled time stamp.
194  * @param   Stamp2Ptr is the second sampled time stamp.
195  *
196  * @return  0
197  *
198  * @note
199  *
200  * This macro must be implemented by the user.
201  *
202  *****************************************************************************/
203 #define XENV_TIME_STAMP_DELTA_US(Stamp1Ptr, Stamp2Ptr)     (0)
204
205 /*****************************************************************************/
206 /**
207  *
208  * This macro is not yet implemented and always returns 0.
209  *
210  * @param   Stamp1Ptr is the first sampled time stamp.
211  * @param   Stamp2Ptr is the second sampled time stamp.
212  *
213  * @return  0
214  *
215  * @note
216  *
217  * This macro must be implemented by the user.
218  *
219  *****************************************************************************/
220 #define XENV_TIME_STAMP_DELTA_MS(Stamp1Ptr, Stamp2Ptr)     (0)
221
222 /*****************************************************************************/
223 /**
224  * XENV_USLEEP(unsigned delay)
225  *
226  * Delay the specified number of microseconds. Not implemented without OS
227  * support.
228  *
229  * @param       delay
230  *              Number of microseconds to delay.
231  *
232  * @return      None.
233  *
234  *****************************************************************************/
235
236 #ifdef __PPC__
237 #define XENV_USLEEP(delay)      usleep(delay)
238 #define udelay(delay)   usleep(delay)
239 #else
240 #define XENV_USLEEP(delay)
241 #define udelay(delay)
242 #endif
243
244
245 /******************************************************************************
246  *
247  * CACHE handling macros / mappings
248  *
249  ******************************************************************************/
250 /******************************************************************************
251  *
252  * Processor independent macros
253  *
254  ******************************************************************************/
255
256 #define XCACHE_ENABLE_CACHE()   \
257                 { XCACHE_ENABLE_DCACHE(); XCACHE_ENABLE_ICACHE(); }
258
259 #define XCACHE_DISABLE_CACHE()  \
260                 { XCACHE_DISABLE_DCACHE(); XCACHE_DISABLE_ICACHE(); }
261
262
263 /******************************************************************************
264  *
265  * MicroBlaze case
266  *
267  * NOTE: Currently the following macros will only work on systems that contain
268  * only ONE MicroBlaze processor. Also, the macros will only be enabled if the
269  * system is built using a xparameters.h file.
270  *
271  ******************************************************************************/
272
273 #if defined __MICROBLAZE__
274
275 /* Check if MicroBlaze data cache was built into the core.
276  */
277 #if (XPAR_MICROBLAZE_USE_DCACHE == 1)
278 #  define XCACHE_ENABLE_DCACHE()                microblaze_enable_dcache()
279 #  define XCACHE_DISABLE_DCACHE()               microblaze_disable_dcache()
280 #  define XCACHE_INVALIDATE_DCACHE()    microblaze_invalidate_dcache()
281
282 #  define XCACHE_INVALIDATE_DCACHE_RANGE(Addr, Len) \
283                         microblaze_invalidate_dcache_range((s32)(Addr), (s32)(Len))
284
285 #if (XPAR_MICROBLAZE_DCACHE_USE_WRITEBACK == 1)
286 #  define XCACHE_FLUSH_DCACHE()                 microblaze_flush_dcache()
287 #  define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len) \
288                         microblaze_flush_dcache_range((s32)(Addr), (s32)(Len))
289 #else
290 #  define XCACHE_FLUSH_DCACHE()                 microblaze_invalidate_dcache()
291 #  define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len) \
292                         microblaze_invalidate_dcache_range((s32)(Addr), (s32)(Len))
293 #endif  /*XPAR_MICROBLAZE_DCACHE_USE_WRITEBACK*/
294
295 #else
296 #  define XCACHE_ENABLE_DCACHE()
297 #  define XCACHE_DISABLE_DCACHE()
298 #  define XCACHE_INVALIDATE_DCACHE_RANGE(Addr, Len)
299 #  define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len)
300 #endif  /*XPAR_MICROBLAZE_USE_DCACHE*/
301
302
303 /* Check if MicroBlaze instruction cache was built into the core.
304  */
305 #if (XPAR_MICROBLAZE_USE_ICACHE == 1)
306 #  define XCACHE_ENABLE_ICACHE()                microblaze_enable_icache()
307 #  define XCACHE_DISABLE_ICACHE()               microblaze_disable_icache()
308
309 #  define XCACHE_INVALIDATE_ICACHE()    microblaze_invalidate_icache()
310
311 #  define XCACHE_INVALIDATE_ICACHE_RANGE(Addr, Len) \
312                         microblaze_invalidate_icache_range((s32)(Addr), (s32)(Len))
313
314 #else
315 #  define XCACHE_ENABLE_ICACHE()
316 #  define XCACHE_DISABLE_ICACHE()
317 #endif  /*XPAR_MICROBLAZE_USE_ICACHE*/
318
319
320 /******************************************************************************
321  *
322  * PowerPC case
323  *
324  *   Note that the XCACHE_ENABLE_xxx functions are hardcoded to enable a
325  *   specific memory region (0x80000001). Each bit (0-30) in the regions
326  *   bitmask stands for 128MB of memory. Bit 31 stands for the upper 2GB
327  *   range.
328  *
329  *   regions    --> cached address range
330  *   ------------|--------------------------------------------------
331  *   0x80000000  | [0, 0x7FFFFFF]
332  *   0x00000001  | [0xF8000000, 0xFFFFFFFF]
333  *   0x80000001  | [0, 0x7FFFFFF],[0xF8000000, 0xFFFFFFFF]
334  *
335  ******************************************************************************/
336
337 #elif defined __PPC__
338
339 #define XCACHE_ENABLE_DCACHE()          XCache_EnableDCache(0x80000001)
340 #define XCACHE_DISABLE_DCACHE()         XCache_DisableDCache()
341 #define XCACHE_ENABLE_ICACHE()          XCache_EnableICache(0x80000001)
342 #define XCACHE_DISABLE_ICACHE()         XCache_DisableICache()
343
344 #define XCACHE_INVALIDATE_DCACHE_RANGE(Addr, Len) \
345                 XCache_InvalidateDCacheRange((u32)(Addr), (u32)(Len))
346
347 #define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len) \
348                 XCache_FlushDCacheRange((u32)(Addr), (u32)(Len))
349
350 #define XCACHE_INVALIDATE_ICACHE()      XCache_InvalidateICache()
351
352
353 /******************************************************************************
354  *
355  * Unknown processor / architecture
356  *
357  ******************************************************************************/
358
359 #else
360 /* #error "Unknown processor / architecture. Must be MicroBlaze or PowerPC." */
361 #endif
362
363
364 #ifdef __cplusplus
365 }
366 #endif
367
368 #endif  /* #ifndef XENV_STANDALONE_H */