VirtualBox

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

Last change on this file since 77922 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1; $Id: bs3-cmn-TestDoModesByOneHlp.asm 76553 2019-01-01 01:45:53Z vboxsync $
2;; @file
3; BS3Kit - Bs3TestDoModesByOne Helpers for switching to the bit-count of the worker function.
4;
5
6;
7; Copyright (C) 2007-2019 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
28;*********************************************************************************************************************************
29;* Header Files *
30;*********************************************************************************************************************************
31%include "bs3kit-template-header.mac"
32
33
34;*********************************************************************************************************************************
35;* Global Variables *
36;*********************************************************************************************************************************
37BS3_BEGIN_DATA16
38BS3_GLOBAL_NAME_EX BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent),,0
39 RTCCPTR_DEF 0
40
41
42;*********************************************************************************************************************************
43;* Exported Symbols *
44;*********************************************************************************************************************************
45%ifdef BS3_STRICT
46BS3_EXTERN_DATA16 g_bBs3CurrentMode
47%endif
48
49%if TMPL_BITS == 16
50BS3_BEGIN_TEXT16
51extern _Bs3SelRealModeCodeToProtMode_c16
52%endif
53
54
55;;
56; @cproto FNBS3TESTDOMODE
57;
58; @param bMode The current mode
59; @uses What allowed by calling convention and possibly mode, caller deals with it.
60;
61
62%if TMPL_BITS == 16
63 ;
64 ; For 16-bit workers.
65 ;
66BS3_BEGIN_TEXT16
67
68BS3_SET_BITS 32
69BS3_PROC_BEGIN _Bs3TestCallDoerTo16_c32
70 push xBP
71 mov xBP, xSP
72
73 ; Load bMode into eax.
74 movzx eax, byte [xBP + xCB*2]
75 %ifdef BS3_STRICT
76 cmp al, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
77 je .ok_mode
78 int3
79.ok_mode:
80 %endif
81 ; Switch to 16-bit.
82 extern _Bs3SwitchTo16Bit_c32
83 call _Bs3SwitchTo16Bit_c32
84 BS3_SET_BITS 16
85
86 push ax ; Worker bMode argument.
87
88 ; Assuming real mode far pointer, convert protected mode before calling it.
89 push word [2 + BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]
90 call _Bs3SelRealModeCodeToProtMode_c16
91 add sp, 2
92
93 push cs ; return selector
94 push word .return ; return address
95
96 push ax ; call converted selector
97 push word [BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))] ; call offset
98 retf
99
100.return:
101 ; Switch back to 32-bit mode.
102 extern _Bs3SwitchTo32Bit_c16
103 call _Bs3SwitchTo32Bit_c16
104 BS3_SET_BITS 32
105
106 leave
107 ret
108BS3_PROC_END _Bs3TestCallDoerTo16_c32
109
110
111BS3_SET_BITS 64
112BS3_PROC_BEGIN _Bs3TestCallDoerTo16_c64
113 push xBP
114 mov xBP, xSP
115
116 ; Load bMode into eax.
117 movzx eax, cl
118 %ifdef BS3_STRICT
119 cmp al, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
120 je .ok_mode
121 int3
122.ok_mode:
123 %endif
124 ; Switch to 16-bit.
125 extern _Bs3SwitchTo16Bit_c64
126 call _Bs3SwitchTo16Bit_c64
127 BS3_SET_BITS 16
128
129 push ax ; Worker bMode argument.
130
131 ; Assuming real mode far pointer, convert protected mode before calling it.
132 push word [2 + BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]
133 call _Bs3SelRealModeCodeToProtMode_c16
134 add sp, 2
135
136 push cs ; return selector
137 push word .return ; return address
138 push ax ; call converted selector
139 push word [BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))] ; call offset
140 retf
141
142.return:
143 ; Switch back to 64-bit mode.
144 extern _Bs3SwitchTo64Bit_c16
145 call _Bs3SwitchTo64Bit_c16
146 BS3_SET_BITS 64
147
148 leave
149 ret
150BS3_PROC_END _Bs3TestCallDoerTo16_c64
151
152
153%elif TMPL_BITS == 32
154 ;
155 ; For 32-bit workers.
156 ;
157
158BS3_BEGIN_TEXT16
159BS3_SET_BITS 16
160BS3_PROC_BEGIN _Bs3TestCallDoerTo32_f16
161 push xBP
162 mov xBP, xSP
163
164 ; Load bMode into eax.
165 movzx eax, byte [xBP + xCB + sCB]
166 %ifdef BS3_STRICT
167 cmp al, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
168 je .ok_mode
169 int3
170.ok_mode:
171 %endif
172 ; Switch to 32-bit.
173 extern _Bs3SwitchTo32Bit_c16
174 call _Bs3SwitchTo32Bit_c16
175 BS3_SET_BITS 32
176
177 push eax ; Worker bMode argument.
178
179 test al, BS3_MODE_CODE_V86
180 jnz .return_to_v86 ; Need to figure this while we still have the mode value.
181
182 call [BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]
183
184 ; Switch back to 16-bit mode.
185 extern _Bs3SwitchTo16Bit_c32
186 call _Bs3SwitchTo16Bit_c32
187 BS3_SET_BITS 16
188.return:
189 leave
190 retf
191
192 BS3_SET_BITS 32
193.return_to_v86:
194 call [BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]
195
196 ; Switch back to v8086 mode.
197 extern _Bs3SwitchTo16BitV86_c32
198 call _Bs3SwitchTo16BitV86_c32
199 BS3_SET_BITS 16
200 jmp .return
201BS3_PROC_END _Bs3TestCallDoerTo32_f16
202
203
204BS3_BEGIN_TEXT32
205BS3_SET_BITS 64
206BS3_PROC_BEGIN _Bs3TestCallDoerTo32_c64
207 push xBP
208 mov xBP, xSP
209
210 ; Load bMode into eax.
211 movzx eax, cl
212 %ifdef BS3_STRICT
213 cmp al, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
214 je .ok_mode
215 int3
216.ok_mode:
217 %endif
218 ; Switch to 32-bit.
219 extern _Bs3SwitchTo32Bit_c64
220 call _Bs3SwitchTo32Bit_c64
221 BS3_SET_BITS 32
222
223 push eax ; Worker bMode argument.
224 call [BS3_DATA16_WRT(BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent))]
225
226 ; Switch back to 64-bit mode.
227 extern _Bs3SwitchTo64Bit_c32
228 call _Bs3SwitchTo64Bit_c32
229 BS3_SET_BITS 64
230
231 leave
232 ret
233BS3_PROC_END _Bs3TestCallDoerTo32_c64
234
235
236%elif TMPL_BITS == 64
237;
238; 64-bit workers makes no sense, so skip that.
239;
240%else
241 %error "TMPL_BITS!"
242%endif
243
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