forked from suyu/suyu
core: hle: kernel: KPageTable: MapProcessCode: Various cleanup.
This commit is contained in:
parent
ee25e0a40b
commit
07add23251
1 changed files with 12 additions and 11 deletions
|
@ -276,22 +276,23 @@ ResultCode KPageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_
|
||||||
|
|
||||||
ResultCode KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemoryState state,
|
ResultCode KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemoryState state,
|
||||||
KMemoryPermission perm) {
|
KMemoryPermission perm) {
|
||||||
std::lock_guard lock{page_table_lock};
|
|
||||||
|
|
||||||
const u64 size{num_pages * PageSize};
|
const u64 size{num_pages * PageSize};
|
||||||
|
|
||||||
if (!CanContain(addr, size, state)) {
|
// Validate the mapping request.
|
||||||
return ResultInvalidCurrentMemory;
|
R_UNLESS(this->CanContain(addr, size, state), ResultInvalidCurrentMemory);
|
||||||
}
|
|
||||||
|
|
||||||
if (IsRegionMapped(addr, size)) {
|
// Lock the table.
|
||||||
return ResultInvalidCurrentMemory;
|
std::lock_guard lock{page_table_lock};
|
||||||
}
|
|
||||||
|
// Verify that the destination memory is unmapped.
|
||||||
|
R_TRY(this->CheckMemoryState(addr, size, KMemoryState::All, KMemoryState::Free,
|
||||||
|
KMemoryPermission::None, KMemoryPermission::None,
|
||||||
|
KMemoryAttribute::None, KMemoryAttribute::None));
|
||||||
|
|
||||||
KPageLinkedList page_linked_list;
|
KPageLinkedList page_linked_list;
|
||||||
CASCADE_CODE(system.Kernel().MemoryManager().Allocate(page_linked_list, num_pages, memory_pool,
|
R_TRY(system.Kernel().MemoryManager().Allocate(page_linked_list, num_pages, memory_pool,
|
||||||
allocation_option));
|
allocation_option));
|
||||||
CASCADE_CODE(Operate(addr, num_pages, page_linked_list, OperationType::MapGroup));
|
R_TRY(Operate(addr, num_pages, page_linked_list, OperationType::MapGroup));
|
||||||
|
|
||||||
block_manager->Update(addr, num_pages, state, perm);
|
block_manager->Update(addr, num_pages, state, perm);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue