Userspace code runs !

This commit is contained in:
Adrien Bourmault 2021-03-01 16:57:48 +01:00
parent d0d546e073
commit 2a1990e043
Signed by: neox
GPG Key ID: 6EB408FE0ACEC664
1 changed files with 17 additions and 6 deletions

View File

@ -113,7 +113,8 @@ void MmInitPaging(void)
//DebugLog("\t\t\t\tPDP %d : %p\n", index, MmPDP);
MmPageMapLevel4[index] = (pdpe_t *)((ulong)MmPDP | PRESENT
| READWRITE);
| READWRITE
| USERMODE );
for (curAddrPDP = curAddrPML4;
curAddrPDP < (curAddrPML4 + ((ulong)KPAGESIZE * 0x8000000));
@ -134,7 +135,8 @@ void MmInitPaging(void)
index = (curAddrPDP / ((ulong)KPAGESIZE * 0x40000)) % 512;
//DebugLog("\t\t\t\tPD %d : %p\n", index, MmPD);
MmPDP[index] = (pde_t *)((ulong)MmPD | PRESENT | READWRITE);
MmPDP[index] = (pde_t *)((ulong)MmPD | PRESENT
| READWRITE );
for (curAddrPD = curAddrPDP;
curAddrPD < (curAddrPDP + ((ulong)KPAGESIZE * 0x40000));
@ -155,7 +157,7 @@ void MmInitPaging(void)
//DebugLog("\t\t\t\tPT %d : %p\n", index, MmPT);
MmPD[index] = (pte_t *)((ulong)MmPT | PRESENT
| READWRITE);
| READWRITE );
for (curAddrPT = curAddrPD;
curAddrPT < (curAddrPD + ((ulong)KPAGESIZE * 0x200));
@ -252,7 +254,10 @@ ulong *MmGetPageDescriptorFromVirtual(void *virtualAddr)
// Set present
MmPageMapLevel4[pml4Index] =
(pml4_t)((ulong)MmPageMapLevel4[pml4Index] | PRESENT | READWRITE);
(pml4_t)((ulong)MmPageMapLevel4[pml4Index]
| PRESENT
| READWRITE
| USERMODE * (virtualAddr >= USERSPACE) );
pdp = (pdpe_t *)((ulong)MmPageMapLevel4[pml4Index] & 0xFFFFFFFFFF000);
//DebugLog("\tCreate PDP at %p\n", MmPageMapLevel4[pml4Index]);
@ -268,7 +273,10 @@ ulong *MmGetPageDescriptorFromVirtual(void *virtualAddr)
pdp[pdpIndex] = memalign(512*sizeof(pde_t), KPAGESIZE);
pdp[pdpIndex] = (pdpe_t)((ulong)pdp[pdpIndex] | PRESENT | READWRITE);
pdp[pdpIndex] = (pdpe_t)((ulong)pdp[pdpIndex]
| PRESENT
| READWRITE
| USERMODE * (virtualAddr >= USERSPACE) );
pd = (pde_t *)((ulong)pdp[pdpIndex] & 0xFFFFFFFFFF000);
//DebugLog("\tCreate PD at %p\n", (ulong)pdp[pdpIndex]);
@ -284,7 +292,10 @@ ulong *MmGetPageDescriptorFromVirtual(void *virtualAddr)
pd[pdIndex] = memalign(512*sizeof(pte_t), KPAGESIZE);
pd[pdIndex] = (pde_t)((ulong)pd[pdIndex] | PRESENT | READWRITE);
pd[pdIndex] = (pde_t)((ulong)pd[pdIndex]
| PRESENT
| READWRITE
| USERMODE * (virtualAddr >= USERSPACE) );
pt = (pte_t *)((ulong)pd[pdIndex] & 0xFFFFFFFFFF000);
//DebugLog("\tCreate PT at %p\n", (ulong)pd[pdIndex]);