Optimization for physics memory

Change-Id: Id7765f13d15014c8b19b75156b9f5971cbe99705
This commit is contained in:
Haryslee 2021-03-13 17:34:27 +08:00
parent 856a44ac95
commit c29806a316
2 changed files with 12 additions and 7 deletions

View File

@ -76,7 +76,12 @@ VOID OsVmPageStartup(VOID)
OsVmPhysAreaSizeAdjust(ROUNDUP((g_vmBootMemBase - KERNEL_ASPACE_BASE), PAGE_SIZE)); OsVmPhysAreaSizeAdjust(ROUNDUP((g_vmBootMemBase - KERNEL_ASPACE_BASE), PAGE_SIZE));
nPage = OsVmPhysPageNumGet(); /*
* Pages getting from OsVmPhysPageNumGet() interface here contain the memory
* struct LosVmPage occupied, which satisfies the equation:
* nPage * sizeof(LosVmPage) + nPage * PAGE_SIZE = OsVmPhysPageNumGet() * PAGE_SIZE.
*/
nPage = OsVmPhysPageNumGet() * PAGE_SIZE / (sizeof(LosVmPage) + PAGE_SIZE);
g_vmPageArraySize = nPage * sizeof(LosVmPage); g_vmPageArraySize = nPage * sizeof(LosVmPage);
g_vmPageArray = (LosVmPage *)OsVmBootMemAlloc(g_vmPageArraySize); g_vmPageArray = (LosVmPage *)OsVmBootMemAlloc(g_vmPageArraySize);

View File

@ -108,12 +108,12 @@ VOID OsVmPhysSegAdd(VOID)
VOID OsVmPhysAreaSizeAdjust(size_t size) VOID OsVmPhysAreaSizeAdjust(size_t size)
{ {
INT32 i; /*
* The first physics memory segment is used for kernel image and kernel heap,
for (i = 0; i < (sizeof(g_physArea) / sizeof(g_physArea[0])); i++) { * so just need to adjust the first one here.
g_physArea[i].start += size; */
g_physArea[i].size -= size; g_physArea[0].start += size;
} g_physArea[0].size -= size;
} }
UINT32 OsVmPhysPageNumGet(VOID) UINT32 OsVmPhysPageNumGet(VOID)