Implemented MmLockUnlockBufferPages
This commit is contained in:
parent
5f27e27a06
commit
0b81db3920
|
@ -113,9 +113,9 @@ XBSYSAPI EXPORTNUM(174) BOOLEAN NTAPI MmIsAddressValid
|
|||
// ******************************************************************
|
||||
XBSYSAPI EXPORTNUM(175) VOID NTAPI MmLockUnlockBufferPages
|
||||
(
|
||||
IN PHYSICAL_ADDRESS BaseAddress,
|
||||
IN ULONG NumberOfBytes,
|
||||
IN ULONG Protect
|
||||
IN PVOID BaseAddress,
|
||||
IN SIZE_T NumberOfBytes,
|
||||
IN BOOLEAN UnlockPages
|
||||
);
|
||||
|
||||
// ******************************************************************
|
||||
|
|
|
@ -280,19 +280,20 @@ XBSYSAPI EXPORTNUM(174) xboxkrnl::BOOLEAN NTAPI xboxkrnl::MmIsAddressValid
|
|||
// ******************************************************************
|
||||
XBSYSAPI EXPORTNUM(175) xboxkrnl::VOID NTAPI xboxkrnl::MmLockUnlockBufferPages
|
||||
(
|
||||
IN PHYSICAL_ADDRESS BaseAddress,
|
||||
IN ULONG NumberOfBytes,
|
||||
IN ULONG Protect
|
||||
IN PVOID BaseAddress,
|
||||
IN SIZE_T NumberOfBytes,
|
||||
IN BOOLEAN UnlockPages
|
||||
)
|
||||
{
|
||||
LOG_FUNC_BEGIN
|
||||
LOG_FUNC_ARG(BaseAddress)
|
||||
LOG_FUNC_ARG(NumberOfBytes)
|
||||
LOG_FUNC_ARG(Protect)
|
||||
LOG_FUNC_ARG(UnlockPages)
|
||||
LOG_FUNC_END;
|
||||
|
||||
// REMARK: all the pages inside the main memory pool are non-relocatable so, for the moment, this function is pointless
|
||||
LOG_IGNORED();
|
||||
|
||||
g_VMManager.LockBufferOrSinglePage(0, (VAddr)BaseAddress, NumberOfBytes, UnlockPages);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
|
|
@ -1496,6 +1496,61 @@ size_t VMManager::QuerySize(VAddr addr, bool bCxbxCaller)
|
|||
RETURN(Size);
|
||||
}
|
||||
|
||||
void VMManager::LockBufferOrSinglePage(PAddr paddr, VAddr addr, size_t Size, bool bUnLock)
|
||||
{
|
||||
LOG_FUNC_BEGIN
|
||||
LOG_FUNC_ARG(paddr)
|
||||
LOG_FUNC_ARG(addr)
|
||||
LOG_FUNC_ARG(Size)
|
||||
LOG_FUNC_ARG(bUnLock)
|
||||
LOG_FUNC_END;
|
||||
|
||||
PMMPTE PointerPte;
|
||||
PMMPTE EndingPte;
|
||||
PFN pfn;
|
||||
PXBOX_PFN PfnEntry;
|
||||
ULONG LockUnit;
|
||||
|
||||
Lock();
|
||||
|
||||
if (addr) // lock the pages of a buffer
|
||||
{
|
||||
if (!IS_PHYSICAL_ADDRESS(addr) && (GetPdeAddress(addr)->Hardware.LargePage == 0))
|
||||
{
|
||||
LockUnit = bUnLock ? -LOCK_COUNT_UNIT : LOCK_COUNT_UNIT;
|
||||
|
||||
PointerPte = GetPteAddress(addr);
|
||||
EndingPte = GetPteAddress(addr + Size - 1);
|
||||
|
||||
while (PointerPte <= EndingPte)
|
||||
{
|
||||
assert(PointerPte->Hardware.Valid != 0);
|
||||
|
||||
pfn = PointerPte->Hardware.PFN;
|
||||
|
||||
if (pfn <= m_HighestPage)
|
||||
{
|
||||
if (g_bIsRetail || g_bIsDebug) {
|
||||
PfnEntry = XBOX_PFN_ELEMENT(pfn);
|
||||
}
|
||||
else { PfnEntry = CHIHIRO_PFN_ELEMENT(pfn); }
|
||||
|
||||
assert(PfnEntry->Busy.Busy != 0);
|
||||
|
||||
PfnEntry->Busy.LockCount += LockUnit;
|
||||
}
|
||||
PointerPte++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Unlock();
|
||||
}
|
||||
|
||||
xboxkrnl::NTSTATUS VMManager::XbAllocateVirtualMemory(VAddr* addr, ULONG ZeroBits, size_t* Size, DWORD AllocationType, DWORD Protect)
|
||||
{
|
||||
LOG_FUNC_BEGIN
|
||||
|
|
|
@ -149,6 +149,8 @@ class VMManager : public PhysicalMemory
|
|||
DWORD QueryProtection(VAddr addr);
|
||||
// retrieves the size of an allocation
|
||||
size_t QuerySize(VAddr addr, bool bCxbxCaller = true);
|
||||
// locks physical pages in memory (prevents relocations)
|
||||
void LockBufferOrSinglePage(PAddr paddr, VAddr addr, size_t Size, bool bUnLock);
|
||||
// MmClaimGpuInstanceMemory implementation
|
||||
VAddr ClaimGpuMemory(size_t Size, size_t* BytesToSkip);
|
||||
// make contiguous memory persist across a quick reboot
|
||||
|
|
Loading…
Reference in New Issue