libyggdrasil
v1.0.0
types.hpp
Go to the documentation of this file.
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
* _____.___. .___ .__.__ *
3
* \__ | | ____ ____ __| _/___________ _____|__| | *
4
* / | |/ ___\ / ___\ / __ |\_ __ \__ \ / ___/ | | *
5
* \____ / /_/ > /_/ > /_/ | | | \// __ \_\___ \| | |__ *
6
* / ______\___ /\___ /\____ | |__| (____ /____ >__|____/ *
7
* \/ /_____//_____/ \/ \/ \/ *
8
* - Common - *
9
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
10
* This software can be used by students and other personal of the *
11
* Bern University of Applied Sciences under the terms of the MIT *
12
* license. *
13
* For other persons this software is under the terms of the GNU *
14
* General Public License version 2. *
15
* *
16
* Copyright © 2021, Bern University of Applied Sciences. *
17
* All rights reserved. *
18
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
26
#pragma once
27
28
#include <cstdint>
// Exact width integer definitions
29
30
35
using
u8
= std::uint8_t;
36
using
u16
= std::uint16_t;
37
using
u32
= std::uint32_t;
38
using
u64
= std::uint64_t;
45
using
i8
= std::int8_t;
46
using
i16
= std::int16_t;
47
using
i32
= std::int32_t;
48
using
i64
= std::int64_t;
51
namespace
bsp
{
52
58
template
<
typename
T>
59
using
IO
=
volatile
T;
60
66
template
<
typename
T>
67
struct
TypeSafe
{
68
TypeSafe
() =
default
;
69
TypeSafe
(
const
TypeSafe
&) =
default
;
70
TypeSafe
(
TypeSafe
&&) =
default
;
71
72
explicit
TypeSafe
(T value) : value(value) {}
73
explicit
operator
T() {
return
this->value; }
74
private
:
75
T value;
76
};
77
84
#define TYPESAFE(T) struct : public ::bsp::TypeSafe<int>{ using TypeSafe::TypeSafe; }
85
90
using
addr_t
= std::uint32_t;
91
using
reg_t
= std::uint32_t;
92
97
constexpr
auto
RegisterAlignment
=
alignof
(
reg_t
);
100
}
bsp::TypeSafe::TypeSafe
TypeSafe(const TypeSafe &)=default
u16
uint16_t u16
Definition:
types.h:37
u8
uint8_t u8
Unsigned integer definitions.
Definition:
types.h:36
i16
int16_t i16
Definition:
types.h:47
bsp::IO
volatile T IO
MMIO type template.
Definition:
types.hpp:59
i32
int32_t i32
Definition:
types.h:48
u64
uint64_t u64
Definition:
types.h:39
bsp::TypeSafe::TypeSafe
TypeSafe(T value)
Definition:
types.hpp:72
u32
uint32_t u32
Definition:
types.h:38
bsp::TypeSafe::TypeSafe
TypeSafe()=default
i8
int8_t i8
Signed integer definitions.
Definition:
types.h:46
bsp
Definition:
cortex.hpp:33
bsp::RegisterAlignment
constexpr auto RegisterAlignment
ARM32 specific constants.
Definition:
types.hpp:97
bsp::reg_t
std::uint32_t reg_t
Definition:
types.hpp:91
bsp::addr_t
std::uint32_t addr_t
ARM32 specific types.
Definition:
types.hpp:90
bsp::TypeSafe
Helper class to create type-safe integral types.
Definition:
types.hpp:67
bsp::TypeSafe::TypeSafe
TypeSafe(TypeSafe &&)=default
i64
int64_t i64
Definition:
types.h:49
Inc
cpp
common
types.hpp
Generated by
1.8.20