void delay (unsigned);
#define DELAY(x) delay(x)
-int fpu_valid_opcode(uint32_t);
void fpu_save(struct proc *, struct trapframe *);
void fpu_load(struct proc *);
void fpu_discard(struct proc *p);
bzero(fp, sizeof (*fp));
}
-// may look into optimizing this, bit map lookup ?
-
-int
-fpu_valid_opcode(uint32_t instr)
-{
- int opcode = instr & 0x7f;
- int valid = 0;
-
- if ((opcode & 0x3) == 0x3) {
- /* 32 bit instruction */
- switch(opcode) {
- case 0x07: // LOAD-FP
- case 0x27: // STORE-FP
- case 0x53: // OP-FP
- valid = 1;
- break;
- default:
- ;
- }
- } else {
- /* 16 bit instruction */
- int opcode16 = instr & 0xe003;
- switch (opcode16) {
- case 0x1000: // C.FLD
- case 0xa000: // C.SLD
- valid = 1;
- break;
- case 0x2002: // C.FLDSP
- // must verify dest register is float
- valid = opcode16 & (1 << 11);
- break;
- case 0xa002: // C.FSDSP
- // must verify dest register is float
- valid = opcode16 & (1 << 6);
- break;
- default:
- ;
- }
- }
- //printf("FPU check requested %d\n", valid);
- return valid;
-}
-
void
fpu_discard(struct proc *p)
{
break;
case EXCP_ILLEGAL_INSTRUCTION:
if ((frame->tf_sstatus & SSTATUS_FS_MASK) == SSTATUS_FS_OFF) {
- if (fpu_valid_opcode(frame->tf_stval)) {
-
- /* XXX do this here or should it be in the
- * trap handler in the restore path?
- */
- fpu_load(p);
-
- frame->tf_sstatus &= ~SSTATUS_FS_MASK;
- break;
- }
+ fpu_load(p);
+ frame->tf_sstatus &= ~SSTATUS_FS_MASK;
+ break;
}
printf("ILL at %lx scause %lx stval %lx\n", frame->tf_sepc,
frame->tf_scause, frame->tf_stval);