L4Re - L4 Runtime Environment
cache.h
Go to the documentation of this file.
1 
9 /*
10  * (c) 2007-2009 Author(s)
11  * economic rights: Technische Universit├Ąt Dresden (Germany)
12  *
13  * This file is part of TUD:OS and distributed under the terms of the
14  * GNU General Public License 2.
15  * Please see the COPYING-GPL-2 file for details.
16  *
17  * As a special exception, you may use this file as part of a free software
18  * library without restriction. Specifically, if other files instantiate
19  * templates or use macros or inline functions from this file, or you compile
20  * this file and link it with other files to produce an executable, this
21  * file does not by itself cause the resulting executable to be covered by
22  * the GNU General Public License. This exception does not however
23  * invalidate any other reasons why the executable file might be covered by
24  * the GNU General Public License.
25  */
26 #ifndef __L4SYS__INCLUDE__ARCH_ARM__CACHE_H__
27 #define __L4SYS__INCLUDE__ARCH_ARM__CACHE_H__
28 
29 #include <l4/sys/compiler.h>
30 #include <l4/sys/syscall_defs.h>
31 
32 #include_next <l4/sys/cache.h>
33 
37 L4_INLINE void
38 l4_cache_op_arm_call(unsigned long op,
39  unsigned long start,
40  unsigned long end);
41 
42 L4_INLINE void
43 l4_cache_op_arm_call(unsigned long op,
44  unsigned long start,
45  unsigned long end)
46 {
47  register unsigned long _op __asm__ ("r0") = op;
48  register unsigned long _start __asm__ ("r1") = start;
49  register unsigned long _end __asm__ ("r2") = end;
50 
51  __asm__ __volatile__
52  ("@ l4_cache_op_arm_call(start) \n\t"
53  "mov lr, pc \n\t"
54  "mov pc, %[sc] \n\t"
55  "@ l4_cache_op_arm_call(end) \n\t"
56  :
57  "=r" (_op),
58  "=r" (_start),
59  "=r" (_end)
60  :
61  [sc] "i" (L4_SYSCALL_MEM_OP),
62  "0" (_op),
63  "1" (_start),
64  "2" (_end)
65  :
66  "cc", "memory", "lr"
67  );
68 }
69 
70 enum L4_mem_cache_ops
71 {
72  L4_MEM_CACHE_OP_CLEAN_DATA = 0,
73  L4_MEM_CACHE_OP_FLUSH_DATA = 1,
74  L4_MEM_CACHE_OP_INV_DATA = 2,
75  L4_MEM_CACHE_OP_COHERENT = 3,
76  L4_MEM_CACHE_OP_DMA_COHERENT = 4,
77  L4_MEM_CACHE_OP_DMA_COHERENT_FULL = 5,
78  L4_MEM_CACHE_OP_L2_CLEAN = 6,
79  L4_MEM_CACHE_OP_L2_FLUSH = 7,
80  L4_MEM_CACHE_OP_L2_INV = 8,
81 };
82 
83 L4_INLINE int
84 l4_cache_clean_data(unsigned long start,
85  unsigned long end) L4_NOTHROW
86 {
87  l4_cache_op_arm_call(L4_MEM_CACHE_OP_CLEAN_DATA, start, end);
88  return 0;
89 }
90 
91 L4_INLINE int
92 l4_cache_flush_data(unsigned long start,
93  unsigned long end) L4_NOTHROW
94 {
95  l4_cache_op_arm_call(L4_MEM_CACHE_OP_FLUSH_DATA, start, end);
96  return 0;
97 }
98 
99 L4_INLINE int
100 l4_cache_inv_data(unsigned long start,
101  unsigned long end) L4_NOTHROW
102 {
103  l4_cache_op_arm_call(L4_MEM_CACHE_OP_INV_DATA, start, end);
104  return 0;
105 }
106 
107 L4_INLINE int
108 l4_cache_coherent(unsigned long start,
109  unsigned long end) L4_NOTHROW
110 {
111  l4_cache_op_arm_call(L4_MEM_CACHE_OP_COHERENT, start, end);
112  return 0;
113 }
114 
115 L4_INLINE int
116 l4_cache_dma_coherent(unsigned long start,
117  unsigned long end) L4_NOTHROW
118 {
119  l4_cache_op_arm_call(L4_MEM_CACHE_OP_DMA_COHERENT, start, end);
120  return 0;
121 }
122 
123 L4_INLINE int
125 {
126  l4_cache_op_arm_call(L4_MEM_CACHE_OP_DMA_COHERENT_FULL, 0, 0);
127  return 0;
128 }
129 
130 L4_INLINE int
131 l4_cache_l2_clean(unsigned long start,
132  unsigned long end) L4_NOTHROW
133 {
134  l4_cache_op_arm_call(L4_MEM_CACHE_OP_L2_CLEAN, start, end);
135  return 0;
136 }
137 
138 L4_INLINE int
139 l4_cache_l2_flush(unsigned long start,
140  unsigned long end) L4_NOTHROW
141 {
142  l4_cache_op_arm_call(L4_MEM_CACHE_OP_L2_FLUSH, start, end);
143  return 0;
144 }
145 
146 L4_INLINE int
147 l4_cache_l2_inv(unsigned long start,
148  unsigned long end) L4_NOTHROW
149 {
150  l4_cache_op_arm_call(L4_MEM_CACHE_OP_L2_INV, start, end);
151  return 0;
152 }
153 
154 #endif /* ! __L4SYS__INCLUDE__ARCH_ARM__CACHE_H__ */
Syscall entry definitions.
int l4_cache_coherent(unsigned long start, unsigned long end) L4_NOTHROW
Make memory coherent between I-cache and D-cache.
Definition: cache.h:108
int l4_cache_flush_data(unsigned long start, unsigned long end) L4_NOTHROW
Cache flush a range.
Definition: cache.h:92
L4 compiler related defines.
int l4_cache_dma_coherent_full(void) L4_NOTHROW
Make memory coherent for use with external memory.
Definition: cache.h:124
int l4_cache_clean_data(unsigned long start, unsigned long end) L4_NOTHROW
Cache clean a range in D-cache.
Definition: cache.h:84
int l4_cache_dma_coherent(unsigned long start, unsigned long end) L4_NOTHROW
Make memory coherent for use with external memory.
Definition: cache.h:116
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition: compiler.h:185
int l4_cache_inv_data(unsigned long start, unsigned long end) L4_NOTHROW
Cache invalidate a range.
Definition: cache.h:100