More work on x86_64 port, near compiling now
[tpg/acess2.git] / Kernel / arch / x86_64 / mm_virt.c
index 4107575..4cce485 100644 (file)
@@ -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 ;
+}

UCC git Repository :: git.ucc.asn.au