7 /* #define DEBUG_INT */
10 struct Win87EmInfoStruct
12 unsigned short Version
;
13 unsigned short SizeSaveArea
;
14 unsigned short WinDataSeg
;
15 unsigned short WinCodeSeg
;
16 unsigned short Have80x87
;
17 unsigned short Unused
;
20 /* Implementing this is easy cause Linux and *BSD* ALWAYS have a numerical
21 * coprocessor. (either real or emulated on kernellevel)
23 /* win87em.dll also sets interrupt vectors: 2 (NMI), 0x34 - 0x3f (emulator
24 * calls of standard libraries, see Ralph Browns interrupt list), 0x75
25 * (int13 error reporting of coprocessor)
28 /* have a look at /usr/src/linux/arch/i386/math-emu/ *.[ch] for more info
29 * especially control_w.h and status_w.h
31 /* FIXME: Only skeletal implementation for now */
33 void WIN87_fpmath( struct sigcontext_struct context
)
35 dprintf_int(stddeb
, "_fpmath: (cs:eip=%x:%lx es=%x bx=%04x ax=%04x dx==%04x)\n",
36 CS_reg(&context
), EIP_reg(&context
),
37 ES_reg(&context
), BX_reg(&context
),
38 AX_reg(&context
), DX_reg(&context
) );
40 switch(BX_reg(&context
))
42 case 0: /* install (increase instanceref) emulator, install NMI vector */
46 case 1: /* Init Emulator */
50 case 2: /* deinstall emulator (decrease instanceref), deinstall NMI vector
51 * if zero. Every '0' call should have a matching '2' call.
57 /*INT_SetHandler(0x3E,MAKELONG(AX,DX));*/
60 case 4: /* set control word (& ~(CW_Denormal|CW_Invalid)) */
61 /* OUT: newset control word in AX */
64 case 5: /* return internal control word in AX */
67 case 6: /* round top of stack to integer using method AX & 0x0C00 */
68 /* returns current controlword */
71 case 7: /* POP top of stack as integer into DX:AX */
72 /* IN: AX&0x0C00 rounding protocol */
73 /* OUT: DX:AX variable popped */
76 /* I don't know much about asm() programming. This could be
79 /* FIXME: could someone who really understands asm() fix this please? --AJ */
80 /* __asm__("fistp %0;wait" : "=m" (dw) : : "memory"); */
81 dprintf_int(stddeb
,"emulate.c:On top of stack was %ld\n",dw
);
82 AX_reg(&context
) = LOWORD(dw
);
83 DX_reg(&context
) = HIWORD(dw
);
87 case 8: /* restore internal control words from emulator control word */
90 case 9: /* clear emu control word and some other things */
93 case 10: /* dunno. but looks like returning nr. of things on stack in AX */
97 case 11: /* just returns the installed flag in DX:AX */
102 case 12: /* save AX in some internal state var */
105 default: /* error. Say that loud and clear */
106 AX_reg(&context
) = DX_reg(&context
) = 0xFFFF;
113 WIN87_WinEm87Info(struct Win87EmInfoStruct
*pWIS
, int cbWin87EmInfoStruct
)
115 dprintf_int(stddeb
, "__WinEm87Info(%p,%d)\n",pWIS
,cbWin87EmInfoStruct
);
119 WIN87_WinEm87Restore(void *pWin87EmSaveArea
, int cbWin87EmSaveArea
)
121 dprintf_int(stddeb
, "__WinEm87Restore(%p,%d)\n",
122 pWin87EmSaveArea
,cbWin87EmSaveArea
);
126 WIN87_WinEm87Save(void *pWin87EmSaveArea
, int cbWin87EmSaveArea
)
128 dprintf_int(stddeb
, "__WinEm87Save(%p,%d)\n",
129 pWin87EmSaveArea
,cbWin87EmSaveArea
);