diff options
author | dfr <dfr@FreeBSD.org> | 1998-12-23 11:50:52 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 1998-12-23 11:50:52 +0000 |
commit | 0d57a81a8be9e9b63084d2b57eaadc0e1d57f2b7 (patch) | |
tree | 1138e6074d535cddfb8dae7e5fd33e3a8508ef1b /sys | |
parent | cb8b246a394601b9e5228fd27edfb6682da216ab (diff) | |
download | FreeBSD-src-0d57a81a8be9e9b63084d2b57eaadc0e1d57f2b7.zip FreeBSD-src-0d57a81a8be9e9b63084d2b57eaadc0e1d57f2b7.tar.gz |
Implement fpsetmask() and other fp*() functions. Programs should use
#include <ieeefp.h>
to access these functions instead of the i386 specific
#include <machine/floatingpoint.h>
Submitted by: Hidetoshi Shimokawa <simokawa@sat.t.u-tokyo.ac.jp>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/alpha/alpha/machdep.c | 43 | ||||
-rw-r--r-- | sys/alpha/alpha/sys_machdep.c | 47 | ||||
-rw-r--r-- | sys/alpha/include/alpha_cpu.h | 8 | ||||
-rw-r--r-- | sys/alpha/include/fpu.h | 12 | ||||
-rw-r--r-- | sys/alpha/include/ieeefp.h | 16 | ||||
-rw-r--r-- | sys/alpha/include/sysarch.h | 6 |
6 files changed, 117 insertions, 15 deletions
diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c index e8240f1..39090de 100644 --- a/sys/alpha/alpha/machdep.c +++ b/sys/alpha/alpha/machdep.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: machdep.c,v 1.26 1998/12/04 22:54:42 archie Exp $ + * $Id: machdep.c,v 1.27 1998/12/16 16:28:56 bde Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -492,6 +492,21 @@ alpha_unknown_sysname() static void identifycpu(void) { + u_int64_t type, major, minor; + u_int64_t amask; + struct pcs *pcsp; + char *cpuname[] = { + "unknown", /* 0 */ + "EV3", /* 1 */ + "EV4 (21064)", /* 2 */ + "Simulation", /* 3 */ + "LCA Family", /* 4 */ + "EV5 (21164)", /* 5 */ + "EV45 (21064A)", /* 6 */ + "EV56 (21164A)", /* 7 */ + "EV6 (21264)", /* 8 */ + "PCA56 (21164PC)" /* 9 */ + }; /* * print out CPU identification information. @@ -509,6 +524,32 @@ identifycpu(void) printf("variation: 0x%lx, revision 0x%lx\n", hwrpb->rpb_variation, *(long *)hwrpb->rpb_revision); #endif + pcsp = LOCATE_PCS(hwrpb, hwrpb->rpb_primary_cpu_id); + /* cpu type */ + type = pcsp->pcs_proc_type; + major = (type & PCS_PROC_MAJOR) >> PCS_PROC_MAJORSHIFT; + minor = (type & PCS_PROC_MINOR) >> PCS_PROC_MINORSHIFT; + if (major < sizeof(cpuname)/sizeof(char *)) + printf("CPU: %s major=%lu minor=%lu", + cpuname[major], major, minor); + else + printf("CPU: major=%lu minor=%lu\n", major, minor); + /* amask */ + if (major >= PCS_PROC_EV56) { + amask = 0xffffffff; /* 32 bit for printf */ + amask = (~alpha_amask(amask)) & amask; + printf(" extensions=0x%b\n", (u_int32_t) amask, + "\020" + "\001BWX" + "\002FIX" + "\003CIX" + "\011MVI" + "\012PRECISE" + ); + } else + printf("\n"); + /* PAL code */ + printf("OSF PAL rev: 0x%lx\n", pcsp->pcs_palrevisions[PALvar_OSF1]); } extern char kernel_text[], _end[]; diff --git a/sys/alpha/alpha/sys_machdep.c b/sys/alpha/alpha/sys_machdep.c index 6ff5956..0d89b8f 100644 --- a/sys/alpha/alpha/sys_machdep.c +++ b/sys/alpha/alpha/sys_machdep.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)sys_machdep.c 5.5 (Berkeley) 1/19/91 - * $Id: sys_machdep.c,v 1.1 1998/06/10 10:53:27 dfr Exp $ + * $Id: sys_machdep.c,v 1.2 1998/11/15 18:25:15 dfr Exp $ * */ @@ -54,6 +54,8 @@ #include <vm/vm_kern.h> /* for kernel_map */ +#include <machine/fpu.h> + #ifndef _SYS_SYSPROTO_H_ struct sysarch_args { int op; @@ -62,6 +64,8 @@ struct sysarch_args { #endif static int alpha_sethae(struct proc *p, char *args); +static int alpha_get_fpmask(struct proc *p, char *args); +static int alpha_set_fpmask(struct proc *p, char *args); int sysarch(p, uap) @@ -74,6 +78,12 @@ sysarch(p, uap) case ALPHA_SETHAE: error = alpha_sethae(p, uap->parms); break; + case ALPHA_GET_FPMASK: + error = alpha_get_fpmask(p, uap->parms); + break; + case ALPHA_SET_FPMASK: + error = alpha_set_fpmask(p, uap->parms); + break; default: error = EINVAL; @@ -106,3 +116,38 @@ alpha_sethae(struct proc *p, char *args) return (0); } + +struct alpha_fpmask_args { + u_int64_t mask; +}; + +static int +alpha_get_fpmask(struct proc *p, char *args) +{ + int error; + struct alpha_fpmask_args ua; + + ua.mask = p->p_addr->u_pcb.pcb_fp_control; + error = copyout(&ua, args, sizeof(struct alpha_fpmask_args)); + + return (error); +} + +static int +alpha_set_fpmask(struct proc *p, char *args) +{ + int error; + u_int64_t oldmask, *fp_control; + struct alpha_fpmask_args ua; + + if (error = copyin(args, &ua, sizeof(struct alpha_fpmask_args))) + return (error); + + fp_control = &p->p_addr->u_pcb.pcb_fp_control; + oldmask = *fp_control; + *fp_control = ua.mask & IEEE_TRAP_ENABLE_MASK; + ua.mask = oldmask; + + error = copyout(&ua, args, sizeof(struct alpha_fpmask_args)); + return (error); +} diff --git a/sys/alpha/include/alpha_cpu.h b/sys/alpha/include/alpha_cpu.h index 5107274..4bd1050 100644 --- a/sys/alpha/include/alpha_cpu.h +++ b/sys/alpha/include/alpha_cpu.h @@ -1,4 +1,4 @@ -/* $Id: alpha_cpu.h,v 1.2 1998/06/10 10:54:21 dfr Exp $ */ +/* $Id: alpha_cpu.h,v 1.3 1998/06/14 13:45:10 dfr Exp $ */ /* From: NetBSD: alpha_cpu.h,v 1.15 1997/09/20 19:02:34 mjacob Exp */ /* @@ -273,8 +273,10 @@ typedef unsigned long alpha_pt_entry_t; */ #define ALPHA_AMASK_BWX 0x0001 /* byte/word extension */ -#define ALPHA_AMASK_CIX 0x0002 /* count extension */ -#define ALPHA_AMASK_MAX 0x0100 /* multimedia extension */ +#define ALPHA_AMASK_FIX 0x0002 /* sqrt and f <-> i conversion extension */ +#define ALPHA_AMASK_CIX 0x0004 /* count extension */ +#define ALPHA_AMASK_MVI 0x0100 /* multimedia extension */ +#define ALPHA_AMASK_PRECISE 0x0200 /* Precise arithmetic traps */ /* * Chip family IDs returned by implver instruction diff --git a/sys/alpha/include/fpu.h b/sys/alpha/include/fpu.h index d4a767e..c9efcee 100644 --- a/sys/alpha/include/fpu.h +++ b/sys/alpha/include/fpu.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: fpu.h,v 1.1 1998/12/04 10:52:48 dfr Exp $ */ #ifndef _MACHINE_FPU_H_ @@ -105,6 +105,16 @@ #define IEEE_INHERIT (1LL << 63) /* inherit on fork */ +/* read and write floating point control register */ +#define GET_FPCR(x) \ + __asm__("trapb"); \ + __asm__("mf_fpcr %0" : "=f" (x)); \ + __asm__("trapb") +#define SET_FPCR(x) \ + __asm__("trapb"); \ + __asm__("mt_fpcr %0" : : "f" (x)); \ + __asm__("trapb") + #ifdef KERNEL extern int fp_software_completion(u_int64_t regmask, struct proc *p); diff --git a/sys/alpha/include/ieeefp.h b/sys/alpha/include/ieeefp.h index c0f4c2f..a838e98 100644 --- a/sys/alpha/include/ieeefp.h +++ b/sys/alpha/include/ieeefp.h @@ -1,4 +1,4 @@ -/* $Id$ */ +/* $Id: ieeefp.h,v 1.1.1.1 1998/03/09 05:43:16 jb Exp $ */ /* From: NetBSD: ieeefp.h,v 1.2 1997/04/06 08:47:28 cgd Exp */ /* @@ -10,12 +10,14 @@ #define _ALPHA_IEEEFP_H_ typedef int fp_except; -#define FP_X_INV 0x01 /* invalid operation exception */ -#define FP_X_DZ 0x02 /* divide-by-zero exception */ -#define FP_X_OFL 0x04 /* overflow exception */ -#define FP_X_UFL 0x08 /* underflow exception */ -#define FP_X_IMP 0x10 /* imprecise (loss of precision; "inexact") */ -#define FP_X_IOV 0x20 /* integer overflow XXX? */ +#define FP_X_INV (1LL << 1) /* invalid operation exception */ +#define FP_X_DZ (1LL << 2) /* divide-by-zero exception */ +#define FP_X_OFL (1LL << 3) /* overflow exception */ +#define FP_X_UFL (1LL << 4) /* underflow exception */ +#define FP_X_IMP (1LL << 5) /* imprecise(inexact) exception */ +#if 0 +#define FP_X_IOV (1LL << 6) /* integer overflow XXX? */ +#endif typedef enum { FP_RZ=0, /* round to zero (truncate) */ diff --git a/sys/alpha/include/sysarch.h b/sys/alpha/include/sysarch.h index 61806f8..e0e0a6b 100644 --- a/sys/alpha/include/sysarch.h +++ b/sys/alpha/include/sysarch.h @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: sysarch.h,v 1.1 1998/11/17 10:40:07 dfr Exp $ */ /* @@ -39,7 +39,9 @@ #ifndef _MACHINE_SYSARCH_H_ #define _MACHINE_SYSARCH_H_ -#define ALPHA_SETHAE 0 +#define ALPHA_SETHAE 0 +#define ALPHA_GET_FPMASK 1 +#define ALPHA_SET_FPMASK 2 #ifndef KERNEL #include <sys/cdefs.h> |