VirtualBox

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

Last change on this file since 95491 was 95491, checked in by vboxsync, 3 years ago

ValKit/bs3kit: Added Bs3ExtCtxRestoreEx, Bs3ExtCtxSaveEx, Bs3RegCtxConvertV86ToRm, Bs3TrapSetJmpAndRestoreInRm, and BS3TESTMODEBYONEENTRY_F_REAL_MODE_READY so that it is possible to use a 32-bit test driver to do 64-bit testing as well as real-mode. bugref:9898

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1; $Id: bs3-cmn-ExtCtxSaveEx.asm 95491 2022-07-03 23:37:29Z vboxsync $
2;; @file
3; BS3Kit - Bs3ExtCtxSaveEx.
4;
5
6;
7; Copyright (C) 2007-2022 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%if ARCH_BITS != 64
31BS3_EXTERN_DATA16 g_bBs3CurrentMode
32
33BS3_BEGIN_TEXT64
34extern _Bs3ExtCtxSave_c64
35 %if ARCH_BITS == 16
36extern BS3_CMN_NM(Bs3SelProtFar16DataToFlat)
37extern _Bs3SwitchTo16Bit_c64
38 %else
39extern _Bs3SwitchTo32Bit_c64
40 %endif
41
42TMPL_BEGIN_TEXT
43extern BS3_CMN_NM(Bs3SwitchTo64Bit)
44 %if ARCH_BITS == 16
45extern BS3_CMN_NM(Bs3SelProtFar16DataToFlat)
46 %endif
47%endif
48
49extern BS3_CMN_NM(Bs3ExtCtxSave)
50
51
52
53;;
54; Saves the extended CPU context (FPU, SSE, AVX, ++), full 64-bit
55; when in long mode.
56;
57; @param pExtCtx
58;
59BS3_PROC_BEGIN_CMN Bs3ExtCtxSaveEx, BS3_PBC_NEAR
60%if ARCH_BITS == 64
61 jmp BS3_CMN_NM(Bs3ExtCtxSave)
62%else
63 push xBP
64 mov xBP, xSP
65 push sAX
66
67 ;
68 ; Check if we're in long mode.
69 ;
70 mov al, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
71 and al, BS3_MODE_SYS_MASK
72 cmp al, BS3_MODE_SYS_LM
73 je .in_long_mode
74
75 ;
76 ; Not in long mode, so do normal save.
77 ;
78 pop sAX
79 leave
80 jmp BS3_CMN_NM(Bs3ExtCtxSave)
81
82 ;
83 ; Switch to 64-bit to do the restoring so we can save the 64-bit only state.
84 ;
85.in_long_mode:
86 push sCX
87BONLY16 push sDX
88
89 ; Load ecx with the flat pExtCtx address.
90 mov ecx, [xBP + xCB + cbCurRetAddr]
91
92 %if ARCH_BITS == 16
93 push ecx
94 call BS3_CMN_NM(Bs3SelProtFar16DataToFlat)
95 mov ecx, edx
96 shl ecx, 16
97 mov cx, ax
98 %endif
99
100 ; Switch to 64-bit mode.
101 call BS3_CMN_NM(Bs3SwitchTo64Bit)
102 BITS 64
103
104 ; Do the save.
105 sub rsp, 20h
106 call _Bs3ExtCtxSave_c64
107 add rsp, 20h
108
109 ; Switch back to the original mode.
110 %if ARCH_BITS == 16
111 call _Bs3SwitchTo16Bit_c64
112 %else
113 call _Bs3SwitchTo32Bit_c64
114 %endif
115 BITS ARCH_BITS
116
117 ; Save context and return.
118BONLY16 pop sDX
119 pop sCX
120
121 pop sAX
122 leave
123 ret
124%endif
125BS3_PROC_END_CMN Bs3ExtCtxSaveEx
126
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