diff options
author | James Mintram <me@jamesrm.com> | 2022-04-02 23:48:04 +0100 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2022-04-02 19:34:20 -0700 |
commit | d3b6201b405fb7a041b5e12001c2dee4de072ef5 (patch) | |
tree | b3c587801514f68e797c814b3fdd3764e28d7404 /Kernel/Arch/PageFault.h | |
parent | 783a44b18ed837ac1aa8891acc47cf06d629817f (diff) | |
download | serenity-d3b6201b405fb7a041b5e12001c2dee4de072ef5.zip |
Kernel: Make PageDirectory.cpp compile on aarch64
Diffstat (limited to 'Kernel/Arch/PageFault.h')
-rw-r--r-- | Kernel/Arch/PageFault.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/Kernel/Arch/PageFault.h b/Kernel/Arch/PageFault.h new file mode 100644 index 0000000000..1d939d8ea2 --- /dev/null +++ b/Kernel/Arch/PageFault.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <AK/Platform.h> +#include <AK/Types.h> +#include <Kernel/VirtualAddress.h> + +namespace Kernel { + +struct PageFaultFlags { + enum Flags { + NotPresent = 0x00, + ProtectionViolation = 0x01, + Read = 0x00, + Write = 0x02, + UserMode = 0x04, + SupervisorMode = 0x00, + ReservedBitViolation = 0x08, + InstructionFetch = 0x10, + }; +}; + +class PageFault { +public: + PageFault(u16 code, VirtualAddress vaddr) + : m_code(code) + , m_vaddr(vaddr) + { + } + + enum class Type { + PageNotPresent = PageFaultFlags::NotPresent, + ProtectionViolation = PageFaultFlags::ProtectionViolation, + }; + + enum class Access { + Read = PageFaultFlags::Read, + Write = PageFaultFlags::Write, + }; + + VirtualAddress vaddr() const { return m_vaddr; } + u16 code() const { return m_code; } + + Type type() const { return (Type)(m_code & 1); } + Access access() const { return (Access)(m_code & 2); } + + bool is_not_present() const { return (m_code & 1) == PageFaultFlags::NotPresent; } + bool is_protection_violation() const { return (m_code & 1) == PageFaultFlags::ProtectionViolation; } + bool is_read() const { return (m_code & 2) == PageFaultFlags::Read; } + bool is_write() const { return (m_code & 2) == PageFaultFlags::Write; } + bool is_user() const { return (m_code & 4) == PageFaultFlags::UserMode; } + bool is_supervisor() const { return (m_code & 4) == PageFaultFlags::SupervisorMode; } + bool is_instruction_fetch() const { return (m_code & 16) == PageFaultFlags::InstructionFetch; } + +private: + u16 m_code; + VirtualAddress m_vaddr; +}; + +} |