1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:17:35 +00:00

Kernel: Move VirtualAddress.h into VM/

This commit is contained in:
Andreas Kling 2019-07-09 14:54:26 +02:00
parent 23a6c2086b
commit eca5c2bdf8
9 changed files with 5 additions and 8 deletions

View file

@ -17,7 +17,6 @@
#include <Kernel/VM/PhysicalRegion.h>
#include <Kernel/VM/Region.h>
#include <Kernel/VM/VMObject.h>
#include <Kernel/VirtualAddress.h>
#define PAGE_ROUND_UP(x) ((((u32)(x)) + PAGE_SIZE - 1) & (~(PAGE_SIZE - 1)))

View file

@ -1,7 +1,7 @@
#pragma once
#include <AK/Vector.h>
#include <Kernel/VirtualAddress.h>
#include <Kernel/VM/VirtualAddress.h>
class Range {
friend class RangeAllocator;

View file

@ -0,0 +1,40 @@
#pragma once
#include <AK/Types.h>
class VirtualAddress {
public:
VirtualAddress() {}
explicit VirtualAddress(u32 address)
: m_address(address)
{
}
bool is_null() const { return m_address == 0; }
bool is_page_aligned() const { return (m_address & 0xfff) == 0; }
VirtualAddress offset(u32 o) const { return VirtualAddress(m_address + o); }
u32 get() const { return m_address; }
void set(u32 address) { m_address = address; }
void mask(u32 m) { m_address &= m; }
bool operator<=(const VirtualAddress& other) const { return m_address <= other.m_address; }
bool operator>=(const VirtualAddress& other) const { return m_address >= other.m_address; }
bool operator>(const VirtualAddress& other) const { return m_address > other.m_address; }
bool operator<(const VirtualAddress& other) const { return m_address < other.m_address; }
bool operator==(const VirtualAddress& other) const { return m_address == other.m_address; }
bool operator!=(const VirtualAddress& other) const { return m_address != other.m_address; }
u8* as_ptr() { return reinterpret_cast<u8*>(m_address); }
const u8* as_ptr() const { return reinterpret_cast<const u8*>(m_address); }
u32 page_base() const { return m_address & 0xfffff000; }
private:
u32 m_address { 0 };
};
inline VirtualAddress operator-(const VirtualAddress& a, const VirtualAddress& b)
{
return VirtualAddress(a.get() - b.get());
}