mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
Kernel/Memory: Split the MemoryManager.h file from user address checks
This commit is contained in:
parent
7550b4175e
commit
3b09560251
2 changed files with 37 additions and 21 deletions
|
@ -13,6 +13,7 @@
|
||||||
#include <Kernel/Forward.h>
|
#include <Kernel/Forward.h>
|
||||||
#include <Kernel/Locking/Spinlock.h>
|
#include <Kernel/Locking/Spinlock.h>
|
||||||
#include <Kernel/Memory/AllocationStrategy.h>
|
#include <Kernel/Memory/AllocationStrategy.h>
|
||||||
|
#include <Kernel/Memory/MemorySections.h>
|
||||||
#include <Kernel/Memory/PhysicalPage.h>
|
#include <Kernel/Memory/PhysicalPage.h>
|
||||||
#include <Kernel/Memory/PhysicalRegion.h>
|
#include <Kernel/Memory/PhysicalRegion.h>
|
||||||
#include <Kernel/Memory/Region.h>
|
#include <Kernel/Memory/Region.h>
|
||||||
|
@ -299,27 +300,6 @@ private:
|
||||||
SpinlockProtected<GlobalData, LockRank::None> m_global_data;
|
SpinlockProtected<GlobalData, LockRank::None> m_global_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool is_user_address(VirtualAddress vaddr)
|
|
||||||
{
|
|
||||||
return vaddr.get() < USER_RANGE_CEILING;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool is_user_range(VirtualAddress vaddr, size_t size)
|
|
||||||
{
|
|
||||||
if (vaddr.offset(size) < vaddr)
|
|
||||||
return false;
|
|
||||||
if (!is_user_address(vaddr))
|
|
||||||
return false;
|
|
||||||
if (size <= 1)
|
|
||||||
return true;
|
|
||||||
return is_user_address(vaddr.offset(size - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool is_user_range(VirtualRange const& range)
|
|
||||||
{
|
|
||||||
return is_user_range(range.base(), range.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool PhysicalPage::is_shared_zero_page() const
|
inline bool PhysicalPage::is_shared_zero_page() const
|
||||||
{
|
{
|
||||||
return this == &MM.shared_zero_page();
|
return this == &MM.shared_zero_page();
|
||||||
|
|
36
Kernel/Memory/MemorySections.h
Normal file
36
Kernel/Memory/MemorySections.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Liav A. <liavalb@hotmail.co.il>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Kernel/Memory/VirtualAddress.h>
|
||||||
|
#include <Kernel/Memory/VirtualRange.h>
|
||||||
|
#include <Kernel/Sections.h>
|
||||||
|
|
||||||
|
namespace Kernel::Memory {
|
||||||
|
|
||||||
|
inline bool is_user_address(VirtualAddress vaddr)
|
||||||
|
{
|
||||||
|
return vaddr.get() < USER_RANGE_CEILING;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool is_user_range(VirtualAddress vaddr, size_t size)
|
||||||
|
{
|
||||||
|
if (vaddr.offset(size) < vaddr)
|
||||||
|
return false;
|
||||||
|
if (!is_user_address(vaddr))
|
||||||
|
return false;
|
||||||
|
if (size <= 1)
|
||||||
|
return true;
|
||||||
|
return is_user_address(vaddr.offset(size - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool is_user_range(VirtualRange const& range)
|
||||||
|
{
|
||||||
|
return is_user_range(range.base(), range.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue