From f0cb4dec51cb09af3ac6fb65eb96627359c5da43 Mon Sep 17 00:00:00 2001
From: Atle Nissestad <atle@nissestad.no>
Date: Sun, 16 Dec 2007 17:28:40 +0100
Subject: [PATCH] nios2: Remove all arch-specific code dependent on CONFIG_FPU

All of this was just copied from m68knommu at some point, and the code was not even
converted for nios2 arch.

Signed-off-by: Atle Nissestad <atle@nissestad.no>
---
 linux-2.6.x/arch/nios2nommu/kernel/nios2_ksyms.c |    1 -
 linux-2.6.x/arch/nios2nommu/kernel/process.c     |   65 ------------------
 linux-2.6.x/arch/nios2nommu/kernel/ptrace.c      |   51 +--------------
 linux-2.6.x/arch/nios2nommu/kernel/signal.c      |   76 ----------------------
 linux-2.6.x/include/asm-nios2nommu/ptrace.h      |    4 -
 linux-2.6.x/include/asm-nios2nommu/ucontext.h    |   15 ----
 6 files changed, 1 insertions(+), 211 deletions(-)

diff --git a/linux-2.6.x/arch/nios2nommu/kernel/nios2_ksyms.c b/linux-2.6.x/arch/nios2nommu/kernel/nios2_ksyms.c
index 1602b67..5f23651 100644
--- a/linux-2.6.x/arch/nios2nommu/kernel/nios2_ksyms.c
+++ b/linux-2.6.x/arch/nios2nommu/kernel/nios2_ksyms.c
@@ -49,7 +49,6 @@ extern void dump_thread(struct pt_regs *, struct user *);
 
 EXPORT_SYMBOL(__ioremap);
 EXPORT_SYMBOL(iounmap);
-EXPORT_SYMBOL(dump_fpu);
 EXPORT_SYMBOL(dump_thread);
 EXPORT_SYMBOL(strnlen);
 EXPORT_SYMBOL(strrchr);
diff --git a/linux-2.6.x/arch/nios2nommu/kernel/process.c b/linux-2.6.x/arch/nios2nommu/kernel/process.c
index 7561052..8927cee 100644
--- a/linux-2.6.x/arch/nios2nommu/kernel/process.c
+++ b/linux-2.6.x/arch/nios2nommu/kernel/process.c
@@ -240,17 +240,7 @@ void flush_thread(void)
 	/* Now, this task is no longer a kernel thread. */
 	current->thread.flags &= ~NIOS2_FLAG_KTHREAD;
 
-#ifdef CONFIG_FPU
-	unsigned long zero = 0;
-#endif
 	set_fs(USER_DS);
-#ifdef CONFIG_FPU
-	if (!FPU_IS_EMU)
-...;dgt2;
-		asm volatile (".chip 68k/68881\n\t"
-			      "frestore %0@\n\t"
-			      ".chip 68k" : : "a" (&zero));
-#endif
 }
 
 /*
@@ -337,22 +327,6 @@ int copy_thread(int nr, unsigned long clone_flags,
 
 	p->thread.ksp = (unsigned long)childstack;
 
-#ifdef CONFIG_FPU
-	if (!FPU_IS_EMU) {
-		/* Copy the current fpu state */
-...;dgt2;
-		asm volatile ("fsave %0" : : "m" (p->thread.fpstate[0]) : "memory");
-
-		if (p->thread.fpstate[0])
-		  asm volatile ("fmovemx %/fp0-%/fp7,%0\n\t"
-				"fmoveml %/fpiar/%/fpcr/%/fpsr,%1"
-				: : "m" (p->thread.fp[0]), "m" (p->thread.fpcntl[0])
-				: "memory");
-		/* Restore the state in case the fpu was busy */
-		asm volatile ("frestore %0" : : "m" (p->thread.fpstate[0]));
-	}
-#endif
-
 	/* Set the return value for the child. */
 	childregs->r2 = 0;  //;dgt2;...redundant?...see childregs->r2 above
 	childregs->r3 = 1;  //;dgt2;...eg: kernel_thread parent test
@@ -364,43 +338,6 @@ int copy_thread(int nr, unsigned long clone_flags,
 	return 0;
 }
 
-/* Fill in the fpu structure for a core dump.  */
-
-int dump_fpu(struct pt_regs *regs, struct user_m68kfp_struct *fpu)
-{
-#ifdef CONFIG_FPU
-	char fpustate[216];
-
-	if (FPU_IS_EMU) {
-		int i;
-
-		memcpy(fpu->fpcntl, current->thread.fpcntl, 12);
-		memcpy(fpu->fpregs, current->thread.fp, 96);
-		/* Convert internal fpu reg representation
-		 * into long double format
-		 */
-		for (i = 0; i < 24; i += 3)
-			fpu->fpregs[i] = ((fpu->fpregs[i] & 0xffff0000) << 15) |
-			                 ((fpu->fpregs[i] & 0x0000ffff) << 16);
-		return 1;
-	}
-
-	/* First dump the fpu context to avoid protocol violation.  */
-...;dgt2;tmp;
-	asm volatile ("fsave %0" :: "m" (fpustate[0]) : "memory");
-	if (!fpustate[0])
-		return 0;
-
-	asm volatile ("fmovem %/fpiar/%/fpcr/%/fpsr,%0"
-		:: "m" (fpu->fpcntl[0])
-		: "memory");
-	asm volatile ("fmovemx %/fp0-%/fp7,%0"
-		:: "m" (fpu->fpregs[0])
-		: "memory");
-#endif
-	return 1;
-}
-
 /*
  * fill in the user structure for a core dump..
  */
@@ -453,8 +390,6 @@ void dump_thread(struct pt_regs * regs, struct user * dump)
 	dump->regs.orig_r2 = regs->orig_r2;
 	dump->regs.estatus = regs->estatus;
 	dump->regs.ea = regs->ea;
-	/* dump floating point stuff */
-	//	dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp);
 }
 
 /*
diff --git a/linux-2.6.x/arch/nios2nommu/kernel/ptrace.c b/linux-2.6.x/arch/nios2nommu/kernel/ptrace.c
index e6ff3b3..59940aa 100644
--- a/linux-2.6.x/arch/nios2nommu/kernel/ptrace.c
+++ b/linux-2.6.x/arch/nios2nommu/kernel/ptrace.c
@@ -1,5 +1,5 @@
 /*
- *  linux/arch/m68knommu/kernel/ptrace.c
+ *  linux/arch/nios2nommu/kernel/ptrace.c
  *
  *  Copyright (C) 1994 by Hamish Macdonald
  *  Taken from linux/kernel/ptrace.c and modified for M680x0.
@@ -144,18 +144,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 			ret = -EIO;
 			if (addr < 19) {
 				tmp = get_reg(child, addr);
-#if 0 // No FPU stuff
-			} else if (addr >= 21 && addr < 49) {
-				tmp = child->thread.fp[addr - 21];
-#ifdef CONFIG_M68KFPU_EMU
-				/* Convert internal fpu reg representation
-				 * into long double format
-				 */
-				if (FPU_IS_EMU && (addr < 45) && !(addr % 3))
-					tmp = ((tmp & 0xffff0000) << 15) |
-					      ((tmp & 0x0000ffff) << 16);
-#endif
-#endif
 			} else if (addr == 49) {
 				tmp = child->mm->start_code;
 			} else if (addr == 50) {
@@ -195,23 +183,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 				ret = 0;
 				break;
 			}
-#if 0 // No FPU stuff
-			if (addr >= 21 && addr < 48)
-			{
-#ifdef CONFIG_M68KFPU_EMU
-				/* Convert long double format
-				 * into internal fpu reg representation
-				 */
-				if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) {
-					data = (unsigned long)data << 15;
-					data = (data & 0xffff0000) |
-					       ((data & 0x0000ffff) >> 1);
-				}
-#endif
-				child->thread.fp[addr - 21] = data;
-				ret = 0;
-			}
-#endif
 			break;
 
 		case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
@@ -303,26 +274,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 			break;
 		}
 
-#ifdef PTRACE_GETFPREGS
-		case PTRACE_GETFPREGS: { /* Get the child FPU state. */
-			ret = 0;
-			if (copy_to_user((void *)data, &child->thread.fp,
-					 sizeof(struct user_m68kfp_struct)))
-				ret = -EFAULT;
-			break;
-		}
-#endif
-
-#ifdef PTRACE_SETFPREGS
-		case PTRACE_SETFPREGS: { /* Set the child FPU state. */
-			ret = 0;
-			if (copy_from_user(&child->thread.fp, (void *)data,
-					   sizeof(struct user_m68kfp_struct)))
-				ret = -EFAULT;
-			break;
-		}
-#endif
-
 		default:
 			ret = -EIO;
 			break;
diff --git a/linux-2.6.x/arch/nios2nommu/kernel/signal.c b/linux-2.6.x/arch/nios2nommu/kernel/signal.c
index d8c30dc..ef7e91a 100644
--- a/linux-2.6.x/arch/nios2nommu/kernel/signal.c
+++ b/linux-2.6.x/arch/nios2nommu/kernel/signal.c
@@ -390,76 +390,6 @@ badframe:
 	return 0;
 }
 
-#ifdef CONFIG_FPU
-/*
- * Set up a signal frame.
- *
- * Not converted, no FPU support at moment.
- */
-
-static inline int save_fpu_state(struct sigcontext *sc, struct pt_regs *regs)
-{
-	int err = 0;
-
-	if (FPU_IS_EMU) {
-		/* save registers */
-		err |= copy_to_user(&sc->sc_fpcntl, current->thread.fpcntl, 12);
-		err |= copy_to_user(&sc->sc_fpregs, current->thread.fp, 24);
-		return err;
-	}
-
-	__asm__ volatile ("Nios II FPUt"
-			  : : );
-
-	if (sc->sc_fpstate[0]) {
-		fpu_version = sc->sc_fpstate[0];
-		__asm__ volatile ("Nios II FPU"
-				  : /* no outputs */
-				  : 
-				  : );
-	}
-	return err;
-}
-
-static inline int rt_save_fpu_state(struct ucontext *uc, struct pt_regs *regs)
-{
-	unsigned char fpstate[FPCONTEXT_SIZE];
-	int context_size = 0;
-	int err = 0;
-
-	if (FPU_IS_EMU) {
-		/* save fpu control register */
-		err |= copy_to_user(&uc->uc_mcontext.fpregs.f_pcr,
-				current->thread.fpcntl, 12);
-		/* save all other fpu register */
-		err |= copy_to_user(uc->uc_mcontext.fpregs.f_fpregs,
-				current->thread.fp, 96);
-		return err;
-	}
-
-	__asm__ volatile ("Nios II FPU"
-			  : : : );
-
-	err |= __put_user(*(long *)fpstate, (long *)&uc->uc_fpstate);
-	if (fpstate[0]) {
-		fpregset_t fpregs;
-		context_size = fpstate[1];
-		fpu_version = fpstate[0];
-		__asm__ volatile ("Nios II FPU"
-				  : /* no outputs */
-				  : 
-				  : );
-		err |= copy_to_user(&uc->uc_mcontext.fpregs, &fpregs,
-				    sizeof(fpregs));
-	}
-	if (context_size)
-		err |= copy_to_user((long *)&uc->uc_fpstate + 1, fpstate + 4,
-				    context_size);
-	return err;
-}
-
-#endif
-
 static int setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
 			     unsigned long mask)
 {
@@ -467,9 +397,6 @@ static int setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
 
 	err |= __put_user(mask, &sc->sc_mask);
 	err |= copy_to_user(&sc->regs, regs, sizeof(*regs));
-#ifdef CONFIG_FPU
-	err |= save_fpu_state(sc, regs);
-#endif
 	return err;
 }
 
@@ -508,9 +435,6 @@ static inline int rt_setup_ucontext(struct ucontext *uc, struct pt_regs *regs)
 	err |= __put_user(regs->sp, &gregs[23]);
 	err |= __put_user(sw->fp, &gregs[24]);
 	err |= __put_user(sw->gp, &gregs[25]);
-#ifdef CONFIG_FPU
-	err |= rt_save_fpu_state(uc, regs);
-#endif
 	return err;
 }
 
diff --git a/linux-2.6.x/include/asm-nios2nommu/ptrace.h b/linux-2.6.x/include/asm-nios2nommu/ptrace.h
index c4e20c3..924ad12 100644
--- a/linux-2.6.x/include/asm-nios2nommu/ptrace.h
+++ b/linux-2.6.x/include/asm-nios2nommu/ptrace.h
@@ -117,10 +117,6 @@ struct switch_stack {
 /* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
 #define PTRACE_GETREGS            12
 #define PTRACE_SETREGS            13
-#ifdef CONFIG_FPU
-#define PTRACE_GETFPREGS          14
-#define PTRACE_SETFPREGS          15
-#endif
 
 #ifdef __KERNEL__
 
diff --git a/linux-2.6.x/include/asm-nios2nommu/ucontext.h b/linux-2.6.x/include/asm-nios2nommu/ucontext.h
index f2e7ce2..dd904b4 100644
--- a/linux-2.6.x/include/asm-nios2nommu/ucontext.h
+++ b/linux-2.6.x/include/asm-nios2nommu/ucontext.h
@@ -29,22 +29,10 @@ typedef int greg_t;
 #define NGREG 32
 typedef greg_t gregset_t[NGREG];
 
-#ifdef CONFIG_FPU
-typedef struct fpregset {
-	int f_pcr;
-	int f_psr;
-	int f_fpiaddr;
-	int f_fpregs[8][3];
-} fpregset_t;
-#endif
-
 struct mcontext {
 	int version;
 	int status_extension;
 	gregset_t gregs;
-#ifdef CONFIG_FPU
-	fpregset_t fpregs;
-#endif
 };
 
 #define MCONTEXT_VERSION 2
@@ -54,9 +42,6 @@ struct ucontext {
 	struct ucontext  *uc_link;
 	stack_t		  uc_stack;
 	struct mcontext	  uc_mcontext;
-#ifdef CONFIG_FPU
-	unsigned long	  uc_filler[80];
-#endif
 	sigset_t	  uc_sigmask;	/* mask last for extensibility */
 };
 
-- 
1.5.3.3

