1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:57:45 +00:00

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!
This commit is contained in:
Andreas Kling 2018-10-18 13:05:00 +02:00
parent 89851a9ded
commit f67d695254
10 changed files with 339 additions and 66 deletions

View file

@ -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 };
};