#define DEBUG 0
#define SANITY 1
#include <acess.h>
+#include <mm_virt.h>
#include <mm_phys.h>
#include <proc.h>
extern void Error_Backtrace(Uint eip, Uint ebp);
// === PROTOTYPES ===
-void MM_PreinitVirtual();
-void MM_InstallVirtual();
+void MM_PreinitVirtual(void);
+void MM_InstallVirtual(void);
void MM_PageFault(tVAddr Addr, Uint ErrorCode, tRegs *Regs);
void MM_DumpTables(tVAddr Start, tVAddr End);
tPAddr MM_DuplicatePage(tVAddr VAddr);
// === CODE ===
/**
- * \fn void MM_PreinitVirtual()
+ * \fn void MM_PreinitVirtual(void)
* \brief Maps the fractal mappings
*/
-void MM_PreinitVirtual()
+void MM_PreinitVirtual(void)
{
#if USE_PAE
gaInitPageDir[ ((PAGE_TABLE_ADDR >> TAB)-3*512+3)*2 ] = ((tTabEnt)&gaInitPageDir - KERNEL_BASE) | 3;
}
/**
- * \fn void MM_InstallVirtual()
+ * \fn void MM_InstallVirtual(void)
* \brief Sets up the constant page mappings
*/
-void MM_InstallVirtual()
+void MM_InstallVirtual(void)
{
int i;
/**
* \brief Cleans up the SMP required mappings
*/
-void MM_FinishVirtualInit()
+void MM_FinishVirtualInit(void)
{
#if USE_PAE
gaInitPDPT[ 0 ] = 0;
return (gaPageTable[Addr >> 12] & ~0xFFF) | (Addr & 0xFFF);
}
-
/**
- * \fn int MM_IsUser(tVAddr VAddr)
- * \brief Checks if a page is user accessable
- */
-int MM_IsUser(tVAddr VAddr)
-{
- if( !(gaPageDir[VAddr >> 22] & 1) )
- return 0;
- if( !(gaPageTable[VAddr >> 12] & 1) )
- return 0;
- if( !(gaPageTable[VAddr >> 12] & PF_USER) )
- return 0;
- return 1;
-}
-
-/**
- * \fn void MM_SetCR3(tPAddr CR3)
+ * \fn void MM_SetCR3(Uint CR3)
* \brief Sets the current process space
*/
-void MM_SetCR3(tPAddr CR3)
+void MM_SetCR3(Uint CR3)
{
__asm__ __volatile__ ("mov %0, %%cr3"::"r"(CR3));
}
* \fn tVAddr MM_ClearUser()
* \brief Clear user's address space
*/
-tVAddr MM_ClearUser()
+tVAddr MM_ClearUser(void)
{
Uint i, j;
}
/**
- * \fn tPAddr MM_Clone()
+ * \fn tPAddr MM_Clone(void)
* \brief Clone the current address space
*/
-tPAddr MM_Clone()
+tPAddr MM_Clone(void)
{
Uint i, j;
tVAddr ret;
}
/**
- * \fn tVAddr MM_NewKStack()
+ * \fn tVAddr MM_NewKStack(void)
* \brief Create a new kernel stack
*/
-tVAddr MM_NewKStack()
+tVAddr MM_NewKStack(void)
{
tVAddr base = KERNEL_STACKS;
Uint i;
// *ent, VAddr >> 22, gaPageDir[VAddr >> 22]);
}
+/**
+ * \brief Get the flags on a page
+ */
+Uint MM_GetFlags(tVAddr VAddr)
+{
+ tTabEnt *ent;
+ Uint ret = 0;
+
+ // Validity Check
+ if( !(gaPageDir[VAddr >> 22] & 1) ) return 0;
+ if( !(gaPageTable[VAddr >> 12] & 1) ) return 0;
+
+ ent = &gaPageTable[VAddr >> 12];
+
+ // Read-Only
+ if( !(*ent & PF_WRITE) ) ret |= MM_PFLAG_RO;
+ // Kernel
+ if( !(*ent & PF_USER) ) ret |= MM_PFLAG_KERNEL;
+ // Copy-On-Write
+ if( *ent & PF_COW ) ret |= MM_PFLAG_COW;
+
+ return ret;
+}
+
/**
* \fn tPAddr MM_DuplicatePage(tVAddr VAddr)
* \brief Duplicates a virtual page to a physical one