VirtualBox

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

最後變更 在這個檔案從60749是 60749,由 vboxsync 提交於 9 年 前

bs3kit: updates

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 7.4 KB
 
1; $Id: bs3-cmn-TestDoModesByOneHlp.asm 60749 2016-04-28 19:41:14Z vboxsync $
2;; @file
3; BS3Kit - Bs3TestDoModesByOne Helpers for switching to the bit-count of the worker function.
4;
5
6;
7; Copyright (C) 2007-2016 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.alldomusa.eu.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 [BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent) + 2]
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_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 [BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent) + 2]
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_CMN_NM(g_pfnBs3TestDoModesByOneCurrent)] ; call offset
140 retf
141
142.return:
143hlt
144 ; Switch back to 64-bit mode.
145 extern _Bs3SwitchTo64Bit_c16
146 call _Bs3SwitchTo64Bit_c16
147 BS3_SET_BITS 64
148
149 leave
150 ret
151BS3_PROC_END _Bs3TestCallDoerTo16_c64
152
153
154%elif TMPL_BITS == 32
155 ;
156 ; For 32-bit workers.
157 ;
158
159BS3_BEGIN_TEXT16
160BS3_SET_BITS 32
161BS3_PROC_BEGIN _Bs3TestCallDoerTo32_f16
162 push xBP
163 mov xBP, xSP
164
165 ; Load bMode into eax.
166 movzx eax, byte [xBP + xCB + sCB]
167 %ifdef BS3_STRICT
168 cmp al, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
169 je .ok_mode
170 int3
171.ok_mode:
172 %endif
173 ; Switch to 32-bit.
174 extern _Bs3SwitchTo32Bit_c16
175 call _Bs3SwitchTo32Bit_c16
176 BS3_SET_BITS 32
177
178 push eax ; Worker bMode argument.
179
180 test al, BS3_MODE_CODE_V86
181 jnz .return_to_v86 ; Need to figure this while we still have the mode value.
182
183 call [BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent)]
184
185 ; Switch back to 16-bit mode.
186 extern _Bs3SwitchTo16Bit_c32
187 call _Bs3SwitchTo16Bit_c32
188 BS3_SET_BITS 16
189.return:
190 leave
191 retf
192
193 BS3_SET_BITS 32
194.return_to_v86:
195 call [BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent)]
196
197 ; Switch back to v8086 mode.
198 extern _Bs3SwitchTo16BitV86_c32
199 call _Bs3SwitchTo16BitV86_c32
200 BS3_SET_BITS 16
201 jmp .return
202BS3_PROC_END _Bs3TestCallDoerTo32_f16
203
204
205BS3_BEGIN_TEXT32
206BS3_SET_BITS 64
207BS3_PROC_BEGIN _Bs3TestCallDoerTo32_c64
208 push xBP
209 mov xBP, xSP
210
211 ; Load bMode into eax.
212 movzx eax, cl
213 %ifdef BS3_STRICT
214 cmp al, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
215 je .ok_mode
216 int3
217.ok_mode:
218 %endif
219 ; Switch to 32-bit.
220 extern _Bs3SwitchTo32Bit_c64
221 call _Bs3SwitchTo32Bit_c64
222 BS3_SET_BITS 32
223
224 push eax ; Worker bMode argument.
225 call [BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent)]
226
227 ; Switch back to 64-bit mode.
228 extern _Bs3SwitchTo64Bit_c32
229 call _Bs3SwitchTo64Bit_c32
230 BS3_SET_BITS 64
231
232 leave
233 ret
234BS3_PROC_END _Bs3TestCallDoerTo32_c64
235
236
237%elif TMPL_BITS == 64
238;
239; 64-bit workers makes no sense, so skip that.
240;
241%else
242 %error "TMPL_BITS!"
243%endif
244
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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