X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Fproc.c;h=45c5a56126ce89fb453b42e54ff9369d3ace3216;hb=f73bf5f5cf0e188bafe905091aa311627af54b76;hp=62980674215919ebd538b0ee2ce2f0403e2c1795;hpb=7d2f8503550796a3cd42d01f944c2baa49a2fcfa;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/proc.c b/Kernel/arch/x86/proc.c index 62980674..45c5a561 100644 --- a/Kernel/arch/x86/proc.c +++ b/Kernel/arch/x86/proc.c @@ -26,7 +26,7 @@ extern void APStartup(); // 16-bit AP startup code extern Uint GetEIP(); // start.asm extern Uint32 gaInitPageDir[1024]; // start.asm extern void Kernel_Stack_Top; -extern volatile int giThreadListLock; +extern tSpinlock glThreadListLock; extern int giNumCPUs; extern int giNextTID; extern int giTotalTickets; @@ -39,6 +39,7 @@ extern tThread *Threads_GetNextToRun(int CPU); extern void Threads_Dump(); extern tThread *Threads_CloneTCB(Uint *Err, Uint Flags); extern void Isr8(); // Double Fault +extern void Proc_ReturnToUser(); // === PROTOTYPES === void ArchThreads_Init(); @@ -51,6 +52,7 @@ 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_CallFaultHandler(tThread *Thread); void Proc_Scheduler(); // === GLOBALS === @@ -693,6 +695,18 @@ int Proc_Demote(Uint *Err, int Dest, tRegs *Regs) return 0; } +/** + * \brief Calls a signal handler in user mode + * \note Used for signals + */ +void Proc_CallFaultHandler(tThread *Thread) +{ + // Rewinds the stack and calls the user function + // Never returns + __asm__ __volatile__ ("mov %0, %%ebp;\n\tcall Proc_ReturnToUser" :: "r"(Thread->FaultHandler)); + for(;;); +} + /** * \fn void Proc_Scheduler(int CPU) * \brief Swap current thread and clears dead threads @@ -703,7 +717,7 @@ void Proc_Scheduler(int CPU) tThread *thread; // If the spinlock is set, let it complete - if(giThreadListLock) return; + if(IS_LOCKED(&glThreadListLock)) return; // Clear Delete Queue while(gDeleteThreads)