linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Kernel Math Emulation again
@ 1999-11-30  9:03 Ole.Reinartz
  1999-11-30 10:04 ` Neil Blackwood
  0 siblings, 1 reply; 8+ messages in thread
From: Ole.Reinartz @ 1999-11-30  9:03 UTC (permalink / raw)
  To: linuxppc-embedded


Hi there,

I know this was raised here already several times...
I like to run linux on an 860 with the full distribution NFS mounted
 ( ftp://linuxppc.cs.nmt.edu/pub/linuxppc/embedded/mbxroot.full.tgz )
Unfortunately most (or all) or the binaries out of this tar is compiled
without builtin math emulation. So to run this I need kernel math emulation.
I found that in
arch/ppc/kernel/softemu8xx.c
there are already some instructions emulated, using the FPU exception (at
least since version 2.2.5. ). But those are only load/store instructions
which are in C- compiler generated function pre/post code already when it is
compiled without -msoft-float.
Is there something in the works by someone which will also support all the
other instructions?
In time I try to get those in, linking libgcc.a to the kernel (zImage grows
about 200k) and implementing the instructions using functions inside it. But
until now without great success.

Cheers
	Ole


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Kernel Math Emulation again
  1999-11-30  9:03 Ole.Reinartz
@ 1999-11-30 10:04 ` Neil Blackwood
  1999-12-02 22:32   ` Bill Roman
  0 siblings, 1 reply; 8+ messages in thread
From: Neil Blackwood @ 1999-11-30 10:04 UTC (permalink / raw)
  To: Ole.Reinartz; +Cc: linuxppc-embedded


There is some kernel maths emulation stuff in 2.3.18.
You will need to copy it over to which ever version you are using. It works.
Look for directories math-emu.
You will need to change config files and make files as well. Its fairly
easy. Even I managed it.

                                Neil Blackwood
----- Original Message -----
From: <Ole.Reinartz@nokia.com>
To: <linuxppc-embedded@lists.linuxppc.org>
Sent: 30 November 1999 09:03
Subject: Kernel Math Emulation again


>
> Hi there,
>
> I know this was raised here already several times...
> I like to run linux on an 860 with the full distribution NFS mounted
>  ( ftp://linuxppc.cs.nmt.edu/pub/linuxppc/embedded/mbxroot.full.tgz )
> Unfortunately most (or all) or the binaries out of this tar is compiled
> without builtin math emulation. So to run this I need kernel math
emulation.
> I found that in
> arch/ppc/kernel/softemu8xx.c
> there are already some instructions emulated, using the FPU exception (at
> least since version 2.2.5. ). But those are only load/store instructions
> which are in C- compiler generated function pre/post code already when it
is
> compiled without -msoft-float.
> Is there something in the works by someone which will also support all the
> other instructions?
> In time I try to get those in, linking libgcc.a to the kernel (zImage
grows
> about 200k) and implementing the instructions using functions inside it.
But
> until now without great success.
>
> Cheers
> Ole
>
>
>


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Kernel Math Emulation again
  1999-11-30 10:04 ` Neil Blackwood
@ 1999-12-02 22:32   ` Bill Roman
  0 siblings, 0 replies; 8+ messages in thread
From: Bill Roman @ 1999-12-02 22:32 UTC (permalink / raw)
  To: linuxppc-embedded


Neil Blackwood wrote:
> 
> There is some kernel maths emulation stuff in 2.3.18.
> You will need to copy it over to which ever version you are using. It works.
> Look for directories math-emu.
> You will need to change config files and make files as well. Its fairly
> easy. Even I managed it.

Thanks, Neil!  I had been very optimistic when I found this code in 2.3.18, and
was disappointed when it turned out it wouldn't compile in that context.
Without your hint, I don't think I would have guessed that transplanting it
into a 2.2 kernel would have worked.

To save everyone else a few hours of grepping and tweaking, here are
instructions and a patch file to add math emulation to the 2.2.13 kernel
sources from linuxppc.cs.nmt.edu.

1.  Obtain mpc8xx-2.2.13.tgz and linux-2.3.18.tgz from
ftp://linuxppc.cs.nmt.edu/pub/linuxppc/embedded/.  Untar them into two
separate source trees.  (Note: all that's needed from 2.3.18 is the
math emulator; does anyone know whether that's available separately,
or could someone split it out and put it on the FTP site?)

2.  Copy the arch/ppc/mathemu directory from the 2.3.18 tree to the
2.2.13 tree.

3.  Apply the patch (below).  Note that I am building for an MBX, so that's
what .config gets patched for.

4.  make symlinks config dep clean zImage.

The following is the patch.
----------------------------------------------------------------------------
diff -ur linux-mpc8xx-2.2.13/.config linux/.config
--- linux-mpc8xx-2.2.13/.config	Fri Oct 22 16:08:42 1999
+++ linux/.config	Wed Dec  1 17:10:01 1999
@@ -10,9 +10,9 @@
 # CONFIG_PPC64 is not set
 CONFIG_8xx=y
 # CONFIG_MPC821 is not set
-CONFIG_MPC823=y
+# CONFIG_MPC823 is not set
 # CONFIG_MPC850 is not set
-# CONFIG_MPC860 is not set
+CONFIG_MPC860=y
 # CONFIG_MPC860T is not set
 CONFIG_SERIAL_CONSOLE=y
 # CONFIG_PMAC is not set
@@ -20,12 +20,13 @@
 # CONFIG_CHRP is not set
 # CONFIG_ALL_PPC is not set
 # CONFIG_APUS is not set
-# CONFIG_MBX is not set
+CONFIG_MBX=y
 # CONFIG_RPXLITE is not set
 # CONFIG_RPXCLASSIC is not set
-CONFIG_BSEIP=y
+# CONFIG_BSEIP is not set
 # CONFIG_SMP is not set
 CONFIG_MACH_SPECIFIC=y
+CONFIG_MATH_EMULATION=y
 
 #
 # General setup
@@ -297,8 +298,7 @@
 # MPC8xx CPM Options
 #
 CONFIG_SCC_ENET=y
-# CONFIG_SCC1_ENET is not set
-CONFIG_SCC2_ENET=y
+CONFIG_SCC1_ENET=y
 # CONFIG_FEC_ENET is not set
 # CONFIG_CPM_IIC is not set
 # CONFIG_UCODE_PATCH is not set
diff -ur linux-mpc8xx-2.2.13/arch/ppc/Makefile linux/arch/ppc/Makefile
--- linux-mpc8xx-2.2.13/arch/ppc/Makefile	Wed Oct 20 15:33:30 1999
+++ linux/arch/ppc/Makefile	Wed Dec  1 16:16:45 1999
@@ -41,6 +41,12 @@
 ARCHIVES := arch/ppc/kernel/kernel.o arch/ppc/mm/mm.o arch/ppc/lib/lib.o $(ARCHIVES)
 CORE_FILES := arch/ppc/kernel/kernel.o arch/ppc/mm/mm.o arch/ppc/lib/lib.o $(CORE_FILES)
 
+ifdef CONFIG_MATH_EMULATION
+SUBDIRS += arch/ppc/math-emu
+ARCHIVES += arch/ppc/math-emu/math-emu.o
+CORE_FILES += arch/ppc/math-emu/math-emu.o
+endif
+
 ifdef CONFIG_XMON
 SUBDIRS += arch/ppc/xmon
 CORE_FILES += arch/ppc/xmon/x.o
diff -ur linux-mpc8xx-2.2.13/arch/ppc/config.in linux/arch/ppc/config.in
--- linux-mpc8xx-2.2.13/arch/ppc/config.in	Fri Oct 22 14:56:10 1999
+++ linux/arch/ppc/config.in	Wed Dec  1 16:29:14 1999
@@ -37,6 +37,15 @@
 if [ "$CONFIG_ALL_PPC" != "y" ];then
   define_bool CONFIG_MACH_SPECIFIC y
 fi
+
+if [ "$CONFIG_8xx" = "y" ]; then
+  bool 'Math emulation' CONFIG_MATH_EMULATION
+else
+  if [ "$CONFIG_PPC64" != "y" ];then
+    define_bool CONFIG_6xx y
+  fi
+fi
+
 endmenu
 
 mainmenu_option next_comment
diff -ur linux-mpc8xx-2.2.13/arch/ppc/kernel/Makefile linux/arch/ppc/kernel/Makefile
--- linux-mpc8xx-2.2.13/arch/ppc/kernel/Makefile	Fri Oct 22 15:21:39 1999
+++ linux/arch/ppc/kernel/Makefile	Thu Dec  2 10:34:19 1999
@@ -30,7 +30,7 @@
 endif
 
 ifeq ($(CONFIG_8xx),y)
-O_OBJS += m8xx_setup.o softemu8xx.o ppc8xx_pic.o
+O_OBJS += m8xx_setup.o  ppc8xx_pic.o
 ifdef CONFIG_PCI
 O_OBJS += qspan_pci.o
 endif
diff -ur linux-mpc8xx-2.2.13/arch/ppc/kernel/traps.c linux/arch/ppc/kernel/traps.c
--- linux-mpc8xx-2.2.13/arch/ppc/kernel/traps.c	Fri Oct 22 14:04:09 1999
+++ linux/arch/ppc/kernel/traps.c	Thu Dec  2 10:32:22 1999
@@ -230,12 +230,12 @@
 SoftwareEmulation(struct pt_regs *regs)
 {
 	int	errcode;
-	extern int	Soft_emulate_8xx (struct pt_regs *regs);
+	extern int	do_mathemu(struct pt_regs *regs);
 	extern void print_8xx_pte(struct mm_struct *, unsigned long);	
 
 	if (user_mode(regs))
 	{
-		if ((errcode = Soft_emulate_8xx(regs))) {
+		if ((errcode = do_mathemu(regs))) {
 printk("Software Emulation %s/%d NIP: %lx *NIP: 0x%x code: %x",
        current->comm,current->pid,
        regs->nip, *((uint *)regs->nip), errcode);
diff -ur linux-mpc8xx-2.2.13/include/asm-ppc/processor.h linux/include/asm-ppc/processor.h
--- linux-mpc8xx-2.2.13/include/asm-ppc/processor.h	Fri Oct 22 16:10:02 1999
+++ linux/include/asm-ppc/processor.h	Wed Dec  1 16:56:20 1999
@@ -57,8 +57,33 @@
 #define HID0_BTCD	(1<<1)		/* Branch target cache disable */
 
 /* fpscr settings */
-#define FPSCR_FX        (1<<31)
-#define FPSCR_FEX       (1<<30)
+#define FPSCR_FX        0x80000000      /* FPU exception summary */
+#define FPSCR_FEX       0x40000000      /* FPU enabled exception summary */
+#define FPSCR_VX        0x20000000      /* Invalid operation summary */
+#define FPSCR_OX        0x10000000      /* Overflow exception summary */
+#define FPSCR_UX        0x08000000      /* Underflow exception summary */
+#define FPSCR_ZX        0x04000000      /* Zero-devide exception summary */
+#define FPSCR_XX        0x02000000      /* Inexact exception summary */
+#define FPSCR_VXSNAN    0x01000000      /* Invalid op for SNaN */
+#define FPSCR_VXISI     0x00800000      /* Invalid op for Inv - Inv */
+#define FPSCR_VXIDI     0x00400000      /* Invalid op for Inv / Inv */
+#define FPSCR_VXZDZ     0x00200000      /* Invalid op for Zero / Zero */
+#define FPSCR_VXIMZ     0x00100000      /* Invalid op for Inv * Zero */
+#define FPSCR_VXVC      0x00080000      /* Invalid op for Compare */
+#define FPSCR_FR        0x00040000      /* Fraction rounded */
+#define FPSCR_FI        0x00020000      /* Fraction inexact */
+#define FPSCR_FPRF      0x0001f000      /* FPU Result Flags */
+#define FPSCR_FPCC      0x0000f000      /* FPU Condition Codes */
+#define FPSCR_VXSOFT    0x00000400      /* Invalid op for software request */
+#define FPSCR_VXSQRT    0x00000200      /* Invalid op for square root */
+#define FPSCR_VXCVI     0x00000100      /* Invalid op for integer convert */
+#define FPSCR_VE        0x00000080      /* Invalid op exception enable */
+#define FPSCR_OE        0x00000040      /* IEEE overflow exception enable */
+#define FPSCR_UE        0x00000020      /* IEEE underflow exception enable */
+#define FPSCR_ZE        0x00000010      /* IEEE zero divide exception enable */
+#define FPSCR_XE        0x00000008      /* FP inexact exception enable */
+#define FPSCR_NI        0x00000004      /* FPU non IEEE-Mode */
+#define FPSCR_RN        0x00000003      /* FPU rounding control */
 
 #define _MACH_prep     1
 #define _MACH_Pmac     2  /* pmac or pmac clone (non-chrp) */

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Kernel Math Emulation again
@ 1999-12-03  8:46 Ralf HECKHAUSEN
  0 siblings, 0 replies; 8+ messages in thread
From: Ralf HECKHAUSEN @ 1999-12-03  8:46 UTC (permalink / raw)
  To: linuxppc-embedded


Question: 
Is there any significant difference in execution speed or program size in either of the two solutions (compiling with soft-float or using the kernel math emulation)?

Ralf

>>> Bill Roman <roman@alerton.com> 12/02 11:32 pm >>>

Neil Blackwood wrote:
> 
> There is some kernel maths emulation stuff in 2.3.18.
> You will need to copy it over to which ever version you are using. It works.
> Look for directories math-emu.
> You will need to change config files and make files as well. Its fairly
> easy. Even I managed it.

Thanks, Neil!  I had been very optimistic when I found this code in 2.3.18, and
was disappointed when it turned out it wouldn't compile in that context.
Without your hint, I don't think I would have guessed that transplanting it
into a 2.2 kernel would have worked.

To save everyone else a few hours of grepping and tweaking, here are
instructions and a patch file to add math emulation to the 2.2.13 kernel
sources from linuxppc.cs.nmt.edu.

1.  Obtain mpc8xx-2.2.13.tgz and linux-2.3.18.tgz from
ftp://linuxppc.cs.nmt.edu/pub/linuxppc/embedded/.  Untar them into two
separate source trees.  (Note: all that's needed from 2.3.18 is the
math emulator; does anyone know whether that's available separately,
or could someone split it out and put it on the FTP site?)

2.  Copy the arch/ppc/mathemu directory from the 2.3.18 tree to the
2.2.13 tree.

3.  Apply the patch (below).  Note that I am building for an MBX, so that's
what .config gets patched for.

4.  make symlinks config dep clean zImage.

The following is the patch.
----------------------------------------------------------------------------
diff -ur linux-mpc8xx-2.2.13/.config linux/.config
--- linux-mpc8xx-2.2.13/.config	Fri Oct 22 16:08:42 1999
+++ linux/.config	Wed Dec  1 17:10:01 1999
@@ -10,9 +10,9 @@
 # CONFIG_PPC64 is not set
 CONFIG_8xx=y
 # CONFIG_MPC821 is not set
-CONFIG_MPC823=y
+# CONFIG_MPC823 is not set
 # CONFIG_MPC850 is not set
-# CONFIG_MPC860 is not set
+CONFIG_MPC860=y
 # CONFIG_MPC860T is not set
 CONFIG_SERIAL_CONSOLE=y
 # CONFIG_PMAC is not set
@@ -20,12 +20,13 @@
 # CONFIG_CHRP is not set
 # CONFIG_ALL_PPC is not set
 # CONFIG_APUS is not set
-# CONFIG_MBX is not set
+CONFIG_MBX=y
 # CONFIG_RPXLITE is not set
 # CONFIG_RPXCLASSIC is not set
-CONFIG_BSEIP=y
+# CONFIG_BSEIP is not set
 # CONFIG_SMP is not set
 CONFIG_MACH_SPECIFIC=y
+CONFIG_MATH_EMULATION=y
 
 #
 # General setup
@@ -297,8 +298,7 @@
 # MPC8xx CPM Options
 #
 CONFIG_SCC_ENET=y
-# CONFIG_SCC1_ENET is not set
-CONFIG_SCC2_ENET=y
+CONFIG_SCC1_ENET=y
 # CONFIG_FEC_ENET is not set
 # CONFIG_CPM_IIC is not set
 # CONFIG_UCODE_PATCH is not set
diff -ur linux-mpc8xx-2.2.13/arch/ppc/Makefile linux/arch/ppc/Makefile
--- linux-mpc8xx-2.2.13/arch/ppc/Makefile	Wed Oct 20 15:33:30 1999
+++ linux/arch/ppc/Makefile	Wed Dec  1 16:16:45 1999
@@ -41,6 +41,12 @@
 ARCHIVES := arch/ppc/kernel/kernel.o arch/ppc/mm/mm.o arch/ppc/lib/lib.o $(ARCHIVES)
 CORE_FILES := arch/ppc/kernel/kernel.o arch/ppc/mm/mm.o arch/ppc/lib/lib.o $(CORE_FILES)
 
+ifdef CONFIG_MATH_EMULATION
+SUBDIRS += arch/ppc/math-emu
+ARCHIVES += arch/ppc/math-emu/math-emu.o
+CORE_FILES += arch/ppc/math-emu/math-emu.o
+endif
+
 ifdef CONFIG_XMON
 SUBDIRS += arch/ppc/xmon
 CORE_FILES += arch/ppc/xmon/x.o
diff -ur linux-mpc8xx-2.2.13/arch/ppc/config.in linux/arch/ppc/config.in
--- linux-mpc8xx-2.2.13/arch/ppc/config.in	Fri Oct 22 14:56:10 1999
+++ linux/arch/ppc/config.in	Wed Dec  1 16:29:14 1999
@@ -37,6 +37,15 @@
 if [ "$CONFIG_ALL_PPC" != "y" ];then
   define_bool CONFIG_MACH_SPECIFIC y
 fi
+
+if [ "$CONFIG_8xx" = "y" ]; then
+  bool 'Math emulation' CONFIG_MATH_EMULATION
+else
+  if [ "$CONFIG_PPC64" != "y" ];then
+    define_bool CONFIG_6xx y
+  fi
+fi
+
 endmenu
 
 mainmenu_option next_comment
diff -ur linux-mpc8xx-2.2.13/arch/ppc/kernel/Makefile linux/arch/ppc/kernel/Makefile
--- linux-mpc8xx-2.2.13/arch/ppc/kernel/Makefile	Fri Oct 22 15:21:39 1999
+++ linux/arch/ppc/kernel/Makefile	Thu Dec  2 10:34:19 1999
@@ -30,7 +30,7 @@
 endif
 
 ifeq ($(CONFIG_8xx),y)
-O_OBJS += m8xx_setup.o softemu8xx.o ppc8xx_pic.o
+O_OBJS += m8xx_setup.o  ppc8xx_pic.o
 ifdef CONFIG_PCI
 O_OBJS += qspan_pci.o
 endif
diff -ur linux-mpc8xx-2.2.13/arch/ppc/kernel/traps.c linux/arch/ppc/kernel/traps.c
--- linux-mpc8xx-2.2.13/arch/ppc/kernel/traps.c	Fri Oct 22 14:04:09 1999
+++ linux/arch/ppc/kernel/traps.c	Thu Dec  2 10:32:22 1999
@@ -230,12 +230,12 @@
 SoftwareEmulation(struct pt_regs *regs)
 {
 	int	errcode;
-	extern int	Soft_emulate_8xx (struct pt_regs *regs);
+	extern int	do_mathemu(struct pt_regs *regs);
 	extern void print_8xx_pte(struct mm_struct *, unsigned long);	
 
 	if (user_mode(regs))
 	{
-		if ((errcode = Soft_emulate_8xx(regs))) {
+		if ((errcode = do_mathemu(regs))) {
 printk("Software Emulation %s/%d NIP: %lx *NIP: 0x%x code: %x",
        current->comm,current->pid,
        regs->nip, *((uint *)regs->nip), errcode);
diff -ur linux-mpc8xx-2.2.13/include/asm-ppc/processor.h linux/include/asm-ppc/processor.h
--- linux-mpc8xx-2.2.13/include/asm-ppc/processor.h	Fri Oct 22 16:10:02 1999
+++ linux/include/asm-ppc/processor.h	Wed Dec  1 16:56:20 1999
@@ -57,8 +57,33 @@
 #define HID0_BTCD	(1<<1)		/* Branch target cache disable */
 
 /* fpscr settings */
-#define FPSCR_FX        (1<<31)
-#define FPSCR_FEX       (1<<30)
+#define FPSCR_FX        0x80000000      /* FPU exception summary */
+#define FPSCR_FEX       0x40000000      /* FPU enabled exception summary */
+#define FPSCR_VX        0x20000000      /* Invalid operation summary */
+#define FPSCR_OX        0x10000000      /* Overflow exception summary */
+#define FPSCR_UX        0x08000000      /* Underflow exception summary */
+#define FPSCR_ZX        0x04000000      /* Zero-devide exception summary */
+#define FPSCR_XX        0x02000000      /* Inexact exception summary */
+#define FPSCR_VXSNAN    0x01000000      /* Invalid op for SNaN */
+#define FPSCR_VXISI     0x00800000      /* Invalid op for Inv - Inv */
+#define FPSCR_VXIDI     0x00400000      /* Invalid op for Inv / Inv */
+#define FPSCR_VXZDZ     0x00200000      /* Invalid op for Zero / Zero */
+#define FPSCR_VXIMZ     0x00100000      /* Invalid op for Inv * Zero */
+#define FPSCR_VXVC      0x00080000      /* Invalid op for Compare */
+#define FPSCR_FR        0x00040000      /* Fraction rounded */
+#define FPSCR_FI        0x00020000      /* Fraction inexact */
+#define FPSCR_FPRF      0x0001f000      /* FPU Result Flags */
+#define FPSCR_FPCC      0x0000f000      /* FPU Condition Codes */
+#define FPSCR_VXSOFT    0x00000400      /* Invalid op for software request */
+#define FPSCR_VXSQRT    0x00000200      /* Invalid op for square root */
+#define FPSCR_VXCVI     0x00000100      /* Invalid op for integer convert */
+#define FPSCR_VE        0x00000080      /* Invalid op exception enable */
+#define FPSCR_OE        0x00000040      /* IEEE overflow exception enable */
+#define FPSCR_UE        0x00000020      /* IEEE underflow exception enable */
+#define FPSCR_ZE        0x00000010      /* IEEE zero divide exception enable */
+#define FPSCR_XE        0x00000008      /* FP inexact exception enable */
+#define FPSCR_NI        0x00000004      /* FPU non IEEE-Mode */
+#define FPSCR_RN        0x00000003      /* FPU rounding control */
 
 #define _MACH_prep     1
 #define _MACH_Pmac     2  /* pmac or pmac clone (non-chrp) */


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Kernel Math Emulation again
@ 1999-12-03  9:03 Ole.Reinartz
  1999-12-05 23:54 ` Peter Brown
  0 siblings, 1 reply; 8+ messages in thread
From: Ole.Reinartz @ 1999-12-03  9:03 UTC (permalink / raw)
  To: linuxppc-embedded


With soft-float your code generally gets bigger but potentially faster,
because in the case of soft-float the µP can execute the jump instr. to the
math- emulation routines out of line (or the compiler can even inline them).
In the case of kernel math emulation the µP has to handle an exception
everytime a fp- instr. is executed.
On the other hand with kernel math emulation you can potentially run any
pmac- compiled program on your mpc8xx without recompilation. You could even
run a pmac- netscape on it (anyone tried that yet?).
In general you should avoid doing heavy fp- calculation on a µP without HW
support for it. I once tried to run an mpeg3- player on an mpc860@50MHz
(compiled with -msoft-float) to decode a 1:30 song, but after 30 minutes I
ran out of patience... :-)

Ole

BTW: I put math-emu into kernel v.2.2.5 after Neil's hint (thank you Neil!)



> -----Original Message-----
> From: EXT Ralf HECKHAUSEN [mailto:RHeckhau@frequentis.com]
> Sent: Freitag, 3. Dezember 1999 9:46
> To: linuxppc-embedded@lists.linuxppc.org
> Subject: Re: Kernel Math Emulation again
> 
> 
> 
> Question: 
> Is there any significant difference in execution speed or 
> program size in either of the two solutions (compiling with 
> soft-float or using the kernel math emulation)?
> 
> Ralf
> 
> >>> Bill Roman <roman@alerton.com> 12/02 11:32 pm >>>
> 
> Neil Blackwood wrote:
> > 
> > There is some kernel maths emulation stuff in 2.3.18.
> > You will need to copy it over to which ever version you are 
> using. It works.
> > Look for directories math-emu.
> > You will need to change config files and make files as 
> well. Its fairly
> > easy. Even I managed it.
> 
> Thanks, Neil!  I had been very optimistic when I found this 
> code in 2.3.18, and
> was disappointed when it turned out it wouldn't compile in 
> that context.
> Without your hint, I don't think I would have guessed that 
> transplanting it
> into a 2.2 kernel would have worked.
> 
> To save everyone else a few hours of grepping and tweaking, here are
> instructions and a patch file to add math emulation to the 
> 2.2.13 kernel
> sources from linuxppc.cs.nmt.edu.
> 
> 1.  Obtain mpc8xx-2.2.13.tgz and linux-2.3.18.tgz from
> ftp://linuxppc.cs.nmt.edu/pub/linuxppc/embedded/.  Untar them into two
> separate source trees.  (Note: all that's needed from 2.3.18 is the
> math emulator; does anyone know whether that's available separately,
> or could someone split it out and put it on the FTP site?)
> 
> 2.  Copy the arch/ppc/mathemu directory from the 2.3.18 tree to the
> 2.2.13 tree.
> 
> 3.  Apply the patch (below).  Note that I am building for an 
> MBX, so that's
> what .config gets patched for.
> 
> 4.  make symlinks config dep clean zImage.
> 
> The following is the patch.
> --------------------------------------------------------------
> --------------
> diff -ur linux-mpc8xx-2.2.13/.config linux/.config
> --- linux-mpc8xx-2.2.13/.config	Fri Oct 22 16:08:42 1999
> +++ linux/.config	Wed Dec  1 17:10:01 1999
> @@ -10,9 +10,9 @@
>  # CONFIG_PPC64 is not set
>  CONFIG_8xx=y
>  # CONFIG_MPC821 is not set
> -CONFIG_MPC823=y
> +# CONFIG_MPC823 is not set
>  # CONFIG_MPC850 is not set
> -# CONFIG_MPC860 is not set
> +CONFIG_MPC860=y
>  # CONFIG_MPC860T is not set
>  CONFIG_SERIAL_CONSOLE=y
>  # CONFIG_PMAC is not set
> @@ -20,12 +20,13 @@
>  # CONFIG_CHRP is not set
>  # CONFIG_ALL_PPC is not set
>  # CONFIG_APUS is not set
> -# CONFIG_MBX is not set
> +CONFIG_MBX=y
>  # CONFIG_RPXLITE is not set
>  # CONFIG_RPXCLASSIC is not set
> -CONFIG_BSEIP=y
> +# CONFIG_BSEIP is not set
>  # CONFIG_SMP is not set
>  CONFIG_MACH_SPECIFIC=y
> +CONFIG_MATH_EMULATION=y
>  
>  #
>  # General setup
> @@ -297,8 +298,7 @@
>  # MPC8xx CPM Options
>  #
>  CONFIG_SCC_ENET=y
> -# CONFIG_SCC1_ENET is not set
> -CONFIG_SCC2_ENET=y
> +CONFIG_SCC1_ENET=y
>  # CONFIG_FEC_ENET is not set
>  # CONFIG_CPM_IIC is not set
>  # CONFIG_UCODE_PATCH is not set
> diff -ur linux-mpc8xx-2.2.13/arch/ppc/Makefile linux/arch/ppc/Makefile
> --- linux-mpc8xx-2.2.13/arch/ppc/Makefile	Wed Oct 20 15:33:30 1999
> +++ linux/arch/ppc/Makefile	Wed Dec  1 16:16:45 1999
> @@ -41,6 +41,12 @@
>  ARCHIVES := arch/ppc/kernel/kernel.o arch/ppc/mm/mm.o 
> arch/ppc/lib/lib.o $(ARCHIVES)
>  CORE_FILES := arch/ppc/kernel/kernel.o arch/ppc/mm/mm.o 
> arch/ppc/lib/lib.o $(CORE_FILES)
>  
> +ifdef CONFIG_MATH_EMULATION
> +SUBDIRS += arch/ppc/math-emu
> +ARCHIVES += arch/ppc/math-emu/math-emu.o
> +CORE_FILES += arch/ppc/math-emu/math-emu.o
> +endif
> +
>  ifdef CONFIG_XMON
>  SUBDIRS += arch/ppc/xmon
>  CORE_FILES += arch/ppc/xmon/x.o
> diff -ur linux-mpc8xx-2.2.13/arch/ppc/config.in 
> linux/arch/ppc/config.in
> --- linux-mpc8xx-2.2.13/arch/ppc/config.in	Fri Oct 22 14:56:10 1999
> +++ linux/arch/ppc/config.in	Wed Dec  1 16:29:14 1999
> @@ -37,6 +37,15 @@
>  if [ "$CONFIG_ALL_PPC" != "y" ];then
>    define_bool CONFIG_MACH_SPECIFIC y
>  fi
> +
> +if [ "$CONFIG_8xx" = "y" ]; then
> +  bool 'Math emulation' CONFIG_MATH_EMULATION
> +else
> +  if [ "$CONFIG_PPC64" != "y" ];then
> +    define_bool CONFIG_6xx y
> +  fi
> +fi
> +
>  endmenu
>  
>  mainmenu_option next_comment
> diff -ur linux-mpc8xx-2.2.13/arch/ppc/kernel/Makefile 
> linux/arch/ppc/kernel/Makefile
> --- linux-mpc8xx-2.2.13/arch/ppc/kernel/Makefile	Fri Oct 
> 22 15:21:39 1999
> +++ linux/arch/ppc/kernel/Makefile	Thu Dec  2 10:34:19 1999
> @@ -30,7 +30,7 @@
>  endif
>  
>  ifeq ($(CONFIG_8xx),y)
> -O_OBJS += m8xx_setup.o softemu8xx.o ppc8xx_pic.o
> +O_OBJS += m8xx_setup.o  ppc8xx_pic.o
>  ifdef CONFIG_PCI
>  O_OBJS += qspan_pci.o
>  endif
> diff -ur linux-mpc8xx-2.2.13/arch/ppc/kernel/traps.c 
> linux/arch/ppc/kernel/traps.c
> --- linux-mpc8xx-2.2.13/arch/ppc/kernel/traps.c	Fri Oct 
> 22 14:04:09 1999
> +++ linux/arch/ppc/kernel/traps.c	Thu Dec  2 10:32:22 1999
> @@ -230,12 +230,12 @@
>  SoftwareEmulation(struct pt_regs *regs)
>  {
>  	int	errcode;
> -	extern int	Soft_emulate_8xx (struct pt_regs *regs);
> +	extern int	do_mathemu(struct pt_regs *regs);
>  	extern void print_8xx_pte(struct mm_struct *, unsigned long);	
>  
>  	if (user_mode(regs))
>  	{
> -		if ((errcode = Soft_emulate_8xx(regs))) {
> +		if ((errcode = do_mathemu(regs))) {
>  printk("Software Emulation %s/%d NIP: %lx *NIP: 0x%x code: %x",
>         current->comm,current->pid,
>         regs->nip, *((uint *)regs->nip), errcode);
> diff -ur linux-mpc8xx-2.2.13/include/asm-ppc/processor.h 
> linux/include/asm-ppc/processor.h
> --- linux-mpc8xx-2.2.13/include/asm-ppc/processor.h	Fri Oct 
> 22 16:10:02 1999
> +++ linux/include/asm-ppc/processor.h	Wed Dec  1 16:56:20 1999
> @@ -57,8 +57,33 @@
>  #define HID0_BTCD	(1<<1)		/* Branch target cache 
> disable */
>  
>  /* fpscr settings */
> -#define FPSCR_FX        (1<<31)
> -#define FPSCR_FEX       (1<<30)
> +#define FPSCR_FX        0x80000000      /* FPU exception summary */
> +#define FPSCR_FEX       0x40000000      /* FPU enabled 
> exception summary */
> +#define FPSCR_VX        0x20000000      /* Invalid operation 
> summary */
> +#define FPSCR_OX        0x10000000      /* Overflow 
> exception summary */
> +#define FPSCR_UX        0x08000000      /* Underflow 
> exception summary */
> +#define FPSCR_ZX        0x04000000      /* Zero-devide 
> exception summary */
> +#define FPSCR_XX        0x02000000      /* Inexact exception 
> summary */
> +#define FPSCR_VXSNAN    0x01000000      /* Invalid op for SNaN */
> +#define FPSCR_VXISI     0x00800000      /* Invalid op for 
> Inv - Inv */
> +#define FPSCR_VXIDI     0x00400000      /* Invalid op for 
> Inv / Inv */
> +#define FPSCR_VXZDZ     0x00200000      /* Invalid op for 
> Zero / Zero */
> +#define FPSCR_VXIMZ     0x00100000      /* Invalid op for 
> Inv * Zero */
> +#define FPSCR_VXVC      0x00080000      /* Invalid op for Compare */
> +#define FPSCR_FR        0x00040000      /* Fraction rounded */
> +#define FPSCR_FI        0x00020000      /* Fraction inexact */
> +#define FPSCR_FPRF      0x0001f000      /* FPU Result Flags */
> +#define FPSCR_FPCC      0x0000f000      /* FPU Condition Codes */
> +#define FPSCR_VXSOFT    0x00000400      /* Invalid op for 
> software request */
> +#define FPSCR_VXSQRT    0x00000200      /* Invalid op for 
> square root */
> +#define FPSCR_VXCVI     0x00000100      /* Invalid op for 
> integer convert */
> +#define FPSCR_VE        0x00000080      /* Invalid op 
> exception enable */
> +#define FPSCR_OE        0x00000040      /* IEEE overflow 
> exception enable */
> +#define FPSCR_UE        0x00000020      /* IEEE underflow 
> exception enable */
> +#define FPSCR_ZE        0x00000010      /* IEEE zero divide 
> exception enable */
> +#define FPSCR_XE        0x00000008      /* FP inexact 
> exception enable */
> +#define FPSCR_NI        0x00000004      /* FPU non IEEE-Mode */
> +#define FPSCR_RN        0x00000003      /* FPU rounding control */
>  
>  #define _MACH_prep     1
>  #define _MACH_Pmac     2  /* pmac or pmac clone (non-chrp) */
> 

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Kernel Math Emulation again
  1999-12-03  9:03 Ole.Reinartz
@ 1999-12-05 23:54 ` Peter Brown
  1999-12-06  1:31   ` Dan Malek
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Brown @ 1999-12-05 23:54 UTC (permalink / raw)
  To: Ole.Reinartz; +Cc: linuxppc-embedded


Has anyone tried writing a driver for the MPC860 CPM DSP?  The Motorola FAQ
says that it can perform an 8x8 pixel Discrete Cosine Transform in 30uS (@
25Mhz clock speed).  The MPC823 has a DSP coprocessor in it as well.  The
MPC860 DSP library is targeted for modem processing but could be used for
other purposes.  
-- 
Peter Brown, Software Engineer      | Phone: +61 2 6279 8830
Robotic Systems Lab, RSISE          | Fax:   +61 2 6279 8660
Australian National University      | 
Canberra ACT 0200 AUSTRALIA         |
--------------------------------------------------------------------------

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Kernel Math Emulation again
  1999-12-05 23:54 ` Peter Brown
@ 1999-12-06  1:31   ` Dan Malek
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Malek @ 1999-12-06  1:31 UTC (permalink / raw)
  To: Peter Brown; +Cc: Ole.Reinartz, linuxppc-embedded


Peter Brown wrote:


> Has anyone tried writing a driver for the MPC860 CPM DSP?


The actual interface isn't any different than other devices.
Just allocate some buffer descriptors and go for it.


> .....  The Motorola FAQ
> says that it can perform an 8x8 pixel Discrete Cosine Transform in 30uS (@
> 25Mhz clock speed).


Yes, and Motorola has a version of this for selected customers.

> ....  The MPC823 has a DSP coprocessor in it as well.  The
> MPC860 DSP library is targeted for modem processing but could be used for
> other purposes.


Motorola also has a version of the soft modem.  I don't know
the status of that.

Just to clarify this a little.  The CPM has a MAC (multiply-accumulate)
piece of hardware available.  The 'DSP' is a few functions written
in CPM microcode that use the MAC to provide DSP-like features.
There is no DSP in the processor.  The soft modem is CPM
microcode that uses the MAC and some of the DSP functions internally.

Writing CPM microcode is not available to anyone for general
purpose use.


	-- Dan

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Kernel Math Emulation again
@ 1999-12-06  8:15 Ole.Reinartz
  0 siblings, 0 replies; 8+ messages in thread
From: Ole.Reinartz @ 1999-12-06  8:15 UTC (permalink / raw)
  To: pfb, Ole.Reinartz; +Cc: linuxppc-embedded


> Has anyone tried writing a driver for the MPC860 CPM DSP?  
> The Motorola FAQ
> says that it can perform an 8x8 pixel Discrete Cosine 
> Transform in 30uS (@
> 25Mhz clock speed).  The MPC823 has a DSP coprocessor in it 
> as well.  The
> MPC860 DSP library is targeted for modem processing but could 
> be used for
> other purposes.  
> -- 
> Peter Brown, Software Engineer      | Phone: +61 2 6279 8830
> Robotic Systems Lab, RSISE          | Fax:   +61 2 6279 8660
> Australian National University      | 
> Canberra ACT 0200 AUSTRALIA         |
> --------------------------------------------------------------
> ------------

Peter,

I never heard of a driver especially for the CPM. But for the single
services of it there are drivers, like ethernet, SCC, SMC...
I know you can add functionality like DCT to the CPM via 'downloading'
'microcode' to it. Perhaps we could make a 'modem driver'?
There should be a very low level driver which at least manages the dual
ported ram, perhaps even virtualises the access to the data structures in it
like managing the buffer pointer allocation, localizing the register files
a.s.o.

 Ole

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~1999-12-06  8:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-12-03  8:46 Kernel Math Emulation again Ralf HECKHAUSEN
  -- strict thread matches above, loose matches on Subject: below --
1999-12-06  8:15 Ole.Reinartz
1999-12-03  9:03 Ole.Reinartz
1999-12-05 23:54 ` Peter Brown
1999-12-06  1:31   ` Dan Malek
1999-11-30  9:03 Ole.Reinartz
1999-11-30 10:04 ` Neil Blackwood
1999-12-02 22:32   ` Bill Roman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).