From: John Hodge Date: Sat, 17 Jul 2010 10:23:04 +0000 (+0800) Subject: APs start nicely now. X-Git-Tag: rel0.06~100 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;ds=sidebyside;h=ed3be2f46a5875d4ca2bd7e54b1a3f663e223c0d;p=tpg%2Facess2.git APs start nicely now. TODO: Get APIC timers working --- diff --git a/Kernel/arch/x86/proc.asm b/Kernel/arch/x86/proc.asm index 348c31ba..b0a1ef05 100644 --- a/Kernel/arch/x86/proc.asm +++ b/Kernel/arch/x86/proc.asm @@ -26,8 +26,8 @@ SchedulerBase: mov fs, ax mov gs, ax - mov eax, [esp+12*4] ; CPU Number - push eax ; Pus as argument + call GetCPUNum + push eax ; Push as argument call Proc_Scheduler diff --git a/Kernel/arch/x86/proc.c b/Kernel/arch/x86/proc.c index c9035e1b..5ee3ccc5 100644 --- a/Kernel/arch/x86/proc.c +++ b/Kernel/arch/x86/proc.c @@ -76,6 +76,7 @@ tMPInfo *gMPFloatPtr = NULL; tAPIC *gpMP_LocalAPIC = NULL; Uint8 gaAPIC_to_CPU[256] = {0}; tCPU gaCPUs[MAX_CPUS]; +tTSS gaTSSs[MAX_CPUS]; // TSS Array int giProc_BootProcessorID = 0; #else tThread *gCurrentThread = NULL; @@ -83,7 +84,7 @@ tThread *gCurrentThread = NULL; #if USE_PAE Uint32 *gPML4s[4] = NULL; #endif -tTSS *gTSSs = NULL; +tTSS *gTSSs = NULL; // Pointer to TSS array tTSS gTSS0 = {0}; // --- Error Recovery --- char gaDoubleFaultStack[1024]; @@ -271,6 +272,7 @@ void ArchThreads_Init(void) Warning("Too many CPUs detected (%i), only using %i of them", giNumCPUs, MAX_CPUS); giNumCPUs = MAX_CPUS; } + gTSSs = gaTSSs; } else { Log("No MP Table was found, assuming uniprocessor\n"); @@ -825,6 +827,8 @@ void Proc_Scheduler(int CPU) gCurrentThread = thread; #endif + //Log("CPU = %i", CPU); + // Update Kernel Stack pointer gTSSs[CPU].ESP0 = thread->KernelStack-4; diff --git a/Kernel/arch/x86/start.asm b/Kernel/arch/x86/start.asm index 1e2563b4..302d1c3c 100644 --- a/Kernel/arch/x86/start.asm +++ b/Kernel/arch/x86/start.asm @@ -141,22 +141,22 @@ APStartup: lidt [gIDTPtr] mov eax, [gpMP_LocalAPIC] - xor ecx, ecx - mov cl, BYTE [eax+0x20] + mov ecx, [eax+0x20] ; Read ID + shr ecx, 24 + ;xchg bx, bx ; MAGIC BREAK ; CL is now local APIC ID mov cl, BYTE [gaAPIC_to_CPU+ecx] ; CL is now the CPU ID mov BYTE [gaCPUs+ecx*8+1], 1 ; Decrement the remaining CPU count dec DWORD [giNumInitingCPUs] - xchg bx, bx ; MAGIC BREAK ; Set TSS shl cx, 3 add cx, 0x30 ltr cx ; CPU is now marked as initialised sti - xchg bx, bx ; MAGIC BREAK + ;xchg bx, bx ; MAGIC BREAK .hlt: hlt jmp .hlt