X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Fproc.c;h=ceb80ad61964868c5f797987ad2702225487c385;hb=4ed0dbeaa387b3d04e7b2853ceac4e148d0f8ea9;hp=b677dfdb388b26e2c97ad9504a425690fa8eaf71;hpb=3764c294f21229bdf700f436fa4884f5e76e0d3a;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/proc.c b/Kernel/arch/x86/proc.c index b677dfdb..ceb80ad6 100644 --- a/Kernel/arch/x86/proc.c +++ b/Kernel/arch/x86/proc.c @@ -13,14 +13,19 @@ #endif // === FLAGS === -#define DEBUG_TRACE_SWITCH 1 +#define DEBUG_TRACE_SWITCH 0 #define DEBUG_DISABLE_DOUBLEFAULT 1 +#define DEBUG_VERY_SLOW_SWITCH 0 // === CONSTANTS === #define SWITCH_MAGIC 0xFF5317C8 // FF SWITCH - There is no code in this area // Base is 1193182 #define TIMER_BASE 1193182 -#define TIMER_DIVISOR 11932 //~100Hz +#if DEBUG_VERY_SLOW_PERIOD +# define TIMER_DIVISOR 1193 //~10Hz switch, with 10 quantum = 1s per thread +#else +# define TIMER_DIVISOR 11932 //~100Hz +#endif // === TYPES === #if USE_MP @@ -88,9 +93,6 @@ tTSS gaTSSs[MAX_CPUS]; // TSS Array tThread *gCurrentThread = NULL; tThread *gpIdleThread = NULL; #endif -#if USE_PAE -Uint32 *gPML4s[4] = NULL; -#endif tTSS *gTSSs = NULL; // Pointer to TSS array tTSS gTSS0 = {0}; // --- Error Recovery --- @@ -366,18 +368,12 @@ void ArchThreads_Init(void) #endif gThreadZero.CurCPU = 0; - #if USE_PAE - gThreadZero.MemState.PDP[0] = 0; - gThreadZero.MemState.PDP[1] = 0; - gThreadZero.MemState.PDP[2] = 0; - #else gThreadZero.MemState.CR3 = (Uint)gaInitPageDir - KERNEL_BASE; - #endif // Create Per-Process Data Block if( !MM_Allocate(MM_PPD_CFG) ) { - Panic("OOM - No space for initiali Per-Process Config"); + Panic("OOM - No space for initial Per-Process Config"); } // Change Stacks @@ -586,11 +582,7 @@ int Proc_Clone(Uint *Err, Uint Flags) Uint tmpEbp, oldEsp = esp; // Set CR3 - #if USE_PAE - # warning "PAE Unimplemented" - #else newThread->MemState.CR3 = cur->MemState.CR3; - #endif // Create new KStack newThread->KernelStack = MM_NewKStack(); @@ -999,16 +991,6 @@ void Proc_Scheduler(int CPU) thread = Threads_GetNextToRun(CPU, thread); - #if DEBUG_TRACE_SWITCH - if(thread) { - Log("Switching to task %i, CR3 = 0x%x, EIP = %p", - thread->TID, - thread->MemState.CR3, - thread->SavedState.EIP - ); - } - #endif - // No avaliable tasks, just go into low power mode (idle thread) if(thread == NULL) { #if USE_MP @@ -1019,6 +1001,17 @@ void Proc_Scheduler(int CPU) #endif } + #if DEBUG_TRACE_SWITCH + if(thread && thread != Proc_GetCurThread() ) { + Log("Switching to task %i(%s), CR3 = 0x%x, EIP = %p", + thread->TID, + thread->ThreadName, + thread->MemState.CR3, + thread->SavedState.EIP + ); + } + #endif + // Set current thread #if USE_MP gaCPUs[CPU].Current = thread; @@ -1044,9 +1037,6 @@ void Proc_Scheduler(int CPU) Log("%p Scheduled", thread); } - #if USE_PAE - # error "Todo: Implement PAE Address space switching" - #else // Set thread pointer __asm__ __volatile__("mov %0, %%db0\n\t" : : "r"(thread) ); // Switch threads @@ -1061,7 +1051,6 @@ void Proc_Scheduler(int CPU) "r"(thread->MemState.CR3), "r"(thread->bInstrTrace&&thread->SavedState.EIP==(Uint)&GetEIP_Sched_ret?0x100:0) ); - #endif for(;;); // Shouldn't reach here }