1 | ; $Id: bs3-cmn-ExtCtxSave.asm 66214 2017-03-22 20:56:06Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - Bs3ExtCtxSave.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2007-2017 Oracle Corporation
|
---|
8 | ;
|
---|
9 | ; This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | ; available from http://www.virtualbox.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 | %include "bs3kit-template-header.mac"
|
---|
28 |
|
---|
29 |
|
---|
30 | ;;
|
---|
31 | ; Saves the extended CPU context (FPU, SSE, AVX, ++).
|
---|
32 | ;
|
---|
33 | ; @param pExtCtx
|
---|
34 | ;
|
---|
35 | BS3_PROC_BEGIN_CMN Bs3ExtCtxSave, BS3_PBC_NEAR
|
---|
36 | push xBP
|
---|
37 | mov xBP, xSP
|
---|
38 | push xAX
|
---|
39 | BONLY32 push xCX
|
---|
40 | BONLY16 push es
|
---|
41 | BONLY16 push bx
|
---|
42 |
|
---|
43 | %if ARCH_BITS == 16
|
---|
44 | les bx, [xBP + xCB + cbCurRetAddr]
|
---|
45 | mov al, [es:bx + BS3EXTCTX.enmMethod]
|
---|
46 | cmp al, BS3EXTCTXMETHOD_XSAVE
|
---|
47 | je .do_16_xsave
|
---|
48 | cmp al, BS3EXTCTXMETHOD_FXSAVE
|
---|
49 | je .do_16_fxsave
|
---|
50 | cmp al, BS3EXTCTXMETHOD_ANCIENT
|
---|
51 | je .do_16_ancient
|
---|
52 | int3
|
---|
53 |
|
---|
54 | .do_16_ancient:
|
---|
55 | fnsave [es:bx + BS3EXTCTX.Ctx]
|
---|
56 | jmp .return
|
---|
57 |
|
---|
58 | .do_16_xsave:
|
---|
59 | xsave [es:bx + BS3EXTCTX.Ctx]
|
---|
60 | jmp .return
|
---|
61 |
|
---|
62 | .do_16_fxsave:
|
---|
63 | fxsave [es:bx + BS3EXTCTX.Ctx]
|
---|
64 | ;jmp .return
|
---|
65 |
|
---|
66 | %else
|
---|
67 | BONLY32 mov ecx, [xBP + xCB + cbCurRetAddr]
|
---|
68 |
|
---|
69 | mov al, [xCX + BS3EXTCTX.enmMethod]
|
---|
70 | cmp al, BS3EXTCTXMETHOD_XSAVE
|
---|
71 | je .do_xsave
|
---|
72 | cmp al, BS3EXTCTXMETHOD_FXSAVE
|
---|
73 | je .do_fxsave
|
---|
74 | cmp al, BS3EXTCTXMETHOD_ANCIENT
|
---|
75 | je .do_ancient
|
---|
76 | int3
|
---|
77 |
|
---|
78 | .do_ancient:
|
---|
79 | fnsave [xCX + BS3EXTCTX.Ctx]
|
---|
80 | jmp .return
|
---|
81 |
|
---|
82 | .do_xsave:
|
---|
83 | BONLY32 xsave [xCX + BS3EXTCTX.Ctx]
|
---|
84 | BONLY64 xsave64 [xCX + BS3EXTCTX.Ctx]
|
---|
85 | jmp .return
|
---|
86 |
|
---|
87 | .do_fxsave:
|
---|
88 | BONLY32 fxsave [xCX + BS3EXTCTX.Ctx]
|
---|
89 | BONLY64 fxsave64 [xCX + BS3EXTCTX.Ctx]
|
---|
90 | ;jmp .return
|
---|
91 |
|
---|
92 | %endif
|
---|
93 |
|
---|
94 | .return:
|
---|
95 | BONLY16 pop bx
|
---|
96 | BONLY16 pop es
|
---|
97 | BONLY32 pop xCX
|
---|
98 | pop xAX
|
---|
99 | mov xSP, xBP
|
---|
100 | pop xBP
|
---|
101 | ret
|
---|
102 | BS3_PROC_END_CMN Bs3ExtCtxSave
|
---|
103 |
|
---|