// === CONSTANTS ===
#define SWITCH_MAGIC 0xFFFACE55 // There is no code in this area
+// Base is 1193182
#define TIMER_DIVISOR 11931 //~100Hz
// === IMPORTS ===
tThread *Proc_GetCurThread();
void Proc_ChangeStack();
int Proc_Clone(Uint *Err, Uint Flags);
+void Proc_StartProcess(Uint16 SS, Uint Stack, Uint Flags, Uint16 CS, Uint IP);
void Proc_Scheduler();
// === GLOBALS ===
// --- Multiprocessing ---
#if USE_MP
+volatile int giNumInitingCPUs = 0;
tMPInfo *gMPFloatPtr = NULL;
tAPIC *gpMP_LocalAPIC = NULL;
Uint8 gaAPIC_to_CPU[256] = {0};
if( giNumCPUs > MAX_CPUS ) {
Warning("Too many CPUs detected (%i), only using %i of them", giNumCPUs, MAX_CPUS);
+ giNumCPUs = MAX_CPUS;
}
+
+ while( giNumInitingCPUs )
+ MM_FinishVirtualInit();
Panic("Uh oh... MP Table Parsing is unimplemented\n");
}
#else
giNumCPUs = 1;
gTSSs = &gTSS0;
+ MM_FinishVirtualInit();
#endif
// Initialise Double Fault TSS
*(Uint16*)(KERNEL_BASE|0x469) = 0xFFFF;
outb(0x70, 0x0F); outb(0x71, 0x0A); // Warm Reset
MP_SendIPI(gaCPUs[CPU].APICID, 0, 5);
+ giNumInitingCPUs ++;
}
void MP_SendIPI(Uint8 APICID, int Vector, int DeliveryMode)
while(*Bases)
*--stack = *Bases++;
*--stack = 0; // Return Address
- delta = (Uint)stack; // Reuse delta to save SP
- *--stack = ss; //Stack Segment
- *--stack = delta; //Stack Pointer
- *--stack = 0x0202; //EFLAGS (Resvd (0x2) and IF (0x20))
- *--stack = cs; //Code Segment
- *--stack = Entrypoint; //EIP
+ Proc_StartProcess(ss, (Uint)stack, 0x202, cs, Entrypoint);
+}
+
+void Proc_StartProcess(Uint16 SS, Uint Stack, Uint Flags, Uint16 CS, Uint IP)
+{
+ Uint *stack = (void*)Stack;
+ *--stack = SS; //Stack Segment
+ *--stack = Stack; //Stack Pointer
+ *--stack = Flags; //EFLAGS (Resvd (0x2) and IF (0x20))
+ *--stack = CS; //Code Segment
+ *--stack = IP; //EIP
//PUSHAD
*--stack = 0xAAAAAAAA; // eax
*--stack = 0xCCCCCCCC; // ecx
*--stack = 0x51515151; // esi
*--stack = 0xB4B4B4B4; // ebp
//Individual PUSHs
- *--stack = ss; // ds
- *--stack = ss; // es
- *--stack = ss; // fs
- *--stack = ss; // gs
+ *--stack = SS; // ds
+ *--stack = SS; // es
+ *--stack = SS; // fs
+ *--stack = SS; // gs
__asm__ __volatile__ (
"mov %%eax,%%esp;\n\t" // Set stack pointer
#endif
// Update Kernel Stack pointer
- gTSSs[CPU].ESP0 = thread->KernelStack;
+ gTSSs[CPU].ESP0 = thread->KernelStack-4;
// Set address space
#if USE_PAE