1 /**
2  * \file
3  * Cache-consistency functions.
4  *
5  * \date   2007-11
6  * \author Adam Lackorzynski <adam@os.inf.tu-dresden.de>
7  *
8  * \ingroup l4_api
9  *
10  */
11 /*
12  * (c) 2007-2009 Author(s)
13  *     economic rights: Technische Universität Dresden (Germany)
14  *
15  * This file is part of TUD:OS and distributed under the terms of the
16  * GNU General Public License 2.
17  * Please see the COPYING-GPL-2 file for details.
18  *
19  * As a special exception, you may use this file as part of a free software
20  * library without restriction.  Specifically, if other files instantiate
21  * templates or use macros or inline functions from this file, or you compile
22  * this file and link it with other files to produce an executable, this
23  * file does not by itself cause the resulting executable to be covered by
24  * the GNU General Public License.  This exception does not however
25  * invalidate any other reasons why the executable file might be covered by
26  * the GNU General Public License.
27  */
28 
29 #ifndef __L4SYS__INCLUDE__CACHE_H__
30 #define __L4SYS__INCLUDE__CACHE_H__
31 
32 #include <l4/sys/compiler.h>
33 
34 /**
35  * \defgroup l4_cache_api Cache Consistency
36  * \ingroup l4_api
37  * Various functions for cache consistency.
38  *
39  * \includefile{l4/sys/cache.h}
40  */
41 
42 EXTERN_C_BEGIN
43 
44 /**
45  * Cache clean a range in D-cache.
46  * \ingroup l4_cache_api
47  *
48  * \param start  Start of range (inclusive)
49  * \param end    End of range (exclusive)
50  *
51  * \retval 0        on success
52  * \retval -EFAULT  in the case of an unresolved page fault
53  *                  in the given area
54  *
55  * Writes back any dirty cache lines in the range but leaves them
56  * in the cache.
57  */
58 L4_INLINE int
59 l4_cache_clean_data(unsigned long start,
60                     unsigned long end) L4_NOTHROW;
61 
62 /**
63  * Cache flush a range.
64  * \ingroup l4_cache_api
65  *
66  * \param start  Start of range (inclusive)
67  * \param end    End of range (exclusive)
68  *
69  * \retval 0        on success
70  * \retval -EFAULT  in the case of an unresolved page fault
71  *                  in the given area
72  *
73  * Writes back any dirty cache lines and invalidates
74  * all cache entries in the range.
75  */
76 L4_INLINE int
77 l4_cache_flush_data(unsigned long start,
78                     unsigned long end) L4_NOTHROW;
79 
80 /**
81  * Cache invalidate a range.
82  * \ingroup l4_cache_api
83  *
84  * \param start  Start of range (inclusive)
85  * \param end    End of range (exclusive)
86  *
87  * \retval 0        on success
88  * \retval -EFAULT  in the case of an unresolved page fault
89  *                  in the given area
90  *
91  * Invalidates all cache entries in the range but does not
92  * necessarily write back dirty cache lines.
93  *
94  * \note Implementations may choose to write back dirty
95  *       lines nonetheless if this is more efficient.
96  *
97  */
98 L4_INLINE int
99 l4_cache_inv_data(unsigned long start,
100                   unsigned long end) L4_NOTHROW;
101 
102 /**
103  * Make memory coherent between I-cache and D-cache.
104  * \ingroup l4_cache_api
105  *
106  * \param start  Start of range (inclusive)
107  * \param end    End of range (exclusive)
108  *
109  * \retval 0        on success
110  * \retval -EFAULT  in the case of an unresolved page fault
111  *                  in the given area
112  */
113 L4_INLINE int
114 l4_cache_coherent(unsigned long start,
115                   unsigned long end) L4_NOTHROW;
116 
117 /**
118  * Make memory coherent for use with external memory.
119  * \ingroup l4_cache_api
120  *
121  * \param start  Start of range (inclusive)
122  * \param end    End of range (exclusive)
123  *
124  * \retval 0        on success
125  * \retval -EFAULT  in the case of an unresolved page fault
126  *                  in the given area
127  */
128 L4_INLINE int
129 l4_cache_dma_coherent(unsigned long start,
130                       unsigned long end) L4_NOTHROW;
131 
132 /**
133  * Make memory coherent for use with external memory.
134  * \ingroup l4_cache_api
135  */
136 L4_INLINE int
137 l4_cache_dma_coherent_full(void) L4_NOTHROW;
138 
139 EXTERN_C_END
140 
141 #endif /* ! __L4SYS__INCLUDE__CACHE_H__ */
142