VirtualBox

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

Last change on this file since 106743 was 106061, checked in by vboxsync, 3 months ago

Copyright year updates by scm.

  • 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-SwitchToLM64.asm 106061 2024-09-16 14:03:52Z vboxsync $
2;; @file
3; BS3Kit - Bs3SwitchToLM64
4;
5
6;
7; Copyright (C) 2007-2024 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 64-bit long mode from any other mode.
42;
43; @cproto BS3_DECL(void) Bs3SwitchToLM64(void);
44;
45; @uses Nothing (except possibly high 32-bit and/or upper 64-bit register parts).
46;
47; @remarks Obviously returns to 64-bit mode, even if the caller was in 16-bit
48; or 32-bit mode. It doesn't not preserve the callers ring, but
49; instead changes to ring-0.
50;
51; @remarks Does not require 20h of parameter scratch space in 64-bit mode.
52;
53BS3_GLOBAL_NAME_EX TMPL_NM(Bs3SwitchToLM64_Safe), function, 0
54BS3_PROC_BEGIN_MODE Bs3SwitchToLM64, BS3_PBC_NEAR
55%ifdef TMPL_LM64
56 ret
57
58%elifdef TMPL_CMN_LM
59 ;
60 ; Already in long mode, just switch to 64-bit.
61 ;
62 extern BS3_CMN_NM(Bs3SwitchTo64Bit)
63 jmp BS3_CMN_NM(Bs3SwitchTo64Bit)
64
65%else
66 ;
67 ; Switch to LM32 and then switch to 64-bits (IDT & TSS are the same for
68 ; LM16, LM32 and LM64, unlike the rest).
69 ;
70 ; (The long mode switching code is going via 32-bit protected mode, so
71 ; Bs3SwitchToLM32 contains the actual code for switching to avoid
72 ; unnecessary 32-bit -> 64-bit -> 32-bit trips.)
73 ;
74 %ifdef TMPL_16BIT
75 and esp, 0ffffh
76 push word [esp] ; copy return address.
77 and word [esp + 2], 0 ; clear upper return address
78 add dword [esp], BS3_ADDR_BS3TEXT16 ; Add base of return segment, completing 32-bit conversion.
79 %endif
80 extern TMPL_NM(Bs3SwitchToLM32)
81 call TMPL_NM(Bs3SwitchToLM32)
82 BS3_SET_BITS 32
83
84 extern _Bs3SwitchTo64Bit_c32
85 jmp _Bs3SwitchTo64Bit_c32
86%endif
87BS3_PROC_END_MODE Bs3SwitchToLM64
88
89
90%if TMPL_BITS == 16
91;;
92; Custom far stub.
93BS3_BEGIN_TEXT16_FARSTUBS
94BS3_PROC_BEGIN_MODE Bs3SwitchToLM64, BS3_PBC_FAR
95 inc bp
96 push bp
97 mov bp, sp
98
99 ; Call the real thing.
100 call TMPL_NM(Bs3SwitchToLM64)
101 BS3_SET_BITS 64
102
103 ; Jmp to common code for the tedious conversion.
104 %if BS3_MODE_IS_RM_OR_V86(TMPL_MODE)
105 extern _Bs3SwitchHlpConvRealModeRetfPopBpDecBpAndReturn_c64
106 jmp _Bs3SwitchHlpConvRealModeRetfPopBpDecBpAndReturn_c64
107 %else
108 extern _Bs3SwitchHlpConvProtModeRetfPopBpDecBpAndReturn_c64
109 jmp _Bs3SwitchHlpConvProtModeRetfPopBpDecBpAndReturn_c64
110 %endif
111 BS3_SET_BITS 16
112BS3_PROC_END_MODE Bs3SwitchToLM64
113%endif
114
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