Loading...
Searching...
No Matches
mem_op.h
Go to the documentation of this file.
/*
* (c) 2010 Author(s)
* economic rights: Technische Universität Dresden (Germany)
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#ifndef __L4SYS__INCLUDE__ARCH_ARM__MEM_OP_H__
#define __L4SYS__INCLUDE__ARCH_ARM__MEM_OP_H__
#include <l4/sys/compiler.h>
#include <l4/sys/syscall_defs.h>
L4_BEGIN_DECLS
enum L4_mem_op_widths
{
L4_MEM_WIDTH_1BYTE = 0,
L4_MEM_WIDTH_2BYTE = 1,
L4_MEM_WIDTH_4BYTE = 2,
};
L4_INLINE unsigned long
l4_mem_read(unsigned long virtaddress, unsigned width);
L4_INLINE void
l4_mem_write(unsigned long virtaddress, unsigned width,
unsigned long value);
enum L4_mem_ops
{
L4_MEM_OP_MEM_READ = 0x10,
L4_MEM_OP_MEM_WRITE = 0x11,
};
L4_INLINE unsigned long
l4_mem_arm_op_call(unsigned long op,
unsigned long va,
unsigned long width,
unsigned long value);
L4_INLINE unsigned long
l4_mem_arm_op_call(unsigned long op,
unsigned long va,
unsigned long width,
unsigned long value)
{
register unsigned long _op __asm__ ("r0") = op;
register unsigned long _va __asm__ ("r1") = va;
register unsigned long _width __asm__ ("r2") = width;
register unsigned long _value __asm__ ("r3") = value;
__asm__ __volatile__
("@ l4_cache_op_arm_call(start) \n\t"
"mov r5, %[sc] \n\t"
"blx __l4_sys_syscall \n\t"
"@ l4_cache_op_arm_call(end) \n\t"
:
"=r" (_op),
"=r" (_va),
"=r" (_width),
"=r" (_value)
:
[sc] "i" (L4_SYSCALL_MEM_OP),
"0" (_op),
"1" (_va),
"2" (_width),
"3" (_value)
:
"cc", "memory", "r5", "ip", "lr"
);
return _value;
}
L4_INLINE unsigned long
l4_mem_read(unsigned long virtaddress, unsigned width)
{
return l4_mem_arm_op_call(L4_MEM_OP_MEM_READ, virtaddress, width, 0);
}
L4_INLINE void
l4_mem_write(unsigned long virtaddress, unsigned width,
unsigned long value)
{
l4_mem_arm_op_call(L4_MEM_OP_MEM_WRITE, virtaddress, width, value);
}
L4_END_DECLS
#endif /* ! __L4SYS__INCLUDE__ARCH_ARM__MEM_OP_H__ */
compiler.h
L4 compiler related defines.
l4_mem_write
void l4_mem_write(unsigned long virtaddress, unsigned width, unsigned long value)
Write user task memory from kernel privilege level.
Definition mem_op.h:136
l4_mem_read
unsigned long l4_mem_read(unsigned long virtaddress, unsigned width)
Read user task memory from kernel privilege level.
Definition mem_op.h:130
L4_mem_op_widths
L4_mem_op_widths
Memory access width definitions.
Definition mem_op.h:41
L4_MEM_WIDTH_4BYTE
@ L4_MEM_WIDTH_4BYTE
Access four bytes (32-bit width).
Definition mem_op.h:44
L4_MEM_WIDTH_2BYTE
@ L4_MEM_WIDTH_2BYTE
Access two bytes (16-bit width).
Definition mem_op.h:43
L4_MEM_WIDTH_1BYTE
@ L4_MEM_WIDTH_1BYTE
Access one byte (8-bit width).
Definition mem_op.h:42
L4_INLINE
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
L4_BEGIN_DECLS
#define L4_BEGIN_DECLS
Start section with C types and functions.
Definition compiler.h:165
L4_END_DECLS
#define L4_END_DECLS
End section with C types and functions.
Definition compiler.h:166
l4_mem_arm_op_call
unsigned long l4_mem_arm_op_call(unsigned long op, unsigned long va, unsigned long width, unsigned long value)
Implementations.
Definition mem_op.h:96
syscall_defs.h
Syscall entry definitions.