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): Georg Kotheimer <georg.kotheimer@kernkonzept.com>
5
*/
6
7
#pragma once
8
9
#include <l4/sys/l4int.h>
10
11
namespace
Asm_access {
12
13
inline
14
l4_uint8_t
15
read(
l4_uint8_t
const
*mem)
16
{
17
l4_uint8_t
val;
18
19
asm
volatile
(
"lb %[val], %[mem]"
: [val]
"=r"
(val) : [mem]
"m"
(*mem));
20
21
return
val;
22
}
23
24
inline
25
l4_uint16_t
26
read(
l4_uint16_t
const
*mem)
27
{
28
l4_uint16_t
val;
29
30
asm
volatile
(
"lh %[val], %[mem]"
: [val]
"=r"
(val) : [mem]
"m"
(*mem));
31
32
return
val;
33
}
34
35
inline
36
l4_uint32_t
37
read(
l4_uint32_t
const
*mem)
38
{
39
l4_uint32_t
val;
40
41
asm
volatile
(
"lw %[val], %[mem]"
: [val]
"=r"
(val) : [mem]
"m"
(*mem));
42
43
return
val;
44
}
45
46
inline
47
void
48
write(
l4_uint8_t
val,
l4_uint8_t
*mem)
49
{
50
asm
volatile
(
"sb %[val], %[mem]"
:[mem]
"=m"
(*mem) : [val]
"r"
(val));
51
}
52
53
inline
54
void
55
write(
l4_uint16_t
val,
l4_uint16_t
*mem)
56
{
57
asm
volatile
(
"sh %[val], %[mem]"
: [mem]
"=m"
(*mem) : [val]
"r"
(val));
58
}
59
60
inline
61
void
62
write(
l4_uint32_t
val,
l4_uint32_t
*mem)
63
{
64
asm
volatile
(
"sw %[val], %[mem]"
: [mem]
"=m"
(*mem) : [val]
"r"
(val));
65
}
66
67
#if __riscv_xlen == 64
68
69
inline
70
l4_uint64_t
71
read(
l4_uint64_t
const
*mem)
72
{
73
l4_uint64_t
val;
74
75
asm
volatile
(
"ld %[val], %[mem]"
: [val]
"=r"
(val) : [mem]
"m"
(*mem));
76
77
return
val;
78
}
79
80
inline
81
void
82
write(
l4_uint64_t
val,
l4_uint64_t
*mem)
83
{
84
asm
volatile
(
"sd %[val], %[mem]"
: [mem]
"=m"
(*mem) : [val]
"r"
(val));
85
}
86
87
#endif
88
89
}
l4_uint8_t
unsigned char l4_uint8_t
Unsigned 8bit value.
Definition
l4int.h:36
l4_uint32_t
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition
l4int.h:40
l4_uint16_t
unsigned short int l4_uint16_t
Unsigned 16bit value.
Definition
l4int.h:38
l4_uint64_t
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition
l4int.h:42
pkg
drivers-frst
include
ARCH-riscv
asm_access.h
Generated on Sat Aug 24 2024 16:07:21 for L4Re Operating System Framework by
1.9.8