L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
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
57
70L4_INLINE unsigned long
71l4_mem_read(unsigned long virtaddress, unsigned width);
72
85L4_INLINE void
86l4_mem_write(unsigned long virtaddress, unsigned width,
87 unsigned long value);
88
89enum L4_mem_ops
90{
91 L4_MEM_OP_MEM_READ = 0x10,
92 L4_MEM_OP_MEM_WRITE = 0x11,
93};
94
98L4_INLINE unsigned long
99l4_mem_arm_op_call(unsigned long op,
100 unsigned long va,
101 unsigned long width,
102 unsigned long value);
103
106L4_INLINE unsigned long
107l4_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 r5, %[sc] \n\t"
120 "blx __l4_sys_syscall \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", "r5", "ip", "lr"
135 );
136
137 return _value;
138}
139
140L4_INLINE unsigned long
141l4_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
146L4_INLINE void
147l4_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__ */
L4 compiler related defines.
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
unsigned long l4_mem_read(unsigned long virtaddress, unsigned width)
Read user task memory from kernel privilege level.
Definition mem_op.h:141
L4_mem_op_widths
Memory access width definitions.
Definition mem_op.h:52
@ L4_MEM_WIDTH_4BYTE
Access four bytes (32-bit width)
Definition mem_op.h:55
@ L4_MEM_WIDTH_2BYTE
Access two bytes (16-bit width)
Definition mem_op.h:54
@ L4_MEM_WIDTH_1BYTE
Access one byte (8-bit width)
Definition mem_op.h:53
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:62
#define EXTERN_C_BEGIN
Start section with C types and functions.
Definition compiler.h:192
#define EXTERN_C_END
End section with C types and functions.
Definition compiler.h:193
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
Syscall entry definitions.