5 DEFAULT_DEBUG_CHANNEL(int)
7 struct Win87EmInfoStruct
9 unsigned short Version
;
10 unsigned short SizeSaveArea
;
11 unsigned short WinDataSeg
;
12 unsigned short WinCodeSeg
;
13 unsigned short Have80x87
;
14 unsigned short Unused
;
17 /* Implementing this is easy cause Linux and *BSD* ALWAYS have a numerical
18 * coprocessor. (either real or emulated on kernellevel)
20 /* win87em.dll also sets interrupt vectors: 2 (NMI), 0x34 - 0x3f (emulator
21 * calls of standard libraries, see Ralph Browns interrupt list), 0x75
22 * (int13 error reporting of coprocessor)
25 /* have a look at /usr/src/linux/arch/i386/math-emu/ *.[ch] for more info
26 * especially control_w.h and status_w.h
28 /* FIXME: Only skeletal implementation for now */
30 void WINAPI
WIN87_fpmath( CONTEXT
*context
)
32 TRACE(int, "(cs:eip=%x:%lx es=%x bx=%04x ax=%04x dx==%04x)\n",
33 (WORD
)CS_reg(context
), EIP_reg(context
),
34 (WORD
)ES_reg(context
), BX_reg(context
),
35 AX_reg(context
), DX_reg(context
) );
37 switch(BX_reg(context
))
39 case 0: /* install (increase instanceref) emulator, install NMI vector */
43 case 1: /* Init Emulator */
47 case 2: /* deinstall emulator (decrease instanceref), deinstall NMI vector
48 * if zero. Every '0' call should have a matching '2' call.
54 /*INT_SetHandler(0x3E,MAKELONG(AX,DX));*/
57 case 4: /* set control word (& ~(CW_Denormal|CW_Invalid)) */
58 /* OUT: newset control word in AX */
61 case 5: /* return internal control word in AX */
64 case 6: /* round top of stack to integer using method AX & 0x0C00 */
65 /* returns current controlword */
68 /* I don't know much about asm() programming. This could be
71 __asm__
__volatile__("frndint");
72 __asm__
__volatile__("fist %0;wait" : "=m" (dw
) : : "memory");
73 TRACE(int,"On top of stack is %ld\n",dw
);
77 case 7: /* POP top of stack as integer into DX:AX */
78 /* IN: AX&0x0C00 rounding protocol */
79 /* OUT: DX:AX variable popped */
82 /* I don't know much about asm() programming. This could be
85 /* FIXME: could someone who really understands asm() fix this please? --AJ */
86 /* __asm__("fistp %0;wait" : "=m" (dw) : : "memory"); */
87 TRACE(int,"On top of stack was %ld\n",dw
);
88 AX_reg(context
) = LOWORD(dw
);
89 DX_reg(context
) = HIWORD(dw
);
93 case 8: /* restore internal control words from emulator control word */
96 case 9: /* clear emu control word and some other things */
99 case 10: /* dunno. but looks like returning nr. of things on stack in AX */
103 case 11: /* just returns the installed flag in DX:AX */
108 case 12: /* save AX in some internal state var */
111 default: /* error. Say that loud and clear */
112 FIXME(int,"unhandled switch %d\n",BX_reg(context
));
113 AX_reg(context
) = DX_reg(context
) = 0xFFFF;
119 void WINAPI
WIN87_WinEm87Info(struct Win87EmInfoStruct
*pWIS
,
120 int cbWin87EmInfoStruct
)
122 TRACE(int, "(%p,%d)\n",pWIS
,cbWin87EmInfoStruct
);
125 void WINAPI
WIN87_WinEm87Restore(void *pWin87EmSaveArea
,
126 int cbWin87EmSaveArea
)
128 TRACE(int, "(%p,%d)\n",
129 pWin87EmSaveArea
,cbWin87EmSaveArea
);
132 void WINAPI
WIN87_WinEm87Save(void *pWin87EmSaveArea
, int cbWin87EmSaveArea
)
134 TRACE(int, "(%p,%d)\n",
135 pWin87EmSaveArea
,cbWin87EmSaveArea
);