VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxSave.asm@ 82968

Last change on this file since 82968 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1; $Id: bs3-cmn-ExtCtxSave.asm 82968 2020-02-04 10:35:17Z vboxsync $
2;; @file
3; BS3Kit - Bs3ExtCtxSave.
4;
5
6;
7; Copyright (C) 2007-2020 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;
35BS3_PROC_BEGIN_CMN Bs3ExtCtxSave, BS3_PBC_NEAR
36 push xBP
37 mov xBP, xSP
38 push sAX
39 push sCX
40 push sDX
41 push xBX
42BONLY16 push es
43
44%if ARCH_BITS == 16
45 les bx, [xBP + xCB + cbCurRetAddr]
46 mov al, [es:bx + BS3EXTCTX.enmMethod]
47 cmp al, BS3EXTCTXMETHOD_XSAVE
48 je .do_16_xsave
49 cmp al, BS3EXTCTXMETHOD_FXSAVE
50 je .do_16_fxsave
51 cmp al, BS3EXTCTXMETHOD_ANCIENT
52 je .do_16_ancient
53 int3
54
55.do_16_ancient:
56 fnsave [es:bx + BS3EXTCTX.Ctx]
57 jmp .return
58
59.do_16_fxsave:
60 fxsave [es:bx + BS3EXTCTX.Ctx]
61 jmp .return
62
63.do_16_xsave:
64 xor ecx, ecx
65 xgetbv
66 mov [es:bx + BS3EXTCTX.fXcr0Saved], eax
67 mov [es:bx + BS3EXTCTX.fXcr0Saved + 4], edx
68 mov eax, [es:bx + BS3EXTCTX.fXcr0Nominal]
69 mov edx, [es:bx + BS3EXTCTX.fXcr0Nominal + 4]
70 xsetbv
71
72 xsave [es:bx + BS3EXTCTX.Ctx]
73
74 mov eax, [es:bx + BS3EXTCTX.fXcr0Saved]
75 mov edx, [es:bx + BS3EXTCTX.fXcr0Saved + 4]
76 xsetbv
77 ;jmp .return
78
79%else
80BONLY32 mov ebx, [xBP + xCB + cbCurRetAddr]
81BONLY64 mov rbx, rcx
82
83 mov al, [xBX + BS3EXTCTX.enmMethod]
84 cmp al, BS3EXTCTXMETHOD_XSAVE
85 je .do_xsave
86 cmp al, BS3EXTCTXMETHOD_FXSAVE
87 je .do_fxsave
88 cmp al, BS3EXTCTXMETHOD_ANCIENT
89 je .do_ancient
90 int3
91
92.do_ancient:
93 fnsave [xBX + BS3EXTCTX.Ctx]
94 jmp .return
95
96.do_fxsave:
97BONLY32 fxsave [xBX + BS3EXTCTX.Ctx]
98BONLY64 fxsave64 [xBX + BS3EXTCTX.Ctx]
99 jmp .return
100
101.do_xsave:
102 xor ecx, ecx
103 xgetbv
104 mov [xBX + BS3EXTCTX.fXcr0Saved], eax
105 mov [xBX + BS3EXTCTX.fXcr0Saved + 4], edx
106 mov eax, [xBX + BS3EXTCTX.fXcr0Nominal]
107 mov edx, [xBX + BS3EXTCTX.fXcr0Nominal + 4]
108 xsetbv
109
110BONLY32 xsave [xBX + BS3EXTCTX.Ctx]
111BONLY64 xsave64 [xBX + BS3EXTCTX.Ctx]
112
113 mov eax, [xBX + BS3EXTCTX.fXcr0Saved]
114 mov edx, [xBX + BS3EXTCTX.fXcr0Saved + 4]
115 xsetbv
116 ;jmp .return
117
118%endif
119
120.return:
121BONLY16 pop es
122 pop xBX
123 pop sDX
124 pop sCX
125 pop sAX
126 mov xSP, xBP
127 pop xBP
128 ret
129BS3_PROC_END_CMN Bs3ExtCtxSave
130
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette