VirtualBox

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

Last change on this file since 96407 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: 3.5 KB
Line 
1; $Id: bs3-mode-SwitchToPEV86.asm 96407 2022-08-22 17:43:14Z vboxsync $
2;; @file
3; BS3Kit - Bs3SwitchToPEV86
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%include "bs3kit-template-header.mac"
38
39
40;;
41; Switch to 16-bit v8086 unpaged protected mode with 32-bit sys+tss from any other mode.
42;
43; @cproto BS3_DECL(void) Bs3SwitchToPEV86(void);
44;
45; @uses Nothing (except high 32-bit register parts).
46;
47; @remarks Obviously returns to 16-bit v8086 mode, even if the caller was
48; in 32-bit or 64-bit mode.
49;
50; @remarks Does not require 20h of parameter scratch space in 64-bit mode.
51;
52%if TMPL_BITS == 16
53BS3_GLOBAL_NAME_EX TMPL_NM(Bs3SwitchToPEV86_Safe), function , 0
54%endif
55BS3_PROC_BEGIN_MODE Bs3SwitchToPEV86, BS3_PBC_NEAR
56%if TMPL_MODE == BS3_MODE_PEV86
57 ret
58
59%else
60 ;
61 ; Switch to 32-bit PE32 and from there to V8086.
62 ;
63 extern TMPL_NM(Bs3SwitchToPE32)
64 call TMPL_NM(Bs3SwitchToPE32)
65 BS3_SET_BITS 32
66
67 ;
68 ; Switch to v8086 mode after adjusting the return address.
69 ;
70 %if TMPL_BITS == 16
71 push word [esp]
72 mov word [esp + 2], 0
73 %elif TMPL_BITS == 64
74 pop dword [esp + 4]
75 %endif
76 extern _Bs3SwitchTo16BitV86_c32
77 jmp _Bs3SwitchTo16BitV86_c32
78%endif
79BS3_PROC_END_MODE Bs3SwitchToPEV86
80
81
82%if TMPL_BITS == 16
83;;
84; Custom far stub.
85BS3_BEGIN_TEXT16_FARSTUBS
86BS3_PROC_BEGIN_MODE Bs3SwitchToPEV86, BS3_PBC_FAR
87 inc bp
88 push bp
89 mov bp, sp
90
91 ; Call the real thing.
92 call TMPL_NM(Bs3SwitchToPEV86)
93
94 %if !BS3_MODE_IS_RM_OR_V86(TMPL_MODE)
95 ; Jmp to common code for the tedious conversion.
96 BS3_EXTERN_CMN Bs3SwitchHlpConvProtModeRetfPopBpDecBpAndReturn
97 jmp Bs3SwitchHlpConvProtModeRetfPopBpDecBpAndReturn
98 %else
99 pop bp
100 dec bp
101 retf
102 %endif
103BS3_PROC_END_MODE Bs3SwitchToPEV86
104
105%else
106;;
107; Safe far return to non-BS3TEXT16 code.
108BS3_EXTERN_CMN Bs3SwitchHlpConvFlatRetToRetfProtMode
109BS3_BEGIN_TEXT16
110BS3_SET_BITS TMPL_BITS
111BS3_PROC_BEGIN_MODE Bs3SwitchToPEV86_Safe, BS3_PBC_NEAR
112 call Bs3SwitchHlpConvFlatRetToRetfProtMode ; Special internal function. Uses nothing, but modifies the stack.
113 call TMPL_NM(Bs3SwitchToPEV86)
114 BS3_SET_BITS 16
115 retf
116BS3_PROC_END_MODE Bs3SwitchToPEV86_Safe
117%endif
118
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