From f39b6a05acd582271603783421cd37553f43150d Mon Sep 17 00:00:00 2001 From: phk Date: Thu, 14 Dec 1995 08:21:33 +0000 Subject: Make math_emulators LKMable. --- sys/gnu/i386/fpemul/fpu_entry.c | 64 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 7 deletions(-) (limited to 'sys/gnu') diff --git a/sys/gnu/i386/fpemul/fpu_entry.c b/sys/gnu/i386/fpemul/fpu_entry.c index edbe94d..d00a6de 100644 --- a/sys/gnu/i386/fpemul/fpu_entry.c +++ b/sys/gnu/i386/fpemul/fpu_entry.c @@ -55,7 +55,7 @@ * * W. Metzenthen June 1994. * - * $Id: fpu_entry.c,v 1.5 1994/08/30 20:18:52 davidg Exp $ + * $Id: fpu_entry.c,v 1.6 1995/05/30 07:57:45 rgrimes Exp $ * */ @@ -71,11 +71,17 @@ +---------------------------------------------------------------------------*/ -#include "param.h" -#include "systm.h" -#include "proc.h" -#include "machine/cpu.h" -#include "machine/pcb.h" +#include +#include +#include +#include + +#ifdef LKM +#include +#endif + +#include +#include #include "fpu_emu.h" #include "fpu_system.h" @@ -192,7 +198,7 @@ char emulating = 0; #define math_abort(signo) \ FPU_EIP = FPU_ORIG_EIP;REENTRANT_CHECK(OFF);return(signo); -int +static int math_emulate(struct trapframe * tframe) { @@ -481,3 +487,47 @@ if (--lookahead_limit) REENTRANT_CHECK(OFF); return (0); /* --pink-- */ } + +#ifdef LKM +MOD_MISC(gnufpu); +static int +gnufpu_load(struct lkm_table *lkmtp, int cmd) +{ + if (pmath_emulate) { + printf("Math emulator already present\n"); + return EBUSY; + } + pmath_emulate = math_emulate; + return 0; +} + +static int +gnufpu_unload(struct lkm_table *lkmtp, int cmd) +{ + if (pmath_emulate != math_emulate) { + printf("Cannot unload another math emulator\n"); + return EACCES; + } + pmath_emulate = 0; + return 0; +} + +int +gnufpu(struct lkm_table *lkmtp, int cmd, int ver) +{ + DISPATCH(lkmtp, cmd, ver, gnufpu_load, gnufpu_unload, lkm_nullcmd); +} +#else /* !LKM */ + +static void +gnufpu_init(void) +{ + if (pmath_emulate) + printf("Another Math emulator already present\n"); + else + pmath_emulate = math_emulate; +} + +SYSINIT(gnufpu, SI_SUB_CPU, SI_ORDER_ANY, gnufpu_init, NULL); + +#endif /* LKM */ -- cgit v1.1