Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Minor fpu initialisation cleanups:
details: https://anonhg.NetBSD.org/src/rev/60c1fe356f4b
branches: trunk
changeset: 326561:60c1fe356f4b
user: dsl <dsl%NetBSD.org@localhost>
date: Sun Feb 02 22:41:20 2014 +0000
description:
Minor fpu initialisation cleanups:
Set default CR) so that the FPU is enabled (unset CR0_EM) and initialise
i386_fpu_present to 1.
No need to call the npx trap indirectly, rename to fpunda() to match amd64.
Remove the i386_fpu_exception variable and sysctl (It used to indicate
which irq was used for fpu exceptions, but we only support 'internal'
now). Hopefully no one cares.
fpuinit() now only needs to clear TS before the fninit(). Apart from the
checks for 486SX and the 'fdiv bug' this matches the amd64 version.
Exclude fpuinit() from XEN kernels, they don't call it - which rather begs
the question as to whether it is needed at all!
diffstat:
sys/arch/i386/acpi/acpi_wakecode.S | 4 +-
sys/arch/i386/i386/i386_trap.S | 6 ++--
sys/arch/i386/i386/locore.S | 8 +++---
sys/arch/i386/i386/machdep.c | 9 +------
sys/arch/i386/i386/mptramp.S | 8 +++---
sys/arch/i386/isa/npx.c | 40 +++++++++++++++++--------------------
sys/arch/x86/x86/procfs_machdep.c | 10 +++-----
7 files changed, 37 insertions(+), 48 deletions(-)
diffs (283 lines):
diff -r 91b0c4943163 -r 60c1fe356f4b sys/arch/i386/acpi/acpi_wakecode.S
--- a/sys/arch/i386/acpi/acpi_wakecode.S Sun Feb 02 22:00:38 2014 +0000
+++ b/sys/arch/i386/acpi/acpi_wakecode.S Sun Feb 02 22:41:20 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_wakecode.S,v 1.15 2012/04/19 18:00:34 jym Exp $ */
+/* $NetBSD: acpi_wakecode.S,v 1.16 2014/02/02 22:41:20 dsl Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -165,7 +165,7 @@
movl WAKEUP_r_cr3 + ACPI_WAKEUP_ADDR,%eax
movl %eax,%cr3
movl %cr0,%eax
- orl $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_WP|CR0_AM),%eax
+ orl $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP|CR0_AM),%eax
movl %eax,%cr0
/* Flush the prefetch queue */
diff -r 91b0c4943163 -r 60c1fe356f4b sys/arch/i386/i386/i386_trap.S
--- a/sys/arch/i386/i386/i386_trap.S Sun Feb 02 22:00:38 2014 +0000
+++ b/sys/arch/i386/i386/i386_trap.S Sun Feb 02 22:41:20 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i386_trap.S,v 1.2 2014/01/26 19:16:17 dsl Exp $ */
+/* $NetBSD: i386_trap.S,v 1.3 2014/02/02 22:41:20 dsl Exp $ */
/*
* Copyright 2002 (c) Wasabi Systems, Inc.
@@ -66,7 +66,7 @@
#if 0
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.2 2014/01/26 19:16:17 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.3 2014/02/02 22:41:20 dsl Exp $");
#endif
/*
@@ -163,7 +163,7 @@
movl CPUVAR(ILEVEL),%ebx
#endif
pushl CPUVAR(SELF)
- call *_C_LABEL(npxdna_func)
+ call _C_LABEL(fpudna)
addl $4,%esp
testl %eax,%eax
jz calltrap
diff -r 91b0c4943163 -r 60c1fe356f4b sys/arch/i386/i386/locore.S
--- a/sys/arch/i386/i386/locore.S Sun Feb 02 22:00:38 2014 +0000
+++ b/sys/arch/i386/i386/locore.S Sun Feb 02 22:41:20 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.110 2014/01/26 19:16:17 dsl Exp $ */
+/* $NetBSD: locore.S,v 1.111 2014/02/02 22:41:20 dsl Exp $ */
/*
* Copyright-o-rama!
@@ -129,7 +129,7 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.110 2014/01/26 19:16:17 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.111 2014/02/02 22:41:20 dsl Exp $");
#include "opt_compat_oldboot.h"
#include "opt_ddb.h"
@@ -697,8 +697,8 @@
* 2. Enable paging and the rest of it.
*/
movl %cr0,%eax # get control word
- # enable paging & NPX emulation
- orl $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_WP|CR0_AM),%eax
+ # enable paging & NPX
+ orl $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP|CR0_AM),%eax
movl %eax,%cr0 # and page NOW!
pushl $begin # jump to high mem
diff -r 91b0c4943163 -r 60c1fe356f4b sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Sun Feb 02 22:00:38 2014 +0000
+++ b/sys/arch/i386/i386/machdep.c Sun Feb 02 22:41:20 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.744 2014/02/01 18:57:38 bouyer Exp $ */
+/* $NetBSD: machdep.c,v 1.745 2014/02/02 22:41:20 dsl Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.744 2014/02/01 18:57:38 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.745 2014/02/02 22:41:20 dsl Exp $");
#include "opt_beep.h"
#include "opt_compat_ibcs2.h"
@@ -229,12 +229,7 @@
int cpu_class;
int use_pae;
-#ifdef XEN
int i386_fpu_present = 1;
-#else
-int i386_fpu_present;
-#endif
-int i386_fpu_exception;
int i386_fpu_fdivbug;
int i386_use_fxsave;
diff -r 91b0c4943163 -r 60c1fe356f4b sys/arch/i386/i386/mptramp.S
--- a/sys/arch/i386/i386/mptramp.S Sun Feb 02 22:00:38 2014 +0000
+++ b/sys/arch/i386/i386/mptramp.S Sun Feb 02 22:41:20 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mptramp.S,v 1.26 2014/01/15 22:24:41 joerg Exp $ */
+/* $NetBSD: mptramp.S,v 1.27 2014/02/02 22:41:20 dsl Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: mptramp.S,v 1.26 2014/01/15 22:24:41 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mptramp.S,v 1.27 2014/02/02 22:41:20 dsl Exp $");
#include "opt_mpbios.h" /* for MPDEBUG */
@@ -178,8 +178,8 @@
/* Load base of page directory and enable mapping. */
movl %ecx,%cr3 # load ptd addr into mmu
movl %cr0,%eax # get control word
- # enable paging & NPX emulation
- orl $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_WP|CR0_AM),%eax
+ # enable paging & the fpu
+ orl $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP|CR0_AM),%eax
movl %eax,%cr0 # and page NOW!
#ifdef MPDEBUG
diff -r 91b0c4943163 -r 60c1fe356f4b sys/arch/i386/isa/npx.c
--- a/sys/arch/i386/isa/npx.c Sun Feb 02 22:00:38 2014 +0000
+++ b/sys/arch/i386/isa/npx.c Sun Feb 02 22:41:20 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npx.c,v 1.149 2014/01/26 19:16:17 dsl Exp $ */
+/* $NetBSD: npx.c,v 1.150 2014/02/02 22:41:20 dsl Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.149 2014/01/26 19:16:17 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.150 2014/02/02 22:41:20 dsl Exp $");
#if 0
#define IPRINTF(x) printf x
@@ -145,7 +145,8 @@
*/
static int x86fpflags_to_ksiginfo(uint32_t flags);
-static int npxdna(struct cpu_info *);
+/* Called directly from i386_trap.S */
+int fpudna(struct cpu_info *);
#ifdef XEN
#define clts() HYPERVISOR_fpu_taskswitch(0)
@@ -156,7 +157,6 @@
volatile u_int npx_traps_while_probing;
extern int i386_fpu_present;
-extern int i386_fpu_exception;
extern int i386_fpu_fdivbug;
struct npx_softc *npx_softc;
@@ -174,33 +174,28 @@
fnsave(&addr->sv_87);
}
-int (*npxdna_func)(struct cpu_info *) = npxdna;
-
+#ifndef XEN
+/* Initialise fpu, might be boot cpu or a later cpu coming online */
void
fpuinit(struct cpu_info *ci)
{
uint16_t control;
- uint32_t cr0;
- /* Assume we have an FPU */
- cr0 = rcr0();
- cr0 &= ~(CR0_EM | CR0_TS);
- cr0 |= CR0_NE | CR0_MP;
- lcr0(cr0);
- /* Read back the default contol word */
+ /* The default cr0 has the fpu enabled */
+ clts();
fninit();
+
+ /* Read the default control word */
fnstcw(&control);
if (control != __INITIAL_NPXCW__) {
- /* Must be a 486SX, emulate FP instructions */
- lcr0((cr0 & ~CR0_MP) | CR0_EM);
- aprint_normal_dev(ci->ci_dev, "no fpu\n");
+ /* Must be a 486SX, trap FP instructions */
+ lcr0((rcr0() & ~CR0_MP) | CR0_EM);
+ aprint_normal_dev(ci->ci_dev, "no fpu (control %x)\n", control);
+ i386_fpu_present = 0;
return;
}
- /* We have a valid FPU */
- i386_fpu_present = 1;
-
if (npx586bug1(4195835, 3145727) != 0) {
/* NB 120+MHz cpus are not affected */
i386_fpu_fdivbug = 1;
@@ -209,8 +204,9 @@
}
/* Set TS so first fp instruction faults */
- lcr0(cr0 | CR0_TS);
+ stts();
}
+#endif
/*
* Record the FPU state and reinitialize it all except for the control word.
@@ -384,8 +380,8 @@
* Otherwise, we save the previous state, if necessary, and restore
* our last saved state.
*/
-static int
-npxdna(struct cpu_info *ci)
+int
+fpudna(struct cpu_info *ci)
{
struct lwp *l, *fl;
struct pcb *pcb;
diff -r 91b0c4943163 -r 60c1fe356f4b sys/arch/x86/x86/procfs_machdep.c
--- a/sys/arch/x86/x86/procfs_machdep.c Sun Feb 02 22:00:38 2014 +0000
+++ b/sys/arch/x86/x86/procfs_machdep.c Sun Feb 02 22:41:20 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: procfs_machdep.c,v 1.1 2010/07/08 11:25:00 rmind Exp $ */
+/* $NetBSD: procfs_machdep.c,v 1.2 2014/02/02 22:41:20 dsl Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.1 2010/07/08 11:25:00 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.2 2014/02/02 22:41:20 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -56,7 +56,7 @@
#include <machine/reg.h>
#include <machine/specialreg.h>
-extern int i386_fpu_present, i386_fpu_exception, i386_fpu_fdivbug;
+extern int i386_fpu_present, i386_fpu_fdivbug;
extern char cpu_model[];
static const char * const x86_features[] = {
@@ -210,18 +210,16 @@
l = snprintf(p, left,
"fdiv_bug\t: %s\n"
"fpu\t\t: %s\n"
- "fpu_exception\t: %s\n"
+ "fpu_exception\t: yes\n"
"cpuid level\t: %d\n"
"wp\t\t: %s\n"
"flags\t\t: %s\n",
#ifdef __x86_64__
"no", /* XXX */
"yes", /* XXX */
- "yes", /* XXX */
#else
i386_fpu_fdivbug ? "yes" : "no",
i386_fpu_present ? "yes" : "no",
- i386_fpu_exception ? "yes" : "no",
#endif
cpuid_level,
(rcr0() & CR0_WP) ? "yes" : "no",
Home |
Main Index |
Thread Index |
Old Index