⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 freebsd v4.4内核源码
💻
字号:
/* *  wm-FPU-emu   an FPU emulator for 80386 and 80486SX microprocessors. * * * Copyright (C) 1992,1993,1994 *                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163, *                       Australia.  E-mail   billm@vaxc.cc.monash.edu.au * All rights reserved. * * This copyright notice covers the redistribution and use of the * FPU emulator developed by W. Metzenthen. It covers only its use * in the 386BSD, FreeBSD and NetBSD operating systems. Any other * use is not permitted under this copyright. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must include information specifying *    that source code for the emulator is freely available and include *    either: *      a) an offer to provide the source code for a nominal distribution *         fee, or *      b) list at least two alternative methods whereby the source *         can be obtained, e.g. a publically accessible bulletin board *         and an anonymous ftp site from which the software can be *         downloaded. * 3. All advertising materials specifically mentioning features or use of *    this emulator must acknowledge that it was developed by W. Metzenthen. * 4. The name of W. Metzenthen may not be used to endorse or promote *    products derived from this software without specific prior written *    permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL * W. METZENTHEN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * * The purpose of this copyright, based upon the Berkeley copyright, is to * ensure that the covered software remains freely available to everyone. * * The software (with necessary differences) is also available, but under * the terms of the GNU copyleft, for the Linux operating system and for * the djgpp ms-dos extender. * * W. Metzenthen   June 1994. * */wm-FPU-emu is an FPU emulator for Linux. It is derived from wm-emu387which is my 80387 emulator for djgpp (gcc under msdos); wm-emu387 wasin turn based upon emu387 which was written by DJ Delorie for djgpp.The interface to the Linux kernel is based upon the original Linuxmath emulator by Linus Torvalds.My target FPU for wm-FPU-emu is that described in the Intel486Programmer's Reference Manual (1992 edition). Numerous facets of thefunctioning of the FPU are not well covered in the Reference Manual;in the absence of clear details I have made guesses about the mostreasonable behaviour. Recently, this situation has improved becauseI now have some access to the results produced by a real 80486 FPU.wm-FPU-emu does not implement all of the behaviour of the 80486 FPU. See "Limitations" later in this file for a partial list of somedifferences.  I believe that the missing features are never used bynormal C or FORTRAN programs. Please report bugs, etc to me at:       apm233m@vaxc.cc.monash.edu.au--Bill Metzenthen  May 1993----------------------- Internals of wm-FPU-emu -----------------------Numeric algorithms:(1) Add, subtract, and multiply. Nothing remarkable in these.(2) Divide has been tuned to get reasonable performance. The algorithm    is not the obvious one which most people seem to use, but is designed    to take advantage of the characteristics of the 80386. I expect that    it has been invented many times before I discovered it, but I have not    seen it. It is based upon one of those ideas which one carries around    for years without ever bothering to check it out.(3) The sqrt function has been tuned to get good performance. It is based    upon Newton's classic method. Performance was improved by capitalizing    upon the properties of Newton's method, and the code is once again    structured taking account of the 80386 characteristics.(4) The trig, log, and exp functions are based in each case upon quasi-    "optimal" polynomial approximations. My definition of "optimal" was    based upon getting good accuracy with reasonable speed.The code of the emulator is complicated slightly by the need toaccount for a limited form of re-entrancy. Normally, the emulator willemulate each FPU instruction to completion without interruption.However, it may happen that when the emulator is accessing the usermemory space, swapping may be needed. In this case the emulator may betemporarily suspended while disk i/o takes place. During this timeanother process may use the emulator, thereby changing some staticvariables (eg FPU_st0_ptr, etc). The code which accesses user memoryis confined to five files:    fpu_entry.c    reg_ld_str.c    load_store.c    get_address.c    errors.c----------------------- Limitations of wm-FPU-emu -----------------------There are a number of differences between the current wm-FPU-emu(version beta 1.4) and the 80486 FPU (apart from bugs). Some of themore important differences are listed below:All internal computations are performed at 64 bit or higher precisionand rounded etc as required by the PC bits of the FPU control word.Under the crt0 version for Linux current at March 1993, the FPU PCbits specify 53 bits precision.The precision flag (PE of the FPU status word) and the Roundup flag(C1 of the status word) are now partially implemented. Does anyonewrite code which uses these features?The functions which load/store the FPU state are partially implemented,but the implementation should be sufficient for handling FPU errors etcin 32 bit protected mode.The implementation of the exception mechanism is flawed for unmaskedinterrupts.Detection of certain conditions, such as denormal operands, is not yetcomplete.----------------------- Performance of wm-FPU-emu -----------------------Speed.-----The speed of floating point computation with the emulator will dependupon instruction mix. Relative performance is best for the instructionswhich require most computation. The simple instructions are adverselyaffected by the fpu instruction trap overhead.Timing: Some simple timing tests have been made on the emulator functions.The times include load/store instructions. All times are in microsecondsmeasured on a 33MHz 386 with 64k cache. The Turbo C tests were underms-dos, the next two columns are for emulators running with the djgppms-dos extender. The final column is for wm-FPU-emu in Linux 0.97,using libm4.0 (hard).function      Turbo C        djgpp 1.06        WM-emu387     wm-FPU-emu   +          60.5           154.8              76.5          139.4   -          61.1-65.5      157.3-160.8        76.2-79.5     142.9-144.7   *          71.0           190.8              79.6          146.6   /          61.2-75.0      261.4-266.9        75.3-91.6     142.2-158.1 sin()        310.8          4692.0            319.0          398.5 cos()        284.4          4855.2            308.0          388.7 tan()        495.0          8807.1            394.9          504.7 atan()       328.9          4866.4            601.1          419.5-491.9 sqrt()       128.7          crashed           145.2          227.0 log()        413.1-419.1    5103.4-5354.21    254.7-282.2    409.4-437.1 exp()        479.1          6619.2            469.1          850.8The performance under Linux is improved by the use of look-ahead code.The following results show the improvement which is obtained underLinux due to the look-ahead code. Also given are the times for theoriginal Linux emulator with the 4.1 'soft' lib. [ Linus' note: I changed look-ahead to be the default under linux, as   there was no reason not to use it after I had edited it to be   disabled during tracing ]            wm-FPU-emu w     original w            look-ahead       'soft' lib   +         106.4             190.2   -         108.6-111.6      192.4-216.2   *         113.4             193.1   /         108.8-124.4      700.1-706.2 sin()       390.5            2642.0 cos()       381.5            2767.4 tan()       496.5            3153.3 atan()      367.2-435.5     2439.4-3396.8 sqrt()      195.1            4732.5 log()       358.0-387.5     3359.2-3390.3 exp()       619.3            4046.4These figures are now somewhat out-of-date. The emulator has becomeprogressively slower for most functions as more of the 80486 featureshave been implemented.----------------------- Accuracy of wm-FPU-emu -----------------------Accuracy: The following table gives the accuracy of the sqrt(), trigand log functions. Each function was tested at about 400 points. Idealresults would be 64 bits. The reduced accuracy of cos() and tan() forarguments greater than pi/4 can be thought of as being due to theprecision of the argument x; e.g. an argument of pi/2-(1e-10) which isaccurate to 64 bits can result in a relative accuracy in cos() of about64 + log2(cos(x)) = 31 bits. Results for the Turbo C emulator are givenin the last column.Function      Tested x range            Worst result (bits)         Turbo Csqrt(x)       1 .. 2                    64.1                         63.2atan(x)       1e-10 .. 200              62.6                         62.8cos(x)        0 .. pi/2-(1e-10)         63.2 (x <= pi/4)             62.4                                        35.2 (x = pi/2-(1e-10))      31.9sin(x)        1e-10 .. pi/2             63.0                         62.8tan(x)        1e-10 .. pi/2-(1e-10)     62.4 (x <= pi/4)             62.1                                        35.2 (x = pi/2-(1e-10))      31.9exp(x)        0 .. 1                    63.1                         62.9log(x)        1+1e-6 .. 2               62.4                         62.1As of version 1.3 of the emulator, the accuracy of the basicarithmetic has been improved (by a small fraction of a bit). Care hasbeen taken to ensure full accuracy of the rounding of the basicarithmetic functions (+,-,*,/,and fsqrt), and they all now produceresults which are exact to the 64th bit (unless there are any bugsleft). To ensure this, it was necessary to effectively get informationof up to about 128 bits precision. The emulator now passes the"paranoia" tests (compiled with gcc 2.3.3) for 'float' variables (24bit precision numbers) when precision control is set to 24, 53 or 64bits, and for 'double' variables (53 bit precision numbers) whenprecision control is set to 53 bits (a properly performing FPU cannotpass the 'paranoia' tests for 'double' variables when precisioncontrol is set to 64 bits).------------------------- Contributors -------------------------------A number of people have contributed to the development of theemulator, often by just reporting bugs, sometimes with a suggestedfix, and a few kind people have provided me with access in one way oranother to an 80486 machine. Contributors include (to those people whoI have forgotten, please excuse me):Linus TorvaldsTommy.Thorn@daimi.aau.dkAndrew.Tridgell@anu.edu.auNick Holloway alfie@dcs.warwick.ac.ukHermano Moura moura@dcs.gla.ac.ukJon Jagger J.Jagger@scp.ac.ukLennart BenschopBrian Gallew geek+@CMU.EDUThomas Staniszewski ts3v+@andrew.cmu.eduMartin Howell mph@plasma.apana.org.auM Saggaf alsaggaf@athena.mit.eduPeter Barker PETER@socpsy.sci.fau.edutom@vlsivie.tuwien.ac.atDan Russel russed@rpi.eduDaniel Carosone danielce@ee.mu.oz.aucae@jpmorgan.comHamish Coleman t933093@minyos.xx.rmit.oz.au...and numerous others who responded to my request for help witha real 80486.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -