summaryrefslogtreecommitdiff
path: root/Kernel/PhysicalAddress.h
blob: 6fd869dca6958a8afeb84a52acfff390bbe8fea1 (plain)
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
#pragma once

class PhysicalAddress {
public:
    PhysicalAddress() {}
    explicit PhysicalAddress(dword address)
        : m_address(address)
    {
    }

    PhysicalAddress offset(dword o) const { return PhysicalAddress(m_address + o); }
    dword get() const { return m_address; }
    void set(dword address) { m_address = address; }
    void mask(dword m) { m_address &= m; }

    bool is_null() const { return m_address == 0; }

    byte* as_ptr() { return reinterpret_cast<byte*>(m_address); }
    const byte* as_ptr() const { return reinterpret_cast<const byte*>(m_address); }

    dword page_base() const { return m_address & 0xfffff000; }

    bool operator==(const PhysicalAddress& other) const { return m_address == other.m_address; }

private:
    dword m_address { 0 };
};