#if USE_MP
# include <mp.h>
#endif
+#include <hal_proc.h>
// === FLAGS ===
#define DEBUG_TRACE_SWITCH 0
extern void APStartup(void); // 16-bit AP startup code
extern Uint GetEIP(void); // start.asm
extern Uint GetEIP_Sched(void); // proc.asm
-extern int GetCPUNum(void); // start.asm
extern Uint32 gaInitPageDir[1024]; // start.asm
extern char Kernel_Stack_Top[];
extern tShortSpinlock glThreadListLock;
extern void GetEIP_Sched_ret; // GetEIP call return location
// === PROTOTYPES ===
-void ArchThreads_Init(void);
+//void ArchThreads_Init(void);
#if USE_MP
void MP_StartAP(int CPU);
void MP_SendIPI(Uint8 APICID, int Vector, int DeliveryMode);
void Proc_ChangeStack(void);
// int Proc_Clone(Uint *Err, Uint Flags);
Uint Proc_MakeUserStack(void);
-void Proc_StartUser(Uint Entrypoint, Uint *Bases, int ArgC, char **ArgV, char **EnvP, int DataSize);
+//void Proc_StartUser(Uint Entrypoint, Uint *Bases, int ArgC, char **ArgV, char **EnvP, int DataSize);
void Proc_StartProcess(Uint16 SS, Uint Stack, Uint Flags, Uint16 CS, Uint IP);
int Proc_Demote(Uint *Err, int Dest, tRegs *Regs);
-void Proc_CallFaultHandler(tThread *Thread);
-void Proc_DumpThreadCPUState(tThread *Thread);
+//void Proc_CallFaultHandler(tThread *Thread);
+//void Proc_DumpThreadCPUState(tThread *Thread);
void Proc_Scheduler(int CPU);
// === GLOBALS ===
while( giNumInitingCPUs ) __asm__ __volatile__ ("hlt");
#else
// Create Idle Task
- if(Proc_Clone(0, 0) == 0)
+ if(Proc_Clone(0) == 0)
{
gpIdleThread = Proc_GetCurThread();
gpIdleThread->ThreadName = strdup("Idle Thread");
* \fn int Proc_Clone(Uint *Err, Uint Flags)
* \brief Clone the current process
*/
-int Proc_Clone(Uint *Err, Uint Flags)
+int Proc_Clone(Uint Flags)
{
tThread *newThread;
tThread *cur = Proc_GetCurThread();
__asm__ __volatile__ ("mov %%esp, %0": "=r"(esp));
__asm__ __volatile__ ("mov %%ebp, %0": "=r"(ebp));
- newThread = Threads_CloneTCB(Err, Flags);
+ newThread = Threads_CloneTCB(NULL, Flags);
if(!newThread) return -1;
// Initialise Memory Space (New Addr space or kernel stack)
thread = gCurrentThread;
#endif
- // NOTE:
- // 2011-04-05
- // Bug may be caused by DR0 not being maintained somewhere, hence
- // login is getting loaded with the idle state.
if( thread )
{
tRegs *regs;
__asm__ __volatile__ ( "mov %%esp, %0" : "=r" (esp) );
__asm__ __volatile__ ( "mov %%ebp, %0" : "=r" (ebp) );
eip = GetEIP();
- if(eip == SWITCH_MAGIC) return; // Check if a switch happened
+ if(eip == SWITCH_MAGIC) {
+ __asm__ __volatile__ ( "nop" : : : "eax","ebx","ecx","edx","edi","esi");
+ regs = (tRegs*)(ebp+(2+2)*4); // EBP,Ret + CPU,CurThread
+ #if USE_MP
+ thread = gaCPUs[CPU].Current;
+ #else
+ thread = gCurrentThread;
+ #endif
+ if(thread->bInstrTrace) {
+ regs->eflags |= 0x100; // Set TF
+// LogF("Tracing enabled\n");
+ Log("%p Scheduled (EIP = %p)", thread, thread->SavedState.EIP);
+ }
+ else
+ regs->eflags &= ~0x100;
+
+ return; // Check if a switch happened
+ }
// Save machine state
thread->SavedState.ESP = esp;
#endif
if( thread->bInstrTrace ) {
- Log("%p Scheduled", thread);
+ Log("%p Scheduled (EIP = %p)", thread, thread->SavedState.EIP);
}
// Set thread pointer