kern: finish KProcess::Initialize() for KIPs

This commit is contained in:
Michael Scire
2020-02-19 06:46:59 -08:00
parent d9c3908caf
commit b857153964
6 changed files with 209 additions and 5 deletions

View File

@@ -29,7 +29,7 @@ namespace ams::kern {
auto page_buf_guard = SCOPE_GUARD { KPageBuffer::Free(page_buf); };
/* Map the address in. */
MESOSPHERE_TODO("R_TRY(this->owner->GetPageTable().Map(...));");
R_TRY(this->owner->GetPageTable().MapPages(std::addressof(this->virt_addr), 1, PageSize, page_buf->GetPhysicalAddress(), KMemoryState_ThreadLocal, KMemoryPermission_UserReadWrite));
/* We succeeded. */
page_buf_guard.Cancel();
@@ -41,10 +41,10 @@ namespace ams::kern {
/* Get the physical address of the page. */
KPhysicalAddress phys_addr = Null<KPhysicalAddress>;
MESOSPHERE_TODO("MESOSPHERE_ABORT_UNLESS(this->owner->GetPageTable().GetPhysicalAddress(&phys_addr, this->GetAddress()));");
MESOSPHERE_ABORT_UNLESS(this->owner->GetPageTable().GetPhysicalAddress(&phys_addr, this->GetAddress()));
/* Unmap the page. */
MESOSPHERE_TODO("R_TRY(this->owner->GetPageTable().Unmap(...);");
R_TRY(this->owner->GetPageTable().UnmapPages(this->GetAddress(), 1, KMemoryState_ThreadLocal));
/* Free the page. */
KPageBuffer::Free(KPageBuffer::FromPhysicalAddress(phys_addr));
@@ -70,4 +70,12 @@ namespace ams::kern {
this->is_region_free[this->GetRegionIndex(addr)] = true;
}
void *KThreadLocalPage::GetPointer() const {
MESOSPHERE_ASSERT_THIS();
KPhysicalAddress phys_addr;
MESOSPHERE_ABORT_UNLESS(this->owner->GetPageTable().GetPhysicalAddress(std::addressof(phys_addr), this->GetAddress()));
return static_cast<void *>(KPageBuffer::FromPhysicalAddress(phys_addr));
}
}