mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
kern: simplify size calculations in KPageTableBase::Read/WriteDebugIoMemory
This commit is contained in:
parent
4aac5f0082
commit
cfb12deb51
1 changed files with 2 additions and 2 deletions
|
@ -2994,7 +2994,7 @@ namespace ams::kern {
|
||||||
MESOSPHERE_ABORT_UNLESS(src_page_table.GetPhysicalAddressLocked(std::addressof(phys_addr), address));
|
MESOSPHERE_ABORT_UNLESS(src_page_table.GetPhysicalAddressLocked(std::addressof(phys_addr), address));
|
||||||
|
|
||||||
/* Determine the current read size. */
|
/* Determine the current read size. */
|
||||||
const size_t cur_size = std::min<size_t>(last_address - address + 1, util::AlignDown(GetInteger(address) + PageSize, PageSize) - GetInteger(address));
|
const size_t cur_size = std::min<size_t>(last_address - address + 1, PageSize - (GetInteger(address) & (PageSize - 1)));
|
||||||
|
|
||||||
/* Read. */
|
/* Read. */
|
||||||
R_TRY(dst_page_table.ReadIoMemoryImpl(dst, phys_addr, cur_size, state));
|
R_TRY(dst_page_table.ReadIoMemoryImpl(dst, phys_addr, cur_size, state));
|
||||||
|
@ -3030,7 +3030,7 @@ namespace ams::kern {
|
||||||
MESOSPHERE_ABORT_UNLESS(src_page_table.GetPhysicalAddressLocked(std::addressof(phys_addr), address));
|
MESOSPHERE_ABORT_UNLESS(src_page_table.GetPhysicalAddressLocked(std::addressof(phys_addr), address));
|
||||||
|
|
||||||
/* Determine the current read size. */
|
/* Determine the current read size. */
|
||||||
const size_t cur_size = std::min<size_t>(last_address - address + 1, util::AlignDown(GetInteger(address) + PageSize, PageSize) - GetInteger(address));
|
const size_t cur_size = std::min<size_t>(last_address - address + 1, PageSize - (GetInteger(address) & (PageSize - 1)));
|
||||||
|
|
||||||
/* Read. */
|
/* Read. */
|
||||||
R_TRY(dst_page_table.WriteIoMemoryImpl(phys_addr, src, cur_size, state));
|
R_TRY(dst_page_table.WriteIoMemoryImpl(phys_addr, src, cur_size, state));
|
||||||
|
|
Loading…
Reference in a new issue