VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TestDoModesHlp.asm@ 97613

Last change on this file since 97613 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 35.8 KB
Line 
1; $Id: bs3-mode-TestDoModesHlp.asm 96407 2022-08-22 17:43:14Z vboxsync $
2;; @file
3; BS3Kit - Bs3TestDoModes helpers
4;
5
6;
7; Copyright (C) 2007-2022 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;* Header Files *
39;*********************************************************************************************************************************
40%include "bs3kit-template-header.mac"
41
42
43;*********************************************************************************************************************************
44;* Defined Constants And Macros *
45;*********************************************************************************************************************************
46;
47; We put most of this mess in the RMTEXT16 segment when in real mode.
48;
49%if TMPL_MODE == BS3_MODE_RM
50 %define MY_BEGIN_TEXT BS3_BEGIN_RMTEXT16
51 %define MY_BEGIN_TEXT16 BS3_BEGIN_RMTEXT16
52 %define MY_TEXT16_WRT(a_Label) a_Label wrt BS3GROUPRMTEXT16
53%else
54 %define MY_BEGIN_TEXT TMPL_BEGIN_TEXT
55 %define MY_BEGIN_TEXT16 BS3_BEGIN_TEXT16
56 %define MY_TEXT16_WRT(a_Label) BS3_TEXT16_WRT(a_Label)
57%endif
58
59
60;*********************************************************************************************************************************
61;* External Symbols *
62;*********************************************************************************************************************************
63%if TMPL_MODE == BS3_MODE_RM
64BS3_BEGIN_TEXT16_FARSTUBS
65extern TMPL_FAR_NM(Bs3SwitchToRM)
66extern TMPL_FAR_NM(Bs3SwitchToPE16)
67extern TMPL_FAR_NM(Bs3SwitchToPE16_32)
68extern TMPL_FAR_NM(Bs3SwitchToPE16_V86)
69extern TMPL_FAR_NM(Bs3SwitchToPE32)
70extern TMPL_FAR_NM(Bs3SwitchToPE32_16)
71extern TMPL_FAR_NM(Bs3SwitchToPEV86)
72extern TMPL_FAR_NM(Bs3SwitchToPP16)
73extern TMPL_FAR_NM(Bs3SwitchToPP16_32)
74extern TMPL_FAR_NM(Bs3SwitchToPP16_V86)
75extern TMPL_FAR_NM(Bs3SwitchToPP32)
76extern TMPL_FAR_NM(Bs3SwitchToPP32_16)
77extern TMPL_FAR_NM(Bs3SwitchToPPV86)
78extern TMPL_FAR_NM(Bs3SwitchToPAE16)
79extern TMPL_FAR_NM(Bs3SwitchToPAE16_32)
80extern TMPL_FAR_NM(Bs3SwitchToPAE16_V86)
81extern TMPL_FAR_NM(Bs3SwitchToPAE32)
82extern TMPL_FAR_NM(Bs3SwitchToPAE32_16)
83extern TMPL_FAR_NM(Bs3SwitchToPAEV86)
84extern TMPL_FAR_NM(Bs3SwitchToLM16)
85extern TMPL_FAR_NM(Bs3SwitchToLM32)
86extern TMPL_FAR_NM(Bs3SwitchToLM64)
87extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_rm_far)
88extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pe16_far)
89extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pe16_v86_far)
90extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pe32_16_far)
91extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pev86_far)
92extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pp16_far)
93extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pp16_v86_far)
94extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pp32_16_far)
95extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_ppv86_far)
96extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pae16_far)
97extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pae16_v86_far)
98extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pae32_16_far)
99extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_paev86_far)
100extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_lm16_far)
101%else
102BS3_BEGIN_TEXT16
103extern TMPL_NM(Bs3SwitchToRM)
104extern TMPL_NM(Bs3SwitchToPE16)
105extern TMPL_NM(Bs3SwitchToPE16_32)
106extern TMPL_NM(Bs3SwitchToPE16_V86)
107extern TMPL_NM(Bs3SwitchToPE32)
108extern TMPL_NM(Bs3SwitchToPE32_16)
109extern TMPL_NM(Bs3SwitchToPEV86)
110extern TMPL_NM(Bs3SwitchToPP16)
111extern TMPL_NM(Bs3SwitchToPP16_32)
112extern TMPL_NM(Bs3SwitchToPP16_V86)
113extern TMPL_NM(Bs3SwitchToPP32)
114extern TMPL_NM(Bs3SwitchToPP32_16)
115extern TMPL_NM(Bs3SwitchToPPV86)
116extern TMPL_NM(Bs3SwitchToPAE16)
117extern TMPL_NM(Bs3SwitchToPAE16_32)
118extern TMPL_NM(Bs3SwitchToPAE16_V86)
119extern TMPL_NM(Bs3SwitchToPAE32)
120extern TMPL_NM(Bs3SwitchToPAE32_16)
121extern TMPL_NM(Bs3SwitchToPAEV86)
122extern TMPL_NM(Bs3SwitchToLM16)
123extern TMPL_NM(Bs3SwitchToLM32)
124extern TMPL_NM(Bs3SwitchToLM64)
125extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_rm)
126extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pe16)
127extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pe16_v86)
128extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pe32_16)
129extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pev86)
130extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pp16)
131extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pp16_v86)
132extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pp32_16)
133extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_ppv86)
134extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae16)
135extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae16_v86)
136extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae32_16)
137extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_paev86)
138extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_lm16)
139%endif
140BS3_BEGIN_TEXT16
141extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pe16_32):wrt BS3FLAT
142extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pe32):wrt BS3FLAT
143extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pp16_32):wrt BS3FLAT
144extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pp32):wrt BS3FLAT
145extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae16_32):wrt BS3FLAT
146extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae32):wrt BS3FLAT
147extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_lm32):wrt BS3FLAT
148extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_lm64):wrt BS3FLAT
149
150
151MY_BEGIN_TEXT16 ; need the group definition
152MY_BEGIN_TEXT
153
154;;
155; Shared prologue code.
156; @param xAX Where to jump to for the main event.
157;
158BS3_GLOBAL_NAME_EX TMPL_NM(bs3TestCallDoerPrologue), , 0
159 BS3_CALL_CONV_PROLOG 1
160 push xBP
161 mov xBP, xSP
162 xPUSHF
163
164 ; Save non-volatile registers so the DO function doesn't have to.
165 push xBX
166 push xCX
167 push xDX
168 push xSI
169 push xDI
170%if TMPL_BITS != 64
171 push ds
172 push es
173 push ss
174 %if TMPL_BITS != 16
175 push fs
176 push gs
177 %endif
178%endif
179%if TMPL_BITS == 64
180 push r8
181 push r9
182 push r10
183 push r11
184 push r12
185 push r13
186 push r14
187 push r15
188%endif
189
190 ; Jump to the main code.
191 jmp xAX
192
193;;
194; Shared epilogue code.
195; @param xAX Return code.
196;
197BS3_GLOBAL_NAME_EX TMPL_NM(bs3TestCallDoerEpilogue), , 0
198 ; Restore registers.
199%if TMPL_BITS == 16
200 sub bp, (1+5+3)*2
201 mov sp, bp
202%elif TMPL_BITS == 32
203 lea xSP, [xBP - (1+5+5)*4]
204%else
205 lea xSP, [xBP - (1+5+8)*8]
206 pop r15
207 pop r14
208 pop r13
209 pop r12
210 pop r11
211 pop r10
212 pop r9
213 pop r8
214%endif
215%if TMPL_BITS != 64
216 %if TMPL_BITS != 16
217 pop gs
218 pop fs
219 %endif
220 pop ss
221 pop es
222 pop ds
223%endif
224 pop xDI
225 pop xSI
226 pop xDX
227 pop xCX
228 pop xBX
229 xPOPF
230 pop xBP
231 ret
232
233;
234; For checking that the mode switching macros doesn't screw up GPRs.
235; Note! Does not work on pre 286 hardware! So, for debugging only.
236;
237%if 0
238 %macro STRICT_SAVE_REGS 0
239 movzx esp, sp
240 sub esp, BS3REGCTX_size
241 mov [esp + BS3REGCTX.rax], eax
242 mov dword [esp + BS3REGCTX.rax+4], 0xdead0000
243 mov [esp + BS3REGCTX.rcx], ecx
244 mov dword [esp + BS3REGCTX.rcx+4], 0xdead0001
245 mov [esp + BS3REGCTX.rdx], edx
246 mov dword [esp + BS3REGCTX.rdx+4], 0xdead0002
247 mov [esp + BS3REGCTX.rbx], ebx
248 mov dword [esp + BS3REGCTX.rbx+4], 0xdead0003
249 mov [esp + BS3REGCTX.rbp], ebp
250 mov [esp + BS3REGCTX.rsp], esp
251 mov [esp + BS3REGCTX.rsi], esi
252 mov [esp + BS3REGCTX.rdi], edi
253 %endmacro
254
255 %macro STRICT_CHECK_REGS 0
256%%_esp: cmp [esp + BS3REGCTX.rsp], esp
257 jne %%_esp
258%%_eax: cmp [esp + BS3REGCTX.rax], eax
259 jne %%_eax
260%%_ecx: mov [esp + BS3REGCTX.rcx], ecx
261 jne %%_ecx
262%%_edx: cmp [esp + BS3REGCTX.rdx], edx
263 jne %%_edx
264%%_ebx: cmp [esp + BS3REGCTX.rbx], ebx
265 jne %%_ebx
266%%_ebp: cmp [esp + BS3REGCTX.rbp], ebp
267 jne %%_ebp
268%%_esi: cmp [esp + BS3REGCTX.rsi], esi
269 jne %%_esi
270%%_edi: cmp [esp + BS3REGCTX.rdi], edi
271 jne %%_edi
272 add esp, BS3REGCTX_size
273 %endmacro
274%else
275
276 %macro STRICT_SAVE_REGS 0
277 %endmacro
278 %macro STRICT_CHECK_REGS 0
279 %endmacro
280%endif
281
282
283;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
284;; Real mode
285;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
286
287;;
288; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInRM(uint16_t offBs3Text16);
289; @uses rax
290BS3_PROC_BEGIN_MODE Bs3TestCallDoerInRM, BS3_PBC_NEAR
291 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
292 jmp TMPL_NM(bs3TestCallDoerPrologue)
293MY_BEGIN_TEXT16
294BS3_SET_BITS TMPL_BITS
295BS3_GLOBAL_LOCAL_LABEL .doit
296 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
297 mov dx, [xBP + xCB + cbCurRetAddr + 2]
298
299 ; Mode switch, make the call, switch back.
300 STRICT_SAVE_REGS
301%if TMPL_MODE == BS3_MODE_RM
302 call far TMPL_FAR_NM(Bs3SwitchToRM)
303%else
304 call TMPL_NM(Bs3SwitchToRM)
305%endif
306 BS3_SET_BITS 16
307 STRICT_CHECK_REGS
308
309 mov cx, BS3_MODE_RM
310 push cx
311 push cs
312 mov cx, .return
313 push cx
314 push dx
315 push ax
316 retf
317.return:
318
319 STRICT_SAVE_REGS
320%if TMPL_MODE == BS3_MODE_RM
321 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_rm_far)
322%else
323 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_rm)
324%endif
325 BS3_SET_BITS TMPL_BITS
326 STRICT_CHECK_REGS
327 jmp TMPL_NM(bs3TestCallDoerEpilogue)
328MY_BEGIN_TEXT
329BS3_PROC_END_MODE Bs3TestCallDoerInRM
330
331
332;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
333;; Unpage protection mode.
334;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
335
336;;
337; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPE16(uint16_t offBs3Text16);
338; @uses rax
339BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPE16, BS3_PBC_NEAR
340 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
341 jmp TMPL_NM(bs3TestCallDoerPrologue)
342MY_BEGIN_TEXT16
343BS3_SET_BITS TMPL_BITS
344BS3_GLOBAL_LOCAL_LABEL .doit
345 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
346 mov dx, [xBP + xCB + cbCurRetAddr + 2]
347
348 ; Mode switch, make the call, switch back.
349 STRICT_SAVE_REGS
350%if TMPL_MODE == BS3_MODE_RM
351 call far TMPL_FAR_NM(Bs3SwitchToPE16)
352%else
353 call TMPL_NM(Bs3SwitchToPE16)
354%endif
355 BS3_SET_BITS 16
356 STRICT_CHECK_REGS
357
358 push BS3_MODE_PE16
359 push cs
360 push .return
361 push dx
362 push ax
363 retf
364.return:
365
366 STRICT_SAVE_REGS
367%if TMPL_MODE == BS3_MODE_RM
368 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pe16_far)
369%else
370 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pe16)
371%endif
372 BS3_SET_BITS TMPL_BITS
373 jmp TMPL_NM(bs3TestCallDoerEpilogue)
374MY_BEGIN_TEXT
375BS3_PROC_END_MODE Bs3TestCallDoerInPE16
376
377;;
378; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPE16_32(uint32_t FlatWorkerAddr, uint8_t bMode);
379; @uses rax
380BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPE16_32, BS3_PBC_NEAR
381 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
382 jmp TMPL_NM(bs3TestCallDoerPrologue)
383.doit:
384 mov eax, [xBP + xCB + cbCurRetAddr] ; Load function pointer.
385 movzx edx, byte [xBP + xCB + cbCurRetAddr + sCB] ; bMode
386
387 ; Mode switch, make the call, switch back.
388 STRICT_SAVE_REGS
389%if TMPL_MODE == BS3_MODE_RM
390 call far TMPL_FAR_NM(Bs3SwitchToPE16_32)
391%else
392 call TMPL_NM(Bs3SwitchToPE16_32)
393%endif
394 BS3_SET_BITS 32
395 STRICT_CHECK_REGS
396
397 push edx ; bMode
398 call eax
399
400 STRICT_SAVE_REGS
401 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pe16_32)
402 BS3_SET_BITS TMPL_BITS
403 STRICT_CHECK_REGS
404 jmp TMPL_NM(bs3TestCallDoerEpilogue)
405BS3_PROC_END_MODE Bs3TestCallDoerInPE16_32
406
407;;
408; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPE16_V86(uint16_t offBs3Text16);
409; @uses rax
410BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPE16_V86, BS3_PBC_NEAR
411 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
412 jmp TMPL_NM(bs3TestCallDoerPrologue)
413MY_BEGIN_TEXT16
414BS3_SET_BITS TMPL_BITS
415BS3_GLOBAL_LOCAL_LABEL .doit
416 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
417 mov dx, [xBP + xCB + cbCurRetAddr + 2]
418
419 ; Mode switch, make the call, switch back.
420 STRICT_SAVE_REGS
421%if TMPL_MODE == BS3_MODE_RM
422 call far TMPL_FAR_NM(Bs3SwitchToPE16_V86)
423%else
424 call TMPL_NM(Bs3SwitchToPE16_V86)
425%endif
426 BS3_SET_BITS 16
427 STRICT_CHECK_REGS
428
429 push BS3_MODE_PE16_V86
430 push cs
431 push .return
432 push dx
433 push ax
434 retf
435.return:
436
437 STRICT_SAVE_REGS
438%if TMPL_MODE == BS3_MODE_RM
439 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pe16_v86_far)
440%else
441 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pe16_v86)
442%endif
443 BS3_SET_BITS TMPL_BITS
444 STRICT_CHECK_REGS
445 jmp TMPL_NM(bs3TestCallDoerEpilogue)
446MY_BEGIN_TEXT
447BS3_PROC_END_MODE Bs3TestCallDoerInPE16_V86
448
449;;
450; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPE32(uint32_t FlatWorkerAddr, uint8_t bMode);
451; @uses rax
452BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPE32, BS3_PBC_NEAR
453 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
454 jmp TMPL_NM(bs3TestCallDoerPrologue)
455.doit:
456 mov eax, [xBP + xCB + cbCurRetAddr] ; Load function pointer.
457 movzx edx, byte [xBP + xCB + cbCurRetAddr + sCB] ; bMode
458
459 ; Mode switch, make the call, switch back.
460 STRICT_SAVE_REGS
461%if TMPL_MODE == BS3_MODE_RM
462 call far TMPL_FAR_NM(Bs3SwitchToPE32)
463%else
464 call TMPL_NM(Bs3SwitchToPE32)
465%endif
466 BS3_SET_BITS 32
467 STRICT_CHECK_REGS
468
469 push edx ; bMode
470 call eax
471
472 STRICT_SAVE_REGS
473 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pe32)
474 BS3_SET_BITS TMPL_BITS
475 STRICT_CHECK_REGS
476 jmp TMPL_NM(bs3TestCallDoerEpilogue)
477BS3_PROC_END_MODE Bs3TestCallDoerInPE32
478
479;;
480; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPE32_16(uint16_t offBs3Text16);
481; @uses rax
482BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPE32_16, BS3_PBC_NEAR
483 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
484 jmp TMPL_NM(bs3TestCallDoerPrologue)
485MY_BEGIN_TEXT16
486BS3_SET_BITS TMPL_BITS
487BS3_GLOBAL_LOCAL_LABEL .doit
488 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
489 mov dx, [xBP + xCB + cbCurRetAddr + 2]
490
491 ; Mode switch, make the call, switch back.
492 STRICT_SAVE_REGS
493%if TMPL_MODE == BS3_MODE_RM
494 call far TMPL_FAR_NM(Bs3SwitchToPE32_16)
495%else
496 call TMPL_NM(Bs3SwitchToPE32_16)
497%endif
498 BS3_SET_BITS 16
499 STRICT_CHECK_REGS
500
501 push BS3_MODE_PE32_16
502 push cs
503 push .return
504 push dx
505 push ax
506 retf
507.return:
508
509 STRICT_SAVE_REGS
510%if TMPL_MODE == BS3_MODE_RM
511 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pe32_16_far)
512%else
513 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pe32_16)
514%endif
515 BS3_SET_BITS TMPL_BITS
516 STRICT_CHECK_REGS
517 jmp TMPL_NM(bs3TestCallDoerEpilogue)
518MY_BEGIN_TEXT
519BS3_PROC_END_MODE Bs3TestCallDoerInPE32_16
520
521;;
522; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPEV86(uint16_t offBs3Text16);
523; @uses rax
524BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPEV86, BS3_PBC_NEAR
525 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
526 jmp TMPL_NM(bs3TestCallDoerPrologue)
527MY_BEGIN_TEXT16
528BS3_SET_BITS TMPL_BITS
529BS3_GLOBAL_LOCAL_LABEL .doit
530 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
531 mov dx, [xBP + xCB + cbCurRetAddr + 2]
532
533 ; Mode switch, make the call, switch back.
534 STRICT_SAVE_REGS
535%if TMPL_MODE == BS3_MODE_RM
536 call far TMPL_FAR_NM(Bs3SwitchToPEV86)
537%else
538 call TMPL_NM(Bs3SwitchToPEV86)
539%endif
540 BS3_SET_BITS 16
541 STRICT_CHECK_REGS
542
543 push BS3_MODE_PEV86
544 push cs
545 push .return
546 push dx
547 push ax
548 retf
549.return:
550
551 STRICT_SAVE_REGS
552%if TMPL_MODE == BS3_MODE_RM
553 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pev86_far)
554%else
555 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pev86)
556%endif
557 BS3_SET_BITS TMPL_BITS
558 STRICT_CHECK_REGS
559 jmp TMPL_NM(bs3TestCallDoerEpilogue)
560MY_BEGIN_TEXT
561BS3_PROC_END_MODE Bs3TestCallDoerInPEV86
562
563
564
565;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
566;; Page protection mode.
567;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
568
569;;
570; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPP16(uint16_t offBs3Text16);
571; @uses rax
572BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPP16, BS3_PBC_NEAR
573 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
574 jmp TMPL_NM(bs3TestCallDoerPrologue)
575MY_BEGIN_TEXT16
576BS3_SET_BITS TMPL_BITS
577BS3_GLOBAL_LOCAL_LABEL .doit
578 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
579 mov dx, [xBP + xCB + cbCurRetAddr + 2]
580
581 ; Mode switch, make the call, switch back.
582 STRICT_SAVE_REGS
583%if TMPL_MODE == BS3_MODE_RM
584 call far TMPL_FAR_NM(Bs3SwitchToPP16)
585%else
586 call TMPL_NM(Bs3SwitchToPP16)
587%endif
588 BS3_SET_BITS 16
589 STRICT_CHECK_REGS
590
591 push BS3_MODE_PP16
592 push cs
593 push .return
594 push dx
595 push ax
596 retf
597.return:
598
599 STRICT_SAVE_REGS
600%if TMPL_MODE == BS3_MODE_RM
601 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pp16_far)
602%else
603 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pp16)
604%endif
605 BS3_SET_BITS TMPL_BITS
606 STRICT_CHECK_REGS
607 jmp TMPL_NM(bs3TestCallDoerEpilogue)
608MY_BEGIN_TEXT
609BS3_PROC_END_MODE Bs3TestCallDoerInPP16
610
611;;
612; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPP16_32(uint32_t uFlatWorkerAddr, uint8_t bMode);
613; @uses rax
614BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPP16_32, BS3_PBC_NEAR
615 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
616 jmp TMPL_NM(bs3TestCallDoerPrologue)
617.doit:
618 mov eax, [xBP + xCB + cbCurRetAddr] ; Load function pointer.
619 movzx edx, byte [xBP + xCB + cbCurRetAddr + sCB] ; bMode
620
621 ; Mode switch, make the call, switch back.
622 STRICT_SAVE_REGS
623%if TMPL_MODE == BS3_MODE_RM
624 call far TMPL_FAR_NM(Bs3SwitchToPP16_32)
625%else
626 call TMPL_NM(Bs3SwitchToPP16_32)
627%endif
628 BS3_SET_BITS 32
629 STRICT_CHECK_REGS
630
631 push edx
632 call eax
633
634 STRICT_SAVE_REGS
635 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pp16_32)
636 BS3_SET_BITS TMPL_BITS
637 STRICT_CHECK_REGS
638 jmp TMPL_NM(bs3TestCallDoerEpilogue)
639BS3_PROC_END_MODE Bs3TestCallDoerInPP16_32
640
641;;
642; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPP16_V86(uint16_t offBs3Text16);
643; @uses rax
644BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPP16_V86, BS3_PBC_NEAR
645 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
646 jmp TMPL_NM(bs3TestCallDoerPrologue)
647MY_BEGIN_TEXT16
648BS3_SET_BITS TMPL_BITS
649BS3_GLOBAL_LOCAL_LABEL .doit
650 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
651 mov dx, [xBP + xCB + cbCurRetAddr + 2]
652
653 ; Mode switch, make the call, switch back.
654 STRICT_SAVE_REGS
655%if TMPL_MODE == BS3_MODE_RM
656 call far TMPL_FAR_NM(Bs3SwitchToPP16_V86)
657%else
658 call TMPL_NM(Bs3SwitchToPP16_V86)
659%endif
660 BS3_SET_BITS 16
661 STRICT_CHECK_REGS
662
663 push BS3_MODE_PP16_V86
664 push cs
665 push .return
666 push dx
667 push ax
668 retf
669.return:
670
671 STRICT_SAVE_REGS
672%if TMPL_MODE == BS3_MODE_RM
673 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pp16_v86_far)
674%else
675 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pp16_v86)
676%endif
677 BS3_SET_BITS TMPL_BITS
678 STRICT_CHECK_REGS
679 jmp TMPL_NM(bs3TestCallDoerEpilogue)
680MY_BEGIN_TEXT
681BS3_PROC_END_MODE Bs3TestCallDoerInPP16_V86
682
683;;
684; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPP32(uint32_t uFlatWorkerAddr, uint8_t bMode);
685; @uses rax
686BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPP32, BS3_PBC_NEAR
687 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
688 jmp TMPL_NM(bs3TestCallDoerPrologue)
689.doit:
690 mov eax, [xBP + xCB + cbCurRetAddr] ; Load function pointer.
691 movzx edx, byte [xBP + xCB + cbCurRetAddr + sCB] ; bMode
692
693 ; Mode switch, make the call, switch back.
694 STRICT_SAVE_REGS
695%if TMPL_MODE == BS3_MODE_RM
696 call far TMPL_FAR_NM(Bs3SwitchToPP32)
697%else
698 call TMPL_NM(Bs3SwitchToPP32)
699%endif
700 BS3_SET_BITS 32
701 STRICT_CHECK_REGS
702
703 push edx ; bMode
704 call eax
705
706 STRICT_SAVE_REGS
707 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pp32)
708 BS3_SET_BITS TMPL_BITS
709 STRICT_CHECK_REGS
710 jmp TMPL_NM(bs3TestCallDoerEpilogue)
711BS3_PROC_END_MODE Bs3TestCallDoerInPP32
712
713;;
714; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPP32_16(uint16_t offBs3Text16);
715; @uses rax
716BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPP32_16, BS3_PBC_NEAR
717 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
718 jmp TMPL_NM(bs3TestCallDoerPrologue)
719MY_BEGIN_TEXT16
720BS3_SET_BITS TMPL_BITS
721BS3_GLOBAL_LOCAL_LABEL .doit
722 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
723 mov dx, [xBP + xCB + cbCurRetAddr + 2]
724
725 ; Mode switch, make the call, switch back.
726 STRICT_SAVE_REGS
727%if TMPL_MODE == BS3_MODE_RM
728 call far TMPL_FAR_NM(Bs3SwitchToPP32_16)
729%else
730 call TMPL_NM(Bs3SwitchToPP32_16)
731%endif
732 BS3_SET_BITS 16
733 STRICT_CHECK_REGS
734
735 push BS3_MODE_PP32_16
736 push cs
737 push .return
738 push dx
739 push ax
740 retf
741.return:
742
743 STRICT_SAVE_REGS
744%if TMPL_MODE == BS3_MODE_RM
745 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pp32_16_far)
746%else
747 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pp32_16)
748%endif
749 BS3_SET_BITS TMPL_BITS
750 STRICT_CHECK_REGS
751 jmp TMPL_NM(bs3TestCallDoerEpilogue)
752MY_BEGIN_TEXT
753BS3_PROC_END_MODE Bs3TestCallDoerInPP32_16
754
755;;
756; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPPV86(uint16_t offBs3Text16);
757; @uses rax
758BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPPV86, BS3_PBC_NEAR
759 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
760 jmp TMPL_NM(bs3TestCallDoerPrologue)
761MY_BEGIN_TEXT16
762BS3_SET_BITS TMPL_BITS
763BS3_GLOBAL_LOCAL_LABEL .doit
764 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
765 mov dx, [xBP + xCB + cbCurRetAddr + 2]
766
767 ; Mode switch, make the call, switch back.
768 STRICT_SAVE_REGS
769%if TMPL_MODE == BS3_MODE_RM
770 call far TMPL_FAR_NM(Bs3SwitchToPPV86)
771%else
772 call TMPL_NM(Bs3SwitchToPPV86)
773%endif
774 BS3_SET_BITS 16
775 STRICT_CHECK_REGS
776
777 push BS3_MODE_PPV86
778 push cs
779 push .return
780 push dx
781 push ax
782 retf
783.return:
784
785 STRICT_SAVE_REGS
786%if TMPL_MODE == BS3_MODE_RM
787 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_ppv86_far)
788%else
789 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_ppv86)
790%endif
791 BS3_SET_BITS TMPL_BITS
792 STRICT_CHECK_REGS
793 jmp TMPL_NM(bs3TestCallDoerEpilogue)
794MY_BEGIN_TEXT
795BS3_PROC_END_MODE Bs3TestCallDoerInPPV86
796
797
798;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
799;; PAE paged protection mode.
800;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
801
802;;
803; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPAE16(uint16_t offBs3Text16);
804; @uses rax
805BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAE16, BS3_PBC_NEAR
806 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
807 jmp TMPL_NM(bs3TestCallDoerPrologue)
808MY_BEGIN_TEXT16
809BS3_SET_BITS TMPL_BITS
810BS3_GLOBAL_LOCAL_LABEL .doit
811 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
812 mov dx, [xBP + xCB + cbCurRetAddr + 2]
813
814 ; Mode switch, make the call, switch back.
815 STRICT_SAVE_REGS
816%if TMPL_MODE == BS3_MODE_RM
817 call far TMPL_FAR_NM(Bs3SwitchToPAE16)
818%else
819 call TMPL_NM(Bs3SwitchToPAE16)
820%endif
821 BS3_SET_BITS 16
822 STRICT_CHECK_REGS
823
824 push BS3_MODE_PAE16
825 push cs
826 push .return
827 push dx
828 push ax
829 retf
830.return:
831
832 STRICT_SAVE_REGS
833%if TMPL_MODE == BS3_MODE_RM
834 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pae16_far)
835%else
836 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae16)
837%endif
838 BS3_SET_BITS TMPL_BITS
839 STRICT_CHECK_REGS
840 jmp TMPL_NM(bs3TestCallDoerEpilogue)
841MY_BEGIN_TEXT
842BS3_PROC_END_MODE Bs3TestCallDoerInPAE16
843
844;;
845; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPAE16_32(uint32_t uFlatWorkerAddr, uint8_t bMode);
846; @uses rax
847BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAE16_32, BS3_PBC_NEAR
848 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
849 jmp TMPL_NM(bs3TestCallDoerPrologue)
850.doit:
851 mov eax, [xBP + xCB + cbCurRetAddr] ; Load function pointer.
852 movzx edx, byte [xBP + xCB + cbCurRetAddr + sCB] ; bMode
853
854 ; Mode switch, make the call, switch back.
855 STRICT_SAVE_REGS
856%if TMPL_MODE == BS3_MODE_RM
857 call far TMPL_FAR_NM(Bs3SwitchToPAE16_32)
858%else
859 call TMPL_NM(Bs3SwitchToPAE16_32)
860%endif
861 BS3_SET_BITS 32
862 STRICT_CHECK_REGS
863
864 push edx ; bMode
865 call eax
866
867 STRICT_SAVE_REGS
868 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae16_32)
869 BS3_SET_BITS TMPL_BITS
870 STRICT_CHECK_REGS
871 jmp TMPL_NM(bs3TestCallDoerEpilogue)
872BS3_PROC_END_MODE Bs3TestCallDoerInPAE16_32
873
874;;
875; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPAE16_V86(uint16_t offBs3Text16);
876; @uses rax
877BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAE16_V86, BS3_PBC_NEAR
878 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
879 jmp TMPL_NM(bs3TestCallDoerPrologue)
880MY_BEGIN_TEXT16
881BS3_SET_BITS TMPL_BITS
882BS3_GLOBAL_LOCAL_LABEL .doit
883 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
884 mov dx, [xBP + xCB + cbCurRetAddr + 2]
885
886 ; Mode switch, make the call, switch back.
887 STRICT_SAVE_REGS
888%if TMPL_MODE == BS3_MODE_RM
889 call far TMPL_FAR_NM(Bs3SwitchToPAE16_V86)
890%else
891 call TMPL_NM(Bs3SwitchToPAE16_V86)
892%endif
893 BS3_SET_BITS 16
894 STRICT_CHECK_REGS
895
896 push BS3_MODE_PAE16_V86
897 push cs
898 push .return
899 push dx
900 push ax
901 retf
902.return:
903
904 STRICT_SAVE_REGS
905%if TMPL_MODE == BS3_MODE_RM
906 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pae16_v86_far)
907%else
908 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae16_v86)
909%endif
910 BS3_SET_BITS TMPL_BITS
911 STRICT_CHECK_REGS
912 jmp TMPL_NM(bs3TestCallDoerEpilogue)
913MY_BEGIN_TEXT
914BS3_PROC_END_MODE Bs3TestCallDoerInPAE16_V86
915
916;;
917; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPAE32(uint32_t uFlatWorkerAddr, uint8_t bMode);
918; @uses rax
919BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAE32, BS3_PBC_NEAR
920 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
921 jmp TMPL_NM(bs3TestCallDoerPrologue)
922.doit:
923 mov eax, [xBP + xCB + cbCurRetAddr] ; Load function pointer.
924 movzx edx, byte [xBP + xCB + cbCurRetAddr + sCB] ; bMode
925
926 ; Mode switch, make the call, switch back.
927 STRICT_SAVE_REGS
928%if TMPL_MODE == BS3_MODE_RM
929 call far TMPL_FAR_NM(Bs3SwitchToPAE32)
930%else
931 call TMPL_NM(Bs3SwitchToPAE32)
932%endif
933 BS3_SET_BITS 32
934 STRICT_CHECK_REGS
935
936 push edx ; bMode
937 call eax
938
939 STRICT_SAVE_REGS
940 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae32)
941 BS3_SET_BITS TMPL_BITS
942 STRICT_CHECK_REGS
943 jmp TMPL_NM(bs3TestCallDoerEpilogue)
944BS3_PROC_END_MODE Bs3TestCallDoerInPAE32
945
946;;
947; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPAE32_16(uint16_t offBs3Text16);
948; @uses rax
949BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAE32_16, BS3_PBC_NEAR
950 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
951 jmp TMPL_NM(bs3TestCallDoerPrologue)
952MY_BEGIN_TEXT16
953BS3_SET_BITS TMPL_BITS
954BS3_GLOBAL_LOCAL_LABEL .doit
955 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
956 mov dx, [xBP + xCB + cbCurRetAddr + 2]
957
958 ; Mode switch, make the call, switch back.
959 STRICT_SAVE_REGS
960%if TMPL_MODE == BS3_MODE_RM
961 call far TMPL_FAR_NM(Bs3SwitchToPAE32_16)
962%else
963 call TMPL_NM(Bs3SwitchToPAE32_16)
964%endif
965 BS3_SET_BITS 16
966 STRICT_CHECK_REGS
967
968 push BS3_MODE_PAE32_16
969 push cs
970 push .return
971 push dx
972 push ax
973 retf
974.return:
975
976 STRICT_SAVE_REGS
977%if TMPL_MODE == BS3_MODE_RM
978 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pae32_16_far)
979%else
980 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae32_16)
981%endif
982 BS3_SET_BITS TMPL_BITS
983 STRICT_CHECK_REGS
984 jmp TMPL_NM(bs3TestCallDoerEpilogue)
985MY_BEGIN_TEXT
986BS3_PROC_END_MODE Bs3TestCallDoerInPAE32_16
987
988;;
989; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPAEV86(uint16_t offBs3Text16);
990; @uses rax
991BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAEV86, BS3_PBC_NEAR
992 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
993 jmp TMPL_NM(bs3TestCallDoerPrologue)
994MY_BEGIN_TEXT16
995BS3_SET_BITS TMPL_BITS
996BS3_GLOBAL_LOCAL_LABEL .doit
997 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
998 mov dx, [xBP + xCB + cbCurRetAddr + 2]
999
1000 ; Mode switch, make the call, switch back.
1001 STRICT_SAVE_REGS
1002%if TMPL_MODE == BS3_MODE_RM
1003 call far TMPL_FAR_NM(Bs3SwitchToPAEV86)
1004%else
1005 call TMPL_NM(Bs3SwitchToPAEV86)
1006%endif
1007 BS3_SET_BITS 16
1008 STRICT_CHECK_REGS
1009
1010 push BS3_MODE_PAEV86
1011 push cs
1012 push .return
1013 push dx
1014 push ax
1015 retf
1016.return:
1017
1018 STRICT_SAVE_REGS
1019%if TMPL_MODE == BS3_MODE_RM
1020 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_paev86_far)
1021%else
1022 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_paev86)
1023%endif
1024 BS3_SET_BITS TMPL_BITS
1025 STRICT_CHECK_REGS
1026 jmp TMPL_NM(bs3TestCallDoerEpilogue)
1027MY_BEGIN_TEXT
1028BS3_PROC_END_MODE Bs3TestCallDoerInPAEV86
1029
1030
1031
1032;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1033;; Long mode
1034;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1035
1036;;
1037; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInLM16(uint16_t offBs3Text16);
1038; @uses rax
1039BS3_PROC_BEGIN_MODE Bs3TestCallDoerInLM16, BS3_PBC_NEAR
1040 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
1041 jmp TMPL_NM(bs3TestCallDoerPrologue)
1042MY_BEGIN_TEXT16
1043BS3_SET_BITS TMPL_BITS
1044BS3_GLOBAL_LOCAL_LABEL .doit
1045 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
1046 mov dx, [xBP + xCB + cbCurRetAddr + 2]
1047
1048 ; Mode switch, make the call, switch back.
1049 STRICT_SAVE_REGS
1050%if TMPL_MODE == BS3_MODE_RM
1051 call far TMPL_FAR_NM(Bs3SwitchToLM16)
1052%else
1053 call TMPL_NM(Bs3SwitchToLM16)
1054%endif
1055 BS3_SET_BITS 16
1056 STRICT_CHECK_REGS
1057
1058 push BS3_MODE_LM16
1059 push cs
1060 push .return
1061 push dx
1062 push ax
1063 retf
1064.return:
1065
1066 STRICT_SAVE_REGS
1067%if TMPL_MODE == BS3_MODE_RM
1068 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_lm16_far)
1069%else
1070 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_lm16)
1071%endif
1072 BS3_SET_BITS TMPL_BITS
1073 STRICT_CHECK_REGS
1074 jmp TMPL_NM(bs3TestCallDoerEpilogue)
1075MY_BEGIN_TEXT
1076BS3_PROC_END_MODE Bs3TestCallDoerInLM16
1077
1078;;
1079; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInLM32(uint16_t offBs3Text16);
1080; @uses rax
1081BS3_PROC_BEGIN_MODE Bs3TestCallDoerInLM32, BS3_PBC_NEAR
1082 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
1083 jmp TMPL_NM(bs3TestCallDoerPrologue)
1084.doit:
1085 mov eax, [xBP + xCB + cbCurRetAddr] ; Load function pointer.
1086
1087 ; Mode switch, make the call, switch back.
1088 STRICT_SAVE_REGS
1089%if TMPL_MODE == BS3_MODE_RM
1090 call far TMPL_FAR_NM(Bs3SwitchToLM32)
1091%else
1092 call TMPL_NM(Bs3SwitchToLM32)
1093%endif
1094 BS3_SET_BITS 32
1095 STRICT_CHECK_REGS
1096
1097 and esp, ~03h
1098 push BS3_MODE_LM32
1099 call eax
1100
1101 STRICT_SAVE_REGS
1102 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_lm32)
1103 BS3_SET_BITS TMPL_BITS
1104 STRICT_CHECK_REGS
1105 jmp TMPL_NM(bs3TestCallDoerEpilogue)
1106BS3_PROC_END_MODE Bs3TestCallDoerInLM32
1107
1108;;
1109; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInLM64(uint32_t uFlatWorkerAddr, uint8_t bMode);
1110; @uses rax
1111BS3_PROC_BEGIN_MODE Bs3TestCallDoerInLM64, BS3_PBC_NEAR
1112 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
1113 jmp TMPL_NM(bs3TestCallDoerPrologue)
1114.doit:
1115 mov eax, [xBP + xCB + cbCurRetAddr] ; Load function pointer.
1116 movzx edx, byte [xBP + xCB + cbCurRetAddr + sCB] ; bMode
1117
1118 ; Mode switch, make the call, switch back.
1119 STRICT_SAVE_REGS
1120%if TMPL_MODE == BS3_MODE_RM
1121 call far TMPL_FAR_NM(Bs3SwitchToLM64)
1122%else
1123 call TMPL_NM(Bs3SwitchToLM64)
1124%endif
1125 BS3_SET_BITS 64
1126 STRICT_CHECK_REGS
1127
1128 and rsp, ~0fh
1129 sub rsp, 18h
1130 push rdx ; bMode
1131 BS3_CALL rax, 1
1132
1133 STRICT_SAVE_REGS
1134 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_lm64)
1135 BS3_SET_BITS TMPL_BITS
1136 STRICT_CHECK_REGS
1137 jmp TMPL_NM(bs3TestCallDoerEpilogue)
1138BS3_PROC_END_MODE Bs3TestCallDoerInLM64
1139
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