-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcppreg_Defines.h
73 lines (51 loc) · 1.53 KB
/
cppreg_Defines.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! Project-wide definitions header.
/**
* @file cppreg_Defines.h
* @author Nicolas Clauvelin (nclauvelin@sendyne.com)
* @copyright Copyright 2010-2022 Sendyne Corp. All rights reserved.
*
* This header mostly defines data types used across the project. These data
* types have been defined with 32-bits address space hardware in mind. It
* can easily be extended to larger types if needed.
*/
#ifndef CPPREG_CPPREG_DEFINES_H
#define CPPREG_CPPREG_DEFINES_H
#include "cppreg_Includes.h"
namespace cppreg {
//! Type alias for register and field addresses.
/**
* By design this type ensures that any address can be stored.
*/
using Address = std::uintptr_t;
//! Enumeration type for register size in bits.
/**
* This is used to enforce the supported register sizes.
*/
enum class RegBitSize : std::uint8_t {
//! 8-bit register.
b8, // NOLINT
//! 16-bit register.
b16, // NOLINT
//! 32-bit register.
b32, // NOLINT
//! 64-bit register.
b64 // NOLINT
};
//! Type alias field width.
using FieldWidth = std::uint8_t;
//! Type alias for field offset.
using FieldOffset = std::uint8_t;
//! Shorthand for max value as a mask.
/**
* @tparam T Data type.
*
* This is used to define register masks.
*/
template <typename T>
struct type_mask { // NOLINT
constexpr static const T value = std::numeric_limits<T>::max();
};
//! Global constant to convert bits to bytes.
constexpr static const auto one_byte = std::size_t{8};
} // namespace cppreg
#endif // CPPREG_CPPREG_DEFINES_H