VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SwitchTo64Bit.asm@ 97613

Last change on this file since 97613 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.2 KB
Line 
1; $Id: bs3-cmn-SwitchTo64Bit.asm 96407 2022-08-22 17:43:14Z vboxsync $
2;; @file
3; BS3Kit - Bs3SwitchTo64Bit
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%if TMPL_BITS != 64
40BS3_EXTERN_DATA16 g_bBs3CurrentMode
41TMPL_BEGIN_TEXT
42%endif
43
44
45;;
46; @cproto BS3_DECL(void) Bs3SwitchTo64Bit(void);
47;
48; @remarks Does not require 20h of parameter scratch space in 64-bit mode.
49; @uses No GPRs.
50;
51BS3_PROC_BEGIN_CMN Bs3SwitchTo64Bit, BS3_PBC_NEAR
52%if TMPL_BITS == 64
53 ret
54
55%else
56 %if TMPL_BITS == 16
57 sub sp, 6 ; Space for extended return value (corrected in 64-bit mode).
58 %else
59 push xPRE [xSP] ; Duplicate the return address.
60 and dword [xSP + xCB], 0 ; Clear the high dword or it.
61 %endif
62 push dword 0
63 push sAX
64 push dword 0
65 pushfd
66 cli
67
68 %if TMPL_BITS == 16
69 ; Check that this is LM16
70 mov ax, seg g_bBs3CurrentMode
71 cmp byte [BS3_DATA16_WRT(g_bBs3CurrentMode)], BS3_MODE_LM16
72 je .ok_lm16
73 int3
74 .ok_lm16:
75 %endif
76
77 ; Calc ring addend.
78 mov ax, cs
79 and xAX, 3
80 shl xAX, BS3_SEL_RING_SHIFT
81 add xAX, BS3_SEL_R0_CS64
82
83 ; setup far return.
84 push sAX
85 %if TMPL_BITS == 16
86 push dword .sixty_four_bit wrt FLAT
87 o32 retf
88 %else
89 push .sixty_four_bit
90 retf
91 %endif
92
93BS3_SET_BITS 64
94.sixty_four_bit:
95
96 ; Load 64-bit segment registers (SS64==DS64).
97 add eax, BS3_SEL_R0_DS64 - BS3_SEL_R0_CS64
98 mov ss, ax
99 mov ds, ax
100 mov es, ax
101
102 ; Update globals.
103 and byte [BS3_DATA16_WRT(g_bBs3CurrentMode)], ~BS3_MODE_CODE_MASK
104 or byte [BS3_DATA16_WRT(g_bBs3CurrentMode)], BS3_MODE_CODE_64
105
106 %if TMPL_BITS == 16
107 movzx eax, word [rsp + 8*2+6]
108 add eax, BS3_ADDR_BS3TEXT16
109 mov [rsp + 8*2], rax
110 %endif
111
112 popfq
113 pop rax
114 ret
115%endif
116BS3_PROC_END_CMN Bs3SwitchTo64Bit
117
118
119;; @todo far 16-bit variant.
120
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