mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:27:35 +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:
parent
89851a9ded
commit
f67d695254
10 changed files with 339 additions and 66 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "types.h"
|
||||
|
||||
#define PAGE_SIZE 4096u
|
||||
|
||||
union Descriptor {
|
||||
struct {
|
||||
WORD limit_lo;
|
||||
|
@ -76,6 +78,42 @@ void writeGDTEntry(WORD selector, Descriptor&);
|
|||
/* Map IRQ0-15 @ ISR 0x50-0x5F */
|
||||
#define IRQ_VECTOR_BASE 0x50
|
||||
|
||||
struct PageFaultFlags {
|
||||
enum Flags {
|
||||
NotPresent = 0x00,
|
||||
ProtectionViolation = 0x01,
|
||||
Read = 0x00,
|
||||
Write = 0x02,
|
||||
UserMode = 0x04,
|
||||
SupervisorMode = 0x00,
|
||||
InstructionFetch = 0x08,
|
||||
};
|
||||
};
|
||||
|
||||
class PageFault {
|
||||
public:
|
||||
PageFault(word code, LinearAddress address)
|
||||
: m_code(code)
|
||||
, m_address(address)
|
||||
{
|
||||
}
|
||||
|
||||
LinearAddress address() const { return m_address; }
|
||||
word code() const { return m_code; }
|
||||
|
||||
bool isNotPresent() const { return (m_code & 1) == PageFaultFlags::NotPresent; }
|
||||
bool isProtectionViolation() const { return (m_code & 1) == PageFaultFlags::ProtectionViolation; }
|
||||
bool isRead() const { return (m_code & 2) == PageFaultFlags::Read; }
|
||||
bool isWrite() const { return (m_code & 2) == PageFaultFlags::Write; }
|
||||
bool isUser() const { return (m_code & 4) == PageFaultFlags::UserMode; }
|
||||
bool isSupervisor() const { return (m_code & 4) == PageFaultFlags::SupervisorMode; }
|
||||
bool isInstructionFetch() const { return (m_code & 8) == PageFaultFlags::InstructionFetch; }
|
||||
|
||||
private:
|
||||
word m_code;
|
||||
LinearAddress m_address;
|
||||
};
|
||||
|
||||
struct RegisterDump {
|
||||
WORD gs;
|
||||
WORD fs;
|
||||
|
@ -95,3 +133,8 @@ struct RegisterDump {
|
|||
DWORD eflags;
|
||||
} PACKED;
|
||||
|
||||
inline constexpr dword pageBaseOf(dword address)
|
||||
{
|
||||
return address & 0xfffff000;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue