1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:27:43 +00:00

Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace

This commit is contained in:
Andreas Kling 2021-08-06 13:49:36 +02:00
parent a1d7ebf85a
commit 93d98d4976
153 changed files with 473 additions and 467 deletions

View file

@ -11,7 +11,7 @@
#include <Kernel/Memory/PhysicalPage.h>
#include <Kernel/Process.h>
namespace Kernel {
namespace Kernel::Memory {
RefPtr<VMObject> AnonymousVMObject::try_clone()
{

View file

@ -12,7 +12,7 @@
#include <Kernel/Memory/VMObject.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {
namespace Kernel::Memory {
class AnonymousVMObject final : public VMObject {
public:

View file

@ -7,7 +7,7 @@
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/Memory/InodeVMObject.h>
namespace Kernel {
namespace Kernel::Memory {
InodeVMObject::InodeVMObject(Inode& inode, size_t size)
: VMObject(size)

View file

@ -10,7 +10,7 @@
#include <Kernel/Memory/VMObject.h>
#include <Kernel/UnixTypes.h>
namespace Kernel {
namespace Kernel::Memory {
class InodeVMObject : public VMObject {
public:

View file

@ -10,7 +10,7 @@
#include <Kernel/Memory/Region.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {
namespace Kernel::Memory {
class MappedROM {
public:

View file

@ -40,7 +40,7 @@ extern size_t multiboot_copy_boot_modules_count;
// Treat the super pages as logically separate from .bss
__attribute__((section(".super_pages"))) static u8 super_pages[1 * MiB];
namespace Kernel {
namespace Kernel::Memory {
// NOTE: We can NOT use AK::Singleton for this class, because
// MemoryManager::initialize is called *before* global constructors are
@ -49,7 +49,7 @@ namespace Kernel {
static MemoryManager* s_the;
RecursiveSpinLock s_mm_lock;
MemoryManager& MM
MemoryManager& MemoryManager::the()
{
return *s_the;
}

View file

@ -21,7 +21,7 @@
#include <Kernel/Memory/VMObject.h>
#include <Kernel/SpinLock.h>
namespace Kernel {
namespace Kernel::Memory {
constexpr bool page_round_up_would_wrap(FlatPtr x)
{
@ -88,7 +88,7 @@ struct PhysicalMemoryRange {
PhysicalSize length {};
};
#define MM Kernel::MemoryManager::the()
#define MM Kernel::Memory::MemoryManager::the()
struct MemoryManagerData {
static ProcessorSpecificDataID processor_specific_data_id() { return ProcessorSpecificDataID::MemoryManager; }

View file

@ -15,7 +15,7 @@
extern u8 end_of_kernel_image[];
namespace Kernel {
namespace Kernel::Memory {
static AK::Singleton<HashMap<FlatPtr, PageDirectory*>> s_cr3_map;

View file

@ -13,7 +13,7 @@
#include <Kernel/Memory/PhysicalPage.h>
#include <Kernel/Memory/RangeAllocator.h>
namespace Kernel {
namespace Kernel::Memory {
class PageDirectory : public RefCounted<PageDirectory> {
friend class MemoryManager;

View file

@ -8,7 +8,7 @@
#include <Kernel/Memory/MemoryManager.h>
#include <Kernel/Memory/PhysicalPage.h>
namespace Kernel {
namespace Kernel::Memory {
NonnullRefPtr<PhysicalPage> PhysicalPage::create(PhysicalAddress paddr, MayReturnToFreeList may_return_to_freelist)
{

View file

@ -9,7 +9,7 @@
#include <AK/NonnullRefPtr.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {
namespace Kernel::Memory {
enum class MayReturnToFreeList : bool {
No,

View file

@ -12,7 +12,7 @@
#include <Kernel/Memory/PhysicalZone.h>
#include <Kernel/Random.h>
namespace Kernel {
namespace Kernel::Memory {
static constexpr u32 next_power_of_two(u32 value)
{

View file

@ -10,7 +10,7 @@
#include <Kernel/Memory/PhysicalPage.h>
#include <Kernel/Memory/PhysicalZone.h>
namespace Kernel {
namespace Kernel::Memory {
class PhysicalRegion {
AK_MAKE_ETERNAL;

View file

@ -9,7 +9,7 @@
#include <Kernel/Memory/PhysicalPage.h>
#include <Kernel/Memory/PhysicalZone.h>
namespace Kernel {
namespace Kernel::Memory {
PhysicalPageEntry& PhysicalZone::get_freelist_entry(ChunkIndex index) const
{

View file

@ -9,7 +9,7 @@
#include <AK/Bitmap.h>
#include <AK/IntrusiveList.h>
namespace Kernel {
namespace Kernel::Memory {
// A PhysicalZone is an allocator that manages a sub-area of a PhysicalRegion.
// Its total size is always a power of two.

View file

@ -7,7 +7,7 @@
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/Memory/PrivateInodeVMObject.h>
namespace Kernel {
namespace Kernel::Memory {
RefPtr<PrivateInodeVMObject> PrivateInodeVMObject::try_create_with_inode(Inode& inode)
{

View file

@ -10,7 +10,7 @@
#include <Kernel/Memory/InodeVMObject.h>
#include <Kernel/UnixTypes.h>
namespace Kernel {
namespace Kernel::Memory {
class PrivateInodeVMObject final : public InodeVMObject {
AK_MAKE_NONMOVABLE(PrivateInodeVMObject);

View file

@ -10,7 +10,7 @@
#include <Kernel/Memory/Range.h>
#include <LibC/limits.h>
namespace Kernel {
namespace Kernel::Memory {
Vector<Range, 2> Range::carve(const Range& taken) const
{

View file

@ -10,7 +10,7 @@
#include <Kernel/KResult.h>
#include <Kernel/VirtualAddress.h>
namespace Kernel {
namespace Kernel::Memory {
class Range {
friend class RangeAllocator;
@ -61,8 +61,8 @@ private:
}
template<>
struct AK::Formatter<Kernel::Range> : Formatter<FormatString> {
void format(FormatBuilder& builder, Kernel::Range value)
struct AK::Formatter<Kernel::Memory::Range> : Formatter<FormatString> {
void format(FormatBuilder& builder, Kernel::Memory::Range value)
{
return Formatter<FormatString>::format(builder, "{} - {} (size {:p})", value.base().as_ptr(), value.base().offset(value.size() - 1).as_ptr(), value.size());
}

View file

@ -10,7 +10,7 @@
#define VM_GUARD_PAGES
namespace Kernel {
namespace Kernel::Memory {
RangeAllocator::RangeAllocator()
: m_total_range({}, 0)

View file

@ -11,7 +11,7 @@
#include <Kernel/Memory/Range.h>
#include <Kernel/SpinLock.h>
namespace Kernel {
namespace Kernel::Memory {
class RangeAllocator {
public:
@ -42,7 +42,7 @@ private:
namespace AK {
template<>
struct Traits<Kernel::Range> : public GenericTraits<Kernel::Range> {
struct Traits<Kernel::Memory::Range> : public GenericTraits<Kernel::Memory::Range> {
static constexpr bool is_trivial() { return true; }
};
}

View file

@ -17,7 +17,7 @@
#include <Kernel/Process.h>
#include <Kernel/Thread.h>
namespace Kernel {
namespace Kernel::Memory {
Region::Region(Range const& range, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, OwnPtr<KString> name, Region::Access access, Cacheable cacheable, bool shared)
: m_range(range)

View file

@ -18,7 +18,7 @@
#include <Kernel/Sections.h>
#include <Kernel/UnixTypes.h>
namespace Kernel {
namespace Kernel::Memory {
enum class ShouldFlushTLB {
No,

View file

@ -8,7 +8,7 @@
#include <Kernel/Memory/RingBuffer.h>
#include <Kernel/UserOrKernelBuffer.h>
namespace Kernel {
namespace Kernel::Memory {
RingBuffer::RingBuffer(String region_name, size_t capacity)
: m_region(MM.allocate_contiguous_kernel_region(page_round_up(capacity), move(region_name), Region::Access::Read | Region::Access::Write))

View file

@ -10,7 +10,7 @@
#include <Kernel/PhysicalAddress.h>
#include <Kernel/UserOrKernelBuffer.h>
namespace Kernel {
namespace Kernel::Memory {
class RingBuffer {
public:
@ -30,7 +30,7 @@ public:
size_t bytes_till_end() const { return (m_capacity_in_bytes - ((m_start_of_used + m_num_used_bytes) % m_capacity_in_bytes)) % m_capacity_in_bytes; };
private:
OwnPtr<Region> m_region;
OwnPtr<Memory::Region> m_region;
SpinLock<u8> m_lock;
size_t m_start_of_used {};
size_t m_num_used_bytes {};

View file

@ -6,7 +6,7 @@
#include <Kernel/Memory/ScatterGatherList.h>
namespace Kernel {
namespace Kernel::Memory {
RefPtr<ScatterGatherList> ScatterGatherList::try_create(AsyncBlockDeviceRequest& request, Span<NonnullRefPtr<PhysicalPage>> allocated_pages, size_t device_block_size)
{

View file

@ -12,7 +12,7 @@
#include <Kernel/Memory/MemoryManager.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {
namespace Kernel::Memory {
// A Scatter-Gather List type that owns its buffers

View file

@ -7,7 +7,7 @@
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/Memory/SharedInodeVMObject.h>
namespace Kernel {
namespace Kernel::Memory {
RefPtr<SharedInodeVMObject> SharedInodeVMObject::try_create_with_inode(Inode& inode)
{

View file

@ -10,7 +10,7 @@
#include <Kernel/Memory/InodeVMObject.h>
#include <Kernel/UnixTypes.h>
namespace Kernel {
namespace Kernel::Memory {
class SharedInodeVMObject final : public InodeVMObject {
AK_MAKE_NONMOVABLE(SharedInodeVMObject);

View file

@ -13,7 +13,7 @@
#include <Kernel/Process.h>
#include <Kernel/SpinLock.h>
namespace Kernel {
namespace Kernel::Memory {
OwnPtr<Space> Space::try_create(Process& process, Space const* parent)
{

View file

@ -14,7 +14,7 @@
#include <Kernel/Memory/PageDirectory.h>
#include <Kernel/UnixTypes.h>
namespace Kernel {
namespace Kernel::Memory {
class Space {
public:

View file

@ -9,7 +9,7 @@
#include <AK/StringView.h>
#include <Kernel/Memory/MemoryManager.h>
namespace Kernel {
namespace Kernel::Memory {
template<typename T>
struct TypedMapping {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -7,7 +7,7 @@
#include <Kernel/Memory/MemoryManager.h>
#include <Kernel/Memory/VMObject.h>
namespace Kernel {
namespace Kernel::Memory {
VMObject::VMObject(VMObject const& other)
: m_physical_pages(other.m_physical_pages)

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -17,7 +17,7 @@
#include <Kernel/Memory/Region.h>
#include <Kernel/Mutex.h>
namespace Kernel {
namespace Kernel::Memory {
class VMObjectDeletedHandler {
public: