@@ -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
}
@@ -98,36 +97,29 @@ class address_range {
98
97
m_description[i] = description[i];
99
98
}
100
99
// All address ranges must be page-aligned
101
- if ((m_length & ~AR_ISTART_START_MASK ) != 0 ) {
100
+ if ((m_length & ~PMA_ISTART_START_MASK ) != 0 ) {
102
101
ABRTF (abrt, " length must be multiple of page size when initializing %s" , m_description);
103
102
}
104
- if ((m_start & ~AR_ISTART_START_MASK ) != 0 ) {
103
+ if ((m_start & ~PMA_ISTART_START_MASK ) != 0 ) {
105
104
ABRTF (abrt, " start of %s (0x%" PRIx64 " ) must be aligned to page boundary of %d bytes" , m_description,
106
105
start, AR_PAGE_SIZE);
107
106
}
108
107
// It must be possible to round length up to the next power of two
109
108
if (m_length_bit_ceil == 0 ) {
110
- ABRTF (abrt, " range too long when initializing %s" , m_description);
109
+ ABRTF (abrt, " address range too long when initializing %s" , m_description);
111
110
}
112
111
// Empty range must really be empty
113
112
if (m_length == 0 ) {
114
113
if (m_start != 0 ) {
115
114
ABRTF (abrt, " range with length 0 must start at 0 when initializing %s" , m_description);
116
115
}
117
- if (!m_flags.E ) {
118
- ABRTF (abrt, " range with length 0 must be flagged empty when initializing %s" , m_description);
119
- }
120
116
if (m_flags.M ) {
121
- ABRTF (abrt, " memory range cannot be empty when initializing %s" , m_description);
117
+ ABRTF (abrt, " memory address range cannot have length 0 when initializing %s" , m_description);
122
118
}
123
119
if (m_flags.IO ) {
124
- ABRTF (abrt, " device range cannot be empty when initializing %s" , m_description);
120
+ ABRTF (abrt, " device address range cannot have length 0 when initializing %s" , m_description);
125
121
}
126
122
}
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
123
}
132
124
133
125
// / \brief Checks if a range of addresses is entirely contained within this range
@@ -178,36 +170,39 @@ class address_range {
178
170
179
171
// / \brief Test if address range is occupied by memory
180
172
// / \returns True if and only if range is occupied by memory
173
+ // / \details In this case, get_host_memory() is guaranteed not to return nullptr.
181
174
bool is_memory () const noexcept {
182
175
return m_flags.M ;
183
176
}
184
177
185
178
// / \brief Test if address range is occupied by a device
186
179
// / \returns True if and only if range is occupied by a device
180
+ // / \details In this case, read_device() and write_device() are operational.
187
181
bool is_device () const noexcept {
188
182
return m_flags.IO ;
189
183
}
190
184
191
185
// / \brief Test if address range is empty
192
186
// / \returns True if and only if range is empty
187
+ // / \details Empty ranges should be used only for sentinels.
193
188
bool is_empty () const noexcept {
194
- return m_flags. E ;
189
+ return m_length == 0 ;
195
190
}
196
191
197
192
// / \brief Tests if range is readable
198
- // / \returns True if and only if range is readable
193
+ // / \returns True if and only if range is readable from within the machine.
199
194
bool is_readable () const noexcept {
200
195
return m_flags.R ;
201
196
}
202
197
203
198
// / \brief Tests if range is writeable
204
- // / \returns True if and only if range is writeable
199
+ // / \returns True if and only if range is writeable from within the machine.
205
200
bool is_writeable () const noexcept {
206
201
return m_flags.W ;
207
202
}
208
203
209
204
// / \brief Tests if range is executable
210
- // / \returns True if and only if range is executable
205
+ // / \returns True if and only if range is executable from within the machine.
211
206
bool is_executable () const noexcept {
212
207
return m_flags.X ;
213
208
}
0 commit comments