VirtualBox

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

Last change on this file since 66112 was 64694, checked in by vboxsync, 8 years ago

bs3kit: Added Bs3SwitchTo32BitAndCallC and fixed a few problems switching from PE32 to other mode and back again.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 35.4 KB
Line 
1; $Id: bs3-mode-TestDoModesHlp.asm 64694 2016-11-17 17:10:47Z vboxsync $
2;; @file
3; BS3Kit - Bs3TestDoModes helpers
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.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(uint16_t offBs3Text16);
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
376 ; Mode switch, make the call, switch back.
377 STRICT_SAVE_REGS
378%if TMPL_MODE == BS3_MODE_RM
379 call far TMPL_FAR_NM(Bs3SwitchToPE16_32)
380%else
381 call TMPL_NM(Bs3SwitchToPE16_32)
382%endif
383 BS3_SET_BITS 32
384 STRICT_CHECK_REGS
385
386 push BS3_MODE_PE16_32
387 call eax
388
389 STRICT_SAVE_REGS
390 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pe16_32)
391 BS3_SET_BITS TMPL_BITS
392 STRICT_CHECK_REGS
393 jmp TMPL_NM(bs3TestCallDoerEpilogue)
394BS3_PROC_END_MODE Bs3TestCallDoerInPE16_32
395
396;;
397; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPE16_V86(uint16_t offBs3Text16);
398; @uses rax
399BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPE16_V86, BS3_PBC_NEAR
400 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
401 jmp TMPL_NM(bs3TestCallDoerPrologue)
402MY_BEGIN_TEXT16
403BS3_SET_BITS TMPL_BITS
404BS3_GLOBAL_LOCAL_LABEL .doit
405 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
406 mov dx, [xBP + xCB + cbCurRetAddr + 2]
407
408 ; Mode switch, make the call, switch back.
409 STRICT_SAVE_REGS
410%if TMPL_MODE == BS3_MODE_RM
411 call far TMPL_FAR_NM(Bs3SwitchToPE16_V86)
412%else
413 call TMPL_NM(Bs3SwitchToPE16_V86)
414%endif
415 BS3_SET_BITS 16
416 STRICT_CHECK_REGS
417
418 push BS3_MODE_PE16_V86
419 push cs
420 push .return
421 push dx
422 push ax
423 retf
424.return:
425
426 STRICT_SAVE_REGS
427%if TMPL_MODE == BS3_MODE_RM
428 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pe16_v86_far)
429%else
430 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pe16_v86)
431%endif
432 BS3_SET_BITS TMPL_BITS
433 STRICT_CHECK_REGS
434 jmp TMPL_NM(bs3TestCallDoerEpilogue)
435MY_BEGIN_TEXT
436BS3_PROC_END_MODE Bs3TestCallDoerInPE16_V86
437
438;;
439; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPE32(uint16_t offBs3Text16);
440; @uses rax
441BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPE32, BS3_PBC_NEAR
442 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
443 jmp TMPL_NM(bs3TestCallDoerPrologue)
444.doit:
445 mov eax, [xBP + xCB + cbCurRetAddr] ; Load function pointer.
446
447 ; Mode switch, make the call, switch back.
448 STRICT_SAVE_REGS
449%if TMPL_MODE == BS3_MODE_RM
450 call far TMPL_FAR_NM(Bs3SwitchToPE32)
451%else
452 call TMPL_NM(Bs3SwitchToPE32)
453%endif
454 BS3_SET_BITS 32
455 STRICT_CHECK_REGS
456
457 push BS3_MODE_PE32
458 call eax
459
460 STRICT_SAVE_REGS
461 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pe32)
462 BS3_SET_BITS TMPL_BITS
463 STRICT_CHECK_REGS
464 jmp TMPL_NM(bs3TestCallDoerEpilogue)
465BS3_PROC_END_MODE Bs3TestCallDoerInPE32
466
467;;
468; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPE32_16(uint16_t offBs3Text16);
469; @uses rax
470BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPE32_16, BS3_PBC_NEAR
471 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
472 jmp TMPL_NM(bs3TestCallDoerPrologue)
473MY_BEGIN_TEXT16
474BS3_SET_BITS TMPL_BITS
475BS3_GLOBAL_LOCAL_LABEL .doit
476 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
477 mov dx, [xBP + xCB + cbCurRetAddr + 2]
478
479 ; Mode switch, make the call, switch back.
480 STRICT_SAVE_REGS
481%if TMPL_MODE == BS3_MODE_RM
482 call far TMPL_FAR_NM(Bs3SwitchToPE32_16)
483%else
484 call TMPL_NM(Bs3SwitchToPE32_16)
485%endif
486 BS3_SET_BITS 16
487 STRICT_CHECK_REGS
488
489 push BS3_MODE_PE32_16
490 push cs
491 push .return
492 push dx
493 push ax
494 retf
495.return:
496
497 STRICT_SAVE_REGS
498%if TMPL_MODE == BS3_MODE_RM
499 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pe32_16_far)
500%else
501 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pe32_16)
502%endif
503 BS3_SET_BITS TMPL_BITS
504 STRICT_CHECK_REGS
505 jmp TMPL_NM(bs3TestCallDoerEpilogue)
506MY_BEGIN_TEXT
507BS3_PROC_END_MODE Bs3TestCallDoerInPE32_16
508
509;;
510; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPEV86(uint16_t offBs3Text16);
511; @uses rax
512BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPEV86, BS3_PBC_NEAR
513 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
514 jmp TMPL_NM(bs3TestCallDoerPrologue)
515MY_BEGIN_TEXT16
516BS3_SET_BITS TMPL_BITS
517BS3_GLOBAL_LOCAL_LABEL .doit
518 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
519 mov dx, [xBP + xCB + cbCurRetAddr + 2]
520
521 ; Mode switch, make the call, switch back.
522 STRICT_SAVE_REGS
523%if TMPL_MODE == BS3_MODE_RM
524 call far TMPL_FAR_NM(Bs3SwitchToPEV86)
525%else
526 call TMPL_NM(Bs3SwitchToPEV86)
527%endif
528 BS3_SET_BITS 16
529 STRICT_CHECK_REGS
530
531 push BS3_MODE_PEV86
532 push cs
533 push .return
534 push dx
535 push ax
536 retf
537.return:
538
539 STRICT_SAVE_REGS
540%if TMPL_MODE == BS3_MODE_RM
541 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pev86_far)
542%else
543 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pev86)
544%endif
545 BS3_SET_BITS TMPL_BITS
546 STRICT_CHECK_REGS
547 jmp TMPL_NM(bs3TestCallDoerEpilogue)
548MY_BEGIN_TEXT
549BS3_PROC_END_MODE Bs3TestCallDoerInPEV86
550
551
552
553;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
554;; Page protection mode.
555;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
556
557;;
558; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPP16(uint16_t offBs3Text16);
559; @uses rax
560BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPP16, BS3_PBC_NEAR
561 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
562 jmp TMPL_NM(bs3TestCallDoerPrologue)
563MY_BEGIN_TEXT16
564BS3_SET_BITS TMPL_BITS
565BS3_GLOBAL_LOCAL_LABEL .doit
566 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
567 mov dx, [xBP + xCB + cbCurRetAddr + 2]
568
569 ; Mode switch, make the call, switch back.
570 STRICT_SAVE_REGS
571%if TMPL_MODE == BS3_MODE_RM
572 call far TMPL_FAR_NM(Bs3SwitchToPP16)
573%else
574 call TMPL_NM(Bs3SwitchToPP16)
575%endif
576 BS3_SET_BITS 16
577 STRICT_CHECK_REGS
578
579 push BS3_MODE_PP16
580 push cs
581 push .return
582 push dx
583 push ax
584 retf
585.return:
586
587 STRICT_SAVE_REGS
588%if TMPL_MODE == BS3_MODE_RM
589 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pp16_far)
590%else
591 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pp16)
592%endif
593 BS3_SET_BITS TMPL_BITS
594 STRICT_CHECK_REGS
595 jmp TMPL_NM(bs3TestCallDoerEpilogue)
596MY_BEGIN_TEXT
597BS3_PROC_END_MODE Bs3TestCallDoerInPP16
598
599;;
600; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPP16_32(uint16_t offBs3Text16);
601; @uses rax
602BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPP16_32, BS3_PBC_NEAR
603 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
604 jmp TMPL_NM(bs3TestCallDoerPrologue)
605.doit:
606 mov eax, [xBP + xCB + cbCurRetAddr] ; Load function pointer.
607
608 ; Mode switch, make the call, switch back.
609 STRICT_SAVE_REGS
610%if TMPL_MODE == BS3_MODE_RM
611 call far TMPL_FAR_NM(Bs3SwitchToPP16_32)
612%else
613 call TMPL_NM(Bs3SwitchToPP16_32)
614%endif
615 BS3_SET_BITS 32
616 STRICT_CHECK_REGS
617
618 push BS3_MODE_PP16_32
619 call eax
620
621 STRICT_SAVE_REGS
622 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pp16_32)
623 BS3_SET_BITS TMPL_BITS
624 STRICT_CHECK_REGS
625 jmp TMPL_NM(bs3TestCallDoerEpilogue)
626BS3_PROC_END_MODE Bs3TestCallDoerInPP16_32
627
628;;
629; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPP16_V86(uint16_t offBs3Text16);
630; @uses rax
631BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPP16_V86, BS3_PBC_NEAR
632 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
633 jmp TMPL_NM(bs3TestCallDoerPrologue)
634MY_BEGIN_TEXT16
635BS3_SET_BITS TMPL_BITS
636BS3_GLOBAL_LOCAL_LABEL .doit
637 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
638 mov dx, [xBP + xCB + cbCurRetAddr + 2]
639
640 ; Mode switch, make the call, switch back.
641 STRICT_SAVE_REGS
642%if TMPL_MODE == BS3_MODE_RM
643 call far TMPL_FAR_NM(Bs3SwitchToPP16_V86)
644%else
645 call TMPL_NM(Bs3SwitchToPP16_V86)
646%endif
647 BS3_SET_BITS 16
648 STRICT_CHECK_REGS
649
650 push BS3_MODE_PP16_V86
651 push cs
652 push .return
653 push dx
654 push ax
655 retf
656.return:
657
658 STRICT_SAVE_REGS
659%if TMPL_MODE == BS3_MODE_RM
660 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pp16_v86_far)
661%else
662 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pp16_v86)
663%endif
664 BS3_SET_BITS TMPL_BITS
665 STRICT_CHECK_REGS
666 jmp TMPL_NM(bs3TestCallDoerEpilogue)
667MY_BEGIN_TEXT
668BS3_PROC_END_MODE Bs3TestCallDoerInPP16_V86
669
670;;
671; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPP32(uint16_t offBs3Text16);
672; @uses rax
673BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPP32, BS3_PBC_NEAR
674 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
675 jmp TMPL_NM(bs3TestCallDoerPrologue)
676.doit:
677 mov eax, [xBP + xCB + cbCurRetAddr] ; Load function pointer.
678
679 ; Mode switch, make the call, switch back.
680 STRICT_SAVE_REGS
681%if TMPL_MODE == BS3_MODE_RM
682 call far TMPL_FAR_NM(Bs3SwitchToPP32)
683%else
684 call TMPL_NM(Bs3SwitchToPP32)
685%endif
686 BS3_SET_BITS 32
687 STRICT_CHECK_REGS
688
689 push BS3_MODE_PP32
690 call eax
691
692 STRICT_SAVE_REGS
693 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pp32)
694 BS3_SET_BITS TMPL_BITS
695 STRICT_CHECK_REGS
696 jmp TMPL_NM(bs3TestCallDoerEpilogue)
697BS3_PROC_END_MODE Bs3TestCallDoerInPP32
698
699;;
700; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPP32_16(uint16_t offBs3Text16);
701; @uses rax
702BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPP32_16, BS3_PBC_NEAR
703 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
704 jmp TMPL_NM(bs3TestCallDoerPrologue)
705MY_BEGIN_TEXT16
706BS3_SET_BITS TMPL_BITS
707BS3_GLOBAL_LOCAL_LABEL .doit
708 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
709 mov dx, [xBP + xCB + cbCurRetAddr + 2]
710
711 ; Mode switch, make the call, switch back.
712 STRICT_SAVE_REGS
713%if TMPL_MODE == BS3_MODE_RM
714 call far TMPL_FAR_NM(Bs3SwitchToPP32_16)
715%else
716 call TMPL_NM(Bs3SwitchToPP32_16)
717%endif
718 BS3_SET_BITS 16
719 STRICT_CHECK_REGS
720
721 push BS3_MODE_PP32_16
722 push cs
723 push .return
724 push dx
725 push ax
726 retf
727.return:
728
729 STRICT_SAVE_REGS
730%if TMPL_MODE == BS3_MODE_RM
731 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pp32_16_far)
732%else
733 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pp32_16)
734%endif
735 BS3_SET_BITS TMPL_BITS
736 STRICT_CHECK_REGS
737 jmp TMPL_NM(bs3TestCallDoerEpilogue)
738MY_BEGIN_TEXT
739BS3_PROC_END_MODE Bs3TestCallDoerInPP32_16
740
741;;
742; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPPV86(uint16_t offBs3Text16);
743; @uses rax
744BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPPV86, BS3_PBC_NEAR
745 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
746 jmp TMPL_NM(bs3TestCallDoerPrologue)
747MY_BEGIN_TEXT16
748BS3_SET_BITS TMPL_BITS
749BS3_GLOBAL_LOCAL_LABEL .doit
750 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
751 mov dx, [xBP + xCB + cbCurRetAddr + 2]
752
753 ; Mode switch, make the call, switch back.
754 STRICT_SAVE_REGS
755%if TMPL_MODE == BS3_MODE_RM
756 call far TMPL_FAR_NM(Bs3SwitchToPPV86)
757%else
758 call TMPL_NM(Bs3SwitchToPPV86)
759%endif
760 BS3_SET_BITS 16
761 STRICT_CHECK_REGS
762
763 push BS3_MODE_PPV86
764 push cs
765 push .return
766 push dx
767 push ax
768 retf
769.return:
770
771 STRICT_SAVE_REGS
772%if TMPL_MODE == BS3_MODE_RM
773 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_ppv86_far)
774%else
775 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_ppv86)
776%endif
777 BS3_SET_BITS TMPL_BITS
778 STRICT_CHECK_REGS
779 jmp TMPL_NM(bs3TestCallDoerEpilogue)
780MY_BEGIN_TEXT
781BS3_PROC_END_MODE Bs3TestCallDoerInPPV86
782
783
784;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
785;; PAE paged protection mode.
786;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
787
788;;
789; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPAE16(uint16_t offBs3Text16);
790; @uses rax
791BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAE16, BS3_PBC_NEAR
792 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
793 jmp TMPL_NM(bs3TestCallDoerPrologue)
794MY_BEGIN_TEXT16
795BS3_SET_BITS TMPL_BITS
796BS3_GLOBAL_LOCAL_LABEL .doit
797 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
798 mov dx, [xBP + xCB + cbCurRetAddr + 2]
799
800 ; Mode switch, make the call, switch back.
801 STRICT_SAVE_REGS
802%if TMPL_MODE == BS3_MODE_RM
803 call far TMPL_FAR_NM(Bs3SwitchToPAE16)
804%else
805 call TMPL_NM(Bs3SwitchToPAE16)
806%endif
807 BS3_SET_BITS 16
808 STRICT_CHECK_REGS
809
810 push BS3_MODE_PAE16
811 push cs
812 push .return
813 push dx
814 push ax
815 retf
816.return:
817
818 STRICT_SAVE_REGS
819%if TMPL_MODE == BS3_MODE_RM
820 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pae16_far)
821%else
822 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae16)
823%endif
824 BS3_SET_BITS TMPL_BITS
825 STRICT_CHECK_REGS
826 jmp TMPL_NM(bs3TestCallDoerEpilogue)
827MY_BEGIN_TEXT
828BS3_PROC_END_MODE Bs3TestCallDoerInPAE16
829
830;;
831; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPAE16_32(uint16_t offBs3Text16);
832; @uses rax
833BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAE16_32, BS3_PBC_NEAR
834 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
835 jmp TMPL_NM(bs3TestCallDoerPrologue)
836.doit:
837 mov eax, [xBP + xCB + cbCurRetAddr] ; Load function pointer.
838
839 ; Mode switch, make the call, switch back.
840 STRICT_SAVE_REGS
841%if TMPL_MODE == BS3_MODE_RM
842 call far TMPL_FAR_NM(Bs3SwitchToPAE16_32)
843%else
844 call TMPL_NM(Bs3SwitchToPAE16_32)
845%endif
846 BS3_SET_BITS 32
847 STRICT_CHECK_REGS
848
849 push BS3_MODE_PAE16_32
850 call eax
851
852 STRICT_SAVE_REGS
853 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae16_32)
854 BS3_SET_BITS TMPL_BITS
855 STRICT_CHECK_REGS
856 jmp TMPL_NM(bs3TestCallDoerEpilogue)
857BS3_PROC_END_MODE Bs3TestCallDoerInPAE16_32
858
859;;
860; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPAE16_V86(uint16_t offBs3Text16);
861; @uses rax
862BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAE16_V86, BS3_PBC_NEAR
863 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
864 jmp TMPL_NM(bs3TestCallDoerPrologue)
865MY_BEGIN_TEXT16
866BS3_SET_BITS TMPL_BITS
867BS3_GLOBAL_LOCAL_LABEL .doit
868 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
869 mov dx, [xBP + xCB + cbCurRetAddr + 2]
870
871 ; Mode switch, make the call, switch back.
872 STRICT_SAVE_REGS
873%if TMPL_MODE == BS3_MODE_RM
874 call far TMPL_FAR_NM(Bs3SwitchToPAE16_V86)
875%else
876 call TMPL_NM(Bs3SwitchToPAE16_V86)
877%endif
878 BS3_SET_BITS 16
879 STRICT_CHECK_REGS
880
881 push BS3_MODE_PAE16_V86
882 push cs
883 push .return
884 push dx
885 push ax
886 retf
887.return:
888
889 STRICT_SAVE_REGS
890%if TMPL_MODE == BS3_MODE_RM
891 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pae16_v86_far)
892%else
893 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae16_v86)
894%endif
895 BS3_SET_BITS TMPL_BITS
896 STRICT_CHECK_REGS
897 jmp TMPL_NM(bs3TestCallDoerEpilogue)
898MY_BEGIN_TEXT
899BS3_PROC_END_MODE Bs3TestCallDoerInPAE16_V86
900
901;;
902; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPAE32(uint16_t offBs3Text16);
903; @uses rax
904BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAE32, BS3_PBC_NEAR
905 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
906 jmp TMPL_NM(bs3TestCallDoerPrologue)
907.doit:
908 mov eax, [xBP + xCB + cbCurRetAddr] ; Load function pointer.
909
910 ; Mode switch, make the call, switch back.
911 STRICT_SAVE_REGS
912%if TMPL_MODE == BS3_MODE_RM
913 call far TMPL_FAR_NM(Bs3SwitchToPAE32)
914%else
915 call TMPL_NM(Bs3SwitchToPAE32)
916%endif
917 BS3_SET_BITS 32
918 STRICT_CHECK_REGS
919
920 push BS3_MODE_PAE32
921 call eax
922
923 STRICT_SAVE_REGS
924 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae32)
925 BS3_SET_BITS TMPL_BITS
926 STRICT_CHECK_REGS
927 jmp TMPL_NM(bs3TestCallDoerEpilogue)
928BS3_PROC_END_MODE Bs3TestCallDoerInPAE32
929
930;;
931; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPAE32_16(uint16_t offBs3Text16);
932; @uses rax
933BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAE32_16, BS3_PBC_NEAR
934 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
935 jmp TMPL_NM(bs3TestCallDoerPrologue)
936MY_BEGIN_TEXT16
937BS3_SET_BITS TMPL_BITS
938BS3_GLOBAL_LOCAL_LABEL .doit
939 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
940 mov dx, [xBP + xCB + cbCurRetAddr + 2]
941
942 ; Mode switch, make the call, switch back.
943 STRICT_SAVE_REGS
944%if TMPL_MODE == BS3_MODE_RM
945 call far TMPL_FAR_NM(Bs3SwitchToPAE32_16)
946%else
947 call TMPL_NM(Bs3SwitchToPAE32_16)
948%endif
949 BS3_SET_BITS 16
950 STRICT_CHECK_REGS
951
952 push BS3_MODE_PAE32_16
953 push cs
954 push .return
955 push dx
956 push ax
957 retf
958.return:
959
960 STRICT_SAVE_REGS
961%if TMPL_MODE == BS3_MODE_RM
962 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_pae32_16_far)
963%else
964 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_pae32_16)
965%endif
966 BS3_SET_BITS TMPL_BITS
967 STRICT_CHECK_REGS
968 jmp TMPL_NM(bs3TestCallDoerEpilogue)
969MY_BEGIN_TEXT
970BS3_PROC_END_MODE Bs3TestCallDoerInPAE32_16
971
972;;
973; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInPAEV86(uint16_t offBs3Text16);
974; @uses rax
975BS3_PROC_BEGIN_MODE Bs3TestCallDoerInPAEV86, BS3_PBC_NEAR
976 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
977 jmp TMPL_NM(bs3TestCallDoerPrologue)
978MY_BEGIN_TEXT16
979BS3_SET_BITS TMPL_BITS
980BS3_GLOBAL_LOCAL_LABEL .doit
981 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
982 mov dx, [xBP + xCB + cbCurRetAddr + 2]
983
984 ; Mode switch, make the call, switch back.
985 STRICT_SAVE_REGS
986%if TMPL_MODE == BS3_MODE_RM
987 call far TMPL_FAR_NM(Bs3SwitchToPAEV86)
988%else
989 call TMPL_NM(Bs3SwitchToPAEV86)
990%endif
991 BS3_SET_BITS 16
992 STRICT_CHECK_REGS
993
994 push BS3_MODE_PAEV86
995 push cs
996 push .return
997 push dx
998 push ax
999 retf
1000.return:
1001
1002 STRICT_SAVE_REGS
1003%if TMPL_MODE == BS3_MODE_RM
1004 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_paev86_far)
1005%else
1006 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_paev86)
1007%endif
1008 BS3_SET_BITS TMPL_BITS
1009 STRICT_CHECK_REGS
1010 jmp TMPL_NM(bs3TestCallDoerEpilogue)
1011MY_BEGIN_TEXT
1012BS3_PROC_END_MODE Bs3TestCallDoerInPAEV86
1013
1014
1015
1016;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1017;; Long mode
1018;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1019
1020;;
1021; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInLM16(uint16_t offBs3Text16);
1022; @uses rax
1023BS3_PROC_BEGIN_MODE Bs3TestCallDoerInLM16, BS3_PBC_NEAR
1024 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
1025 jmp TMPL_NM(bs3TestCallDoerPrologue)
1026MY_BEGIN_TEXT16
1027BS3_SET_BITS TMPL_BITS
1028BS3_GLOBAL_LOCAL_LABEL .doit
1029 mov ax, [xBP + xCB + cbCurRetAddr] ; Load far function pointer.
1030 mov dx, [xBP + xCB + cbCurRetAddr + 2]
1031
1032 ; Mode switch, make the call, switch back.
1033 STRICT_SAVE_REGS
1034%if TMPL_MODE == BS3_MODE_RM
1035 call far TMPL_FAR_NM(Bs3SwitchToLM16)
1036%else
1037 call TMPL_NM(Bs3SwitchToLM16)
1038%endif
1039 BS3_SET_BITS 16
1040 STRICT_CHECK_REGS
1041
1042 push BS3_MODE_LM16
1043 push cs
1044 push .return
1045 push dx
1046 push ax
1047 retf
1048.return:
1049
1050 STRICT_SAVE_REGS
1051%if TMPL_MODE == BS3_MODE_RM
1052 call far RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_lm16_far)
1053%else
1054 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_lm16)
1055%endif
1056 BS3_SET_BITS TMPL_BITS
1057 STRICT_CHECK_REGS
1058 jmp TMPL_NM(bs3TestCallDoerEpilogue)
1059MY_BEGIN_TEXT
1060BS3_PROC_END_MODE Bs3TestCallDoerInLM16
1061
1062;;
1063; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInLM32(uint16_t offBs3Text16);
1064; @uses rax
1065BS3_PROC_BEGIN_MODE Bs3TestCallDoerInLM32, BS3_PBC_NEAR
1066 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
1067 jmp TMPL_NM(bs3TestCallDoerPrologue)
1068.doit:
1069 mov eax, [xBP + xCB + cbCurRetAddr] ; Load function pointer.
1070
1071 ; Mode switch, make the call, switch back.
1072 STRICT_SAVE_REGS
1073%if TMPL_MODE == BS3_MODE_RM
1074 call far TMPL_FAR_NM(Bs3SwitchToLM32)
1075%else
1076 call TMPL_NM(Bs3SwitchToLM32)
1077%endif
1078 BS3_SET_BITS 32
1079 STRICT_CHECK_REGS
1080
1081 and esp, ~03h
1082 push BS3_MODE_LM32
1083 call eax
1084
1085 STRICT_SAVE_REGS
1086 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_lm32)
1087 BS3_SET_BITS TMPL_BITS
1088 STRICT_CHECK_REGS
1089 jmp TMPL_NM(bs3TestCallDoerEpilogue)
1090BS3_PROC_END_MODE Bs3TestCallDoerInLM32
1091
1092;;
1093; @cproto BS3_DECL(uint8_t) Bs3TestCallDoerInLM64(uint16_t offBs3Text16);
1094; @uses rax
1095BS3_PROC_BEGIN_MODE Bs3TestCallDoerInLM64, BS3_PBC_NEAR
1096 BS3_LEA_MOV_WRT_RIP(xAX, MY_TEXT16_WRT(.doit))
1097 jmp TMPL_NM(bs3TestCallDoerPrologue)
1098.doit:
1099 mov eax, [xBP + xCB + cbCurRetAddr] ; Load function pointer.
1100
1101 ; Mode switch, make the call, switch back.
1102 STRICT_SAVE_REGS
1103%if TMPL_MODE == BS3_MODE_RM
1104 call far TMPL_FAR_NM(Bs3SwitchToLM64)
1105%else
1106 call TMPL_NM(Bs3SwitchToLM64)
1107%endif
1108 BS3_SET_BITS 64
1109 STRICT_CHECK_REGS
1110
1111 and rsp, ~0fh
1112 sub rsp, 18h
1113 push BS3_MODE_LM64
1114 BS3_CALL rax, 1
1115
1116 STRICT_SAVE_REGS
1117 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_lm64)
1118 BS3_SET_BITS TMPL_BITS
1119 STRICT_CHECK_REGS
1120 jmp TMPL_NM(bs3TestCallDoerEpilogue)
1121BS3_PROC_END_MODE Bs3TestCallDoerInLM64
1122
1123
1124;
1125; Finally near stub for the API call (16-bit only).
1126;
1127%if TMPL_BITS == 16
1128BS3_BEGIN_TEXT16_NEARSTUBS
1129BS3_PROC_BEGIN_MODE Bs3TestDoModes, BS3_PBC_NEAR
1130 pop ax
1131 %if TMPL_MODE == BS3_MODE_RM
1132 push cs
1133 push ax
1134 extern TMPL_FAR_NM(Bs3TestDoModes):wrt BS3GROUPRMTEXT16
1135 jmp far TMPL_FAR_NM(Bs3TestDoModes)
1136 %else
1137 push cs
1138 push ax
1139 extern TMPL_FAR_NM(Bs3TestDoModes):wrt CGROUP16
1140 jmp TMPL_NM(Bs3TestDoModes)
1141 %endif
1142BS3_PROC_END_MODE Bs3TestDoModes
1143
1144%endif
1145
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