@@ -56,7 +56,6 @@ class address_range {
56
56
m_length{0 },
57
57
m_length_bit_ceil{0 },
58
58
m_flags{} {
59
- m_flags.E = true ;
60
59
for (unsigned i = 0 ; i < std::min<unsigned >(N, m_description.size () - 1 ); ++i) {
61
60
m_description[i] = description[i];
62
61
}
@@ -70,7 +69,8 @@ class address_range {
70
69
constexpr virtual ~address_range () {}; // = default; // doesn't work due to bug in gcc
71
70
72
71
template <typename ABRT, size_t N, typename ... ARGS>
73
- [[noreturn]] static void ABRTF (ABRT abrt, const char (&fmt)[N], ARGS... args) {
72
+ [[noreturn]]
73
+ static void ABRTF (ABRT abrt, const char (&fmt)[N], ARGS... args) {
74
74
char buf[256 ]{};
75
75
std::ignore = snprintf (buf, std::size (buf), fmt, args...);
76
76
abrt (buf);
@@ -98,36 +98,29 @@ class address_range {
98
98
m_description[i] = description[i];
99
99
}
100
100
// All address ranges must be page-aligned
101
- if ((m_length & ~AR_ISTART_START_MASK ) != 0 ) {
102
- ABRTF (abrt, " length must be multiple of page size when initializing %s" , m_description );
101
+ if ((m_length & ~PMA_ISTART_START_MASK ) != 0 ) {
102
+ ABRTF (abrt, " length must be multiple of page size when initializing %s" , description );
103
103
}
104
- if ((m_start & ~AR_ISTART_START_MASK ) != 0 ) {
105
- ABRTF (abrt, " start of %s (0x%" PRIx64 " ) must be aligned to page boundary of %d bytes " , m_description ,
106
- start, AR_PAGE_SIZE);
104
+ if ((m_start & ~PMA_ISTART_START_MASK ) != 0 ) {
105
+ ABRTF (abrt, " start of %s (0x%" PRIx64 " ) must be aligned to page boundary of %" PRId64 " bytes " ,
106
+ description, start, AR_PAGE_SIZE);
107
107
}
108
108
// It must be possible to round length up to the next power of two
109
109
if (m_length_bit_ceil == 0 ) {
110
- ABRTF (abrt, " range too long when initializing %s" , m_description );
110
+ ABRTF (abrt, " address range too long when initializing %s" , description );
111
111
}
112
112
// Empty range must really be empty
113
113
if (m_length == 0 ) {
114
114
if (m_start != 0 ) {
115
- ABRTF (abrt, " range with length 0 must start at 0 when initializing %s" , m_description);
116
- }
117
- if (!m_flags.E ) {
118
- ABRTF (abrt, " range with length 0 must be flagged empty when initializing %s" , m_description);
115
+ ABRTF (abrt, " range with length 0 must start at 0 when initializing %s" , description);
119
116
}
120
117
if (m_flags.M ) {
121
- ABRTF (abrt, " memory range cannot be empty when initializing %s" , m_description );
118
+ ABRTF (abrt, " memory address range cannot have length 0 when initializing %s" , description );
122
119
}
123
120
if (m_flags.IO ) {
124
- ABRTF (abrt, " device range cannot be empty when initializing %s" , m_description );
121
+ ABRTF (abrt, " device address range cannot have length 0 when initializing %s" , description );
125
122
}
126
123
}
127
- // Non-empty range must either be memory or device
128
- if (static_cast <int >(m_flags.M ) + static_cast <int >(m_flags.IO ) + static_cast <int >(m_flags.E ) != 1 ) {
129
- ABRTF (abrt, " range must be one of empty, memory, or device when initializing %s" , m_description);
130
- }
131
124
}
132
125
133
126
// / \brief Checks if a range of addresses is entirely contained within this range
@@ -178,36 +171,39 @@ class address_range {
178
171
179
172
// / \brief Test if address range is occupied by memory
180
173
// / \returns True if and only if range is occupied by memory
174
+ // / \details In this case, get_host_memory() is guaranteed not to return nullptr.
181
175
bool is_memory () const noexcept {
182
176
return m_flags.M ;
183
177
}
184
178
185
179
// / \brief Test if address range is occupied by a device
186
180
// / \returns True if and only if range is occupied by a device
181
+ // / \details In this case, read_device() and write_device() are operational.
187
182
bool is_device () const noexcept {
188
183
return m_flags.IO ;
189
184
}
190
185
191
186
// / \brief Test if address range is empty
192
187
// / \returns True if and only if range is empty
188
+ // / \details Empty ranges should be used only for sentinels.
193
189
bool is_empty () const noexcept {
194
- return m_flags. E ;
190
+ return m_length == 0 ;
195
191
}
196
192
197
193
// / \brief Tests if range is readable
198
- // / \returns True if and only if range is readable
194
+ // / \returns True if and only if range is readable from within the machine.
199
195
bool is_readable () const noexcept {
200
196
return m_flags.R ;
201
197
}
202
198
203
199
// / \brief Tests if range is writeable
204
- // / \returns True if and only if range is writeable
200
+ // / \returns True if and only if range is writeable from within the machine.
205
201
bool is_writeable () const noexcept {
206
202
return m_flags.W ;
207
203
}
208
204
209
205
// / \brief Tests if range is executable
210
- // / \returns True if and only if range is executable
206
+ // / \returns True if and only if range is executable from within the machine.
211
207
bool is_executable () const noexcept {
212
208
return m_flags.X ;
213
209
}
0 commit comments