X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Fmm_virt.c;h=72c40c2a84b7be751ab2ddbfc1b5ef98307ed586;hb=046980a1afd982af07dc97aaadb186e31eebb340;hp=2b2f02c15979cccb92d1319b2b46958e56eeb551;hpb=8051546ad5894e093211d2ec69dde6b99cdaa71d;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/mm_virt.c b/Kernel/arch/x86/mm_virt.c index 2b2f02c1..72c40c2a 100644 --- a/Kernel/arch/x86/mm_virt.c +++ b/Kernel/arch/x86/mm_virt.c @@ -56,7 +56,7 @@ #define PF_WRITE 0x2 #define PF_USER 0x4 #define PF_COW 0x200 -#define PF_PAGED 0x400 +#define PF_NOPAGE 0x400 #define INVLPG(addr) __asm__ __volatile__ ("invlpg (%0)"::"r"(addr)) @@ -78,6 +78,7 @@ void MM_PreinitVirtual(void); 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 === @@ -217,6 +218,9 @@ void MM_PageFault(tVAddr Addr, Uint ErrorCode, tRegs *Regs) ); 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 ; } @@ -306,7 +310,7 @@ void MM_DumpTables(tVAddr Start, tVAddr End) rangeStart, curPos - 1, gaPageTable[rangeStart>>12] & ~0xFFF, (expected & ~0xFFF) - 1, - (expected & PF_PAGED ? "p" : "-"), + (expected & PF_NOPAGE ? "P" : "-"), (expected & PF_COW ? "C" : "-"), (expected & PF_USER ? "U" : "-"), (expected & PF_WRITE ? "W" : "-") @@ -327,7 +331,7 @@ void MM_DumpTables(tVAddr Start, tVAddr End) rangeStart, curPos - 1, gaPageTable[rangeStart>>12] & ~0xFFF, (expected & ~0xFFF) - 1, - (expected & PF_PAGED ? "p" : "-"), + (expected & PF_NOPAGE ? "p" : "-"), (expected & PF_COW ? "C" : "-"), (expected & PF_USER ? "U" : "-"), (expected & PF_WRITE ? "W" : "-") @@ -660,14 +664,28 @@ tVAddr MM_NewKStack(void) 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; }