FreeBSD/sys/powerpc/powerpc/trap.c
/*
 * For now, this only deals with the particular unaligned access case
 * that gcc tends to generate.  Eventually it should handle all of the
 * possibilities that can happen on a 32-bit PowerPC in big-endian mode.
 */
For now, this only deals with the particular unaligned access case
that gcc tends to generate.  Eventually it should handle all of the
possibilities that can happen on a 32-bit PowerPC in big-endian mode.
For now this only deals with the particular unaligned access case that gcc tends to generate . Eventually it should handle all of the possibilities that can happen on a 32 - bit PowerPC in big - endian mode .
static int
fix_unaligned(struct thread *td, struct trapframe *frame)
{
	struct thread	*fputhread;
	int		indicator, reg;
	double		*fpr;
	indicator = EXC_ALI_OPCODE_INDICATOR(frame->cpu.aim.dsisr);
	switch (indicator) {
	case EXC_ALI_LFD:
	case EXC_ALI_STFD:
		reg = EXC_ALI_RST(frame->cpu.aim.dsisr);
		fpr = &td->td_pcb->pcb_fpu.fpr[reg].fpr;
		fputhread = PCPU_GET(fputhread);
		if (fputhread != td) {
			if (fputhread)
				save_fpu(fputhread);
			enable_fpu(td);
		}
		save_fpu(td);
		if (indicator == EXC_ALI_LFD) {
			if (copyin((void *)frame->dar, fpr,
			    sizeof(double)) != 0)
				return (-1);
			enable_fpu(td);
		} else {
			if (copyout(fpr, (void *)frame->dar,
			    sizeof(double)) != 0)
				return (-1);
		}
		return (0);
		break;
	}
	return (-1);
}
static int fix_unaligned ( struct thread * td , struct trapframe * frame ) { struct thread * fputhread ; int indicator , reg ; double * fpr ; indicator = EXC_ALI_OPCODE_INDICATOR ( frame -> cpu . aim . dsisr ) ; switch ( indicator ) { case EXC_ALI_LFD : case EXC_ALI_STFD : reg = EXC_ALI_RST ( frame -> cpu . aim . dsisr ) ; fpr = & td -> td_pcb -> pcb_fpu . fpr [ reg ] . fpr ; fputhread = PCPU_GET ( fputhread ) ; if ( fputhread != td ) { if ( fputhread ) save_fpu ( fputhread ) ; enable_fpu ( td ) ; } save_fpu ( td ) ; if ( indicator == EXC_ALI_LFD ) { if ( copyin ( ( void * ) frame -> dar , fpr , sizeof ( double ) ) != 0 ) return ( -1 ) ; enable_fpu ( td ) ; } else { if ( copyout ( fpr , ( void * ) frame -> dar , sizeof ( double ) ) != 0 ) return ( -1 ) ; } return ( 0 ) ; break ; } return ( -1 ) ; }
For now, this only deals with the particular unaligned access case
 that gcc tends to generate.
For now this only deals with the particular unaligned access case that gcc tends to generate .
/* Juggle the FPU to ensure that we've initialized
		 * the FPRs, and that their current state is in
		 * the PCB.
		 */