VirtualBox

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

Last change on this file since 106560 was 106061, checked in by vboxsync, 4 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.8 KB
Line 
1; $Id: bs3-cmn-TestDoModesByOneHlp.asm 106061 2024-09-16 14:03:52Z vboxsync $
2;; @file
3; BS3Kit - Bs3TestDoModesByOne Helpers for switching to the bit-count of the worker function.
4;
5
6;
7; Copyright (C) 2007-2024 Oracle and/or its affiliates.
8;
9; This file is part of VirtualBox base platform packages, as
10; available from https://www.virtualbox.org.
11;
12; This program is free software; you can redistribute it and/or
13; modify it under the terms of the GNU General Public License
14; as published by the Free Software Foundation, in version 3 of the
15; License.
16;
17; This program is distributed in the hope that it will be useful, but
18; WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20; General Public License for more details.
21;
22; You should have received a copy of the GNU General Public License
23; along with this program; if not, see <https://www.gnu.org/licenses>.
24;
25; The contents of this file may alternatively be used under the terms
26; of the Common Development and Distribution License Version 1.0
27; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28; in the VirtualBox distribution, in which case the provisions of the
29; CDDL are applicable instead of those of the GPL.
30;
31; You may elect to license modified versions of this file under the
32; terms and conditions of either the GPL or the CDDL or both.
33;
34; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35;
36
37
38;*********************************************************************************************************************************
39;* Header Files *
40;*********************************************************************************************************************************
41%include "bs3kit-template-header.mac"
42
43
44;*********************************************************************************************************************************
45;* Global Variables *
46;*********************************************************************************************************************************
47BS3_BEGIN_DATA16
48BS3_GLOBAL_NAME_EX BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent),,0
49 RTCCPTR_DEF 0
50
51
52;*********************************************************************************************************************************
53;* Exported Symbols *
54;*********************************************************************************************************************************
55%ifdef BS3_STRICT
56BS3_EXTERN_DATA16 g_bBs3CurrentMode
57%endif
58
59%if TMPL_BITS == 16
60BS3_BEGIN_TEXT16
61extern _Bs3SelRealModeCodeToProtMode_c16
62%endif
63
64
65;;
66; @cproto FNBS3TESTDOMODE
67;
68; @param bMode The current mode
69; @uses What allowed by calling convention and possibly mode, caller deals with it.
70;
71
72%if TMPL_BITS == 16
73 ;
74 ; For 16-bit workers.
75 ;
76BS3_BEGIN_TEXT16
77
78BS3_SET_BITS 32
79BS3_PROC_BEGIN _Bs3TestCallDoerTo16_c32
80 push xBP
81 mov xBP, xSP
82
83 ; Load bMode into eax.
84 movzx eax, byte [xBP + xCB*2]
85 %ifdef BS3_STRICT
86 cmp al, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
87 je .ok_mode
88 int3
89.ok_mode:
90 %endif
91 ; Switch to 16-bit.
92 extern _Bs3SwitchTo16Bit_c32
93 call _Bs3SwitchTo16Bit_c32
94 BS3_SET_BITS 16
95
96 push ax ; Worker bMode argument.
97
98 ; Assuming real mode far pointer, convert protected mode before calling it.
99 push word [2 + BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]
100 call _Bs3SelRealModeCodeToProtMode_c16
101 add sp, 2
102
103 push cs ; return selector
104 push word .return ; return address
105
106 push ax ; call converted selector
107 push word [BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))] ; call offset
108 retf
109
110.return:
111 ; Switch back to 32-bit mode.
112 extern _Bs3SwitchTo32Bit_c16
113 call _Bs3SwitchTo32Bit_c16
114 BS3_SET_BITS 32
115
116 leave
117 ret
118BS3_PROC_END _Bs3TestCallDoerTo16_c32
119
120
121BS3_SET_BITS 64
122BS3_PROC_BEGIN _Bs3TestCallDoerTo16_c64
123 push xBP
124 mov xBP, xSP
125
126 ; Load bMode into eax.
127 movzx eax, cl
128 %ifdef BS3_STRICT
129 cmp al, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
130 je .ok_mode
131 int3
132.ok_mode:
133 %endif
134 ; Switch to 16-bit.
135 extern _Bs3SwitchTo16Bit_c64
136 call _Bs3SwitchTo16Bit_c64
137 BS3_SET_BITS 16
138
139 push ax ; Worker bMode argument.
140
141 ; Assuming real mode far pointer, convert protected mode before calling it.
142 push word [2 + BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]
143 call _Bs3SelRealModeCodeToProtMode_c16
144 add sp, 2
145
146 push cs ; return selector
147 push word .return ; return address
148 push ax ; call converted selector
149 push word [BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))] ; call offset
150 retf
151
152.return:
153 ; Switch back to 64-bit mode.
154 extern _Bs3SwitchTo64Bit_c16
155 call _Bs3SwitchTo64Bit_c16
156 BS3_SET_BITS 64
157
158 leave
159 ret
160BS3_PROC_END _Bs3TestCallDoerTo16_c64
161
162
163%elif TMPL_BITS == 32
164 ;
165 ; For 32-bit workers.
166 ;
167
168BS3_BEGIN_TEXT16
169BS3_SET_BITS 16
170BS3_PROC_BEGIN _Bs3TestCallDoerTo32_f16
171 push xBP
172 mov xBP, xSP
173
174 ; Load bMode into eax.
175 movzx eax, byte [xBP + xCB + sCB]
176 %ifdef BS3_STRICT
177 cmp al, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
178 je .ok_mode
179 int3
180.ok_mode:
181 %endif
182 ; Switch to 32-bit.
183 extern _Bs3SwitchTo32Bit_c16
184 call _Bs3SwitchTo32Bit_c16
185 BS3_SET_BITS 32
186
187 push eax ; Worker bMode argument.
188
189 test al, BS3_MODE_CODE_V86
190 jnz .return_to_v86 ; Need to figure this while we still have the mode value.
191
192 call [BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]
193
194 ; Switch back to 16-bit mode.
195 extern _Bs3SwitchTo16Bit_c32
196 call _Bs3SwitchTo16Bit_c32
197 BS3_SET_BITS 16
198.return:
199 leave
200 retf
201
202 BS3_SET_BITS 32
203.return_to_v86:
204 call [BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]
205
206 ; Switch back to v8086 mode.
207 extern _Bs3SwitchTo16BitV86_c32
208 call _Bs3SwitchTo16BitV86_c32
209 BS3_SET_BITS 16
210 jmp .return
211BS3_PROC_END _Bs3TestCallDoerTo32_f16
212
213
214BS3_BEGIN_TEXT32
215BS3_SET_BITS 64
216BS3_PROC_BEGIN _Bs3TestCallDoerTo32_c64
217 push xBP
218 mov xBP, xSP
219
220 ; Load bMode into eax.
221 movzx eax, cl
222 %ifdef BS3_STRICT
223 cmp al, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
224 je .ok_mode
225 int3
226.ok_mode:
227 %endif
228 ; Switch to 32-bit.
229 extern _Bs3SwitchTo32Bit_c64
230 call _Bs3SwitchTo32Bit_c64
231 BS3_SET_BITS 32
232
233 push eax ; Worker bMode argument.
234 call [BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]
235
236 ; Switch back to 64-bit mode.
237 extern _Bs3SwitchTo64Bit_c32
238 call _Bs3SwitchTo64Bit_c32
239 BS3_SET_BITS 64
240
241 leave
242 ret
243BS3_PROC_END _Bs3TestCallDoerTo32_c64
244
245
246%elif TMPL_BITS == 64
247;
248; 64-bit workers makes no sense, so skip that.
249;
250%else
251 %error "TMPL_BITS!"
252%endif
253
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