X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Ferrors.c;h=c66e49d193c268f3a2a26d0862ba336864c60a26;hb=dcebc16c576aa98eb6a33047f4c4b2b69b30a1bc;hp=3821281dc89b6d464f36762ac5b576f907c1ce8f;hpb=c575e49ea4543b45ccd2a47d57ec590ca995e707;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/errors.c b/Kernel/arch/x86/errors.c index 3821281d..c66e49d1 100644 --- a/Kernel/arch/x86/errors.c +++ b/Kernel/arch/x86/errors.c @@ -16,10 +16,13 @@ extern void Threads_Dump(void); extern void Threads_Fault(int Num); extern int GetCPUNum(void); extern void MM_DumpTables(tVAddr, tVAddr); +extern void Proc_EnableSSE(void); +extern void Proc_RestoreSSE(Uint32 Data); // === PROTOTYPES === void __stack_chk_fail(void); void ErrorHandler(tRegs *Regs); +void Proc_PrintBacktrace(void); void Error_Backtrace(Uint eip, Uint ebp); void StartupPrint(char *Str); @@ -81,6 +84,24 @@ void ErrorHandler(tRegs *Regs) MM_PageFault( cr, Regs->err_code, Regs ); return ; } + + // #NM - Coprocessor unavaliable + if(Regs->int_num == 7) + { + tThread *thread = Proc_GetCurThread(); + if(!thread->SavedState.bSSEModified) + { + Proc_EnableSSE(); + if(!thread->SavedState.SSE) + thread->SavedState.SSE = malloc(sizeof(tSSEState) + 0xF); + else + Proc_RestoreSSE( ((Uint)thread->SavedState.SSE + 0xF) & ~0xF ); + thread->SavedState.bSSEModified = 1; + __asm__ __volatile__ ("sti"); + return ; + } + // oops, SSE enabled but a #NM, bad news + } // VM8086 GPF if(Regs->int_num == 13 && Regs->eflags & 0x20000) @@ -160,6 +181,14 @@ void ErrorHandler(tRegs *Regs) for(;;) __asm__ __volatile__ ("hlt"); } + +void Proc_PrintBacktrace(void) +{ + Uint32 ebp; + __asm__ __volatile__ ("mov %%ebp, %0" : "=r" (ebp)); + Error_Backtrace( *(Uint32*)(ebp+4), *(Uint32*)ebp ); +} + /** * \fn void Error_Backtrace(Uint eip, Uint ebp) * \brief Unrolls the stack to trace execution