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 %w[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 %w[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 %w[val], %[mem]" : [val] "=r" (val) : [mem] "m" (*mem));
42
43 return val;
44}
45
46inline
48read(l4_uint64_t const *mem)
49{
50 l4_uint64_t val;
51
52 asm volatile ("ldr %[val], %[mem]" : [val] "=r" (val) : [mem] "m" (*mem));
53
54 return val;
55}
56
57inline
58void
59write(l4_uint8_t val, l4_uint8_t *mem)
60{
61 asm volatile ("strb %w[val], %[mem]" :[mem] "=m" (*mem) : [val] "r" (val));
62}
63
64inline
65void
66write(l4_uint16_t val, l4_uint16_t *mem)
67{
68 asm volatile ("strh %w[val], %[mem]" : [mem] "=m" (*mem) : [val] "r" (val));
69}
70
71inline
72void
73write(l4_uint32_t val, l4_uint32_t *mem)
74{
75 asm volatile ("str %w[val], %[mem]" : [mem] "=m" (*mem) : [val] "r" (val));
76}
77
78inline
79void
80write(l4_uint64_t val, l4_uint64_t *mem)
81{
82 asm volatile ("str %[val], %[mem]" : [mem] "=m" (*mem) : [val] "r" (val));
83}
84
85}
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
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:42