VirtualBox

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

Last change on this file since 60009 was 59946, checked in by vboxsync, 9 years ago

bs3kit: fixes (can switch to every weird mode now, though v86 requires some additional work).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1; $Id: bs3-mode-SwitchToLM16.asm 59946 2016-03-07 16:37:34Z vboxsync $
2;; @file
3; BS3Kit - Bs3SwitchToLM16
4;
5
6;
7; Copyright (C) 2007-2016 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 long mode from any other mode.
32;
33; @cproto BS3_DECL(void) Bs3SwitchToLM16(void);
34;
35; @uses Nothing (except possibly high 32-bit and/or upper 64-bit register parts).
36;
37; @remarks Obviously returns to 16-bit mode, even if the caller was in 32-bit
38; or 64-bit mode. It doesn't not preserve the callers ring, but
39; instead changes to ring-0.
40;
41; @remarks Does not require 20h of parameter scratch space in 64-bit mode.
42;
43BS3_PROC_BEGIN_MODE Bs3SwitchToLM16
44%ifdef TMPL_LM16
45 ret
46
47%elifdef TMPL_CMN_LM
48 ;
49 ; Already in long mode, just switch to 16-bit.
50 ;
51 extern BS3_CMN_NM(Bs3SwitchTo16Bit)
52 jmp BS3_CMN_NM(Bs3SwitchTo16Bit)
53
54%else
55 ;
56 ; Switch to LM32 and then switch to 64-bits (IDT & TSS are the same for
57 ; LM16, LM32 and LM64, unlike the rest).
58 ;
59 ; (The long mode switching code is going via 32-bit protected mode, so
60 ; Bs3SwitchToLM32 contains the actual code for switching to avoid
61 ; unnecessary 32-bit -> 64-bit -> 32-bit trips.)
62 ;
63 extern TMPL_NM(Bs3SwitchToLM32)
64 call TMPL_NM(Bs3SwitchToLM32)
65 BS3_SET_BITS 32
66
67 extern _Bs3SwitchTo16Bit_c32
68 %if TMPL_BITS == 16
69 sub esp, 2
70 shr dword [esp], 16
71 %elif TMPL_BITS == 64
72 pop dword [esp + 4]
73 %endif
74 jmp _Bs3SwitchTo16Bit_c32
75%endif
76BS3_PROC_END_MODE Bs3SwitchToLM16
77
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