Kernel: Add some convenient getters to Region

Add getters for the underlying Range, the access bits, and also add
contains(Range) which just wraps m_range.contains().
This commit is contained in:
Andreas Kling 2019-08-29 20:55:40 +02:00
parent 10e0e13bf3
commit 0e53b1d1ad

View file

@ -27,12 +27,14 @@ public:
~Region();
const Range& range() const { return m_range; }
VirtualAddress vaddr() const { return m_range.base(); }
size_t size() const { return m_range.size(); }
bool is_readable() const { return m_access & Access::Read; }
bool is_writable() const { return m_access & Access::Write; }
bool is_executable() const { return m_access & Access::Execute; }
const String& name() const { return m_name; }
unsigned access() const { return m_access; }
void set_name(const String& name) { m_name = name; }
@ -51,6 +53,11 @@ public:
return m_range.contains(vaddr);
}
bool contains(const Range& range) const
{
return m_range.contains(range);
}
unsigned page_index_from_address(VirtualAddress vaddr) const
{
return (vaddr - m_range.base()).get() / PAGE_SIZE;