Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 39 → Rev 40

/shark/trunk/oslib/xlib/fpu.c
1,4 → 1,3
 
/* Project: OSLib
* Description: The OS Construction Kit
* Date: 1.6.2000
27,6 → 26,7
 
#include <ll/i386/hw-data.h>
#include <ll/i386/hw-instr.h>
#include <ll/i386/hw-func.h>
#include <ll/i386/mem.h>
 
#include <ll/i386/tss-ctx.h>
33,15 → 33,15
 
FILE(FPU);
 
extern TSS TSS_table[];
extern TSS main_tss;
 
BYTE LL_FPU_savearea[FPU_CONTEXT_SIZE]; /* Global FPU scratch SaveArea */
BYTE LL_FPU_savearea[FPU_CONTEXT_SIZE]; /* Global FPU scratch SaveArea */
#ifdef __FPU_DEBUG__
long int ndp_called = 0, ndp_switched = 0;
long int ndp_called = 0,ndp_switched = 0;
#endif
 
/* FPU context management */
static CONTEXT LL_has_FPU = TSSMain;
static TSS *LL_has_FPU = &main_tss;
 
/* As the 8086 does not have an hardware mechanism to support task */
/* switch, also the FPU context switch is implemented via software. */
51,37 → 51,40
 
void ll_FPU_hook(void)
{
CONTEXT current;
TSS *base;
 
current = get_TR();
base = (TSS *)GDT_read(current, NULL, NULL, NULL);
 
clts();
#ifdef __FPU_DEBUG__
ndp_called++;
#endif
if (LL_has_FPU == TSSsel2index(get_TR()))
return;
#ifdef __FPU_DEBUG__
ndp_switched++;
#endif
#ifdef __FPU_DEBUG__
ndp_called++;
#endif
if (LL_has_FPU == base) return;
#ifdef __FPU_DEBUG__
ndp_switched++;
#endif
 
#if 0
LL_FPU_save();
memcpy(TSS_table[LL_has_FPU].ctx_FPU, LL_FPU_savearea,
FPU_CONTEXT_SIZE);
#else
save_fpu(&(TSS_table[LL_has_FPU]));
memcpy(TSS_table[LL_has_FPU].ctx_FPU,LL_FPU_savearea,FPU_CONTEXT_SIZE);
#else
save_fpu(LL_has_FPU);
#endif
 
LL_has_FPU = TSSsel2index(get_TR());
LL_has_FPU = base;
 
#if 1
memcpy(LL_FPU_savearea, TSS_table[LL_has_FPU].ctx_FPU,
FPU_CONTEXT_SIZE);
memcpy(LL_FPU_savearea, base->ctx_FPU, FPU_CONTEXT_SIZE);
LL_FPU_restore();
#else
#else
restore_fpu(&(TSS_table[LL_has_FPU]));
#endif
return;
}
 
CONTEXT LL_FPU_get_task(void)
TSS *LL_FPU_get_task(void)
{
return (LL_has_FPU);
return(LL_has_FPU);
}