/* * Copyright (c) 2018-2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include namespace Kernel::Memory { static Singleton> s_all_instances; SpinlockProtected& VMObject::all_instances() { return s_all_instances; } ErrorOr>> VMObject::try_clone_physical_pages() const { return m_physical_pages.try_clone(); } ErrorOr>> VMObject::try_create_physical_pages(size_t size) { return FixedArray>::try_create(ceil_div(size, static_cast(PAGE_SIZE))); } VMObject::VMObject(FixedArray>&& new_physical_pages) : m_physical_pages(move(new_physical_pages)) { all_instances().with([&](auto& list) { list.append(*this); }); } VMObject::~VMObject() { VERIFY(m_regions.is_empty()); } }