L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
asm_access_gen.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#include <l4/cxx/type_traits>
11
12namespace Asm_access {
13
14template <typename T>
15struct is_supported_type
16{
17 static const bool value = cxx::is_same<T, l4_uint8_t>::value
18 || cxx::is_same<T, l4_uint16_t>::value
19 || cxx::is_same<T, l4_uint32_t>::value
20 || cxx::is_same<T, l4_uint64_t>::value;
21};
22
23template <typename T>
24inline
25typename cxx::enable_if<is_supported_type<T>::value, T>::type
26read(T const *mem)
27{
28 return *reinterpret_cast<volatile T const *>(mem);
29}
30
31template <typename T>
32inline
33typename cxx::enable_if<is_supported_type<T>::value, void>::type
34write(T val, T *mem)
35{
36 *reinterpret_cast<volatile T *>(mem) = val;
37}
38
39}