1 /******************************************************************************
3 * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
4 * AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND
5 * SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE,
6 * OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,
7 * APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION
8 * THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
9 * AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
10 * FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
11 * WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
12 * IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
13 * REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
14 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
15 * FOR A PARTICULAR PURPOSE.
17 * (c) Copyright 2002-2008 Xilinx Inc.
18 * All rights reserved.
20 ******************************************************************************/
21 /*****************************************************************************/
24 * @file xenv_standalone.h
26 * Defines common services specified by xenv.h.
29 * This file is not intended to be included directly by driver code.
30 * Instead, the generic xenv.h file is intended to be included by driver
34 * MODIFICATION HISTORY:
36 * Ver Who Date Changes
37 * ----- ---- -------- -----------------------------------------------
38 * 1.00a wgr 02/28/07 Added cache handling macros.
39 * 1.00a wgr 02/27/07 Simplified code. Deprecated old-style macro names.
40 * 1.00a rmm 01/24/06 Implemented XENV_USLEEP. Assume implementation is being
41 * used under Xilinx standalone BSP.
42 * 1.00a xd 11/03/04 Improved support for doxygen.
43 * 1.00a rmm 03/21/02 First release
44 * 1.00a wgr 03/22/07 Converted to new coding style.
45 * 1.00a rpm 06/29/07 Added udelay macro for standalone
46 * 1.00a xd 07/19/07 Included xparameters.h as XPAR_ constants are referred
47 * to in MICROBLAZE section
48 * 1.00a ecm 09/19/08 updated for v7.20 of Microblaze, new functionality
53 ******************************************************************************/
55 #ifndef XENV_STANDALONE_H
56 #define XENV_STANDALONE_H
62 /***************************** Include Files *********************************/
63 /******************************************************************************
65 * Get the processor dependent includes
67 ******************************************************************************/
71 #if defined __MICROBLAZE__
72 # include "mb_interface.h"
73 # include "xparameters.h" /* XPAR constants used below in MB section */
77 # include "xcache_l.h" /* also include xcache_l.h for caching macros */
80 /******************************************************************************
82 * MEMCPY / MEMSET related macros.
84 * The following are straight forward implementations of memset and memcpy.
86 * NOTE: memcpy may not work if source and target memory area are overlapping.
88 ******************************************************************************/
89 /*****************************************************************************/
92 * Copies a non-overlapping block of memory.
95 * Destination address to copy data to.
98 * Source address to copy data from.
101 * Number of bytes to copy.
106 * The use of XENV_MEM_COPY is deprecated. Use memcpy() instead.
109 * This implemention MAY BREAK work if source and target memory
110 * area are overlapping.
112 *****************************************************************************/
114 #define XENV_MEM_COPY(DestPtr, SrcPtr, Bytes) \
115 memcpy((void *) DestPtr, (const void *) SrcPtr, (size_t) Bytes)
119 /*****************************************************************************/
122 * Fills an area of memory with constant data.
125 * Destination address to copy data to.
131 * Number of bytes to copy.
136 * The use of XENV_MEM_FILL is deprecated. Use memset() instead.
138 *****************************************************************************/
140 #define XENV_MEM_FILL(DestPtr, Data, Bytes) \
141 memset((void *) DestPtr, (int) Data, (size_t) Bytes)
145 /******************************************************************************
147 * TIME related macros
149 ******************************************************************************/
152 * A structure that contains a time stamp used by other time stamp macros
153 * defined below. This structure is processor dependent.
155 typedef int XENV_TIME_STAMP;
157 /*****************************************************************************/
160 * Time is derived from the 64 bit PPC timebase register
162 * @param StampPtr is the storage for the retrieved time stamp.
168 * Signature: void XENV_TIME_STAMP_GET(XTIME_STAMP *StampPtr)
170 * This macro must be implemented by the user.
172 *****************************************************************************/
173 #define XENV_TIME_STAMP_GET(StampPtr)
175 /*****************************************************************************/
178 * This macro is not yet implemented and always returns 0.
180 * @param Stamp1Ptr is the first sampled time stamp.
181 * @param Stamp2Ptr is the second sampled time stamp.
187 * This macro must be implemented by the user.
189 *****************************************************************************/
190 #define XENV_TIME_STAMP_DELTA_US(Stamp1Ptr, Stamp2Ptr) (0)
192 /*****************************************************************************/
195 * This macro is not yet implemented and always returns 0.
197 * @param Stamp1Ptr is the first sampled time stamp.
198 * @param Stamp2Ptr is the second sampled time stamp.
204 * This macro must be implemented by the user.
206 *****************************************************************************/
207 #define XENV_TIME_STAMP_DELTA_MS(Stamp1Ptr, Stamp2Ptr) (0)
209 /*****************************************************************************/
211 * XENV_USLEEP(unsigned delay)
213 * Delay the specified number of microseconds. Not implemented without OS
217 * Number of microseconds to delay.
221 *****************************************************************************/
224 #define XENV_USLEEP(delay) usleep(delay)
225 #define udelay(delay) usleep(delay)
227 #define XENV_USLEEP(delay)
228 #define udelay(delay)
232 /******************************************************************************
234 * CACHE handling macros / mappings
236 ******************************************************************************/
237 /******************************************************************************
239 * Processor independent macros
241 ******************************************************************************/
243 #define XCACHE_ENABLE_CACHE() \
244 { XCACHE_ENABLE_DCACHE(); XCACHE_ENABLE_ICACHE(); }
246 #define XCACHE_DISABLE_CACHE() \
247 { XCACHE_DISABLE_DCACHE(); XCACHE_DISABLE_ICACHE(); }
250 /******************************************************************************
254 * NOTE: Currently the following macros will only work on systems that contain
255 * only ONE MicroBlaze processor. Also, the macros will only be enabled if the
256 * system is built using a xparameters.h file.
258 ******************************************************************************/
260 #if defined __MICROBLAZE__
262 /* Check if MicroBlaze data cache was built into the core.
264 #if (XPAR_MICROBLAZE_USE_DCACHE == 1)
265 # define XCACHE_ENABLE_DCACHE() microblaze_enable_dcache()
266 # define XCACHE_DISABLE_DCACHE() microblaze_disable_dcache()
267 # define XCACHE_INVALIDATE_DCACHE() microblaze_invalidate_dcache()
269 # define XCACHE_INVALIDATE_DCACHE_RANGE(Addr, Len) \
270 microblaze_invalidate_dcache_range((int)(Addr), (int)(Len))
272 #if (XPAR_MICROBLAZE_DCACHE_USE_WRITEBACK == 1)
273 # define XCACHE_FLUSH_DCACHE() microblaze_flush_dcache()
274 # define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len) \
275 microblaze_flush_dcache_range((int)(Addr), (int)(Len))
277 # define XCACHE_FLUSH_DCACHE() microblaze_invalidate_dcache()
278 # define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len) \
279 microblaze_invalidate_dcache_range((int)(Addr), (int)(Len))
280 #endif /*XPAR_MICROBLAZE_DCACHE_USE_WRITEBACK*/
283 # define XCACHE_ENABLE_DCACHE()
284 # define XCACHE_DISABLE_DCACHE()
285 # define XCACHE_INVALIDATE_DCACHE_RANGE(Addr, Len)
286 # define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len)
287 #endif /*XPAR_MICROBLAZE_USE_DCACHE*/
290 /* Check if MicroBlaze instruction cache was built into the core.
292 #if (XPAR_MICROBLAZE_USE_ICACHE == 1)
293 # define XCACHE_ENABLE_ICACHE() microblaze_enable_icache()
294 # define XCACHE_DISABLE_ICACHE() microblaze_disable_icache()
296 # define XCACHE_INVALIDATE_ICACHE() microblaze_invalidate_icache()
298 # define XCACHE_INVALIDATE_ICACHE_RANGE(Addr, Len) \
299 microblaze_invalidate_icache_range((int)(Addr), (int)(Len))
302 # define XCACHE_ENABLE_ICACHE()
303 # define XCACHE_DISABLE_ICACHE()
304 #endif /*XPAR_MICROBLAZE_USE_ICACHE*/
307 /******************************************************************************
311 * Note that the XCACHE_ENABLE_xxx functions are hardcoded to enable a
312 * specific memory region (0x80000001). Each bit (0-30) in the regions
313 * bitmask stands for 128MB of memory. Bit 31 stands for the upper 2GB
316 * regions --> cached address range
317 * ------------|--------------------------------------------------
318 * 0x80000000 | [0, 0x7FFFFFF]
319 * 0x00000001 | [0xF8000000, 0xFFFFFFFF]
320 * 0x80000001 | [0, 0x7FFFFFF],[0xF8000000, 0xFFFFFFFF]
322 ******************************************************************************/
324 #elif defined __PPC__
326 #define XCACHE_ENABLE_DCACHE() XCache_EnableDCache(0x80000001)
327 #define XCACHE_DISABLE_DCACHE() XCache_DisableDCache()
328 #define XCACHE_ENABLE_ICACHE() XCache_EnableICache(0x80000001)
329 #define XCACHE_DISABLE_ICACHE() XCache_DisableICache()
331 #define XCACHE_INVALIDATE_DCACHE_RANGE(Addr, Len) \
332 XCache_InvalidateDCacheRange((unsigned int)(Addr), (unsigned)(Len))
334 #define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len) \
335 XCache_FlushDCacheRange((unsigned int)(Addr), (unsigned)(Len))
337 #define XCACHE_INVALIDATE_ICACHE() XCache_InvalidateICache()
340 /******************************************************************************
342 * Unknown processor / architecture
344 ******************************************************************************/
347 /* #error "Unknown processor / architecture. Must be MicroBlaze or PowerPC." */
355 #endif /* #ifndef XENV_STANDALONE_H */