/* * if haven't started using the FPU the record that we're using it and init * it. If already using it, then restore its state */ static void fpu_device_handler(int trapno, u_int eip) { u_short cpu = sys_get_cpu_id(); assert(cpu < 32); cpulock_acquire(); /* clear the TS bit */ sys_clts(); if ((UAREA.u_fpu & (1<<cpu)) == 0) { asm volatile ("fninit\n"); UAREA.u_fpu |= (1<<cpu); } else {
/* if haven't started using the FPU the record that we're using it and init it. If already using it, then restore its state */ static void fpu_device_handler(int trapno, u_int eip) { dlockputs(__UAREA_LD, "fpu_device_handler get lock "); EXOS_LOCK(UAREA_LOCK); dlockputs(__UAREA_LD, "... got lock\n"); EnterCritical(); /* clear the TS bit */ sys_clts(); if (UAREA.u_fpu == 0) { asm("fninit\n"); UAREA.u_fpu = 1; } else asm("frstor __exos_fpus\n"); _exos_fpu_used_ctxt = 1; EXOS_UNLOCK(UAREA_LOCK); dlockputs(__UAREA_LD, "fpu_device_handler release lock\n"); ExitCritical(); }