X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86_64%2Fmm_virt.c;h=4cce485418ca7727550df12eb88ebc07487ab9ee;hb=9f407c493c33928e0f19b834699d9694036ca42e;hp=41075757374a304cc9ca311449c1c693e890533d;hpb=e7d03978fb7c0c6ab1250e56e73afba9ffb89923;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86_64/mm_virt.c b/Kernel/arch/x86_64/mm_virt.c index 41075757..4cce4854 100644 --- a/Kernel/arch/x86_64/mm_virt.c +++ b/Kernel/arch/x86_64/mm_virt.c @@ -76,6 +76,18 @@ int MM_Map(tVAddr VAddr, tPAddr PAddr) return 1; } +void MM_Unmap(tVAddr VAddr) +{ + // Check PML4 + if( !(PAGEMAPLVL4(VAddr >> 39) & 1) ) return ; + // Check PDP + if( !(PAGEDIRPTR(VAddr >> 30) & 1) ) return ; + // Check Page Dir + if( !(PAGEDIR(VAddr >> 21) & 1) ) return ; + + PAGETABLE(VAddr >> 12) = 0; +} + /** * \brief Allocate a block of memory at the specified virtual address */ @@ -95,6 +107,18 @@ tPAddr MM_Allocate(tVAddr VAddr) return ret; } +void MM_Deallocate(tVAddr VAddr) +{ + tPAddr phys; + + phys = MM_GetPhysAddr(VAddr); + if(!phys) return ; + + MM_Unmap(VAddr); + + MM_DerefPhys(phys); +} + /** * \brief Get the physical address of a virtual location */ @@ -179,6 +203,9 @@ void MM_SetFlags(tVAddr VAddr, Uint Flags, Uint Mask) } } +/** + * \brief Get the flags applied to a page + */ Uint MM_GetFlags(tVAddr VAddr) { tPAddr *ent; @@ -208,3 +235,34 @@ Uint MM_GetFlags(tVAddr VAddr) return ret; } + +// --- Hardware Mappings --- +/** + * \brief Map a range of hardware pages + */ +tVAddr MM_MapHWPages(tPAddr PAddr, Uint Number) +{ + Log_KernelPanic("MM", "TODO: Implement MM_MapHWPages"); + return 0; +} + +/** + * \brief Free a range of hardware pages + */ +void MM_UnmapHWPages(tVAddr VAddr, Uint Number) +{ + Log_KernelPanic("MM", "TODO: Implement MM_UnmapHWPages"); +} + +// --- Tempory Mappings --- +tVAddr MM_MapTemp(tPAddr PAddr) +{ + Log_KernelPanic("MM", "TODO: Implement MM_MapTemp"); + return 0; +} + +void MM_FreeTemp(tVAddr VAddr) +{ + Log_KernelPanic("MM", "TODO: Implement MM_FreeTemp"); + return ; +}