L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
asm_access.h
1/* SPDX-License-Identifier: GPL-2.0-only or License-Ref-kk-custom */
2/*
3 * Copyright (C) 2021 Kernkonzept GmbH.
4 * Author(s): Jakub Jermar <jakub.jermar@kernkonzept.com>
5 */
6
7#pragma once
8
9#include <l4/sys/l4int.h>
10
11namespace Asm_access {
12
13inline
15read(l4_uint8_t const *mem)
16{
17 l4_uint8_t val;
18
19 asm volatile ("ldrb %[val], %[mem]" : [val] "=r" (val) : [mem] "m" (*mem));
20
21 return val;
22}
23
24inline
26read(l4_uint16_t const *mem)
27{
28 l4_uint16_t val;
29
30 asm volatile ("ldrh %[val], %[mem]" : [val] "=r" (val) : [mem] "m" (*mem));
31
32 return val;
33}
34
35inline
37read(l4_uint32_t const *mem)
38{
39 l4_uint32_t val;
40
41 asm volatile ("ldr %[val], %[mem]" : [val] "=r" (val) : [mem] "m" (*mem));
42
43 return val;
44}
45
46inline
47void
48write(l4_uint8_t val, l4_uint8_t *mem)
49{
50 asm volatile ("strb %[val], %[mem]" :[mem] "=m" (*mem) : [val] "r" (val));
51}
52
53inline
54void
55write(l4_uint16_t val, l4_uint16_t *mem)
56{
57 asm volatile ("strh %[val], %[mem]" : [mem] "=m" (*mem) : [val] "r" (val));
58}
59
60inline
61void
62write(l4_uint32_t val, l4_uint32_t *mem)
63{
64 asm volatile ("str %[val], %[mem]" : [mem] "=m" (*mem) : [val] "r" (val));
65}
66
67}
unsigned char l4_uint8_t
Unsigned 8bit value.
Definition l4int.h:36
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:40
unsigned short int l4_uint16_t
Unsigned 16bit value.
Definition l4int.h:38