X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Farch%2Fx86%2Fproc.c;h=5637985fbbfb318638a021eb40c876c1c199ba60;hb=902813fd2da685f025636a13d9f176b592cc8b33;hp=2869c3c3ec36748b2f5f68717bf3f2c348e8062c;hpb=aa62597b70c3f3753ee21b174ca695b6b6c4cdef;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/arch/x86/proc.c b/KernelLand/Kernel/arch/x86/proc.c index 2869c3c3..5637985f 100644 --- a/KernelLand/Kernel/arch/x86/proc.c +++ b/KernelLand/Kernel/arch/x86/proc.c @@ -24,11 +24,14 @@ #define DEBUG_DISABLE_DOUBLEFAULT 1 #define DEBUG_VERY_SLOW_PERIOD 0 #define DEBUG_NOPREEMPT 1 +#define DISABLE_PIT 0 // === CONSTANTS === // Base is 1193182 #define TIMER_BASE 1193182 -#if DEBUG_VERY_SLOW_PERIOD +#if DISABLE_PIT +# define TIMER_DIVISOR 0xFFFF +#elif DEBUG_VERY_SLOW_PERIOD # define TIMER_DIVISOR 1193 //~10Hz switch, with 10 quantum = 1s per thread #else # define TIMER_DIVISOR 11932 //~100Hz @@ -210,7 +213,7 @@ void ArchThreads_Init(void) gProcessZero.MemState.CR3 = (Uint)gaInitPageDir - KERNEL_BASE; // Create Per-Process Data Block - if( !MM_Allocate(MM_PPD_CFG) ) + if( MM_Allocate( (void*)MM_PPD_CFG ) == 0 ) { Panic("OOM - No space for initial Per-Process Config"); } @@ -550,27 +553,28 @@ tThread *Proc_SpawnWorker(void (*Fcn)(void*), void *Data) */ Uint Proc_MakeUserStack(void) { - int i; - Uint base = USER_STACK_TOP - USER_STACK_SZ; + tPage *base = (void*)(USER_STACK_TOP - USER_STACK_SZ); // Check Prospective Space - for( i = USER_STACK_SZ >> 12; i--; ) - if( MM_GetPhysAddr( (void*)(base + (i<<12)) ) != 0 ) - break; - - if(i != -1) return 0; - + for( Uint i = USER_STACK_SZ/PAGE_SIZE; i--; ) + { + if( MM_GetPhysAddr( base + i ) != 0 ) + { + Warning("Proc_MakeUserStack: Address %p in use", base + i); + return 0; + } + } // Allocate Stack - Allocate incrementally to clean up MM_Dump output - for( i = 0; i < USER_STACK_SZ/0x1000; i++ ) + for( Uint i = 0; i < USER_STACK_SZ/PAGE_SIZE; i++ ) { - if( !MM_Allocate( base + (i<<12) ) ) + if( MM_Allocate( base + i ) == 0 ) { Warning("OOM: Proc_MakeUserStack"); return 0; } } - return base + USER_STACK_SZ; + return (tVAddr)( base + USER_STACK_SZ/PAGE_SIZE ); } void Proc_StartUser(Uint Entrypoint, Uint Base, int ArgC, const char **ArgV, int DataSize) @@ -725,7 +729,9 @@ void Proc_DumpThreadCPUState(tThread *Thread) Error_Backtrace(regs->eip, regs->ebp); return ; } - + + Log(" Saved = %p (SP=%p)", Thread->SavedState.EIP, Thread->SavedState.ESP); + tVAddr diffFromScheduler = Thread->SavedState.EIP - (tVAddr)SwitchTasks; tVAddr diffFromClone = Thread->SavedState.EIP - (tVAddr)Proc_CloneInt; tVAddr diffFromSpawn = Thread->SavedState.EIP - (tVAddr)NewTaskHeader;