1 #ifndef __ALT_CACHE_H__
2 #define __ALT_CACHE_H__
3 
4 /******************************************************************************
5 *                                                                             *
6 * License Agreement                                                           *
7 *                                                                             *
8 * Copyright (c) 2003, 2007 Altera Corporation, San Jose, California, USA.     *
9 * All rights reserved.                                                        *
10 *                                                                             *
11 * Permission is hereby granted, free of charge, to any person obtaining a     *
12 * copy of this software and associated documentation files (the "Software"),  *
13 * to deal in the Software without restriction, including without limitation   *
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,    *
15 * and/or sell copies of the Software, and to permit persons to whom the       *
16 * Software is furnished to do so, subject to the following conditions:        *
17 *                                                                             *
18 * The above copyright notice and this permission notice shall be included in  *
19 * all copies or substantial portions of the Software.                         *
20 *                                                                             *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  *
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,    *
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      *
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING     *
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER         *
27 * DEALINGS IN THE SOFTWARE.                                                   *
28 *                                                                             *
29 *                                                                             *
30 ******************************************************************************/
31 
32 #include <stdlib.h>
33 
34 #include "alt_types.h"
35 
36 /*
37  * alt_cache.h defines the processor specific functions for manipulating the
38  * cache.
39  */
40 
41 #ifdef __cplusplus
42 extern "C"
43 {
44 #endif /* __cplusplus */
45 
46 /*
47  * alt_icache_flush() is called to flush the instruction cache for a memory
48  * region of length "len" bytes, starting at address "start".
49  */
50 
51 extern void alt_icache_flush (void* start, alt_u32 len);
52 
53 /*
54  * alt_dcache_flush() is called to flush the data cache for a memory
55  * region of length "len" bytes, starting at address "start".
56  * Any dirty lines in the data cache are written back to memory.
57  */
58 
59 extern void alt_dcache_flush (void* start, alt_u32 len);
60 
61 /*
62  * alt_dcache_flush() is called to flush the data cache for a memory
63  * region of length "len" bytes, starting at address "start".
64  * Any dirty lines in the data cache are NOT written back to memory.
65  */
66 
67 extern void alt_dcache_flush_no_writeback (void* start, alt_u32 len);
68 
69 /*
70  * Flush the entire instruction cache.
71  */
72 
73 extern void alt_icache_flush_all (void);
74 
75 /*
76  * Flush the entire data cache.
77  */
78 
79 extern void alt_dcache_flush_all (void);
80 
81 /*
82  * Allocate a block of uncached memory.
83  */
84 
85 extern volatile void* alt_uncached_malloc (size_t size);
86 
87 /*
88  * Free a block of uncached memory.
89  */
90 
91 extern void alt_uncached_free (volatile void* ptr);
92 
93 /*
94  * Convert a pointer to a block of cached memory, into a block of
95  * uncached memory.
96  */
97 
98 extern volatile void* alt_remap_uncached (void* ptr, alt_u32 len);
99 
100 /*
101  * Convert a pointer to a block of uncached memory, into a block of
102  * cached memory.
103  */
104 
105 extern void* alt_remap_cached (volatile void* ptr, alt_u32 len);
106 
107 /*
108  *
109  */
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #endif /* __ALT_CACHE_H__ */
116