1 | ; $Id: bs3-mode-SwitchToPP16_32.asm 106061 2024-09-16 14:03:52Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - Bs3SwitchToPP16_32
|
---|
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 32-bit code under 16-bit paged protected mode sys/tss from any other mode.
|
---|
42 | ;
|
---|
43 | ; @cproto BS3_DECL(void) Bs3SwitchToPP16_32(void);
|
---|
44 | ;
|
---|
45 | ; @uses Nothing (except high 32-bit register parts).
|
---|
46 | ;
|
---|
47 | ; @remarks Obviously returns to 32-bit mode, even if the caller was
|
---|
48 | ; in 16-bit or 64-bit mode.
|
---|
49 | ;
|
---|
50 | ; @remarks Does not require 20h of parameter scratch space in 64-bit mode.
|
---|
51 | ;
|
---|
52 | BS3_GLOBAL_NAME_EX TMPL_NM(Bs3SwitchToPP16_32_Safe), function, 0
|
---|
53 | BS3_PROC_BEGIN_MODE Bs3SwitchToPP16_32, BS3_PBC_NEAR
|
---|
54 | %ifdef TMPL_PP16_32
|
---|
55 | ret
|
---|
56 |
|
---|
57 | %else
|
---|
58 | ;
|
---|
59 | ; Make sure we're in the 16-bit segment and then call Bs3SwitchToPP16.
|
---|
60 | ;
|
---|
61 | %if TMPL_BITS != 16
|
---|
62 | jmp .sixteen_bit_segment
|
---|
63 | BS3_BEGIN_TEXT16
|
---|
64 | BS3_SET_BITS TMPL_BITS
|
---|
65 | BS3_GLOBAL_LOCAL_LABEL .sixteen_bit_segment
|
---|
66 | %endif
|
---|
67 | extern TMPL_NM(Bs3SwitchToPP16)
|
---|
68 | call TMPL_NM(Bs3SwitchToPP16)
|
---|
69 | BS3_SET_BITS 16
|
---|
70 |
|
---|
71 | ;
|
---|
72 | ; Switch to 32-bit mode.
|
---|
73 | ;
|
---|
74 | extern _Bs3SwitchTo32Bit_c16
|
---|
75 | %if TMPL_BITS == 16
|
---|
76 | jmp _Bs3SwitchTo32Bit_c16
|
---|
77 | %else
|
---|
78 | call _Bs3SwitchTo32Bit_c16
|
---|
79 | BS3_SET_BITS 32
|
---|
80 | %if TMPL_BITS == 32
|
---|
81 | ret
|
---|
82 | %else
|
---|
83 | ret 4 ; Return and pop 4 bytes of "parameters" (unused return address).
|
---|
84 | %endif
|
---|
85 | %endif
|
---|
86 | %endif
|
---|
87 | BS3_PROC_END_MODE Bs3SwitchToPP16_32
|
---|
88 |
|
---|
89 |
|
---|
90 | %if TMPL_BITS == 16
|
---|
91 | ;;
|
---|
92 | ; Custom far stub.
|
---|
93 | BS3_BEGIN_TEXT16_FARSTUBS
|
---|
94 | BS3_PROC_BEGIN_MODE Bs3SwitchToPP16_32, BS3_PBC_FAR
|
---|
95 | inc bp
|
---|
96 | push bp
|
---|
97 | mov bp, sp
|
---|
98 |
|
---|
99 | ; Call the real thing.
|
---|
100 | call TMPL_NM(Bs3SwitchToPP16_32)
|
---|
101 | BS3_SET_BITS 32
|
---|
102 |
|
---|
103 | ; Jmp to common code for the tedious conversion.
|
---|
104 | %if BS3_MODE_IS_RM_OR_V86(TMPL_MODE)
|
---|
105 | extern _Bs3SwitchHlpConvRealModeRetfPopBpDecBpAndReturn_c32
|
---|
106 | jmp _Bs3SwitchHlpConvRealModeRetfPopBpDecBpAndReturn_c32
|
---|
107 | %else
|
---|
108 | extern _Bs3SwitchHlpConvProtModeRetfPopBpDecBpAndReturn_c32
|
---|
109 | jmp _Bs3SwitchHlpConvProtModeRetfPopBpDecBpAndReturn_c32
|
---|
110 | %endif
|
---|
111 | BS3_SET_BITS 16
|
---|
112 | BS3_PROC_END_MODE Bs3SwitchToPP16_32
|
---|
113 | %endif
|
---|
114 |
|
---|