1 | ; $Id: bs3-fpustate-1-template.mac 61315 2016-05-31 01:55:55Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - bs3-fpustate-1, assembly template.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2007-2016 Oracle Corporation
|
---|
8 | ;
|
---|
9 | ; This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | ; available from http://www.alldomusa.eu.org. This file is free software;
|
---|
11 | ; you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | ; General Public License (GPL) as published by the Free Software
|
---|
13 | ; Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | ;
|
---|
17 | ; The contents of this file may alternatively be used under the terms
|
---|
18 | ; of the Common Development and Distribution License Version 1.0
|
---|
19 | ; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | ; VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | ; CDDL are applicable instead of those of the GPL.
|
---|
22 | ;
|
---|
23 | ; You may elect to license modified versions of this file under the
|
---|
24 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | ;
|
---|
26 |
|
---|
27 |
|
---|
28 | ;*********************************************************************************************************************************
|
---|
29 | ;* Header Files *
|
---|
30 | ;*********************************************************************************************************************************
|
---|
31 | %include "bs3kit-template-header.mac" ; setup environment
|
---|
32 |
|
---|
33 |
|
---|
34 | ;*********************************************************************************************************************************
|
---|
35 | ;* External Symbols *
|
---|
36 | ;*********************************************************************************************************************************
|
---|
37 | TMPL_BEGIN_TEXT
|
---|
38 |
|
---|
39 |
|
---|
40 | ;;
|
---|
41 | ; Initializes the FPU state and saves it to pFxState.
|
---|
42 | ;
|
---|
43 | ; BS3_DECL_NEAR(void) TMPL_NM(bs3FpuState1_InitState)(X86FXSTATE BS3_FAR *pFxState);
|
---|
44 | ;
|
---|
45 | BS3_PROC_BEGIN_MODE bs3FpuState1_InitState, BS3_PBC_NEAR
|
---|
46 | BS3_CALL_CONV_PROLOG 1
|
---|
47 | push xBP
|
---|
48 | mov xBP, xSP
|
---|
49 | push xBX
|
---|
50 | TONLY16 push ds
|
---|
51 | pushf
|
---|
52 |
|
---|
53 | ;
|
---|
54 | ; x87 state.
|
---|
55 | ;
|
---|
56 | fninit
|
---|
57 | fld dword [TMPL_DATA16_WRT(g_r32V1)]
|
---|
58 | fld qword [TMPL_DATA16_WRT(g_r64V1)]
|
---|
59 | fld tword [TMPL_DATA16_WRT(g_r80V1)]
|
---|
60 | fld qword [TMPL_DATA16_WRT(g_r64V1)]
|
---|
61 | fld dword [TMPL_DATA16_WRT(g_r32V2)]
|
---|
62 | fld dword [TMPL_DATA16_WRT(g_r80_QNaNMax)]
|
---|
63 | fld tword [TMPL_DATA16_WRT(g_r80_ThirtyTwo)]
|
---|
64 | fld tword [TMPL_DATA16_WRT(g_r80_SNaNMax)]
|
---|
65 | ;; @todo status regs
|
---|
66 |
|
---|
67 |
|
---|
68 | ;
|
---|
69 | ; SSE state
|
---|
70 | ;
|
---|
71 | movdqu xmm0, [TMPL_DATA16_WRT(g_r32_0dot1)]
|
---|
72 | movdqu xmm1, [TMPL_DATA16_WRT(g_r32_Two)]
|
---|
73 | movdqu xmm2, [TMPL_DATA16_WRT(g_r32_ThirtyTwo)]
|
---|
74 | movdqu xmm3, [TMPL_DATA16_WRT(g_r32_ThirtyTwo)]
|
---|
75 | movdqu xmm4, [TMPL_DATA16_WRT(g_r32_SNaN)]
|
---|
76 | movdqu xmm5, [TMPL_DATA16_WRT(g_r32_NegQNaN)]
|
---|
77 | movdqu xmm6, [TMPL_DATA16_WRT(g_r64_Zero)]
|
---|
78 | movdqu xmm7, [TMPL_DATA16_WRT(g_r64_Two)]
|
---|
79 | %if TMPL_BITS == 64
|
---|
80 | movdqu xmm8, [TMPL_DATA16_WRT(g_r64_Ten)]
|
---|
81 | movdqu xmm9, [TMPL_DATA16_WRT(g_r64_ThirtyTwo)]
|
---|
82 | movdqu xmm10, [TMPL_DATA16_WRT(g_r64_Max)]
|
---|
83 | movdqu xmm11, [TMPL_DATA16_WRT(g_r64_SNaN)]
|
---|
84 | movdqu xmm12, [TMPL_DATA16_WRT(g_r64_NegQNaN)]
|
---|
85 | movdqu xmm13, [TMPL_DATA16_WRT(g_r64_QNaNMax)]
|
---|
86 | movdqu xmm14, [TMPL_DATA16_WRT(g_r64_DnMax)]
|
---|
87 | movdqu xmm15, [TMPL_DATA16_WRT(g_r80_Eleven)]
|
---|
88 | %endif
|
---|
89 |
|
---|
90 | ;; @todo status regs
|
---|
91 |
|
---|
92 | ;
|
---|
93 | ; Save it. Note that DS is no longer valid in 16-bit code.
|
---|
94 | ; To be on the safe side, we load and save the state once again.
|
---|
95 | ;
|
---|
96 | TONLY16 mov ds, [xBP + xCB + cbCurRetAddr + 2]
|
---|
97 | mov xBX, [xBP + xCB + cbCurRetAddr]
|
---|
98 | cli
|
---|
99 | %if TMPL_BITS == 64
|
---|
100 | o64 fxsave [xBX]
|
---|
101 | fninit
|
---|
102 | o64 fxrstor [xBX]
|
---|
103 | o64 fxsave [xBX]
|
---|
104 | %else
|
---|
105 | fxsave [xBX]
|
---|
106 | fninit
|
---|
107 | fxrstor [xBX]
|
---|
108 | fxsave [xBX]
|
---|
109 | %endif
|
---|
110 |
|
---|
111 | .return:
|
---|
112 | popf
|
---|
113 | TONLY16 pop ds
|
---|
114 | pop xBX
|
---|
115 | mov xSP, xBP
|
---|
116 | pop xBP
|
---|
117 | BS3_CALL_CONV_EPILOG 1
|
---|
118 | BS3_HYBRID_RET
|
---|
119 | BS3_PROC_END_MODE bs3FpuState1_InitState
|
---|
120 |
|
---|
121 |
|
---|
122 | ;;
|
---|
123 | ; BS3_DECL_NEAR(void) TMPL_NM(bs3FpuState1_Restore)(X86FXSTATE const BS3_FAR *pFxState);
|
---|
124 | ;
|
---|
125 | BS3_PROC_BEGIN_MODE bs3FpuState1_Restore, BS3_PBC_NEAR
|
---|
126 | push xBP
|
---|
127 | mov xBP, xSP
|
---|
128 |
|
---|
129 | %if TMPL_BITS == 64
|
---|
130 | o64 fxrstor [rcx]
|
---|
131 |
|
---|
132 | %elif TMPL_BITS == 32
|
---|
133 | mov eax, [xBP + xCB*2]
|
---|
134 | fxrstor [eax]
|
---|
135 |
|
---|
136 | %elif TMPL_BITS == 16
|
---|
137 | mov ax, ds
|
---|
138 | mov ds, [xBP + xCB + cbCurRetAddr + 2]
|
---|
139 | mov xBX, [xBP + xCB + cbCurRetAddr]
|
---|
140 | fxrstor [bx]
|
---|
141 | mov ds, ax
|
---|
142 | %else
|
---|
143 | %error TMPL_BITS
|
---|
144 | %endif
|
---|
145 |
|
---|
146 | mov xSP, xBP
|
---|
147 | pop xBP
|
---|
148 | BS3_HYBRID_RET
|
---|
149 | BS3_PROC_END_MODE bs3FpuState1_Restore
|
---|
150 |
|
---|
151 | ;;
|
---|
152 | ; BS3_DECL_NEAR(void) TMPL_NM(bs3FpuState1_Save)(X86FXSTATE BS3_FAR *pFxState);
|
---|
153 | ;
|
---|
154 | BS3_PROC_BEGIN_MODE bs3FpuState1_Save, BS3_PBC_NEAR
|
---|
155 | push xBP
|
---|
156 | mov xBP, xSP
|
---|
157 |
|
---|
158 | %if TMPL_BITS == 64
|
---|
159 | o64 fxsave [rcx]
|
---|
160 |
|
---|
161 | %elif TMPL_BITS == 32
|
---|
162 | mov eax, [xBP + xCB*2]
|
---|
163 | fxsave [eax]
|
---|
164 |
|
---|
165 | %elif TMPL_BITS == 16
|
---|
166 | push bx
|
---|
167 | push ds
|
---|
168 | mov ds, [xBP + xCB + cbCurRetAddr + 2]
|
---|
169 | mov bx, [xBP + xCB + cbCurRetAddr]
|
---|
170 | fxsave [bx]
|
---|
171 | pop ds
|
---|
172 | pop bx
|
---|
173 | %else
|
---|
174 | %error TMPL_BITS
|
---|
175 | %endif
|
---|
176 |
|
---|
177 | mov xSP, xBP
|
---|
178 | pop xBP
|
---|
179 | BS3_HYBRID_RET
|
---|
180 | BS3_PROC_END_MODE bs3FpuState1_Save
|
---|
181 |
|
---|
182 |
|
---|
183 | %include "bs3kit-template-footer.mac" ; reset environment
|
---|
184 |
|
---|