X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86_64%2Fproc.c;h=c5c0c18efb50301f848124920778477c3c3c8d82;hb=18b264927674c480481466c40368554fb72f560f;hp=8e7d24c23cb863c9f5907bbeb666ff07dcdbccd0;hpb=f5f082502f5aeaa144a6ff60ad331e23957b0bbb;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86_64/proc.c b/Kernel/arch/x86_64/proc.c index 8e7d24c2..c5c0c18e 100644 --- a/Kernel/arch/x86_64/proc.c +++ b/Kernel/arch/x86_64/proc.c @@ -36,7 +36,7 @@ extern void APStartup(void); // 16-bit AP startup code extern Uint GetRIP(void); // start.asm extern Uint64 gInitialPML4[512]; // start.asm extern char gInitialKernelStack[]; -extern tSpinlock glThreadListLock; +extern tShortSpinlock glThreadListLock; extern int giNumCPUs; extern int giNextTID; extern int giTotalTickets; @@ -289,9 +289,14 @@ void ArchThreads_Init(void) } #endif + // Set Debug registers + __asm__ __volatile__ ("mov %0, %%db0" : : "r"(&gThreadZero)); + __asm__ __volatile__ ("mov %%rax, %%db1" : : "a"(0)); + gaCPUs[0].Current = &gThreadZero; gThreadZero.MemState.CR3 = (Uint)gInitialPML4 - KERNEL_BASE; + gThreadZero.CurCPU = 0; // Set timer frequency outb(0x43, 0x34); // Set Channel 0, Low/High, Rate Generator @@ -303,6 +308,8 @@ void ArchThreads_Init(void) // Change Stacks Proc_ChangeStack(); + + Log("Multithreading initialised"); } #if USE_MP @@ -387,11 +394,13 @@ void Proc_Start(void) // Set current task gaCPUs[0].Current = &gThreadZero; + gaCPUs[0].Current->CurCPU = 0; // Start Interrupts (and hence scheduler) __asm__ __volatile__("sti"); #endif MM_FinishVirtualInit(); + Log("Multithreading started"); } /** @@ -726,7 +735,7 @@ void Proc_Scheduler(int CPU) // If the spinlock is set, let it complete if(IS_LOCKED(&glThreadListLock)) return; - + // Get current thread thread = gaCPUs[CPU].Current;