// Create a device and proceed to the main loop. void device_run(struct cen64_device *device) { fpu_state_t saved_fpu_state; // TODO: Preserve host registers pinned to the device. saved_fpu_state = fpu_get_state(); vr4300_cp1_init(&device->vr4300); rsp_late_init(&device->rsp); // Spin the device until we return (from setjmp). if (unlikely(device->debug_sfd > 0)) device_debug_spin(device); else if (device->multithread) device_multithread_spin(device); else device_spin(device); // TODO: Restore host registers that were pinned. fpu_set_state(saved_fpu_state); }
/* * Duplicate parent state in child * for U**X fork. */ kern_return_t machine_thread_dup( thread_act_t parent, thread_act_t child ) { struct i386_saved_state *parent_state, *child_state; struct i386_machine_state *ims; struct i386_float_state floatregs; #ifdef XXX /* Save the FPU state */ if ((pcb_t)(per_proc_info[cpu_number()].fpu_pcb) == parent->mact.pcb) { fp_state_save(parent); } #endif if (child->mact.pcb == NULL || parent->mact.pcb == NULL) return (KERN_FAILURE); /* Copy over the i386_saved_state registers */ child->mact.pcb->iss = parent->mact.pcb->iss; /* Check to see if parent is using floating point * and if so, copy the registers to the child * FIXME - make sure this works. */ if (parent->mact.pcb->ims.ifps) { if (fpu_get_state(parent, &floatregs) == KERN_SUCCESS) fpu_set_state(child, &floatregs); } /* FIXME - should a user specified LDT, TSS and V86 info * be duplicated as well?? - probably not. */ return (KERN_SUCCESS); }