diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-10-18 13:05:00 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-10-18 13:05:00 +0200 |
commit | f67d695254bf9e0d053e064ade4387665180f27d (patch) | |
tree | f6f74e40a76a89480780f1765e6851d16c234fe6 /Kernel/types.h | |
parent | 89851a9ded3589551df0fe518acc302b5f907f79 (diff) | |
download | serenity-f67d695254bf9e0d053e064ade4387665180f27d.zip |
More paging stuff.
The test userspace process now runs at linear address 0x300000 which is
mapped to a dynamically allocated page from the MemoryManager. Cool!
Diffstat (limited to 'Kernel/types.h')
-rw-r--r-- | Kernel/types.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Kernel/types.h b/Kernel/types.h index 5c1f35d66d..8469e5cd6f 100644 --- a/Kernel/types.h +++ b/Kernel/types.h @@ -1,5 +1,7 @@ #pragma once +#include <AK/Types.h> + #define PACKED __attribute__ ((packed)) #define NORETURN __attribute__ ((noreturn)) #define PURE __attribute__ ((pure)) @@ -26,3 +28,42 @@ struct FarPtr { DWORD offset { 0 }; WORD selector { 0 }; } PACKED; + +class PhysicalAddress { +public: + PhysicalAddress() { } + explicit PhysicalAddress(dword address) : m_address(address) { } + + dword get() const { return m_address; } + void set(dword address) { m_address = address; } + void mask(dword m) { m_address &= m; } + + byte* asPtr() { return reinterpret_cast<byte*>(m_address); } + const byte* asPtr() const { return reinterpret_cast<const byte*>(m_address); } + + dword pageBase() const { return m_address & 0xfffff000; } + +private: + dword m_address { 0 }; +}; + +class LinearAddress { +public: + LinearAddress() { } + explicit LinearAddress(dword address) : m_address(address) { } + + LinearAddress offset(dword o) const { return LinearAddress(m_address + o); } + dword get() const { return m_address; } + void set(dword address) { m_address = address; } + void mask(dword m) { m_address &= m; } + + bool operator==(const LinearAddress& other) const { return m_address == other.m_address; } + + byte* asPtr() { return reinterpret_cast<byte*>(m_address); } + const byte* asPtr() const { return reinterpret_cast<const byte*>(m_address); } + + dword pageBase() const { return m_address & 0xfffff000; } + +private: + dword m_address { 0 }; +}; |