2#include "pedigree/kernel/processor/PhysicalMemoryManager.h"
3#include "pedigree/kernel/processor/Processor.h"
4#include "pedigree/kernel/processor/ProcessorInformation.h"
8SwapStatus MemoryMapManager::activateSwap(uint32_t endpoint) {
9 OperationGuard operation(*
this);
10 return SwapStore::instance().activate(endpoint);
12SwapStatus MemoryMapManager::deactivateSwap(uint32_t endpoint) {
13 OperationGuard operation(*
this);
14 auto& store = SwapStore::instance();
15 if (!endpoint || store.endpointId() != endpoint)
16 return SwapStatus::NotActive;
18 SwapStatus status = SwapStatus::Success;
21 for (
auto*
object : *spaces.value()) {
22 status =
object->restoreSwapPages(*spaces.key());
23 if (status != SwapStatus::Success)
26 if (status != SwapStatus::Success)
30 return status == SwapStatus::Success ? store.finishDeactivate(endpoint) : status;
33 OperationGuard operation(*
this);
34 return SwapStore::instance().snapshot();
37SwapStatus MemoryMapManager::pageOutRange(uintptr_t base,
size_t length) {
38 OperationGuard operation(*
this);
40 if ((base & (pageSize - 1)) || (length & (pageSize - 1)) || length > ~uintptr_t(0) - base)
41 return SwapStatus::Invalid;
42 if (!SwapStore::instance().snapshot().active)
43 return SwapStatus::NotActive;
48 for (
size_t pass = 0; pass < 2; ++pass) {
49 for (uintptr_t address = base; address < base + length; address += pageSize) {
52 for (
auto*
object : *objects)
53 if (object->matches(address)) {
58 return SwapStatus::Unmapped;
59 if (!owner->supportsPageOut(space, address))
60 return SwapStatus::Unsupported;
62 bool released =
false;
63 const auto status = owner->pageOutAt(space, address, released);
64 if (status != SwapStatus::Success)
69 return SwapStatus::Success;
Memory-mapped file interface.
Tree< VirtualAddressSpace *, MmObjectList * > m_MmObjectLists
static constexpr size_t getPageSize() PURE
static ProcessorInformation & information()
static void switchAddressSpace(VirtualAddressSpace &AddressSpace)