L4Re - L4 Runtime Environment
mem_op.h
Go to the documentation of this file.
1 
9 /*
10  * (c) 2010 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__MEM_OP_H__
27 #define __L4SYS__INCLUDE__ARCH_ARM__MEM_OP_H__
28 
29 #include <l4/sys/compiler.h>
30 #include <l4/sys/syscall_defs.h>
31 
33 
52 {
56 };
57 
70 L4_INLINE unsigned long
71 l4_mem_read(unsigned long virtaddress, unsigned width);
72 
85 L4_INLINE void
86 l4_mem_write(unsigned long virtaddress, unsigned width,
87  unsigned long value);
88 
89 enum L4_mem_ops
90 {
91  L4_MEM_OP_MEM_READ = 0x10,
92  L4_MEM_OP_MEM_WRITE = 0x11,
93 };
94 
98 L4_INLINE unsigned long
99 l4_mem_arm_op_call(unsigned long op,
100  unsigned long va,
101  unsigned long width,
102  unsigned long value);
103 
106 L4_INLINE unsigned long
107 l4_mem_arm_op_call(unsigned long op,
108  unsigned long va,
109  unsigned long width,
110  unsigned long value)
111 {
112  register unsigned long _op __asm__ ("r0") = op;
113  register unsigned long _va __asm__ ("r1") = va;
114  register unsigned long _width __asm__ ("r2") = width;
115  register unsigned long _value __asm__ ("r3") = value;
116 
117  __asm__ __volatile__
118  ("@ l4_cache_op_arm_call(start) \n\t"
119  "mov lr, pc \n\t"
120  "mov pc, %[sc] \n\t"
121  "@ l4_cache_op_arm_call(end) \n\t"
122  :
123  "=r" (_op),
124  "=r" (_va),
125  "=r" (_width),
126  "=r" (_value)
127  :
128  [sc] "i" (L4_SYSCALL_MEM_OP),
129  "0" (_op),
130  "1" (_va),
131  "2" (_width),
132  "3" (_value)
133  :
134  "cc", "memory", "lr"
135  );
136 
137  return _value;
138 }
139 
140 L4_INLINE unsigned long
141 l4_mem_read(unsigned long virtaddress, unsigned width)
142 {
143  return l4_mem_arm_op_call(L4_MEM_OP_MEM_READ, virtaddress, width, 0);
144 }
145 
146 L4_INLINE void
147 l4_mem_write(unsigned long virtaddress, unsigned width,
148  unsigned long value)
149 {
150  l4_mem_arm_op_call(L4_MEM_OP_MEM_WRITE, virtaddress, width, value);
151 }
152 
154 
155 #endif /* ! __L4SYS__INCLUDE__ARCH_ARM__MEM_OP_H__ */
Access two bytes (16-bit width)
Definition: mem_op.h:54
unsigned long l4_mem_arm_op_call(unsigned long op, unsigned long va, unsigned long width, unsigned long value)
Implementations.
Definition: mem_op.h:107
Access one byte (8-bit width)
Definition: mem_op.h:53
unsigned long l4_mem_read(unsigned long virtaddress, unsigned width)
Read user task memory from kernel privilege level.
Definition: mem_op.h:141
Syscall entry definitions.
#define EXTERN_C_END
End section with C types and functions.
Definition: compiler.h:187
Access four bytes (32-bit width)
Definition: mem_op.h:55
L4 compiler related defines.
L4_mem_op_widths
Memory access width definitions.
Definition: mem_op.h:51
void l4_mem_write(unsigned long virtaddress, unsigned width, unsigned long value)
Write user task memory from kernel privilege level.
Definition: mem_op.h:147
#define EXTERN_C_BEGIN
Start section with C types and functions.
Definition: compiler.h:186