#define PF_PRESENT 0x1
#define PF_WRITE 0x2
#define PF_USER 0x4
+#define PF_GLOBAL 0x80
#define PF_COW 0x200
#define PF_NOPAGE 0x400
void MM_InstallVirtual(void);
void MM_PageFault(tVAddr Addr, Uint ErrorCode, tRegs *Regs);
void MM_DumpTables(tVAddr Start, tVAddr End);
+tVAddr MM_ClearUser(void);
tPAddr MM_DuplicatePage(tVAddr VAddr);
// === GLOBALS ===
);
Warning("User Pagefault: Instruction at %04x:%08x accessed %p", Regs->cs, Regs->eip, Addr);
__asm__ __volatile__ ("sti"); // Restart IRQs
+ #if 1
+ Error_Backtrace(Regs->eip, Regs->ebp);
+ #endif
Threads_SegFault(Addr);
return ;
}
tPAddr expected = 0;
tVAddr curPos;
Uint page;
- const tPAddr MASK = ~0xF98;
+ const tPAddr MASK = ~0xF78;
Start >>= 12; End >>= 12;
|| (gaPageTable[page] & MASK) != expected)
{
if(expected) {
- Log(" 0x%08x-0x%08x => 0x%08x-0x%08x (%s%s%s%s)",
- rangeStart, curPos - 1,
+ Log(" 0x%08x => 0x%08x - 0x%08x (%s%s%s%s%s)",
+ rangeStart,
gaPageTable[rangeStart>>12] & ~0xFFF,
- (expected & ~0xFFF) - 1,
+ curPos - rangeStart,
(expected & PF_NOPAGE ? "P" : "-"),
(expected & PF_COW ? "C" : "-"),
+ (expected & PF_GLOBAL ? "G" : "-"),
(expected & PF_USER ? "U" : "-"),
- (expected & PF_WRITE ? "W" : "-")
+ (expected & PF_WRITE ? "W" : "-"),
+ gaPageTable[page] & MASK, expected
);
expected = 0;
}
}
if(expected) {
- Log("0x%08x-0x%08x => 0x%08x-0x%08x (%s%s%s%s)",
- rangeStart, curPos - 1,
+ Log("0x%08x => 0x%08x - 0x%08x (%s%s%s%s)",
+ rangeStart,
gaPageTable[rangeStart>>12] & ~0xFFF,
- (expected & ~0xFFF) - 1,
+ curPos - rangeStart,
(expected & PF_NOPAGE ? "p" : "-"),
(expected & PF_COW ? "C" : "-"),
(expected & PF_USER ? "U" : "-"),
Uint i;
for(base = KERNEL_STACKS; base < KERNEL_STACKS_END; base += KERNEL_STACK_SIZE)
{
+ // Check if space is free
if(MM_GetPhysAddr(base) != 0) continue;
- for(i = 0; i < KERNEL_STACK_SIZE; i += 0x1000) {
- MM_Allocate(base+i);
+ // Allocate
+ //for(i = KERNEL_STACK_SIZE; i -= 0x1000 ; )
+ for(i = 0; i < KERNEL_STACK_SIZE; i += 0x1000 )
+ {
+ if( MM_Allocate(base+i) == 0 )
+ {
+ // On error, print a warning and return error
+ Warning("MM_NewKStack - Out of memory");
+ // - Clean up
+ //for( i += 0x1000 ; i < KERNEL_STACK_SIZE; i += 0x1000 )
+ // MM_Deallocate(base+i);
+ return 0;
+ }
}
+ // Success
Log("MM_NewKStack - Allocated %p", base + KERNEL_STACK_SIZE);
return base+KERNEL_STACK_SIZE;
}
- Warning("MM_NewKStack - No address space left\n");
+ // No stacks left
+ Warning("MM_NewKStack - No address space left");
return 0;
}