Detect type and precence of an FPU in the kernel instead of relying on GEM.
This commit is contained in:
parent
cf13e627f4
commit
dd73a31ed8
|
@ -0,0 +1,136 @@
|
||||||
|
/* $NetBSD: fpu.c,v 1.1 1995/08/28 19:31:06 leo Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1995 Gordon W. Ross
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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 reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
* 4. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Gordon Ross
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Floating Point Unit (MC68881/882/040)
|
||||||
|
* Probe for the FPU at autoconfig time.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/device.h>
|
||||||
|
|
||||||
|
#include <machine/psl.h>
|
||||||
|
#include <machine/cpu.h>
|
||||||
|
#include <machine/frame.h>
|
||||||
|
|
||||||
|
#include <setjmp.h>
|
||||||
|
|
||||||
|
extern int fpu_type;
|
||||||
|
extern int *nofault;
|
||||||
|
|
||||||
|
static char *fpu_descr[] = {
|
||||||
|
#ifdef FPU_EMULATE
|
||||||
|
" emulated", /* 0 */
|
||||||
|
#else
|
||||||
|
" no", /* 0 */
|
||||||
|
#endif
|
||||||
|
" mc68881", /* 1 */
|
||||||
|
" mc68882", /* 2 */
|
||||||
|
"/", /* 3 68040 internal */
|
||||||
|
"???" };
|
||||||
|
|
||||||
|
char *
|
||||||
|
fpu_describe(type)
|
||||||
|
int type;
|
||||||
|
{
|
||||||
|
int maxtype = sizeof(fpu_descr)/sizeof(fpu_descr[0]) - 1;
|
||||||
|
|
||||||
|
if ((type < 0) || (type > maxtype))
|
||||||
|
type = 0;
|
||||||
|
return(fpu_descr[type]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
fpu_probe()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* A 68881 idle frame is 28 bytes and a 68882's is 60 bytes.
|
||||||
|
* We, of course, need to have enough room for either.
|
||||||
|
*/
|
||||||
|
int fpframe[60 / sizeof(int)];
|
||||||
|
jmp_buf faultbuf;
|
||||||
|
u_char b;
|
||||||
|
|
||||||
|
nofault = (int *) &faultbuf;
|
||||||
|
if (setjmp(faultbuf)) {
|
||||||
|
nofault = (int *) 0;
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Synchronize FPU or cause a fault.
|
||||||
|
* This should leave the 881/882 in the IDLE state,
|
||||||
|
* state, so we can determine which we have by
|
||||||
|
* examining the size of the FP state frame
|
||||||
|
*/
|
||||||
|
asm("fnop");
|
||||||
|
|
||||||
|
nofault = (int *) 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Presumably, if we're an 040 and did not take exception
|
||||||
|
* above, we have an FPU. Don't bother probing.
|
||||||
|
*/
|
||||||
|
if (mmutype == MMU_68040) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Presumably, this will not cause a fault--the fnop should
|
||||||
|
* have if this will. We save the state in order to get the
|
||||||
|
* size of the frame.
|
||||||
|
*/
|
||||||
|
asm("movl %0, a0; fsave a0@" : : "a" (fpframe) : "a0" );
|
||||||
|
|
||||||
|
b = *((u_char *) fpframe + 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now, restore a NULL state to reset the FPU.
|
||||||
|
*/
|
||||||
|
fpframe[0] = fpframe[1] = 0;
|
||||||
|
m68881_restore(fpframe);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The size of a 68881 IDLE frame is 0x18
|
||||||
|
* and a 68882 frame is 0x38
|
||||||
|
*/
|
||||||
|
if (b == 0x18) return 1;
|
||||||
|
if (b == 0x38) return 2;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If it's not one of the above, we have no clue what it is.
|
||||||
|
*/
|
||||||
|
return 4;
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: machdep.c,v 1.11 1995/07/13 21:36:09 leo Exp $ */
|
/* $NetBSD: machdep.c,v 1.12 1995/08/28 19:31:07 leo Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988 University of Utah.
|
* Copyright (c) 1988 University of Utah.
|
||||||
|
@ -386,49 +386,31 @@ extern char version[];
|
||||||
|
|
||||||
identifycpu()
|
identifycpu()
|
||||||
{
|
{
|
||||||
/* there's alot of XXX in here... */
|
extern char *fpu_describe();
|
||||||
char *mach, *mmu, *fpu, *cpu;
|
extern int *fpu_probe();
|
||||||
|
char *mach, *mmu, *fpu, *cpu;
|
||||||
|
|
||||||
if(machineid & ATARI_TT)
|
if (machineid & ATARI_TT)
|
||||||
mach = "Atari TT";
|
mach = "Atari TT";
|
||||||
else if(machineid & ATARI_FALCON)
|
else if (machineid & ATARI_FALCON)
|
||||||
mach = "Atari Falcon";
|
mach = "Atari Falcon";
|
||||||
else mach = "Atari UNKNOWN";
|
else mach = "Atari UNKNOWN";
|
||||||
|
|
||||||
cpu = "m68k";
|
cpu = "m68k";
|
||||||
fpu = NULL;
|
fputype = fpu_probe();
|
||||||
fputype = 0;
|
fpu = fpu_describe(fputype);
|
||||||
|
|
||||||
if (machineid & ATARI_68040) {
|
if (machineid & ATARI_68040) {
|
||||||
cpu = "m68040";
|
cpu = "m68040";
|
||||||
mmu = "/MMU";
|
mmu = "/MMU";
|
||||||
fpu = "/FPU";
|
|
||||||
fputype = 3; /* XXX define ??? */
|
|
||||||
} else if (machineid & ATARI_68030) {
|
} else if (machineid & ATARI_68030) {
|
||||||
cpu = "m68030"; /* XXX */
|
cpu = "m68030";
|
||||||
mmu = "/MMU";
|
mmu = "/MMU";
|
||||||
} else {
|
} else {
|
||||||
cpu = "m68020";
|
cpu = "m68020";
|
||||||
mmu = " m68851 MMU";
|
mmu = " m68851 MMU";
|
||||||
}
|
}
|
||||||
if (fpu == NULL) {
|
sprintf(cpu_model, "%s (%s CPU%s%s FPU)", mach, cpu, mmu, fpu);
|
||||||
if (machineid & ATARI_68882) {
|
|
||||||
fpu = " m68882 FPU";
|
|
||||||
fputype = 2; /* XXX define ??? */
|
|
||||||
}
|
|
||||||
else if (machineid & ATARI_68881) {
|
|
||||||
fpu = " m68881 FPU";
|
|
||||||
fputype = 1; /* XXX define ??? */
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
#ifdef FPU_EMULATE
|
|
||||||
fpu = " FPU emulator";
|
|
||||||
#else
|
|
||||||
fpu = " no FPU";
|
|
||||||
#endif
|
|
||||||
fputype = 0; /* XXX define ??? */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sprintf(cpu_model, "%s (%s CPU%s%s)", mach, cpu, mmu, fpu);
|
|
||||||
printf("%s\n", cpu_model);
|
printf("%s\n", cpu_model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# $NetBSD: files.atari,v 1.11 1995/08/20 18:17:12 leo Exp $
|
# $NetBSD: files.atari,v 1.12 1995/08/28 19:31:16 leo Exp $
|
||||||
#
|
#
|
||||||
|
|
||||||
maxpartitions 16
|
maxpartitions 16
|
||||||
|
@ -104,6 +104,7 @@ file arch/atari/atari/trap.c
|
||||||
file arch/atari/atari/misc.c
|
file arch/atari/atari/misc.c
|
||||||
file arch/atari/atari/vm_machdep.c
|
file arch/atari/atari/vm_machdep.c
|
||||||
file arch/atari/atari/db_memrw.c ddb
|
file arch/atari/atari/db_memrw.c ddb
|
||||||
|
file arch/atari/atari/fpu.c
|
||||||
file arch/m68k/m68k/copy.s
|
file arch/m68k/m68k/copy.s
|
||||||
|
|
||||||
# Emulation modules
|
# Emulation modules
|
||||||
|
|
Loading…
Reference in New Issue