VirtualBox

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

Last change on this file since 84271 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

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