mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-15 09:36:35 +00:00
kern: add InfoType_TransferMemoryHint
This commit is contained in:
parent
34e27ee97d
commit
483d06ac0e
3 changed files with 31 additions and 0 deletions
|
@ -48,6 +48,22 @@ namespace ams::kern {
|
||||||
KProcess *GetOwner() const { return m_owner; }
|
KProcess *GetOwner() const { return m_owner; }
|
||||||
KProcessAddress GetSourceAddress() { return m_address; }
|
KProcessAddress GetSourceAddress() { return m_address; }
|
||||||
size_t GetSize() const { return m_is_initialized ? GetReference(m_page_group).GetNumPages() * PageSize : 0; }
|
size_t GetSize() const { return m_is_initialized ? GetReference(m_page_group).GetNumPages() * PageSize : 0; }
|
||||||
|
|
||||||
|
constexpr uintptr_t GetHint() const {
|
||||||
|
/* Get memory size. */
|
||||||
|
const size_t size = this->GetSize();
|
||||||
|
|
||||||
|
/* TODO: Is this architecture specific? */
|
||||||
|
if (size >= 2_MB) {
|
||||||
|
return GetInteger(m_address) & (2_MB - 1);
|
||||||
|
} else if (size >= 64_KB) {
|
||||||
|
return GetInteger(m_address) & (64_KB - 1);
|
||||||
|
} else if (size >= 4_KB) {
|
||||||
|
return GetInteger(m_address) & (4_KB - 1);
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,6 +314,19 @@ namespace ams::kern::svc {
|
||||||
*out = io_region->GetHint();
|
*out = io_region->GetHint();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ams::svc::InfoType_TransferMemoryHint:
|
||||||
|
{
|
||||||
|
/* Verify the sub-type is valid. */
|
||||||
|
R_UNLESS(info_subtype == 0, svc::ResultInvalidCombination());
|
||||||
|
|
||||||
|
/* Get the transfer memory from its handle. */
|
||||||
|
KScopedAutoObject transfer_memory = GetCurrentProcess().GetHandleTable().GetObject<KTransferMemory>(handle);
|
||||||
|
R_UNLESS(transfer_memory.IsNotNull(), svc::ResultInvalidHandle());
|
||||||
|
|
||||||
|
/* Get the transfer memory's address hint. */
|
||||||
|
*out = transfer_memory->GetHint();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ams::svc::InfoType_MesosphereMeta:
|
case ams::svc::InfoType_MesosphereMeta:
|
||||||
{
|
{
|
||||||
/* Verify the handle is invalid. */
|
/* Verify the handle is invalid. */
|
||||||
|
|
|
@ -191,6 +191,8 @@ namespace ams::svc {
|
||||||
InfoType_IsSvcPermitted = 26,
|
InfoType_IsSvcPermitted = 26,
|
||||||
InfoType_IoRegionHint = 27,
|
InfoType_IoRegionHint = 27,
|
||||||
InfoType_AliasRegionExtraSize = 28,
|
InfoType_AliasRegionExtraSize = 28,
|
||||||
|
/* ... */
|
||||||
|
InfoType_TransferMemoryHint = 34,
|
||||||
|
|
||||||
InfoType_MesosphereMeta = 65000,
|
InfoType_MesosphereMeta = 65000,
|
||||||
InfoType_MesosphereCurrentProcess = 65001,
|
InfoType_MesosphereCurrentProcess = 65001,
|
||||||
|
|
Loading…
Reference in a new issue