Subject: mysterious problems from floating-point emulation?
To: None <port-mac68k@netbsd.org>
From: J. MacPhail <jrm@kw.igs.net>
List: port-mac68k
Date: 02/25/2004 18:43:27
My attention has been drawn to the FPE.  (On my PB160 -- 68030 without
FPU, using GENERIC 1.6.1 kernel -- even looking at man pages is a
problem: troff tries to use floaing point instructions, giving core
dumps.)  The FPE source code at

   ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/m68k/fpe

leaves me amazed that it works for anybody!  Any call to a hyperbolic
trig function reaches a stub, almost surely causing mysterious
quasi-random failures (just the sort of trouble that happened when I
tried to run X).  Offhand, I guess that competent programmers are
quite likely to use hyperbolic trig when doing graphics.

On the other hand, it appears that considerable work already went into
the FPE, and fixing it might not be too gruesome, if gone about
properly.  Here are some things that seem needed:

1. Better FPE documentation, making it easier for people to work on
it.  This should make it clearer what manuals are appropriate
(Motorola 68881/68882 manual?  Hennessy & Patterson? Good source code
for somebody else's FPE?) and also include a better intro to the
68881/68882 instruction set.

2. Some kind of test harness.  My suggestion is a package
("emu-68k-fpu", or whatever) to generate the FPE as a library,
together with a little calculator that directly calls the library.
(This would allow building the FPE without building a whole kernel,
and would allow teting on systems other than FPU-less 68k.  Done
really well, it could be used to test completely different
implementations of the FPE, and even be used to detect buggy FPUs.)
Note that this comes *after* (1), to avoid re-inventing the wheel.

3. Somebody to work on FPE itself.  After (1) and (2) are under way,
fixing and polishing the FPE might not be too unattractive.  There is
a possibility that simply implementing the hyperbolic trig will result
in something fairly stable.

-- 
John