mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-23 03:05:41 +01:00
core: kernel: Replace instances of KPageLinkedList with KPageGroup
This commit is contained in:
parent
a7d9be1384
commit
7b48e7b363
@ -222,7 +222,7 @@ add_library(core STATIC
|
|||||||
hle/kernel/k_page_buffer.h
|
hle/kernel/k_page_buffer.h
|
||||||
hle/kernel/k_page_heap.cpp
|
hle/kernel/k_page_heap.cpp
|
||||||
hle/kernel/k_page_heap.h
|
hle/kernel/k_page_heap.h
|
||||||
hle/kernel/k_page_linked_list.h
|
hle/kernel/k_page_group.h
|
||||||
hle/kernel/k_page_table.cpp
|
hle/kernel/k_page_table.cpp
|
||||||
hle/kernel/k_page_table.h
|
hle/kernel/k_page_table.h
|
||||||
hle/kernel/k_port.cpp
|
hle/kernel/k_port.cpp
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "core/hle/kernel/k_code_memory.h"
|
#include "core/hle/kernel/k_code_memory.h"
|
||||||
#include "core/hle/kernel/k_light_lock.h"
|
#include "core/hle/kernel/k_light_lock.h"
|
||||||
#include "core/hle/kernel/k_memory_block.h"
|
#include "core/hle/kernel/k_memory_block.h"
|
||||||
#include "core/hle/kernel/k_page_linked_list.h"
|
#include "core/hle/kernel/k_page_group.h"
|
||||||
#include "core/hle/kernel/k_page_table.h"
|
#include "core/hle/kernel/k_page_table.h"
|
||||||
#include "core/hle/kernel/k_process.h"
|
#include "core/hle/kernel/k_process.h"
|
||||||
#include "core/hle/kernel/slab_helpers.h"
|
#include "core/hle/kernel/slab_helpers.h"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "core/device_memory.h"
|
#include "core/device_memory.h"
|
||||||
#include "core/hle/kernel/k_auto_object.h"
|
#include "core/hle/kernel/k_auto_object.h"
|
||||||
#include "core/hle/kernel/k_light_lock.h"
|
#include "core/hle/kernel/k_light_lock.h"
|
||||||
#include "core/hle/kernel/k_page_linked_list.h"
|
#include "core/hle/kernel/k_page_group.h"
|
||||||
#include "core/hle/kernel/k_process.h"
|
#include "core/hle/kernel/k_process.h"
|
||||||
#include "core/hle/kernel/slab_helpers.h"
|
#include "core/hle/kernel/slab_helpers.h"
|
||||||
#include "core/hle/kernel/svc_types.h"
|
#include "core/hle/kernel/svc_types.h"
|
||||||
@ -53,7 +53,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KPageLinkedList m_page_group{};
|
KPageGroup m_page_group{};
|
||||||
KProcess* m_owner{};
|
KProcess* m_owner{};
|
||||||
VAddr m_address{};
|
VAddr m_address{};
|
||||||
KLightLock m_lock;
|
KLightLock m_lock;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "core/device_memory.h"
|
#include "core/device_memory.h"
|
||||||
#include "core/hle/kernel/initial_process.h"
|
#include "core/hle/kernel/initial_process.h"
|
||||||
#include "core/hle/kernel/k_memory_manager.h"
|
#include "core/hle/kernel/k_memory_manager.h"
|
||||||
#include "core/hle/kernel/k_page_linked_list.h"
|
#include "core/hle/kernel/k_page_group.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/svc_results.h"
|
#include "core/hle/kernel/svc_results.h"
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ PAddr KMemoryManager::AllocateAndOpenContinuous(size_t num_pages, size_t align_p
|
|||||||
return allocated_block;
|
return allocated_block;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result KMemoryManager::AllocatePageGroupImpl(KPageLinkedList* out, size_t num_pages, Pool pool,
|
Result KMemoryManager::AllocatePageGroupImpl(KPageGroup* out, size_t num_pages, Pool pool,
|
||||||
Direction dir, bool random) {
|
Direction dir, bool random) {
|
||||||
// Choose a heap based on our page size request.
|
// Choose a heap based on our page size request.
|
||||||
const s32 heap_index = KPageHeap::GetBlockIndex(num_pages);
|
const s32 heap_index = KPageHeap::GetBlockIndex(num_pages);
|
||||||
@ -257,7 +257,7 @@ Result KMemoryManager::AllocatePageGroupImpl(KPageLinkedList* out, size_t num_pa
|
|||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result KMemoryManager::AllocateAndOpen(KPageLinkedList* out, size_t num_pages, u32 option) {
|
Result KMemoryManager::AllocateAndOpen(KPageGroup* out, size_t num_pages, u32 option) {
|
||||||
ASSERT(out != nullptr);
|
ASSERT(out != nullptr);
|
||||||
ASSERT(out->GetNumPages() == 0);
|
ASSERT(out->GetNumPages() == 0);
|
||||||
|
|
||||||
@ -293,7 +293,7 @@ Result KMemoryManager::AllocateAndOpen(KPageLinkedList* out, size_t num_pages, u
|
|||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result KMemoryManager::AllocateAndOpenForProcess(KPageLinkedList* out, size_t num_pages, u32 option,
|
Result KMemoryManager::AllocateAndOpenForProcess(KPageGroup* out, size_t num_pages, u32 option,
|
||||||
u64 process_id, u8 fill_pattern) {
|
u64 process_id, u8 fill_pattern) {
|
||||||
ASSERT(out != nullptr);
|
ASSERT(out != nullptr);
|
||||||
ASSERT(out->GetNumPages() == 0);
|
ASSERT(out->GetNumPages() == 0);
|
||||||
@ -370,12 +370,12 @@ void KMemoryManager::Close(PAddr address, size_t num_pages) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMemoryManager::Close(const KPageLinkedList& pg) {
|
void KMemoryManager::Close(const KPageGroup& pg) {
|
||||||
for (const auto& node : pg.Nodes()) {
|
for (const auto& node : pg.Nodes()) {
|
||||||
Close(node.GetAddress(), node.GetNumPages());
|
Close(node.GetAddress(), node.GetNumPages());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void KMemoryManager::Open(const KPageLinkedList& pg) {
|
void KMemoryManager::Open(const KPageGroup& pg) {
|
||||||
for (const auto& node : pg.Nodes()) {
|
for (const auto& node : pg.Nodes()) {
|
||||||
Open(node.GetAddress(), node.GetNumPages());
|
Open(node.GetAddress(), node.GetNumPages());
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ class System;
|
|||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
class KPageLinkedList;
|
class KPageGroup;
|
||||||
|
|
||||||
class KMemoryManager final {
|
class KMemoryManager final {
|
||||||
public:
|
public:
|
||||||
@ -65,17 +65,17 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
PAddr AllocateAndOpenContinuous(size_t num_pages, size_t align_pages, u32 option);
|
PAddr AllocateAndOpenContinuous(size_t num_pages, size_t align_pages, u32 option);
|
||||||
Result AllocateAndOpen(KPageLinkedList* out, size_t num_pages, u32 option);
|
Result AllocateAndOpen(KPageGroup* out, size_t num_pages, u32 option);
|
||||||
Result AllocateAndOpenForProcess(KPageLinkedList* out, size_t num_pages, u32 option,
|
Result AllocateAndOpenForProcess(KPageGroup* out, size_t num_pages, u32 option, u64 process_id,
|
||||||
u64 process_id, u8 fill_pattern);
|
u8 fill_pattern);
|
||||||
|
|
||||||
static constexpr size_t MaxManagerCount = 10;
|
static constexpr size_t MaxManagerCount = 10;
|
||||||
|
|
||||||
void Close(PAddr address, size_t num_pages);
|
void Close(PAddr address, size_t num_pages);
|
||||||
void Close(const KPageLinkedList& pg);
|
void Close(const KPageGroup& pg);
|
||||||
|
|
||||||
void Open(PAddr address, size_t num_pages);
|
void Open(PAddr address, size_t num_pages);
|
||||||
void Open(const KPageLinkedList& pg);
|
void Open(const KPageGroup& pg);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static size_t CalculateManagementOverheadSize(size_t region_size) {
|
static size_t CalculateManagementOverheadSize(size_t region_size) {
|
||||||
@ -262,7 +262,7 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result AllocatePageGroupImpl(KPageLinkedList* out, size_t num_pages, Pool pool, Direction dir,
|
Result AllocatePageGroupImpl(KPageGroup* out, size_t num_pages, Pool pool, Direction dir,
|
||||||
bool random);
|
bool random);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
class KPageLinkedList final {
|
class KPageGroup final {
|
||||||
public:
|
public:
|
||||||
class Node final {
|
class Node final {
|
||||||
public:
|
public:
|
||||||
@ -36,8 +36,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
KPageLinkedList() = default;
|
KPageGroup() = default;
|
||||||
KPageLinkedList(u64 address, u64 num_pages) {
|
KPageGroup(u64 address, u64 num_pages) {
|
||||||
ASSERT(AddBlock(address, num_pages).IsSuccess());
|
ASSERT(AddBlock(address, num_pages).IsSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public:
|
|||||||
return num_pages;
|
return num_pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsEqual(KPageLinkedList& other) const {
|
bool IsEqual(KPageGroup& other) const {
|
||||||
auto this_node = nodes.begin();
|
auto this_node = nodes.begin();
|
||||||
auto other_node = other.nodes.begin();
|
auto other_node = other.nodes.begin();
|
||||||
while (this_node != nodes.end() && other_node != other.nodes.end()) {
|
while (this_node != nodes.end() && other_node != other.nodes.end()) {
|
@ -9,7 +9,7 @@
|
|||||||
#include "core/hle/kernel/k_address_space_info.h"
|
#include "core/hle/kernel/k_address_space_info.h"
|
||||||
#include "core/hle/kernel/k_memory_block.h"
|
#include "core/hle/kernel/k_memory_block.h"
|
||||||
#include "core/hle/kernel/k_memory_block_manager.h"
|
#include "core/hle/kernel/k_memory_block_manager.h"
|
||||||
#include "core/hle/kernel/k_page_linked_list.h"
|
#include "core/hle/kernel/k_page_group.h"
|
||||||
#include "core/hle/kernel/k_page_table.h"
|
#include "core/hle/kernel/k_page_table.h"
|
||||||
#include "core/hle/kernel/k_process.h"
|
#include "core/hle/kernel/k_process.h"
|
||||||
#include "core/hle/kernel/k_resource_limit.h"
|
#include "core/hle/kernel/k_resource_limit.h"
|
||||||
@ -271,7 +271,7 @@ Result KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemoryStat
|
|||||||
R_TRY(this->CheckMemoryState(addr, size, KMemoryState::All, KMemoryState::Free,
|
R_TRY(this->CheckMemoryState(addr, size, KMemoryState::All, KMemoryState::Free,
|
||||||
KMemoryPermission::None, KMemoryPermission::None,
|
KMemoryPermission::None, KMemoryPermission::None,
|
||||||
KMemoryAttribute::None, KMemoryAttribute::None));
|
KMemoryAttribute::None, KMemoryAttribute::None));
|
||||||
KPageLinkedList pg;
|
KPageGroup pg;
|
||||||
R_TRY(system.Kernel().MemoryManager().AllocateAndOpen(
|
R_TRY(system.Kernel().MemoryManager().AllocateAndOpen(
|
||||||
&pg, num_pages,
|
&pg, num_pages,
|
||||||
KMemoryManager::EncodeOption(KMemoryManager::Pool::Application, allocation_option)));
|
KMemoryManager::EncodeOption(KMemoryManager::Pool::Application, allocation_option)));
|
||||||
@ -313,7 +313,7 @@ Result KPageTable::MapCodeMemory(VAddr dst_address, VAddr src_address, std::size
|
|||||||
const std::size_t num_pages = size / PageSize;
|
const std::size_t num_pages = size / PageSize;
|
||||||
|
|
||||||
// Create page groups for the memory being mapped.
|
// Create page groups for the memory being mapped.
|
||||||
KPageLinkedList pg;
|
KPageGroup pg;
|
||||||
AddRegionToPages(src_address, num_pages, pg);
|
AddRegionToPages(src_address, num_pages, pg);
|
||||||
|
|
||||||
// Reprotect the source as kernel-read/not mapped.
|
// Reprotect the source as kernel-read/not mapped.
|
||||||
@ -489,7 +489,7 @@ VAddr KPageTable::FindFreeArea(VAddr region_start, std::size_t region_num_pages,
|
|||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result KPageTable::MakePageGroup(KPageLinkedList& pg, VAddr addr, size_t num_pages) {
|
Result KPageTable::MakePageGroup(KPageGroup& pg, VAddr addr, size_t num_pages) {
|
||||||
ASSERT(this->IsLockedByCurrentThread());
|
ASSERT(this->IsLockedByCurrentThread());
|
||||||
|
|
||||||
const size_t size = num_pages * PageSize;
|
const size_t size = num_pages * PageSize;
|
||||||
@ -541,7 +541,7 @@ Result KPageTable::MakePageGroup(KPageLinkedList& pg, VAddr addr, size_t num_pag
|
|||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KPageTable::IsValidPageGroup(const KPageLinkedList& pg_ll, VAddr addr, size_t num_pages) {
|
bool KPageTable::IsValidPageGroup(const KPageGroup& pg_ll, VAddr addr, size_t num_pages) {
|
||||||
ASSERT(this->IsLockedByCurrentThread());
|
ASSERT(this->IsLockedByCurrentThread());
|
||||||
|
|
||||||
const size_t size = num_pages * PageSize;
|
const size_t size = num_pages * PageSize;
|
||||||
@ -721,7 +721,7 @@ Result KPageTable::MapPhysicalMemory(VAddr address, std::size_t size) {
|
|||||||
R_UNLESS(memory_reservation.Succeeded(), ResultLimitReached);
|
R_UNLESS(memory_reservation.Succeeded(), ResultLimitReached);
|
||||||
|
|
||||||
// Allocate pages for the new memory.
|
// Allocate pages for the new memory.
|
||||||
KPageLinkedList pg;
|
KPageGroup pg;
|
||||||
R_TRY(system.Kernel().MemoryManager().AllocateAndOpenForProcess(
|
R_TRY(system.Kernel().MemoryManager().AllocateAndOpenForProcess(
|
||||||
&pg, (size - mapped_size) / PageSize,
|
&pg, (size - mapped_size) / PageSize,
|
||||||
KMemoryManager::EncodeOption(memory_pool, allocation_option), 0, 0));
|
KMemoryManager::EncodeOption(memory_pool, allocation_option), 0, 0));
|
||||||
@ -972,7 +972,7 @@ Result KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make a page group for the unmap region.
|
// Make a page group for the unmap region.
|
||||||
KPageLinkedList pg;
|
KPageGroup pg;
|
||||||
{
|
{
|
||||||
auto& impl = this->PageTableImpl();
|
auto& impl = this->PageTableImpl();
|
||||||
|
|
||||||
@ -1147,7 +1147,7 @@ Result KPageTable::MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) {
|
|||||||
return ResultInvalidCurrentMemory;
|
return ResultInvalidCurrentMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
KPageLinkedList page_linked_list;
|
KPageGroup page_linked_list;
|
||||||
const std::size_t num_pages{size / PageSize};
|
const std::size_t num_pages{size / PageSize};
|
||||||
|
|
||||||
AddRegionToPages(src_addr, num_pages, page_linked_list);
|
AddRegionToPages(src_addr, num_pages, page_linked_list);
|
||||||
@ -1188,8 +1188,8 @@ Result KPageTable::UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size)
|
|||||||
KMemoryPermission::None, KMemoryAttribute::Mask,
|
KMemoryPermission::None, KMemoryAttribute::Mask,
|
||||||
KMemoryAttribute::None, KMemoryAttribute::IpcAndDeviceMapped));
|
KMemoryAttribute::None, KMemoryAttribute::IpcAndDeviceMapped));
|
||||||
|
|
||||||
KPageLinkedList src_pages;
|
KPageGroup src_pages;
|
||||||
KPageLinkedList dst_pages;
|
KPageGroup dst_pages;
|
||||||
const std::size_t num_pages{size / PageSize};
|
const std::size_t num_pages{size / PageSize};
|
||||||
|
|
||||||
AddRegionToPages(src_addr, num_pages, src_pages);
|
AddRegionToPages(src_addr, num_pages, src_pages);
|
||||||
@ -1215,7 +1215,7 @@ Result KPageTable::UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size)
|
|||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result KPageTable::MapPages(VAddr addr, const KPageLinkedList& page_linked_list,
|
Result KPageTable::MapPages(VAddr addr, const KPageGroup& page_linked_list,
|
||||||
KMemoryPermission perm) {
|
KMemoryPermission perm) {
|
||||||
ASSERT(this->IsLockedByCurrentThread());
|
ASSERT(this->IsLockedByCurrentThread());
|
||||||
|
|
||||||
@ -1239,7 +1239,7 @@ Result KPageTable::MapPages(VAddr addr, const KPageLinkedList& page_linked_list,
|
|||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result KPageTable::MapPages(VAddr address, KPageLinkedList& page_linked_list, KMemoryState state,
|
Result KPageTable::MapPages(VAddr address, KPageGroup& page_linked_list, KMemoryState state,
|
||||||
KMemoryPermission perm) {
|
KMemoryPermission perm) {
|
||||||
// Check that the map is in range.
|
// Check that the map is in range.
|
||||||
const std::size_t num_pages{page_linked_list.GetNumPages()};
|
const std::size_t num_pages{page_linked_list.GetNumPages()};
|
||||||
@ -1303,7 +1303,7 @@ Result KPageTable::MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t
|
|||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result KPageTable::UnmapPages(VAddr addr, const KPageLinkedList& page_linked_list) {
|
Result KPageTable::UnmapPages(VAddr addr, const KPageGroup& page_linked_list) {
|
||||||
ASSERT(this->IsLockedByCurrentThread());
|
ASSERT(this->IsLockedByCurrentThread());
|
||||||
|
|
||||||
VAddr cur_addr{addr};
|
VAddr cur_addr{addr};
|
||||||
@ -1321,7 +1321,7 @@ Result KPageTable::UnmapPages(VAddr addr, const KPageLinkedList& page_linked_lis
|
|||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result KPageTable::UnmapPages(VAddr addr, KPageLinkedList& page_linked_list, KMemoryState state) {
|
Result KPageTable::UnmapPages(VAddr addr, KPageGroup& page_linked_list, KMemoryState state) {
|
||||||
// Check that the unmap is in range.
|
// Check that the unmap is in range.
|
||||||
const std::size_t num_pages{page_linked_list.GetNumPages()};
|
const std::size_t num_pages{page_linked_list.GetNumPages()};
|
||||||
const std::size_t size{num_pages * PageSize};
|
const std::size_t size{num_pages * PageSize};
|
||||||
@ -1368,7 +1368,7 @@ Result KPageTable::UnmapPages(VAddr address, std::size_t num_pages, KMemoryState
|
|||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result KPageTable::MakeAndOpenPageGroup(KPageLinkedList* out, VAddr address, size_t num_pages,
|
Result KPageTable::MakeAndOpenPageGroup(KPageGroup* out, VAddr address, size_t num_pages,
|
||||||
KMemoryState state_mask, KMemoryState state,
|
KMemoryState state_mask, KMemoryState state,
|
||||||
KMemoryPermission perm_mask, KMemoryPermission perm,
|
KMemoryPermission perm_mask, KMemoryPermission perm,
|
||||||
KMemoryAttribute attr_mask, KMemoryAttribute attr) {
|
KMemoryAttribute attr_mask, KMemoryAttribute attr) {
|
||||||
@ -1641,7 +1641,7 @@ Result KPageTable::SetHeapSize(VAddr* out, std::size_t size) {
|
|||||||
R_UNLESS(memory_reservation.Succeeded(), ResultLimitReached);
|
R_UNLESS(memory_reservation.Succeeded(), ResultLimitReached);
|
||||||
|
|
||||||
// Allocate pages for the heap extension.
|
// Allocate pages for the heap extension.
|
||||||
KPageLinkedList pg;
|
KPageGroup pg;
|
||||||
R_TRY(system.Kernel().MemoryManager().AllocateAndOpen(
|
R_TRY(system.Kernel().MemoryManager().AllocateAndOpen(
|
||||||
&pg, allocation_size / PageSize,
|
&pg, allocation_size / PageSize,
|
||||||
KMemoryManager::EncodeOption(memory_pool, allocation_option)));
|
KMemoryManager::EncodeOption(memory_pool, allocation_option)));
|
||||||
@ -1716,7 +1716,7 @@ ResultVal<VAddr> KPageTable::AllocateAndMapMemory(std::size_t needed_num_pages,
|
|||||||
if (is_map_only) {
|
if (is_map_only) {
|
||||||
R_TRY(Operate(addr, needed_num_pages, perm, OperationType::Map, map_addr));
|
R_TRY(Operate(addr, needed_num_pages, perm, OperationType::Map, map_addr));
|
||||||
} else {
|
} else {
|
||||||
KPageLinkedList page_group;
|
KPageGroup page_group;
|
||||||
R_TRY(system.Kernel().MemoryManager().AllocateAndOpenForProcess(
|
R_TRY(system.Kernel().MemoryManager().AllocateAndOpenForProcess(
|
||||||
&page_group, needed_num_pages,
|
&page_group, needed_num_pages,
|
||||||
KMemoryManager::EncodeOption(memory_pool, allocation_option), 0, 0));
|
KMemoryManager::EncodeOption(memory_pool, allocation_option), 0, 0));
|
||||||
@ -1774,7 +1774,7 @@ Result KPageTable::UnlockForDeviceAddressSpace(VAddr addr, std::size_t size) {
|
|||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result KPageTable::LockForCodeMemory(KPageLinkedList* out, VAddr addr, std::size_t size) {
|
Result KPageTable::LockForCodeMemory(KPageGroup* out, VAddr addr, std::size_t size) {
|
||||||
return this->LockMemoryAndOpen(
|
return this->LockMemoryAndOpen(
|
||||||
out, nullptr, addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory,
|
out, nullptr, addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory,
|
||||||
KMemoryPermission::All, KMemoryPermission::UserReadWrite, KMemoryAttribute::All,
|
KMemoryPermission::All, KMemoryPermission::UserReadWrite, KMemoryAttribute::All,
|
||||||
@ -1784,7 +1784,7 @@ Result KPageTable::LockForCodeMemory(KPageLinkedList* out, VAddr addr, std::size
|
|||||||
KMemoryAttribute::Locked);
|
KMemoryAttribute::Locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result KPageTable::UnlockForCodeMemory(VAddr addr, std::size_t size, const KPageLinkedList& pg) {
|
Result KPageTable::UnlockForCodeMemory(VAddr addr, std::size_t size, const KPageGroup& pg) {
|
||||||
return this->UnlockMemory(
|
return this->UnlockMemory(
|
||||||
addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory,
|
addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory,
|
||||||
KMemoryPermission::None, KMemoryPermission::None, KMemoryAttribute::All,
|
KMemoryPermission::None, KMemoryPermission::None, KMemoryAttribute::All,
|
||||||
@ -1816,7 +1816,7 @@ bool KPageTable::IsRegionContiguous(VAddr addr, u64 size) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void KPageTable::AddRegionToPages(VAddr start, std::size_t num_pages,
|
void KPageTable::AddRegionToPages(VAddr start, std::size_t num_pages,
|
||||||
KPageLinkedList& page_linked_list) {
|
KPageGroup& page_linked_list) {
|
||||||
VAddr addr{start};
|
VAddr addr{start};
|
||||||
while (addr < start + (num_pages * PageSize)) {
|
while (addr < start + (num_pages * PageSize)) {
|
||||||
const PAddr paddr{GetPhysicalAddr(addr)};
|
const PAddr paddr{GetPhysicalAddr(addr)};
|
||||||
@ -1835,7 +1835,7 @@ VAddr KPageTable::AllocateVirtualMemory(VAddr start, std::size_t region_num_page
|
|||||||
IsKernel() ? 1 : 4);
|
IsKernel() ? 1 : 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result KPageTable::Operate(VAddr addr, std::size_t num_pages, const KPageLinkedList& page_group,
|
Result KPageTable::Operate(VAddr addr, std::size_t num_pages, const KPageGroup& page_group,
|
||||||
OperationType operation) {
|
OperationType operation) {
|
||||||
ASSERT(this->IsLockedByCurrentThread());
|
ASSERT(this->IsLockedByCurrentThread());
|
||||||
|
|
||||||
@ -2119,8 +2119,8 @@ Result KPageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermission*
|
|||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result KPageTable::LockMemoryAndOpen(KPageLinkedList* out_pg, PAddr* out_paddr, VAddr addr,
|
Result KPageTable::LockMemoryAndOpen(KPageGroup* out_pg, PAddr* out_paddr, VAddr addr, size_t size,
|
||||||
size_t size, KMemoryState state_mask, KMemoryState state,
|
KMemoryState state_mask, KMemoryState state,
|
||||||
KMemoryPermission perm_mask, KMemoryPermission perm,
|
KMemoryPermission perm_mask, KMemoryPermission perm,
|
||||||
KMemoryAttribute attr_mask, KMemoryAttribute attr,
|
KMemoryAttribute attr_mask, KMemoryAttribute attr,
|
||||||
KMemoryPermission new_perm, KMemoryAttribute lock_attr) {
|
KMemoryPermission new_perm, KMemoryAttribute lock_attr) {
|
||||||
@ -2181,7 +2181,7 @@ Result KPageTable::UnlockMemory(VAddr addr, size_t size, KMemoryState state_mask
|
|||||||
KMemoryState state, KMemoryPermission perm_mask,
|
KMemoryState state, KMemoryPermission perm_mask,
|
||||||
KMemoryPermission perm, KMemoryAttribute attr_mask,
|
KMemoryPermission perm, KMemoryAttribute attr_mask,
|
||||||
KMemoryAttribute attr, KMemoryPermission new_perm,
|
KMemoryAttribute attr, KMemoryPermission new_perm,
|
||||||
KMemoryAttribute lock_attr, const KPageLinkedList* pg) {
|
KMemoryAttribute lock_attr, const KPageGroup* pg) {
|
||||||
// Validate basic preconditions.
|
// Validate basic preconditions.
|
||||||
ASSERT((attr_mask & lock_attr) == lock_attr);
|
ASSERT((attr_mask & lock_attr) == lock_attr);
|
||||||
ASSERT((attr & lock_attr) == lock_attr);
|
ASSERT((attr & lock_attr) == lock_attr);
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
Result UnmapPhysicalMemory(VAddr addr, std::size_t size);
|
Result UnmapPhysicalMemory(VAddr addr, std::size_t size);
|
||||||
Result MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size);
|
Result MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size);
|
||||||
Result UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size);
|
Result UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size);
|
||||||
Result MapPages(VAddr addr, KPageLinkedList& page_linked_list, KMemoryState state,
|
Result MapPages(VAddr addr, KPageGroup& page_linked_list, KMemoryState state,
|
||||||
KMemoryPermission perm);
|
KMemoryPermission perm);
|
||||||
Result MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, PAddr phys_addr,
|
Result MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, PAddr phys_addr,
|
||||||
KMemoryState state, KMemoryPermission perm) {
|
KMemoryState state, KMemoryPermission perm) {
|
||||||
@ -54,7 +54,7 @@ public:
|
|||||||
this->GetRegionAddress(state), this->GetRegionSize(state) / PageSize,
|
this->GetRegionAddress(state), this->GetRegionSize(state) / PageSize,
|
||||||
state, perm);
|
state, perm);
|
||||||
}
|
}
|
||||||
Result UnmapPages(VAddr addr, KPageLinkedList& page_linked_list, KMemoryState state);
|
Result UnmapPages(VAddr addr, KPageGroup& page_linked_list, KMemoryState state);
|
||||||
Result UnmapPages(VAddr address, std::size_t num_pages, KMemoryState state);
|
Result UnmapPages(VAddr address, std::size_t num_pages, KMemoryState state);
|
||||||
Result SetProcessMemoryPermission(VAddr addr, std::size_t size, Svc::MemoryPermission svc_perm);
|
Result SetProcessMemoryPermission(VAddr addr, std::size_t size, Svc::MemoryPermission svc_perm);
|
||||||
KMemoryInfo QueryInfo(VAddr addr);
|
KMemoryInfo QueryInfo(VAddr addr);
|
||||||
@ -70,9 +70,9 @@ public:
|
|||||||
KMemoryPermission perm, PAddr map_addr = 0);
|
KMemoryPermission perm, PAddr map_addr = 0);
|
||||||
Result LockForDeviceAddressSpace(VAddr addr, std::size_t size);
|
Result LockForDeviceAddressSpace(VAddr addr, std::size_t size);
|
||||||
Result UnlockForDeviceAddressSpace(VAddr addr, std::size_t size);
|
Result UnlockForDeviceAddressSpace(VAddr addr, std::size_t size);
|
||||||
Result LockForCodeMemory(KPageLinkedList* out, VAddr addr, std::size_t size);
|
Result LockForCodeMemory(KPageGroup* out, VAddr addr, std::size_t size);
|
||||||
Result UnlockForCodeMemory(VAddr addr, std::size_t size, const KPageLinkedList& pg);
|
Result UnlockForCodeMemory(VAddr addr, std::size_t size, const KPageGroup& pg);
|
||||||
Result MakeAndOpenPageGroup(KPageLinkedList* out, VAddr address, size_t num_pages,
|
Result MakeAndOpenPageGroup(KPageGroup* out, VAddr address, size_t num_pages,
|
||||||
KMemoryState state_mask, KMemoryState state,
|
KMemoryState state_mask, KMemoryState state,
|
||||||
KMemoryPermission perm_mask, KMemoryPermission perm,
|
KMemoryPermission perm_mask, KMemoryPermission perm,
|
||||||
KMemoryAttribute attr_mask, KMemoryAttribute attr);
|
KMemoryAttribute attr_mask, KMemoryAttribute attr);
|
||||||
@ -101,18 +101,18 @@ private:
|
|||||||
KMemoryAttribute::DeviceShared;
|
KMemoryAttribute::DeviceShared;
|
||||||
|
|
||||||
Result InitializeMemoryLayout(VAddr start, VAddr end);
|
Result InitializeMemoryLayout(VAddr start, VAddr end);
|
||||||
Result MapPages(VAddr addr, const KPageLinkedList& page_linked_list, KMemoryPermission perm);
|
Result MapPages(VAddr addr, const KPageGroup& page_linked_list, KMemoryPermission perm);
|
||||||
Result MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, PAddr phys_addr,
|
Result MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, PAddr phys_addr,
|
||||||
bool is_pa_valid, VAddr region_start, std::size_t region_num_pages,
|
bool is_pa_valid, VAddr region_start, std::size_t region_num_pages,
|
||||||
KMemoryState state, KMemoryPermission perm);
|
KMemoryState state, KMemoryPermission perm);
|
||||||
Result UnmapPages(VAddr addr, const KPageLinkedList& page_linked_list);
|
Result UnmapPages(VAddr addr, const KPageGroup& page_linked_list);
|
||||||
bool IsRegionMapped(VAddr address, u64 size);
|
bool IsRegionMapped(VAddr address, u64 size);
|
||||||
bool IsRegionContiguous(VAddr addr, u64 size) const;
|
bool IsRegionContiguous(VAddr addr, u64 size) const;
|
||||||
void AddRegionToPages(VAddr start, std::size_t num_pages, KPageLinkedList& page_linked_list);
|
void AddRegionToPages(VAddr start, std::size_t num_pages, KPageGroup& page_linked_list);
|
||||||
KMemoryInfo QueryInfoImpl(VAddr addr);
|
KMemoryInfo QueryInfoImpl(VAddr addr);
|
||||||
VAddr AllocateVirtualMemory(VAddr start, std::size_t region_num_pages, u64 needed_num_pages,
|
VAddr AllocateVirtualMemory(VAddr start, std::size_t region_num_pages, u64 needed_num_pages,
|
||||||
std::size_t align);
|
std::size_t align);
|
||||||
Result Operate(VAddr addr, std::size_t num_pages, const KPageLinkedList& page_group,
|
Result Operate(VAddr addr, std::size_t num_pages, const KPageGroup& page_group,
|
||||||
OperationType operation);
|
OperationType operation);
|
||||||
Result Operate(VAddr addr, std::size_t num_pages, KMemoryPermission perm,
|
Result Operate(VAddr addr, std::size_t num_pages, KMemoryPermission perm,
|
||||||
OperationType operation, PAddr map_addr = 0);
|
OperationType operation, PAddr map_addr = 0);
|
||||||
@ -159,7 +159,7 @@ private:
|
|||||||
attr_mask, attr, ignore_attr);
|
attr_mask, attr, ignore_attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result LockMemoryAndOpen(KPageLinkedList* out_pg, PAddr* out_paddr, VAddr addr, size_t size,
|
Result LockMemoryAndOpen(KPageGroup* out_pg, PAddr* out_paddr, VAddr addr, size_t size,
|
||||||
KMemoryState state_mask, KMemoryState state,
|
KMemoryState state_mask, KMemoryState state,
|
||||||
KMemoryPermission perm_mask, KMemoryPermission perm,
|
KMemoryPermission perm_mask, KMemoryPermission perm,
|
||||||
KMemoryAttribute attr_mask, KMemoryAttribute attr,
|
KMemoryAttribute attr_mask, KMemoryAttribute attr,
|
||||||
@ -168,10 +168,10 @@ private:
|
|||||||
KMemoryPermission perm_mask, KMemoryPermission perm,
|
KMemoryPermission perm_mask, KMemoryPermission perm,
|
||||||
KMemoryAttribute attr_mask, KMemoryAttribute attr,
|
KMemoryAttribute attr_mask, KMemoryAttribute attr,
|
||||||
KMemoryPermission new_perm, KMemoryAttribute lock_attr,
|
KMemoryPermission new_perm, KMemoryAttribute lock_attr,
|
||||||
const KPageLinkedList* pg);
|
const KPageGroup* pg);
|
||||||
|
|
||||||
Result MakePageGroup(KPageLinkedList& pg, VAddr addr, size_t num_pages);
|
Result MakePageGroup(KPageGroup& pg, VAddr addr, size_t num_pages);
|
||||||
bool IsValidPageGroup(const KPageLinkedList& pg, VAddr addr, size_t num_pages);
|
bool IsValidPageGroup(const KPageGroup& pg, VAddr addr, size_t num_pages);
|
||||||
|
|
||||||
bool IsLockedByCurrentThread() const {
|
bool IsLockedByCurrentThread() const {
|
||||||
return general_lock.IsLockedByCurrentThread();
|
return general_lock.IsLockedByCurrentThread();
|
||||||
|
@ -19,8 +19,7 @@ KSharedMemory::~KSharedMemory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result KSharedMemory::Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_,
|
Result KSharedMemory::Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_,
|
||||||
KPageLinkedList&& page_list_,
|
KPageGroup&& page_list_, Svc::MemoryPermission owner_permission_,
|
||||||
Svc::MemoryPermission owner_permission_,
|
|
||||||
Svc::MemoryPermission user_permission_, PAddr physical_address_,
|
Svc::MemoryPermission user_permission_, PAddr physical_address_,
|
||||||
std::size_t size_, std::string name_) {
|
std::size_t size_, std::string name_) {
|
||||||
// Set members.
|
// Set members.
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/device_memory.h"
|
#include "core/device_memory.h"
|
||||||
#include "core/hle/kernel/k_memory_block.h"
|
#include "core/hle/kernel/k_memory_block.h"
|
||||||
#include "core/hle/kernel/k_page_linked_list.h"
|
#include "core/hle/kernel/k_page_group.h"
|
||||||
#include "core/hle/kernel/k_process.h"
|
#include "core/hle/kernel/k_process.h"
|
||||||
#include "core/hle/kernel/slab_helpers.h"
|
#include "core/hle/kernel/slab_helpers.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
@ -27,7 +27,7 @@ public:
|
|||||||
~KSharedMemory() override;
|
~KSharedMemory() override;
|
||||||
|
|
||||||
Result Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_,
|
Result Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_,
|
||||||
KPageLinkedList&& page_list_, Svc::MemoryPermission owner_permission_,
|
KPageGroup&& page_list_, Svc::MemoryPermission owner_permission_,
|
||||||
Svc::MemoryPermission user_permission_, PAddr physical_address_,
|
Svc::MemoryPermission user_permission_, PAddr physical_address_,
|
||||||
std::size_t size_, std::string name_);
|
std::size_t size_, std::string name_);
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
Core::DeviceMemory* device_memory;
|
Core::DeviceMemory* device_memory;
|
||||||
KProcess* owner_process{};
|
KProcess* owner_process{};
|
||||||
KPageLinkedList page_list;
|
KPageGroup page_list;
|
||||||
Svc::MemoryPermission owner_permission{};
|
Svc::MemoryPermission owner_permission{};
|
||||||
Svc::MemoryPermission user_permission{};
|
Svc::MemoryPermission user_permission{};
|
||||||
PAddr physical_address{};
|
PAddr physical_address{};
|
||||||
|
@ -1365,7 +1365,7 @@ static Result MapProcessMemory(Core::System& system, VAddr dst_address, Handle p
|
|||||||
ResultInvalidMemoryRegion);
|
ResultInvalidMemoryRegion);
|
||||||
|
|
||||||
// Create a new page group.
|
// Create a new page group.
|
||||||
KPageLinkedList pg;
|
KPageGroup pg;
|
||||||
R_TRY(src_pt.MakeAndOpenPageGroup(
|
R_TRY(src_pt.MakeAndOpenPageGroup(
|
||||||
std::addressof(pg), src_address, size / PageSize, KMemoryState::FlagCanMapProcess,
|
std::addressof(pg), src_address, size / PageSize, KMemoryState::FlagCanMapProcess,
|
||||||
KMemoryState::FlagCanMapProcess, KMemoryPermission::None, KMemoryPermission::None,
|
KMemoryState::FlagCanMapProcess, KMemoryPermission::None, KMemoryPermission::None,
|
||||||
|
Loading…
Reference in New Issue
Block a user