[NLUUG]   Welcome to ftp.nluug.nl
Current directory: /pub/ftp/os/NetBSD/NetBSD-current/src/sys/arch/m68k/fpe/
 
Current bandwidth utilization 1256.93 Mbit/s
Bandwidth utilization bar
Contents of README:
* $NetBSD: README,v 1.7 2021/08/21 23:00:31 andvar Exp $
* NetBSD/m68k FPE (floating point emulation) README file
* Created Oct/??/95 by kenn@remus.rutgers.edu (Ken Nakata)
* Last updated Oct/15/2011 by tsutsui

1. INSTALLATION AND COMPILATION

To compile a kernel with FPE built-in, do the following:

1) Add a line "options FPU_EMULATE" to your config file.  If you are
going to use the resulted kernel on a machine with an FPU for
debugging purpose, add "options DEBUG_WITH_FPU" as well.

2) Follow the usual procedure to build a new kernel.

NOTE:  If you add "options DEBUG_WITH_FPU", FPE will accept cpID=6 as
emulated FPU.  You will need a modified gas that generates cpID=6 for
floating point instructions, instead of normal cpID=1.  Mount unionfs
or copy the gas source directory and apply the following patch:

*** /usr/src/gnu/usr.bin/gas/config/tc-m68k.c   Mon Nov 21 16:30:41 1994
--- gas/config/tc-m68k.c    Fri Sep 29 07:59:06 1995
***************
*** 1275,1281 ****
                /* memcpy((char *)(&the_ins.operands[1]), (char *)(&the_ins.operands[0]), opsfound*sizeof(the_ins.operands[0])); */
                memset((char *)(&the_ins.operands[0]), '\0', sizeof(the_ins.operands[0]));
                the_ins.operands[0].mode=MSCR;
!               the_ins.operands[0].reg=COPNUM;         /* COP #1 */
                opsfound++;
        }
  
--- 1275,1281 ----
                /* memcpy((char *)(&the_ins.operands[1]), (char *)(&the_ins.operands[0]), opsfound*sizeof(the_ins.operands[0])); */
                memset((char *)(&the_ins.operands[0]), '\0', sizeof(the_ins.operands[0]));
                the_ins.operands[0].mode=MSCR;
!               the_ins.operands[0].reg=COP5;           /* COP #6 */
                opsfound++;
        }
  

Also, with the DEBUG_WITH_FPU option, you will be able to run only ONE
process that uses FPE at once to get correct results.


2. MISSING PARTS

For missing instructions, refer to the Section 3.  Other than that,
there is one thing that is missing from this version of FPE: packed
BCD support.

I have no plan to support it since it's rarely used.  However, all we
need to support it is explosion/implosion functions between the
internal FP representation and the m68k PBCD format, so you are more
than welcome to write such functions if you wish to.


3. IMPLEMENTED INSTRUCTIONS

This is the list of implemented and unimplemented FPU instructions.
All 040's directly supported type 0 instructions are already
implemented except FSGLDIV and FSGLMUL.

Type field = bit 8-6 of opcode word

* Implemented Instructions

Type=0: FMOVE (mem->FPr), FINT, FINTRZ, FSQRT, FABS, FNEG, FGETEXP,
	FGETMAN, FDIV, FADD, FMUL, FSGLDIV(*), FSCALE, FSGLMUL(*), FSUB,
	FCMP, FTST, FMOVE (FPr->mem), FMOVEM (FPr), FMOVEM (FPcr),
	FMOVECR, FLOGNP1, FLOGN, FLOG10, FLOG2, FMOD, FREM,
	FCOSH, FSINH, FTANH, FCOS, FSIN, FTAN, FSINCOS,
	FETOX, FETOXM1, FTENTOX, FTWOTOX, FATANH, FACOS, FASIN, FATAN

Type=1: FDBcc, FScc, FTRAPcc,

Type=2: FBcc (word, incl. FNOP)

Type=3: FBcc (long)

Type=4: none

Type=5: none

	*: currently FSGLMUL and FSGLDIV are just aliases of
	   FMUL and FDIV, respectively

* Unimplemented Instructions

Type=0: none

Type=1: none

Type=2: none

Type=3: none

Type=4: FSAVE

Type=5: FRESTORE


4. HOW TO ADD A NEW INSTRUCTION SUPPORT

Since we need not support FSAVE and FRESTORE operations, all
instructions we have to implement are type 0, all of which are
arithmetic operations.  It is particularly easy to add a new
arithmetic instruction to the existing ones (not that it is easy to
write a "stable" function to perform floating point operation. That's
entirely another matter).  In "fpu_emulate.c", there's a function
fpu_emul_arith() which calls emulation functions for all arithmetic
operations.  In it, there's a large switch() { case ... } which
dispatches each instruction emulator.  An emulation function of any
type 0 arithmetic instruction follows this prototype:

	struct fpn *fpu_op(struct fpemu *fe);

Where fe is a pointer to a struct fpemu in which frame, fpframe, and
fetched operands are accessible.  That's right, you don't have to
fetch the operands by yourself in your emulation function.  For
instance, the parts calling FSQRT, FSUB, FADD and FTST look like:

	switch(word1 & 0x3F) {
[...]
	case 0x04:	/* fsqrt */
		res = fpu_sqrt(fe);
		break;
[...]
	case 0x28:	/* fsub */
		fe->fe_f2.fp_sign = !fe->fe_f2.fp_sign; /* f2 = -f2 */
	case 0x22:	/* fadd */
		res = fpu_add(fe);
		break;
[...]
	case 0x3A:	/* ftst */
		res = &fe->fe_f2;
		no_store = 1;
		break;
[...]
	default:
		sig = SIGILL;
	} /* switch */

Here, fe->fe_f1 and fe->fe_f2 are fetched operands.  You can use
fe->fe_f3 for storing the result, or you can return a pointer to
either operand if you want to.  At any rate, you have to follow
the following rules:

	1) A dyadic instruction takes two operands fe->fe_f1 and fe->fe_f2.
	2) A monadic instruction takes one operands fe->fe_f2 (NOT fe_f1).
	3) Must return a pointer to struct fpn where the result is stored,
	and assign the pointer to the variable "res".
	4) If exceptions are detected, set corresponding bits in fe->fe_fpsr.
	The rest is taken care of in fpu_emul_arith().
	5) Condition code need not be calculated.  It's taken care of in
	fpu_emul_arith().

Actually, after above was written, stubs for the missing functions were
added to the source, so you do not have to change fpu_emul_arith() at
all.  Function names and prototypes are in fpu_arith_proto.h, and all
except fpu_sincos() follow the rules above.  fpu_sincos() is declared
as

	struct fpn *fpu_sincos(struct fpemu *fe, int cosreg);

where cosreg is the FP register number to which cosine of the argument
is calculated and assigned.  Sine of the argument is stored into the
destination register in the same manner as the other arithmetic
functions.

Icon  Name                                                 Last modified      Size  
[DIR] Parent Directory - [DIR] CVS/ 20-Nov-2023 04:01 - [TXT] README 22-Aug-2021 05:01 5.7K [   ] files.fpe 20-Apr-2013 05:06 1.0K [TXT] fpu_add.c 27-Mar-2013 04:03 6.8K [TXT] fpu_arith.h 02-Apr-2013 05:02 6.1K [TXT] fpu_arith_proto.h 14-Mar-2009 15:46 3.3K [TXT] fpu_calcea.c 07-Apr-2019 05:01 18K [TXT] fpu_cordic.c 07-Dec-2016 04:01 10K [TXT] fpu_div.c 03-Jan-2014 04:03 7.7K [TXT] fpu_emulate.c 18-Sep-2023 05:01 28K [TXT] fpu_emulate.h 07-Dec-2016 04:01 10K [TXT] fpu_exp.c 16-Jan-2017 04:01 5.1K [TXT] fpu_explode.c 09-Mar-2021 04:01 7.7K [TXT] fpu_fmovecr.c 27-Mar-2013 04:03 4.3K [TXT] fpu_fscale.c 27-Mar-2013 04:03 9.2K [TXT] fpu_fstore.c 27-Mar-2013 04:03 4.0K [TXT] fpu_getexp.c 19-Jul-2011 05:01 2.7K [TXT] fpu_hyperb.c 06-Dec-2016 04:01 6.1K [TXT] fpu_implode.c 27-Mar-2013 04:03 13K [TXT] fpu_int.c 20-Mar-2013 04:04 2.6K [TXT] fpu_log.c 05-Jan-2014 04:04 18K [TXT] fpu_mul.c 07-Dec-2016 04:01 6.8K [TXT] fpu_rem.c 20-Nov-2023 04:01 5.3K [TXT] fpu_sqrt.c 25-May-2022 05:01 11K [TXT] fpu_subr.c 21-Apr-2013 05:01 5.9K [TXT] fpu_trig.c 17-Jan-2017 04:00 8.8K

NLUUG - Open Systems. Open Standards
Become a member and get discounts on conferences and more, see the NLUUG website!