| 536 | } |
| 537 | |
| 538 | void MapVirtualMemory4K(uint64_t phys, uint64_t virt, uint64_t amount, address_space_t* addressSpace){ |
| 539 | uint64_t pml4Index, pdptIndex, pageDirIndex, pageIndex; |
| 540 | |
| 541 | //phys &= ~(PAGE_SIZE_4K-1); |
| 542 | //virt &= ~(PAGE_SIZE_4K-1); |
| 543 | |
| 544 | while(amount--){ |
| 545 | pml4Index = PML4_GET_INDEX(virt); |
| 546 | pdptIndex = PDPT_GET_INDEX(virt); |
| 547 | pageDirIndex = PAGE_DIR_GET_INDEX(virt); |
| 548 | pageIndex = PAGE_TABLE_GET_INDEX(virt); |
| 549 | |
| 550 | const char* panic[1] = {"Process address space cannot be >512GB"}; |
| 551 | if(pdptIndex > MAX_PDPT_INDEX || pml4Index) KernelPanic(panic,1); |
| 552 | |
| 553 | if(!(addressSpace->pageDirs[pdptIndex][pageDirIndex] & 0x1)) CreatePageTable(pdptIndex,pageDirIndex,addressSpace); // If we don't have a page table at this address, create one. |
| 554 | |
| 555 | addressSpace->pageTables[pdptIndex][pageDirIndex][pageIndex] = PAGE_PRESENT | PAGE_WRITABLE | PAGE_USER; |
| 556 | SetPageFrame(&(addressSpace->pageTables[pdptIndex][pageDirIndex][pageIndex]), phys); |
| 557 | |
| 558 | invlpg(virt); |
| 559 | |
| 560 | phys += PAGE_SIZE_4K; |
| 561 | virt += PAGE_SIZE_4K; /* Go to next page */ |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | uintptr_t GetIOMapping(uintptr_t addr){ |
| 566 | if(addr > 0xffffffff){ // Typically most MMIO will not reside > 4GB, but check just in case |
no test coverage detected