VirtualBox

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

Last change on this file since 82525 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1; $Id: bs3-mode-SwitchToPPV86.asm 76553 2019-01-01 01:45:53Z vboxsync $
2;; @file
3; BS3Kit - Bs3SwitchToPPV86
4;
5
6;
7; Copyright (C) 2007-2019 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%include "bs3kit-template-header.mac"
28
29
30;;
31; Switch to 16-bit v8086 paged protected mode with 32-bit sys+tss from any other mode.
32;
33; @cproto BS3_DECL(void) Bs3SwitchToPPV86(void);
34;
35; @uses Nothing (except high 32-bit register parts).
36;
37; @remarks Obviously returns to 16-bit v8086 mode, even if the caller was
38; in 32-bit or 64-bit mode.
39;
40; @remarks Does not require 20h of parameter scratch space in 64-bit mode.
41;
42%if TMPL_BITS == 16
43BS3_GLOBAL_NAME_EX TMPL_NM(Bs3SwitchToPPV86_Safe), function , 0
44%endif
45BS3_PROC_BEGIN_MODE Bs3SwitchToPPV86, BS3_PBC_NEAR
46%if TMPL_MODE == BS3_MODE_PPV86
47 ret
48
49%else
50 ;
51 ; Switch to 32-bit PP32 and from there to V8086.
52 ;
53 extern TMPL_NM(Bs3SwitchToPP32)
54 call TMPL_NM(Bs3SwitchToPP32)
55 BS3_SET_BITS 32
56
57 ;
58 ; Switch to v8086 mode after adjusting the return address.
59 ;
60 %if TMPL_BITS == 16
61 push word [esp]
62 mov word [esp + 2], 0
63 %elif TMPL_BITS == 64
64 pop dword [esp + 4]
65 %endif
66 extern _Bs3SwitchTo16BitV86_c32
67 jmp _Bs3SwitchTo16BitV86_c32
68%endif
69BS3_PROC_END_MODE Bs3SwitchToPPV86
70
71
72%if TMPL_BITS == 16
73;;
74; Custom far stub.
75BS3_BEGIN_TEXT16_FARSTUBS
76BS3_PROC_BEGIN_MODE Bs3SwitchToPPV86, BS3_PBC_FAR
77 inc bp
78 push bp
79 mov bp, sp
80
81 ; Call the real thing.
82 call TMPL_NM(Bs3SwitchToPPV86)
83
84 %if !BS3_MODE_IS_RM_OR_V86(TMPL_MODE)
85 ; Jmp to common code for the tedious conversion.
86 BS3_EXTERN_CMN Bs3SwitchHlpConvProtModeRetfPopBpDecBpAndReturn
87 jmp Bs3SwitchHlpConvProtModeRetfPopBpDecBpAndReturn
88 %else
89 pop bp
90 dec bp
91 retf
92 %endif
93BS3_PROC_END_MODE Bs3SwitchToPPV86
94
95%else
96;;
97; Safe far return to non-BS3TEXT16 code.
98BS3_EXTERN_CMN Bs3SwitchHlpConvFlatRetToRetfProtMode
99BS3_BEGIN_TEXT16
100BS3_SET_BITS TMPL_BITS
101BS3_PROC_BEGIN_MODE Bs3SwitchToPPV86_Safe, BS3_PBC_NEAR
102 call Bs3SwitchHlpConvFlatRetToRetfProtMode ; Special internal function. Uses nothing, but modifies the stack.
103 call TMPL_NM(Bs3SwitchToPPV86)
104 BS3_SET_BITS 16
105 retf
106BS3_PROC_END_MODE Bs3SwitchToPPV86_Safe
107%endif
108
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