#define KERNEL_STACK_END 0xFD000000
#define PAGE_TABLE_ADDR 0xFD000000
#define PAGE_DIR_ADDR 0xFD3F4000
-//#define PAGE_CR3_ADDR 0xFD3F47F4
-//#define TMP_CR3_ADDR 0xFD3F47F8 // Part of core instead of temp
#define PAGE_CR3_ADDR 0xFD3F4FD0
#define TMP_CR3_ADDR 0xFD3F4FD4 // Part of core instead of temp
#define TMP_DIR_ADDR 0xFD3F5000 // Same
// === CODE ===
/**
* \fn void MM_PreinitVirtual()
+ * \brief Maps the fractal mappings
*/
void MM_PreinitVirtual()
{
gaInitPageDir[ 0 ] = 0;
gaInitPageDir[ PAGE_TABLE_ADDR >> 22 ] = ((Uint)&gaInitPageDir - KERNEL_BASE) | 3;
}
+
/**
* \fn void MM_InstallVirtual()
+ * \brief Sets up the constant page mappings
*/
void MM_InstallVirtual()
{
*/
void MM_PageFault(Uint Addr, Uint ErrorCode, tRegs *Regs)
{
- ENTER("xAddr bErrorCode", Addr, ErrorCode);
+ //ENTER("xAddr bErrorCode", Addr, ErrorCode);
// -- Check for COW --
if( gaPageDir [Addr>>22] & PF_PRESENT
gaPageTable[Addr>>12] &= PF_USER;
gaPageTable[Addr>>12] |= paddr|PF_PRESENT|PF_WRITE;
INVLPG( Addr & ~0xFFF );
+ //LEAVE('-')
+ return;
}
// -- Check Error Code --
MM_DumpTables(0, -1);
Panic("Page Fault at 0x%x\n", Regs->eip);
- LEAVE('-');
}
/**
}
// Check if the page is already allocated
else if( gaPageTable[ VAddr >> 12 ] != 0 ) {
- Warning("MM_Allocate - Allocating to used address");
+ Warning("MM_Allocate - Allocating to used address (%p)", VAddr);
return gaPageTable[ VAddr >> 12 ] & ~0xFFF;
}
if( Flags & MM_PFLAG_KERNEL ) *ent &= ~PF_USER;
else *ent |= PF_USER;
}
+
+ // Copy-On-Write
+ if( Mask & MM_PFLAG_COW )
+ {
+ if( Flags & MM_PFLAG_COW ) {
+ *ent &= ~PF_WRITE;
+ *ent |= PF_COW;
+ }
+ else {
+ *ent &= ~PF_COW;
+ *ent |= PF_WRITE;
+ }
+ }
}
/**