VirtualBox

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

Last change on this file since 97624 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.7 KB
Line 
1; $Id: bs3-mode-SwitchToPE16_V86.asm 96407 2022-08-22 17:43:14Z vboxsync $
2;; @file
3; BS3Kit - Bs3SwitchToPE16_V86
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 unpaged protected mode with 16-bit sys+tss from any other mode.
42;
43; @cproto BS3_DECL(void) Bs3SwitchToPE16(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 16-bit, 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(Bs3SwitchToPE16_V86_Safe), function , 0
54%endif
55BS3_PROC_BEGIN_MODE Bs3SwitchToPE16_V86, BS3_PBC_NEAR
56%ifdef TMPL_PE16_V86
57 ret
58
59%else
60 ;
61 ; Convert the return address and jump to the 16-bit code segment.
62 ;
63 %if TMPL_BITS != 16
64 shl xPRE [xSP], TMPL_BITS - 16
65 add xSP, (TMPL_BITS - 16) / 8
66 jmp .sixteen_bit_segment
67BS3_BEGIN_TEXT16
68 BS3_SET_BITS TMPL_BITS
69BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
70 %endif
71
72 ;
73 ; Switch to 16-bit PE16 and from there to V8086.
74 ;
75 extern TMPL_NM(Bs3SwitchToPE16)
76 call TMPL_NM(Bs3SwitchToPE16)
77 BS3_SET_BITS 16
78
79 ;
80 ; Switch to v8086 mode (return address is already 16-bit).
81 ;
82 extern _Bs3SwitchTo16BitV86_c16
83 jmp _Bs3SwitchTo16BitV86_c16
84%endif
85BS3_PROC_END_MODE Bs3SwitchToPE16_V86
86
87
88%if TMPL_BITS == 16
89;;
90; Custom far stub.
91BS3_BEGIN_TEXT16_FARSTUBS
92BS3_PROC_BEGIN_MODE Bs3SwitchToPE16_V86, BS3_PBC_FAR
93 inc bp
94 push bp
95 mov bp, sp
96
97 ; Call the real thing.
98 call TMPL_NM(Bs3SwitchToPE16_V86)
99
100 %if !BS3_MODE_IS_RM_OR_V86(TMPL_MODE)
101 ; Jmp to common code for the tedious conversion.
102 BS3_EXTERN_CMN Bs3SwitchHlpConvProtModeRetfPopBpDecBpAndReturn
103 jmp Bs3SwitchHlpConvProtModeRetfPopBpDecBpAndReturn
104 %else
105 pop bp
106 dec bp
107 retf
108 %endif
109BS3_PROC_END_MODE Bs3SwitchToPE16_V86
110
111%else
112;;
113; Safe far return to non-BS3TEXT16 code.
114BS3_EXTERN_CMN Bs3SwitchHlpConvFlatRetToRetfProtMode
115BS3_BEGIN_TEXT16
116BS3_SET_BITS TMPL_BITS
117BS3_PROC_BEGIN_MODE Bs3SwitchToPE16_V86_Safe, BS3_PBC_NEAR
118 call Bs3SwitchHlpConvFlatRetToRetfProtMode ; Special internal function. Uses nothing, but modifies the stack.
119 call TMPL_NM(Bs3SwitchToPE16_V86)
120 BS3_SET_BITS 16
121 retf
122BS3_PROC_END_MODE Bs3SwitchToPE16_V86_Safe
123%endif
124
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